use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class CombineTest method testCombinePerKeyWithHotKeyFanoutPrimitiveDisplayData.
@Test
@Category(ValidatesRunner.class)
public void testCombinePerKeyWithHotKeyFanoutPrimitiveDisplayData() {
int hotKeyFanout = 2;
DisplayDataEvaluator evaluator = DisplayDataEvaluator.create();
CombineTest.UniqueInts combineFn = new CombineTest.UniqueInts();
PTransform<PCollection<KV<Integer, Integer>>, PCollection<KV<Integer, Set<Integer>>>> combine = Combine.<Integer, Integer, Set<Integer>>perKey(combineFn).withHotKeyFanout(hotKeyFanout);
Set<DisplayData> displayData = evaluator.displayDataForPrimitiveTransforms(combine, KvCoder.of(VarIntCoder.of(), VarIntCoder.of()));
assertThat("Combine.perKey.withHotKeyFanout should include the combineFn in its primitive " + "transform", displayData, hasItem(hasDisplayItem("combineFn", combineFn.getClass())));
assertThat("Combine.perKey.withHotKeyFanout(int) should include the fanout in its primitive " + "transform", displayData, hasItem(hasDisplayItem("fanout", hotKeyFanout)));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class CombineTest method testDisplayData.
@Test
public void testDisplayData() {
UniqueInts combineFn = new UniqueInts() {
@Override
public void populateDisplayData(DisplayData.Builder builder) {
builder.add(DisplayData.item("fnMetadata", "foobar"));
}
};
Combine.Globally<?, ?> combine = Combine.globally(combineFn).withFanout(1234);
DisplayData displayData = DisplayData.from(combine);
assertThat(displayData, hasDisplayItem("combineFn", combineFn.getClass()));
assertThat(displayData, hasDisplayItem("emitDefaultOnEmptyInput", true));
assertThat(displayData, hasDisplayItem("fanout", 1234));
assertThat(displayData, includesDisplayDataFor("combineFn", combineFn));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class CombineTest method testCombinePerKeyPrimitiveDisplayData.
@Test
@Category(ValidatesRunner.class)
public void testCombinePerKeyPrimitiveDisplayData() {
DisplayDataEvaluator evaluator = DisplayDataEvaluator.create();
CombineTest.UniqueInts combineFn = new CombineTest.UniqueInts();
PTransform<PCollection<KV<Integer, Integer>>, ? extends POutput> combine = Combine.perKey(combineFn);
Set<DisplayData> displayData = evaluator.displayDataForPrimitiveTransforms(combine, KvCoder.of(VarIntCoder.of(), VarIntCoder.of()));
assertThat("Combine.perKey should include the combineFn in its primitive transform", displayData, hasItem(hasDisplayItem("combineFn", combineFn.getClass())));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class ParDoTest method testDoFnDisplayData.
@Test
public void testDoFnDisplayData() {
DoFn<String, String> fn = new DoFn<String, String>() {
@ProcessElement
public void processElement(ProcessContext c) {
}
@Override
public void populateDisplayData(Builder builder) {
builder.add(DisplayData.item("doFnMetadata", "bar"));
}
};
SingleOutput<String, String> parDo = ParDo.of(fn);
DisplayData displayData = DisplayData.from(parDo);
assertThat(displayData, hasDisplayItem(allOf(hasKey("fn"), hasType(DisplayData.Type.JAVA_CLASS), DisplayDataMatchers.hasValue(fn.getClass().getName()))));
assertThat(displayData, includesDisplayDataFor("fn", fn));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class BigQueryIOTest method testBuildWriteDisplayData.
@Test
public void testBuildWriteDisplayData() {
String tableSpec = "project:dataset.table";
TableSchema schema = new TableSchema().set("col1", "type1").set("col2", "type2");
final String tblDescription = "foo bar table";
BigQueryIO.Write<TableRow> write = BigQueryIO.writeTableRows().to(tableSpec).withSchema(schema).withCreateDisposition(CreateDisposition.CREATE_IF_NEEDED).withWriteDisposition(WriteDisposition.WRITE_APPEND).withTableDescription(tblDescription).withoutValidation();
DisplayData displayData = DisplayData.from(write);
assertThat(displayData, hasDisplayItem("table"));
assertThat(displayData, hasDisplayItem("schema"));
assertThat(displayData, hasDisplayItem("createDisposition", CreateDisposition.CREATE_IF_NEEDED.toString()));
assertThat(displayData, hasDisplayItem("writeDisposition", WriteDisposition.WRITE_APPEND.toString()));
assertThat(displayData, hasDisplayItem("tableDescription", tblDescription));
assertThat(displayData, hasDisplayItem("validation", false));
}
Aggregations