Example #1
0
    public GroupAlsoByWindowEvaluator(
        final EvaluationContext evaluationContext,
        CommittedBundle<KeyedWorkItem<K, V>> inputBundle,
        final AppliedPTransform<
                PCollection<KeyedWorkItem<K, V>>,
                PCollection<KV<K, Iterable<V>>>,
                DirectGroupAlsoByWindow<K, V>>
            application) {
      this.evaluationContext = evaluationContext;
      this.application = application;

      stepContext =
          evaluationContext
              .getExecutionContext(application, inputBundle.getKey())
              .getOrCreateStepContext(
                  evaluationContext.getStepName(application), application.getTransform().getName());
      windowingStrategy =
          (WindowingStrategy<?, BoundedWindow>)
              application.getTransform().getInputWindowingStrategy();

      outputBundles = new ArrayList<>();
      unprocessedElements = ImmutableList.builder();
      aggregatorChanges = evaluationContext.getAggregatorMutator();

      Coder<V> valueCoder =
          application.getTransform().getValueCoder(inputBundle.getPCollection().getCoder());
      reduceFn = SystemReduceFn.buffering(valueCoder);
      droppedDueToClosedWindow =
          aggregatorChanges.createSystemAggregator(
              stepContext,
              GroupAlsoByWindowsDoFn.DROPPED_DUE_TO_CLOSED_WINDOW_COUNTER,
              new Sum.SumLongFn());
      droppedDueToLateness =
          aggregatorChanges.createSystemAggregator(
              stepContext,
              GroupAlsoByWindowsDoFn.DROPPED_DUE_TO_LATENESS_COUNTER,
              new Sum.SumLongFn());
    }