use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class TextIOTest method testWriteWithWritableByteChannelFactory.
@Test
@Category(NeedsRunner.class)
public void testWriteWithWritableByteChannelFactory() throws Exception {
Coder<String> coder = StringUtf8Coder.of();
String outputName = "file.txt";
Path baseDir = Files.createTempDirectory(tempFolder, "testwrite");
PCollection<String> input = p.apply(Create.of(Arrays.asList(LINES2_ARRAY)).withCoder(coder));
final WritableByteChannelFactory writableByteChannelFactory = new DrunkWritableByteChannelFactory();
TextIO.Write write = TextIO.write().to(baseDir.resolve(outputName).toString()).withoutSharding().withWritableByteChannelFactory(writableByteChannelFactory);
DisplayData displayData = DisplayData.from(write);
assertThat(displayData, hasDisplayItem("writableByteChannelFactory", "DRUNK"));
input.apply(write);
p.run();
final List<String> drunkElems = new ArrayList<>(LINES2_ARRAY.length * 2 + 2);
for (String elem : LINES2_ARRAY) {
drunkElems.add(elem);
drunkElems.add(elem);
}
assertOutputFiles(drunkElems.toArray(new String[0]), null, null, 1, baseDir, outputName + writableByteChannelFactory.getFilenameSuffix(), write.getShardTemplate());
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class TextIOTest method testWriteDisplayDataValidateThenFooter.
@Test
public void testWriteDisplayDataValidateThenFooter() {
TextIO.Write write = TextIO.write().to("foo").withFooter("myFooter");
DisplayData displayData = DisplayData.from(write);
assertThat(displayData, hasDisplayItem("fileFooter", "myFooter"));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class GroupByKeyTest method testDisplayData.
@Test
public void testDisplayData() {
GroupByKey<String, String> groupByKey = GroupByKey.create();
GroupByKey<String, String> groupByFewKeys = GroupByKey.createWithFewKeys();
DisplayData gbkDisplayData = DisplayData.from(groupByKey);
DisplayData fewKeysDisplayData = DisplayData.from(groupByFewKeys);
assertThat(gbkDisplayData.items(), empty());
assertThat(fewKeysDisplayData, hasDisplayItem("fewKeys", true));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class ParDoTest method testWithOutputTagsDisplayData.
@Test
public void testWithOutputTagsDisplayData() {
DoFn<String, String> fn = new DoFn<String, String>() {
@ProcessElement
public void proccessElement(ProcessContext c) {
}
@Override
public void populateDisplayData(Builder builder) {
builder.add(DisplayData.item("fnMetadata", "foobar"));
}
};
ParDo.MultiOutput<String, String> parDo = ParDo.of(fn).withOutputTags(new TupleTag<String>(), TupleTagList.empty());
DisplayData displayData = DisplayData.from(parDo);
assertThat(displayData, includesDisplayDataFor("fn", fn));
assertThat(displayData, hasDisplayItem("fn", fn.getClass()));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class ParDoTest method testDoFnWithContextDisplayData.
@Test
public void testDoFnWithContextDisplayData() {
DoFn<String, String> fn = new DoFn<String, String>() {
@ProcessElement
public void proccessElement(ProcessContext c) {
}
@Override
public void populateDisplayData(Builder builder) {
builder.add(DisplayData.item("fnMetadata", "foobar"));
}
};
SingleOutput<String, String> parDo = ParDo.of(fn);
DisplayData displayData = DisplayData.from(parDo);
assertThat(displayData, includesDisplayDataFor("fn", fn));
assertThat(displayData, hasDisplayItem("fn", fn.getClass()));
}
Aggregations