.apply( "extractTopOffsetAndFetch", Top.of(startIndex + count, comparator).withoutDefaults()) .setCoder(ListCoder.of(upstream.getCoder()));
pipeline.apply(Create.of(1)).apply(Sum.integersGlobally().asSingletonView());
@Test @Category(ValidatesRunner.class) public void testHotKeyCombiningWithAccumulationMode() { PCollection<Integer> input = pipeline.apply(Create.of(1, 2, 3, 4, 5)); PCollection<Integer> output = input .apply( Window.<Integer>into(new GlobalWindows()) .triggering(Repeatedly.forever(AfterPane.elementCountAtLeast(1))) .accumulatingFiredPanes() .withAllowedLateness(new Duration(0), ClosingBehavior.FIRE_ALWAYS)) .apply(Sum.integersGlobally().withoutDefaults().withFanout(2)) .apply(ParDo.of(new GetLast())); PAssert.that(output) .satisfies( input1 -> { assertThat(input1, hasItem(15)); return null; }); pipeline.run(); }
FixedWindows.of(Duration.standardMinutes(options.getUserActivityWindowDuration())))) .apply(Mean.<Integer>globally().withoutDefaults())
.apply(Flatten.iterables()); PCollection<Long> count = windowed.apply(Combine.globally(Count.<Integer>combineFn()).withoutDefaults()); PCollection<Integer> sum = windowed.apply(Sum.integersGlobally().withoutDefaults());
new ConcatStringWithContext(view), concatStringTag)) .withoutDefaults() .withSideInputs(ImmutableList.of(view))) .apply(WithKeys.of("global")) .apply(
"CollectWriteTasks", Combine.globally(new IterableCombinerFn<>(TypeDescriptors.integers())) .withoutDefaults()) .setTypeDescriptor(iterableIntType);
globallyInput.apply("Sum", Sum.integersGlobally().withoutDefaults()); globallyInput.apply( Combine.globally(new TestCombineFnWithContext(globallySumView)) .withoutDefaults() .withSideInputs(globallySumView));
namesAndIds .apply(ParDo.of(new TestRow.SelectNameFn())) .apply("Hash row contents", Combine.globally(new HashingFn()).withoutDefaults()); PAssert.that(consolidatedHashcode) .containsInAnyOrder(TestRow.getExpectedHashForRowCount(numberOfRows));
TimestampedValue.of(3, new Instant(100)))) .apply("WindowSideInput", Window.into(windowFn)) .apply("CombineSideInput", Sum.integersGlobally().asSingletonView());
globallyInput .apply("FixedWindows", Window.into(FixedWindows.of(Duration.millis(5)))) .apply("Sum", Combine.globally(new SumInts()).withoutDefaults()); .apply( Combine.globally(new TestCombineFnWithContext(globallyFixedWindowsView)) .withoutDefaults() .withSideInputs(globallyFixedWindowsView));
textValues.apply(Combine.globally(new HashingFn()).withoutDefaults()); PAssert.that(consolidatedHashcode).containsInAnyOrder(expectedHashCode); pipeline.run().waitUntilFinish();
textValues.apply(Combine.globally(new HashingFn()).withoutDefaults()); PAssert.that(consolidatedHashcode).containsInAnyOrder(expectedHashCode); pipeline.run().waitUntilFinish();
sumScores.apply(Values.create()).apply(Mean.<Integer>globally().asSingletonView());
TimestampedValue.of(3, new Instant(13)))) .apply("WindowSideInput", Window.into(FixedWindows.of(Duration.millis(10)))) .apply(Sum.integersGlobally().withoutDefaults()) .apply(View.asSingleton());
TimestampedValue.of(3, new Instant(13)))) .apply("WindowSideInput", Window.into(FixedWindows.of(Duration.millis(10)))) .apply(Sum.integersGlobally().asSingletonView());
textValues.apply(Combine.globally(new HashingFn()).withoutDefaults()); PAssert.that(consolidatedHashcode).containsInAnyOrder(expectedHashCode); pipeline.run().waitUntilFinish();
hasSideInput = sideInputs != null && !sideInputs.isEmpty(); } else if (transform instanceof Combine.Globally) { List<PCollectionView<?>> sideInputs = ((Combine.Globally<?, ?>) transform).getSideInputs(); hasSideInput = sideInputs != null && !sideInputs.isEmpty();
globallyInput.apply("Sum", Combine.globally(new SumInts()).withoutDefaults()); globallyInput.apply( Combine.globally(new TestCombineFnWithContext(globallySumView)) .withoutDefaults() .withSideInputs(globallySumView));