Class ReducingBarrierStep<S,E>

java.lang.Object
org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep<S,E>
org.apache.tinkerpop.gremlin.process.traversal.step.util.ReducingBarrierStep<S,E>
All Implemented Interfaces:
Serializable, Cloneable, Iterator<Traverser.Admin<E>>, Step<S,E>, Barrier<E>, Generating<E,E>, MemoryComputing<E>
Direct Known Subclasses:
CountGlobalStep, FoldStep, GroupCountStep, GroupStep, MaxGlobalStep, MeanGlobalStep, MinGlobalStep, SumGlobalStep, TreeStep

public abstract class ReducingBarrierStep<S,E> extends AbstractStep<S,E> implements Barrier<E>, Generating<E,E>
Author:
Marko A. Rodriguez (http://markorodriguez.com)
See Also:
  • Field Details

    • NON_EMITTING_SEED

      public static final Object NON_EMITTING_SEED
      A seed value not to be emitted from the ReducingBarrierStep helping with flow control within this step.
    • seedSupplier

      protected Supplier<E> seedSupplier
      If the seedSupplier is null then the default behavior is to generate the seed from the starts. This supplier must be callable as a constant and not rely on state from the class. Prefer overriding generateSeedFromStarts() otherwise.
    • reducingBiOperator

      protected BinaryOperator<E> reducingBiOperator
    • hasProcessedOnce

      protected boolean hasProcessedOnce
  • Constructor Details

    • ReducingBarrierStep

      public ReducingBarrierStep(Traversal.Admin traversal)
  • Method Details

    • setSeedSupplier

      public void setSeedSupplier(Supplier<E> seedSupplier)
    • getSeedSupplier

      public Supplier<E> getSeedSupplier()
      Gets the provided seed supplier or provides generateSeedFromStarts().
    • generateSeedFromStarts

      protected E generateSeedFromStarts()
      If the seedSupplier is null then this method is called.
    • projectTraverser

      public abstract E projectTraverser(Traverser.Admin<S> traverser)
    • setReducingBiOperator

      public void setReducingBiOperator(BinaryOperator<E> reducingBiOperator)
    • getBiOperator

      public BinaryOperator<E> getBiOperator()
    • reset

      public void reset()
      Description copied from interface: Step
      Reset the state of the step such that it has no incoming starts. Internal states are to be reset, but any sideEffect data structures are not to be recreated.
      Specified by:
      reset in interface Step<S,E>
      Overrides:
      reset in class AbstractStep<S,E>
    • done

      public void done()
      Description copied from interface: Barrier
      A way to hard set that the barrier is complete. This is necessary when parallel barriers don't all have barriers and need hard resetting. The default implementation does nothing.
      Specified by:
      done in interface Barrier<S>
    • processAllStarts

      public void processAllStarts()
      Description copied from interface: Barrier
      Process all left traversers by do not yield the resultant output. This method is useful for steps like ReducingBarrierStep, where traversers can be processed "on the fly" and thus, reduce memory consumption.
      Specified by:
      processAllStarts in interface Barrier<S>
    • getEmptyBarrier

      public E getEmptyBarrier()
      Description copied from interface: Barrier
      If a barrier is unproductive then provide an empty object suitable to the implementation which can be used to represent that state. This is important for cases like by(out().order().fold()) where the order() might filter but the fold() means the traversal is productive.
      Specified by:
      getEmptyBarrier in interface Barrier<S>
    • hasNextBarrier

      public boolean hasNextBarrier()
      Description copied from interface: Barrier
      Whether or not the step has an accessible barrier.
      Specified by:
      hasNextBarrier in interface Barrier<S>
      Returns:
      whether a barrier exists or not
    • nextBarrier

      public E nextBarrier()
      Description copied from interface: Barrier
      Get the next barrier within this step. Barriers from parallel steps can be the be merged to create a single step with merge barriers.
      Specified by:
      nextBarrier in interface Barrier<S>
      Returns:
      the next barrier of the step
    • addBarrier

      public void addBarrier(E barrier)
      Description copied from interface: Barrier
      Add a barrier to the step. This typically happens when multiple parallel barriers need to become one barrier at a single step.
      Specified by:
      addBarrier in interface Barrier<S>
      Parameters:
      barrier - the barrier to merge in
    • processNextStart

      public Traverser.Admin<E> processNextStart()
      Specified by:
      processNextStart in class AbstractStep<S,E>
    • clone

      public ReducingBarrierStep<S,E> clone()
      Description copied from interface: Step
      Cloning is used to duplicate steps for the purpose of traversal optimization and OLTP replication. When cloning a step, it is important that the steps, the cloned step is equivalent to the state of the step when Step.reset() is called. Moreover, the previous and next steps should be set to EmptyStep.
      Specified by:
      clone in interface Step<S,E>
      Overrides:
      clone in class AbstractStep<S,E>
      Returns:
      The cloned step
    • getMemoryComputeKey

      public MemoryComputeKey<E> getMemoryComputeKey()
      Description copied from interface: MemoryComputing
      The MemoryComputeKey that will be used by this step.
      Specified by:
      getMemoryComputeKey in interface MemoryComputing<S>
      Returns:
      the MemoryComputeKey to use