use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class AvroIOTest method testPrimitiveReadDisplayData.
@Test
@Category(ValidatesRunner.class)
public void testPrimitiveReadDisplayData() {
DisplayDataEvaluator evaluator = DisplayDataEvaluator.create();
AvroIO.Read<GenericRecord> read = AvroIO.readGenericRecords(Schema.create(Schema.Type.STRING)).from("/foo.*");
Set<DisplayData> displayData = evaluator.displayDataForPrimitiveSourceTransforms(read);
assertThat("AvroIO.Read should include the file pattern in its primitive transform", displayData, hasItem(hasDisplayItem("filePattern")));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class CombineJava8Test method testLambdaDisplayData.
@Test
public void testLambdaDisplayData() {
Combine.Globally<?, ?> combine = Combine.globally(xs -> Iterables.getFirst(xs, 0));
DisplayData displayData = DisplayData.from(combine);
assertThat(displayData.items(), not(empty()));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class DisplayDataTranslation method toProto.
public static List<RunnerApi.DisplayData> toProto(DisplayData displayData) {
ImmutableList.Builder<RunnerApi.DisplayData> builder = ImmutableList.builder();
for (DisplayData.Item item : displayData.items()) {
Function<DisplayData.Item, ByteString> translator = WELL_KNOWN_URN_TRANSLATORS.get(item.getKey());
String urn;
if (translator != null) {
urn = item.getKey();
} else {
urn = LABELLED;
translator = DisplayDataTranslation::translate;
}
builder.add(RunnerApi.DisplayData.newBuilder().setUrn(urn).setPayload(translator.apply(item)).build());
}
return builder.build();
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class PrimitiveParDoSingleFactoryTest method getReplacementTransformPopulateDisplayData.
/**
* A test that demonstrates that the replacement transform has the Display Data of the {@link
* ParDo.SingleOutput} it replaces.
*/
@Test
public void getReplacementTransformPopulateDisplayData() {
ParDo.SingleOutput<Integer, Long> originalTransform = ParDo.of(new ToLongFn());
DisplayData originalDisplayData = DisplayData.from(originalTransform);
PCollection<? extends Integer> input = pipeline.apply(Create.of(1, 2, 3));
AppliedPTransform<PCollection<? extends Integer>, PCollection<Long>, ParDo.SingleOutput<Integer, Long>> application = AppliedPTransform.of("original", PValues.expandInput(input), PValues.expandOutput(input.apply(originalTransform)), originalTransform, ResourceHints.create(), pipeline);
PTransformReplacement<PCollection<? extends Integer>, PCollection<Long>> replacement = factory.getReplacementTransform(application);
DisplayData replacementDisplayData = DisplayData.from(replacement.getTransform());
assertThat(replacementDisplayData, equalTo(originalDisplayData));
DisplayData primitiveDisplayData = Iterables.getOnlyElement(DisplayDataEvaluator.create().displayDataForPrimitiveTransforms(replacement.getTransform(), VarIntCoder.of()));
assertThat(primitiveDisplayData, equalTo(replacementDisplayData));
}
use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.
the class GenerateSequenceTest method testBoundedDisplayDataSubrange.
@Test
public void testBoundedDisplayDataSubrange() {
PTransform<?, ?> input = GenerateSequence.from(12).to(1234);
DisplayData displayData = DisplayData.from(input);
assertThat(displayData, hasDisplayItem("from", 12));
assertThat(displayData, hasDisplayItem("to", 1234));
}
Aggregations