简体   繁体   English

我如何使用 Apache Flink 在这个 avro 模式中应用过滤器

[英]How can i apply a filter in this avro schema using Apache Flink

Hello guys i'm deserializing an Avro Kafka message like this:大家好,我正在反序列化一条 Avro Kafka 消息,如下所示:

FlinkKafkaConsumer<String> consumer = new FlinkKafkaConsumer("conekta.public.person",
     new KafkaGenericAvroDeserializationSchema("http://localhost:8081"), kafkaProps);

the messagge i'm getting is like this:我收到的消息是这样的:

{"before": null, "after": {"id": 257, "status": "c4ca4238a0"}, "source": {"version": "0.9.4.Final", "connector": "postgresql", "name": "conekta", "db": "testdb", "ts_usec": 1579909929965704, "txId": 5847, "lsn": 294339488688, "schema": "public", "table": "person", "snapshot": false, "last_snapshot_record": null, "xmin": null}, "op": "c", "ts_ms": 1579909930004}

{"before": null, "after": {"id": 258, "status": "c4ca4238a0"}, "source": {"version": "0.9.4.Final", "connector": "postgresql", "name": "conekta", "db": "testdb", "ts_usec": 1579910374459669, "txId": 5849, "lsn": 294473695272, "schema": "public", "table": "person", "snapshot": false, "last_snapshot_record": null, "xmin": null}, "op": "c", "ts_ms": 1579910374518}

How could i apply a filterto get all the records where the id is < 258 on my flink consumer.我如何应用过滤器来获取我的 flink 消费者上 id < 258 的所有记录。

I'm very new in Apache Flink.我对 Apache Flink 很陌生。

Any help will be much appreciated.任何帮助都感激不尽。

Thanks!谢谢!

您可以覆盖 KafkaGenericAvroDeserializationSchema 上的boolean isEndOfStream(GenericRecord nextElement)以在您希望流结束时返回 true。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM