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

相关推荐
布局呆星15 分钟前
RAG从0~1,初入~优化
python
王志来1379447300822 分钟前
场景驱动选型:4U工控机箱如何匹配多元化工业需求
大数据·人工智能·python
2601_9623815838 分钟前
[Python人工智能] 九.gensim词向量Word2Vec安装及《庆余年》中文短文本相似度计算
人工智能·python·tensorflow·word2vec·文本相似度
️学习的小王40 分钟前
Flask实现云栖笔记|开箱即用网页版本地笔记本
笔记·python·flask
quantdash_cc1 小时前
批量请求和循环请求有什么区别?从 API 请求次数看量化数据获取的工程设计
开发语言·python·数据分析·pandas·量化交易·股票数据·quantdash
码农刚子1 小时前
告别影楼和付费 App,5 分钟本地搭一个证件照自由平台|HivisionIDPhotos 开箱实测
python·图像识别
Tizzy JJ1 小时前
Python + pytest 接口自动化测试框架实战:从零搭建企业级项目骨架
开发语言·python·pytest
Zane19941 小时前
手写"判断key存不存在"的模板代码太烦?一文讲透 collections 四件套
后端·python
海兰1 小时前
【 Python 量化交易】第8章:量化工具箱
开发语言·python
TheBestRucy1 小时前
Python九阳神功之柒:数据分析三剑客·执剑问道
开发语言·python·数据分析