java.lang.Object
org.elasticsearch.compute.operator.Limiter

public class Limiter extends Object
A shared limiter used by multiple drivers to collect hits in parallel without exceeding the output limit. For example, if the query `FROM test-1,test-2 | LIMIT 100` is run with two drivers, and one driver (e.g., querying `test-1`) has collected 60 hits, then the other driver querying `test-2` should collect at most 40 hits.
  • Field Details

    • NO_LIMIT

      public static Limiter NO_LIMIT
  • Constructor Details

    • Limiter

      public Limiter(int limit)
  • Method Details

    • remaining

      public int remaining()
      Returns the remaining number of hits that can be collected.
    • limit

      public int limit()
      Returns the limit of this limiter.
    • tryAccumulateHits

      public int tryAccumulateHits(int numHits)
      Tries to accumulate hits and returns the number of hits that has been accepted.
      Parameters:
      numHits - the number of hits to try to accumulate
      Returns:
      the accepted number of hits. If the returned number is less than the numHits, it means the limit has been reached and the difference can be discarded.