简体   繁体   English

如何使用 Apache Beam 中的流输入 PCollection 请求 Redis 服务器?

[英]How to request Redis server using a streaming input PCollection in Apache Beam?

Using RedisIO , I'm trying to query a collection to a redis server.使用RedisIO ,我正在尝试将集合查询到 redis 服务器。

The Redis server is ok and responding good only when batch pipeline (no streaming). Redis 服务器正常并且只有在批处理管道(无流)时响应良好。

But, using streaming input data (from files) like this:但是,使用这样的流输入数据(来自文件):

  PCollection<String> stream = pipeline.apply("ReadMyFile", TextIO.read().from("/home/out/**")
  .watchForNewFiles(Duration.standardSeconds(60), Watch.Growth.<String>never()))   
  .apply("ParseFn", ParDo.of(new ParseFn()))
  .apply("GlobalString", GlobalString.get(Duration.ZERO, Duration.standardSeconds(60)));

And then, apply the redisIO read() function:然后,应用 redisIO read() 函数:

 PCollection<KV<String, String>> redis = stream.apply(RedisIO.readAll().withEndpoint("127.0.0.1", 6379));

Finally, want to use the result collection, so:最后,想使用结果集合,所以:

 PCollection<String> result = redis.apply("Compose Final Object", ParDo.of(new DoFn<KV<String, String>, String>() {
    @ProcessElement
    public void processElement(ProcessContext c) {
      System.out.println(c.element().getKey());
      c.output(c.element().getKey());
    }
  }));

As far as I tested, the files are being loaded and processed as needed.据我测试,文件正在根据需要加载和处理。

For further developments, it is a bug:对于进一步的发展,这是一个错误:

https://github.com/apache/beam/pull/10624/commits https://github.com/apache/beam/pull/10624/commits

https://issues.apache.org/jira/browse/BEAM-9134 https://issues.apache.org/jira/browse/BEAM-9134

It will be fixed soon.它很快就会被修复。

暂无
暂无

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

相关问题 如何转换 PCollection<tablerow> 到个人收藏<row>在 Apache 梁?</row></tablerow> - How to convert PCollection<TableRow> to PCollection<Row> in Apache Beam? 如何在 PCollection 中组合数据 - Apache Beam - How to combine Data in PCollection - Apache beam 如何为 PCollection 设置编码器<List<String> &gt; 在 Apache Beam 中? - How do I set the coder for a PCollection<List<String>> in Apache Beam? 如何将 JSON Array 反序列化为 Apache beam PCollection<javaobject></javaobject> - How to deserialize JSON Array to Apache beam PCollection<javaObject> Apache Beam:扁平化 PCollection <List<Foo> &gt; 到 PCollection<Foo> - Apache Beam: Flattening PCollection<List<Foo>> to PCollection<Foo> Apache Beam - 使用无界PCollection进行集成测试 - Apache Beam - Integration test with unbounded PCollection 在 Apache Beam PCollection 中使用 AutoValueSchema 会给出“RuntimeException:Creator 参数 arg0 与架构字段不对应” - Using AutoValueSchema in Apache Beam PCollection gives `RuntimeException: Creator parameter arg0 Doesn't correspond to a schema field` 如何在处理PCollection中的元素时将元素发布到kafka主题 <KV<String,String> &gt;在apache梁中的ParDo功能? - How to publish elements to a kafka topic while processing the elements in the PCollection<KV<String,String>> in ParDo function in apache beam? Apache Beam TextIO.ReadAll如何发出KeyValue而不是Pcollection的字符串 - Apache Beam TextIO.ReadAll How to emit KeyValue instead of String of Pcollection 如何在 Apache Beam 中为我的 PCollection 使用 AutoValue 数据类型? - How do I use an AutoValue data type for my PCollection in Apache Beam?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM