private void applicableTo(PCollection<?> input) { WindowingStrategy<?, ?> outputStrategy = getOutputStrategyInternal(input.getWindowingStrategy()); // Make sure that the windowing strategy is complete & valid. if (outputStrategy.isTriggerSpecified() && !(outputStrategy.getTrigger() instanceof DefaultTrigger) && !(outputStrategy.getWindowFn() instanceof GlobalWindows) && !outputStrategy.isAllowedLatenessSpecified()) { throw new IllegalArgumentException( "Except when using GlobalWindows," + " calling .triggering() to specify a trigger requires that the allowed lateness" + " be specified using .withAllowedLateness() to set the upper bound on how late" + " data can arrive before being dropped. See Javadoc for more details."); } if (!outputStrategy.isModeSpecified() && canProduceMultiplePanes(outputStrategy)) { throw new IllegalArgumentException( "Calling .triggering() to specify a trigger or calling .withAllowedLateness() to" + " specify an allowed lateness greater than zero requires that the accumulation" + " mode be specified using .discardingFiredPanes() or .accumulatingFiredPanes()." + " See Javadoc for more details."); } }
@Override public PCollection<T> expand(PCollection<T> input) { applicableTo(input); WindowingStrategy<?, ?> outputStrategy = getOutputStrategyInternal(input.getWindowingStrategy()); if (getWindowFn() == null) { // A new PCollection must be created in case input is reused in a different location as the // two PCollections will, in general, have a different windowing strategy. return PCollectionList.of(input) .apply(Flatten.pCollections()) .setWindowingStrategyInternal(outputStrategy); } else { // This is the AssignWindows primitive return input.apply(new Assign<>(this, outputStrategy)); } }