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')

相关推荐
敏编程36 分钟前
一天一个Python库:tomlkit - 轻松解析和操作TOML配置
python
2401_8796938741 分钟前
使用Python进行图像识别:CNN卷积神经网络实战
jvm·数据库·python
yunyun321231 小时前
机器学习模型部署:将模型转化为Web API
jvm·数据库·python
团子和二花1 小时前
openclaw平替之nanobot源码解析(七):Gateway与多渠道集成
python·gateway·agent·智能体·openclaw·nanobot
未知鱼1 小时前
Python安全开发之简易目录扫描器(含详细注释)
开发语言·python·安全
Be1k02 小时前
推荐一款语雀知识库批量导出工具
python·gui·工具·语雀·批量导出·原创
Sunshine for you2 小时前
如何用FastAPI构建高性能的现代API
jvm·数据库·python
阿贵---2 小时前
Python Web爬虫入门:使用Requests和BeautifulSoup
jvm·数据库·python
Red丶哞3 小时前
内网自建Postfix使用Python发送邮件
开发语言·python
rebekk3 小时前
pytorch custom op的简单介绍
人工智能·pytorch·python