[英]Apache Beam How to use TestStream with files
I have a simple pipeline that just copies files from source to destination.我有一个简单的管道,它只是将文件从源复制到目标。 Im trying to write tests for the windowing I had set up.我正在尝试为我设置的窗口编写测试。
Is there a way to use the TestStream class for files?有没有办法对文件使用 TestStream 类?
For example:例如:
@Test
public void elementsAreInCorrectWindows() {
TestStream<FileIO.ReadableFile> testStream = TestStream.create(ReadableFileCoder.of())
.advanceWatermarkTo(start)
.addElements(readableFile1)
.advanceWatermarkTo(end)
.addElements(readableFile2)
.advanceWatermarkToInfinity();
}
However the constructor for ReadableFile is packaged protected so I wouldn't be able to create those objects.但是, ReadableFile 的构造函数是打包保护的,因此我无法创建这些对象。
I think it would be a reasonable feature/pull request to make this Coder public.我认为将这个 Coder 公开是一个合理的功能/拉取请求。 In the meantime, you could have a TestStream that produces elements of another type that you then transform with a DoFn into ReadableFiles.同时,您可以使用 TestStream 生成另一种类型的元素,然后您可以使用 DoFn 将其转换为 ReadableFiles。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.