org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization

## Class CountStrategy

- java.lang.Object
- - org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy<TraversalStrategy.OptimizationStrategy>
  - - org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.CountStrategy

- All Implemented Interfaces:
    Serializable, Comparable<Class<? extends TraversalStrategy>>, TraversalStrategy<TraversalStrategy.OptimizationStrategy>, TraversalStrategy.OptimizationStrategy

      public final class CountStrategy
      extends AbstractTraversalStrategy<TraversalStrategy.OptimizationStrategy>
      implements TraversalStrategy.OptimizationStrategy

  This strategy optimizes any occurrence of `CountGlobalStep` followed by an `IsStep`. The idea is to limit the number of incoming elements in a way that it's enough for the `IsStep` to decide whether it evaluates `true` or `false`. If the traversal already contains a user supplied limit, the strategy won't modify it.
  Author:
    Daniel Kuppitz (http://gremlin.guru)
  See Also:
    Serialized Form
  Example:

         __.outE().count().is(0)      // is replaced by __.not(outE())
         __.outE().count().is(lt(3))  // is replaced by __.outE().limit(3).count().is(lt(3))
         __.outE().count().is(gt(3))  // is replaced by __.outE().limit(4).count().is(gt(3))

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy

      `TraversalStrategy.DecorationStrategy, TraversalStrategy.FinalizationStrategy, TraversalStrategy.OptimizationStrategy, TraversalStrategy.ProviderOptimizationStrategy, TraversalStrategy.VerificationStrategy`

  - ### Field Summary

    - ### Fields inherited from interface org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy

      `STRATEGY`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `apply(Traversal.Admin<?,?> traversal)`
    `static CountStrategy` | `instance()`

    - ### Methods inherited from class org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy

      `equals, hashCode, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy.OptimizationStrategy

      `compareTo, getTraversalCategory`

    - ### Methods inherited from interface org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy

      `applyPost, applyPrior, getConfiguration`

- - ### Method Detail

    - #### instance

          public static CountStrategy instance()

    - #### apply

          public void apply(Traversal.Admin<?,?> traversal)

      Specified by:
        `apply` in interface `TraversalStrategy<TraversalStrategy.OptimizationStrategy>`

Copyright © 2013–2021 Apache Software Foundation. All rights reserved.