Search in sources :

Example 91 with DisplayData

use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.

the class WindowTest method testDisplayData.

@Test
public void testDisplayData() {
    FixedWindows windowFn = FixedWindows.of(Duration.standardHours(5));
    AfterWatermark.FromEndOfWindow triggerBuilder = AfterWatermark.pastEndOfWindow();
    Duration allowedLateness = Duration.standardMinutes(10);
    Window.ClosingBehavior closingBehavior = Window.ClosingBehavior.FIRE_IF_NON_EMPTY;
    TimestampCombiner timestampCombiner = TimestampCombiner.END_OF_WINDOW;
    Window<?> window = Window.into(windowFn).triggering(triggerBuilder).accumulatingFiredPanes().withAllowedLateness(allowedLateness, closingBehavior).withTimestampCombiner(timestampCombiner);
    DisplayData displayData = DisplayData.from(window);
    assertThat(displayData, hasDisplayItem("windowFn", windowFn.getClass()));
    assertThat(displayData, includesDisplayDataFor("windowFn", windowFn));
    assertThat(displayData, hasDisplayItem("trigger", triggerBuilder.toString()));
    assertThat(displayData, hasDisplayItem("accumulationMode", AccumulationMode.ACCUMULATING_FIRED_PANES.toString()));
    assertThat(displayData, hasDisplayItem("allowedLateness", allowedLateness));
    assertThat(displayData, hasDisplayItem("closingBehavior", closingBehavior.toString()));
    assertThat(displayData, hasDisplayItem("timestampCombiner", timestampCombiner.toString()));
}
Also used : Duration(org.joda.time.Duration) DisplayData(org.apache.beam.sdk.transforms.display.DisplayData) Test(org.junit.Test)

Example 92 with DisplayData

use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.

the class WindowTest method testPrimitiveDisplayData.

@Test
@Category(ValidatesRunner.class)
public void testPrimitiveDisplayData() {
    FixedWindows windowFn = FixedWindows.of(Duration.standardHours(5));
    AfterWatermark.FromEndOfWindow triggerBuilder = AfterWatermark.pastEndOfWindow();
    Duration allowedLateness = Duration.standardMinutes(10);
    Window.ClosingBehavior closingBehavior = Window.ClosingBehavior.FIRE_IF_NON_EMPTY;
    TimestampCombiner timestampCombiner = TimestampCombiner.END_OF_WINDOW;
    Window<?> window = Window.into(windowFn).triggering(triggerBuilder).accumulatingFiredPanes().withAllowedLateness(allowedLateness, closingBehavior).withTimestampCombiner(timestampCombiner);
    DisplayData primitiveDisplayData = Iterables.getOnlyElement(DisplayDataEvaluator.create().displayDataForPrimitiveTransforms(window));
    assertThat(primitiveDisplayData, hasDisplayItem("windowFn", windowFn.getClass()));
    assertThat(primitiveDisplayData, includesDisplayDataFor("windowFn", windowFn));
    assertThat(primitiveDisplayData, hasDisplayItem("trigger", triggerBuilder.toString()));
    assertThat(primitiveDisplayData, hasDisplayItem("accumulationMode", AccumulationMode.ACCUMULATING_FIRED_PANES.toString()));
    assertThat(primitiveDisplayData, hasDisplayItem("allowedLateness", allowedLateness));
    assertThat(primitiveDisplayData, hasDisplayItem("closingBehavior", closingBehavior.toString()));
    assertThat(primitiveDisplayData, hasDisplayItem("timestampCombiner", timestampCombiner.toString()));
}
Also used : Duration(org.joda.time.Duration) DisplayData(org.apache.beam.sdk.transforms.display.DisplayData) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 93 with DisplayData

use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.

the class FixedWindowsTest method testDisplayData.

@Test
public void testDisplayData() {
    Duration offset = Duration.standardSeconds(1234);
    Duration size = Duration.standardSeconds(2345);
    FixedWindows fixedWindows = FixedWindows.of(size).withOffset(offset);
    DisplayData displayData = DisplayData.from(fixedWindows);
    assertThat(displayData, hasDisplayItem("size", size));
    assertThat(displayData, hasDisplayItem("offset", offset));
}
Also used : Duration(org.joda.time.Duration) DisplayData(org.apache.beam.sdk.transforms.display.DisplayData) Test(org.junit.Test)

Example 94 with DisplayData

use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.

the class SlidingWindowsTest method testDisplayData.

@Test
public void testDisplayData() {
    Duration windowSize = Duration.standardSeconds(1234);
    Duration offset = Duration.standardSeconds(2345);
    Duration period = Duration.standardSeconds(3456);
    SlidingWindows slidingWindowFn = SlidingWindows.of(windowSize).every(period).withOffset(offset);
    DisplayData displayData = DisplayData.from(slidingWindowFn);
    assertThat(displayData, hasDisplayItem("size", windowSize));
    assertThat(displayData, hasDisplayItem("period", period));
    assertThat(displayData, hasDisplayItem("offset", offset));
}
Also used : Duration(org.joda.time.Duration) DisplayData(org.apache.beam.sdk.transforms.display.DisplayData) Test(org.junit.Test)

Example 95 with DisplayData

use of org.apache.beam.sdk.transforms.display.DisplayData in project beam by apache.

the class DatastoreV1Test method testWritePrimitiveDisplayData.

@Test
public void testWritePrimitiveDisplayData() {
    int hintNumWorkers = 10;
    DisplayDataEvaluator evaluator = DisplayDataEvaluator.create();
    PTransform<PCollection<Entity>, ?> write = DatastoreIO.v1().write().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 upsertFn in its primitive display data", displayData, hasItem(hasDisplayItem("upsertFn")));
    assertThat("DatastoreIO write should include ramp-up throttling worker count hint if enabled", displayData, hasItem(hasDisplayItem("hintNumWorkers", hintNumWorkers)));
}
Also used : PCollection(org.apache.beam.sdk.values.PCollection) DisplayDataEvaluator(org.apache.beam.sdk.transforms.display.DisplayDataEvaluator) DisplayData(org.apache.beam.sdk.transforms.display.DisplayData) Test(org.junit.Test)

Aggregations

DisplayData (org.apache.beam.sdk.transforms.display.DisplayData)117 Test (org.junit.Test)115 DisplayDataEvaluator (org.apache.beam.sdk.transforms.display.DisplayDataEvaluator)16 PCollection (org.apache.beam.sdk.values.PCollection)11 ByteString (com.google.protobuf.ByteString)9 Category (org.junit.experimental.categories.Category)9 Matchers.containsString (org.hamcrest.Matchers.containsString)6 Duration (org.joda.time.Duration)6 TableRow (com.google.api.services.bigquery.model.TableRow)4 Params (org.apache.beam.sdk.io.DefaultFilenamePolicy.Params)3 BigQueryHelpers.toJsonString (org.apache.beam.sdk.io.gcp.bigquery.BigQueryHelpers.toJsonString)3 Builder (org.apache.beam.sdk.transforms.display.DisplayData.Builder)3 Instant (org.joda.time.Instant)3 TableSchema (com.google.api.services.bigquery.model.TableSchema)2 RowFilter (com.google.bigtable.v2.RowFilter)2 ArrayList (java.util.ArrayList)2 WritableByteChannelFactory (org.apache.beam.sdk.io.FileBasedSink.WritableByteChannelFactory)2 ParDo (org.apache.beam.sdk.transforms.ParDo)2 StringUtils.byteArrayToJsonString (org.apache.beam.sdk.util.StringUtils.byteArrayToJsonString)2 ImmutableSet (com.google.common.collect.ImmutableSet)1