Class FoldContext
java.lang.Object
org.elasticsearch.xpack.esql.core.expression.FoldContext
Context passed to
Expression.fold(org.elasticsearch.xpack.esql.core.expression.FoldContext). This is not thread safe.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncircuitBreakerView(Source source) Adapt this into aCircuitBreakersuitable for building bounded local DriverContext.booleaninthashCode()longThe maximum allowed bytes.static FoldContextsmall()Expression.fold(org.elasticsearch.xpack.esql.core.expression.FoldContext)using less than 5% of heap.toString()voidtrackAllocation(Source source, long bytes) Track an allocation.
-
Constructor Details
-
FoldContext
public FoldContext(long allowedBytes)
-
-
Method Details
-
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 callingExpression.fold(org.elasticsearch.xpack.esql.core.expression.FoldContext)at all, or should pass in a sharedFoldContextmade byConfiguration. -
initialAllowedBytes
public long initialAllowedBytes()The maximum allowed bytes.allowedBytes()will be the same as this for an unused context. -
equals
-
hashCode
public int hashCode() -
toString
-
trackAllocation
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 implementReleasableso 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
Adapt this into aCircuitBreakersuitable for building bounded local DriverContext. This is absolutely an abuse of theCircuitBreakercontract and only methods used by BlockFactory are implemented. And this'll throw aFoldContext.FoldTooMuchMemoryExceptioninstead of the standardCircuitBreakingException. This works for the common folding implementation though.
-