java.lang.Object
org.elasticsearch.xpack.esql.core.expression.FoldContext

public class FoldContext extends Object
  • Constructor Details

    • FoldContext

      public FoldContext(long allowedBytes)
  • Method Details

    • small

      public static FoldContext small()
      Expression.fold(org.elasticsearch.xpack.esql.core.expression.FoldContext) using less than 5% of heap. Fine in tests but otherwise calling this is a signal that you either, shouldn't be calling Expression.fold(org.elasticsearch.xpack.esql.core.expression.FoldContext) at all, or should pass in a shared FoldContext made by Configuration.
    • initialAllowedBytes

      public long initialAllowedBytes()
      The maximum allowed bytes. allowedBytes() will be the same as this for an unused context.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • trackAllocation

      public void trackAllocation(Source source, long bytes)
      Track an allocation. Best to call this before allocating if possible, but after is ok if the allocation is small.

      Note that, unlike CircuitBreaker, you don't have to free this allocation later. This is important because the query plan doesn't implement Releasable so it can't free consistently. But when you have to allocate big chunks of memory during folding and know that you are returning the memory it is kindest to call this with a negative number, effectively giving those bytes back.

    • circuitBreakerView

      public CircuitBreaker circuitBreakerView(Source source)
      Adapt this into a CircuitBreaker suitable for building bounded local DriverContext. This is absolutely an abuse of the CircuitBreaker contract and only methods used by BlockFactory are implemented. And this'll throw a FoldContext.FoldTooMuchMemoryException instead of the standard CircuitBreakingException. This works for the common folding implementation though.