use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class ApproximateQuantilesTest method testDisplayData.
@Test
public void testDisplayData() {
Top.Natural<Integer> comparer = new Top.Natural<Integer>();
PTransform<?, ?> approxQuanitiles = ApproximateQuantiles.globally(20, comparer);
DisplayData displayData = DisplayData.from(approxQuanitiles);
assertThat(displayData, hasDisplayItem("numQuantiles", 20));
assertThat(displayData, hasDisplayItem("comparer", comparer.getClass()));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class CombineTest method testDisplayDataForWrappedFn.
@Test
public void testDisplayDataForWrappedFn() {
UniqueInts combineFn = new UniqueInts() {
@Override
public void populateDisplayData(DisplayData.Builder builder) {
builder.add(DisplayData.item("foo", "bar"));
}
};
Combine.PerKey<?, ?, ?> combine = Combine.perKey(combineFn);
DisplayData displayData = DisplayData.from(combine);
assertThat(displayData, hasDisplayItem("combineFn", combineFn.getClass()));
assertThat(displayData, hasDisplayItem(hasNamespace(combineFn.getClass())));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class BigtableIOTest method testReadingPrimitiveDisplayData.
@Test
public void testReadingPrimitiveDisplayData() throws IOException, InterruptedException {
final String table = "fooTable";
service.createTable(table);
RowFilter rowFilter = RowFilter.newBuilder().setRowKeyRegexFilter(ByteString.copyFromUtf8("foo.*")).build();
DisplayDataEvaluator evaluator = DisplayDataEvaluator.create();
BigtableIO.Read read = BigtableIO.read().withBigtableOptions(BIGTABLE_OPTIONS).withTableId(table).withRowFilter(rowFilter).withBigtableService(service);
Set<DisplayData> displayData = evaluator.displayDataForPrimitiveSourceTransforms(read);
assertThat("BigtableIO.Read should include the table id in its primitive display data", displayData, Matchers.hasItem(hasDisplayItem("tableId")));
assertThat("BigtableIO.Read should include the row filter, if it exists, in its primitive " + "display data", displayData, Matchers.hasItem(hasDisplayItem("rowFilter")));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class BigQueryIOTest method testQuerySourcePrimitiveDisplayData.
@Test
public void testQuerySourcePrimitiveDisplayData() throws IOException, InterruptedException {
DisplayDataEvaluator evaluator = DisplayDataEvaluator.create();
BigQueryIO.Read read = BigQueryIO.read().fromQuery("foobar").withTestServices(new FakeBigQueryServices().withDatasetService(new FakeDatasetService()).withJobService(new FakeJobService())).withoutValidation();
Set<DisplayData> displayData = evaluator.displayDataForPrimitiveSourceTransforms(read);
assertThat("BigQueryIO.Read should include the query in its primitive display data", displayData, hasItem(hasDisplayItem("query")));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class ReadTest method testPrimitiveDisplayData.
private void testPrimitiveDisplayData(boolean isStreaming) {
PipelineOptions options = DisplayDataEvaluator.getDefaultOptions();
options.as(StreamingOptions.class).setStreaming(isStreaming);
DisplayDataEvaluator evaluator = DisplayDataEvaluator.create(options);
SerializableBoundedSource boundedSource = new SerializableBoundedSource() {
@Override
public void populateDisplayData(DisplayData.Builder builder) {
builder.add(DisplayData.item("foo", "bar"));
}
};
SerializableUnboundedSource unboundedSource = new SerializableUnboundedSource() {
@Override
public void populateDisplayData(DisplayData.Builder builder) {
builder.add(DisplayData.item("foo", "bar"));
}
};
Read.Bounded<String> bounded = Read.from(boundedSource);
BoundedReadFromUnboundedSource<String> unbounded = Read.from(unboundedSource).withMaxNumRecords(1234);
Set<DisplayData> boundedDisplayData = evaluator.displayDataForPrimitiveSourceTransforms(bounded);
assertThat(boundedDisplayData, hasItem(hasDisplayItem("source", boundedSource.getClass())));
assertThat(boundedDisplayData, hasItem(includesDisplayDataFor("source", boundedSource)));
Set<DisplayData> unboundedDisplayData = evaluator.displayDataForPrimitiveSourceTransforms(unbounded);
assertThat(unboundedDisplayData, hasItem(hasDisplayItem("source")));
assertThat(unboundedDisplayData, hasItem(includesDisplayDataFor("source", unboundedSource)));
}
Aggregations