【问题标题】:Apache Beam How to use TestStream with filesApache Beam 如何将 TestStream 与文件一起使用
【发布时间】:2020-08-25 17:00:31
【问题描述】:

我有一个简单的管道,它只是将文件从源复制到目标。我正在尝试为我设置的窗口编写测试。

有没有办法对文件使用 TestStream 类?

例如:

    @Test
    public void elementsAreInCorrectWindows() {
     
        TestStream<FileIO.ReadableFile> testStream = TestStream.create(ReadableFileCoder.of())
            .advanceWatermarkTo(start)
            .addElements(readableFile1)
            .advanceWatermarkTo(end)
            .addElements(readableFile2)
            .advanceWatermarkToInfinity();        
    }

但是,ReadableFile 的构造函数被打包保护,所以我无法创建这些对象。

【问题讨论】:

    标签: java junit apache-beam


    【解决方案1】:

    我认为将此 Coder 公开是一个合理的功能/拉取请求。同时,您可以有一个 TestStream 来生成另一种类型的元素,然后您可以使用 DoFn 将其转换为 ReadableFiles。

    【讨论】:

      猜你喜欢
      • 2020-01-17
      • 2022-12-24
      • 1970-01-01
      • 2017-06-25
      • 2021-10-10
      • 1970-01-01
      • 2018-11-09
      • 1970-01-01
      • 2010-10-29
      相关资源
      最近更新 更多