use of org.apache.beam.sdk.extensions.euphoria.core.client.util.Triple in project beam by apache.
the class TopPerKeyTest method testBuild.
@Test
public void testBuild() {
final PCollection<String> dataset = TestUtils.createMockDataset(TypeDescriptors.strings());
final FixedWindows windowing = FixedWindows.of(org.joda.time.Duration.standardHours(1));
final DefaultTrigger trigger = DefaultTrigger.of();
final PCollection<Triple<String, Long, Long>> result = TopPerKey.named("TopPerKey1").of(dataset).keyBy(s -> s).valueBy(s -> 1L).scoreBy(s -> 1L).windowBy(windowing).triggeredBy(trigger).discardingFiredPanes().withAllowedLateness(Duration.millis(1000)).output();
final TopPerKey tpk = (TopPerKey) TestUtils.getProducer(result);
assertTrue(tpk.getName().isPresent());
assertEquals("TopPerKey1", tpk.getName().get());
assertNotNull(tpk.getKeyExtractor());
assertNotNull(tpk.getValueExtractor());
assertNotNull(tpk.getScoreExtractor());
assertTrue(tpk.getWindow().isPresent());
@SuppressWarnings("unchecked") final WindowDesc<?> windowDesc = WindowDesc.of((Window) tpk.getWindow().get());
assertEquals(windowing, windowDesc.getWindowFn());
assertEquals(trigger, windowDesc.getTrigger());
assertEquals(AccumulationMode.DISCARDING_FIRED_PANES, windowDesc.getAccumulationMode());
assertEquals(Duration.millis(1000), windowDesc.getAllowedLateness());
}
Aggregations