@Override protected Dataset<Triple<String, String, Integer>> getOutput(Dataset<Item> input) { return TopPerKey.of(input) .keyBy(Item::getKey) .valueBy(Item::getValue) .scoreBy(Item::getScore) .output(); }
@Override protected Dataset<Triple<String, String, Integer>> getOutput(Dataset<Item> input) { return TopPerKey.of(input) .keyBy(Item::getKey) .valueBy(Item::getValue) .scoreBy(Item::getScore) .output(); }
TopPerKey.of(joined) .keyBy(e -> (byte) 0) .valueBy(e -> e)
@Test public void testBuild_ImplicitName() { Flow flow = Flow.create("TEST"); Dataset<String> dataset = Util.createMockDataset(flow, 2); TopPerKey.of(dataset) .keyBy(s -> s) .valueBy(s -> 1L) .scoreBy(s -> 1L) .output(); TopPerKey tpk = (TopPerKey) Iterables.getOnlyElement(flow.operators()); assertEquals("TopPerKey", tpk.getName()); }
@Test public void testBuild_Windowing() { Flow flow = Flow.create("TEST"); Dataset<String> dataset = Util.createMockDataset(flow, 3); TopPerKey.of(dataset) .keyBy(s -> s) .valueBy(s -> 1L) .scoreBy(s -> 1L) .windowBy(Time.of(Duration.ofHours(1))) .output(); assertTrue(Iterables.getOnlyElement(flow.operators()) instanceof TopPerKey); }
@Test public void testWindow_applyIf() { Flow flow = Flow.create("TEST"); Dataset<String> dataset = Util.createMockDataset(flow, 3); TopPerKey.of(dataset) .keyBy(s -> s) .valueBy(s -> 1L) .scoreBy(s -> 1L) .applyIf(true, b -> b.windowBy(Time.of(Duration.ofHours(1)))) .output(); TopPerKey tpk = (TopPerKey) Iterables.getOnlyElement(flow.operators()); assertTrue(tpk.windowing instanceof Time); }