pyflink filter

import json

import re

import logging

import sys

from collections import Counter

from pyflink.datastream import DataStream, StreamExecutionEnvironment

from pyflink.datastream.functions import RuntimeContext, FlatMapFunction, MapFunction,FilterFunction

from pyflink.common.typeinfo import Types

s_env = StreamExecutionEnvironment.get_execution_environment()

data = DataStream(s_env._j_stream_execution_environment.socketTextStream('192.168.137.201', 8899))

data.print()

def get_key():

return '999'

class LogEvent:

world = None

def init(self, world):

self.world = world

self.count = count

def to_dict(self):

return {

"world": str(self.world)

"count": str(self.count)

}

class MyMapFunction(FlatMapFunction):

def open(self, runtime_context: RuntimeContext):

pass

def flat_map(self, raw_message):

raw_message = raw_message.upper()

dict1 = {}

dict1['value'] = raw_message +'!!!'

yield dict1

class myFilterFunction(FilterFunction):

def filter(self,raw_message):

if re.findall('AAA',raw_message):

return raw_message

data.filter(myFilterFunction()).print()

s_env.execute('data')

相关推荐
web3.08889993 小时前
微店商品详情API实用
python·json·时序数据库
知乎的哥廷根数学学派3 小时前
基于数据驱动的自适应正交小波基优化算法(Python)
开发语言·网络·人工智能·pytorch·python·深度学习·算法
sunfove3 小时前
将 Python 仿真工具部署并嵌入个人博客
开发语言·数据库·python
Learner3 小时前
Python类
开发语言·python
2501_941329723 小时前
门及其组件定位识别_YOLO13-C3k2-PoolingFormer改进模型研究
python
Ancelin安心4 小时前
kali-dirsearch的使用
linux·运维·服务器·python·计算机网络·web安全·网络安全
努力学习的小洋4 小时前
Python训练打卡Day5离散特征的处理-独热编码
人工智能·python·机器学习
Sherry Wangs4 小时前
【ML】机器学习进阶
人工智能·python·机器学习
X1A0RAN4 小时前
python 借助 paramiko 库执行 SSH命令报错:input is not a terminal 解决方式
开发语言·python·ssh
百***78755 小时前
Grok-4.1与GPT-5.2深度对比:技术差异、适用场景及Python集成指南
java·python·gpt