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

相关推荐
Juchecar1 小时前
解惑:NumPy 中 ndarray.ndim 到底是什么?
python
用户8356290780511 小时前
Python 删除 Excel 工作表中的空白行列
后端·python
Json_1 小时前
使用python-fastApi框架开发一个学校宿舍管理系统-前后端分离项目
后端·python·fastapi
数据智能老司机8 小时前
精通 Python 设计模式——分布式系统模式
python·设计模式·架构
数据智能老司机9 小时前
精通 Python 设计模式——并发与异步模式
python·设计模式·编程语言
数据智能老司机9 小时前
精通 Python 设计模式——测试模式
python·设计模式·架构
数据智能老司机9 小时前
精通 Python 设计模式——性能模式
python·设计模式·架构
c8i9 小时前
drf初步梳理
python·django
每日AI新事件9 小时前
python的异步函数
python
这里有鱼汤10 小时前
miniQMT下载历史行情数据太慢怎么办?一招提速10倍!
前端·python