use of org.apache.beam.sdk.transforms.display.DisplayDataEvaluator 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.DisplayDataEvaluator 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.DisplayDataEvaluator 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)));
}
use of org.apache.beam.sdk.transforms.display.DisplayDataEvaluator in project beam by apache.
the class DatastoreV1Test method testSourcePrimitiveDisplayData.
@Test
public void testSourcePrimitiveDisplayData() {
DisplayDataEvaluator evaluator = DisplayDataEvaluator.create();
int numSplits = 98;
PTransform<PBegin, PCollection<Entity>> read = DatastoreIO.v1().read().withProjectId(PROJECT_ID).withQuery(Query.newBuilder().build()).withNumQuerySplits(numSplits);
String assertMessage = "DatastoreIO read should include the '%s' in its primitive display data";
Set<DisplayData> displayData = evaluator.displayDataForPrimitiveSourceTransforms(read);
assertThat(String.format(assertMessage, "project id"), displayData, hasItem(hasDisplayItem("projectId", PROJECT_ID)));
assertThat(String.format(assertMessage, "number of query splits"), displayData, hasItem(hasDisplayItem("numQuerySplits", numSplits)));
}
use of org.apache.beam.sdk.transforms.display.DisplayDataEvaluator in project beam by apache.
the class DatastoreV1Test method testDeleteKeyPrimitiveDisplayData.
@Test
public void testDeleteKeyPrimitiveDisplayData() {
int hintNumWorkers = 10;
DisplayDataEvaluator evaluator = DisplayDataEvaluator.create();
PTransform<PCollection<Key>, ?> write = DatastoreIO.v1().deleteKey().withProjectId("myProject").withHintNumWorkers(hintNumWorkers);
Set<DisplayData> displayData = evaluator.displayDataForPrimitiveTransforms(write);
assertThat("DatastoreIO write should include the project in its primitive display data", displayData, hasItem(hasDisplayItem("projectId")));
assertThat("DatastoreIO write should include the deleteKeyFn in its primitive display data", displayData, hasItem(hasDisplayItem("deleteKeyFn")));
assertThat("DatastoreIO write should include ramp-up throttling worker count hint if enabled", displayData, hasItem(hasDisplayItem("hintNumWorkers", hintNumWorkers)));
}
Aggregations