Class ColumnStatsAccumulator
java.lang.Object
org.elasticsearch.xpack.esql.datasources.cache.ColumnStatsAccumulator
Accumulates per-column null count + min + max across the pages of a single cold scan.
Tracked types: BOOLEAN, INTEGER, LONG (incl. DATETIME / DATE_NANOS), DOUBLE, KEYWORD / TEXT / IP.
UNSIGNED_LONG and VERSION are deliberately untracked (their stored byte order disagrees with the
type's semantic order); all other types are untracked too. Untracked types contribute null counts
only — min and max stay null so the warm path bails out rather than serving an unbounded answer.
Hot-path discipline: the iterator passes blocks by their position index in the page (not by name)
via acceptBlockAt(int, Block) — accumulator state is held in a flat array so each block
dispatch is a single array load.
Multi-valued cells: every value in a position contributes to the running min/max, matching the Parquet stats contract.
Single-instance reuse rule: each instance is owned by exactly one batch-iterator and accumulates over that iterator's full lifetime. Concurrent invocation is not supported.
-
Method Summary
Modifier and TypeMethodDescriptionvoidacceptBlockAt(int blockIndex, Block block) Feeds the block at page positionblockIndexinto the accumulator.voidacceptBooleanAt(int blockIndex, boolean value) voidacceptBytesRefAt(int blockIndex, org.apache.lucene.util.BytesRef value) voidacceptDoubleAt(int blockIndex, double value) voidacceptIntAt(int blockIndex, int value) voidacceptLongAt(int blockIndex, long value) voidacceptNullAt(int blockIndex) voidacceptValueAt(int columnIndex, Object value) Feeds a single already-typed value into the accumulator at column positioncolumnIndex.static ColumnStatsAccumulatorforProjectedAttributes(Attribute[] projectedAttrs) Builds an accumulator covering the page-block positions0..projectedAttrs.length.static ColumnStatsAccumulatorBuilds an accumulator keyed to a file's FULL positional schema, for theALLharvest scope.booleanisEmpty()True when no columns are being tracked — capture loop should skip block iteration.snapshot()Snapshots the current state into an immutableExternalStats.ColumnStatsmap.
-
Method Details
-
forProjectedAttributes
Builds an accumulator covering the page-block positions0..projectedAttrs.length. State for each index is sized for the corresponding attribute's data type. -
forSchema
Builds an accumulator keyed to a file's FULL positional schema, for theALLharvest scope. Identical machinery toforProjectedAttributes(org.elasticsearch.xpack.esql.core.expression.Attribute[])— every tracked file column gets aColumnStatsAccumulator.ColumnStateindexed by its position infileSchema— but the row-format readers feed it raw parsed/typed values viaacceptValueAt(int, Object)(one per file column, regardless of projection) rather than outputBlocks, because the output page only carries the query's projected columns. Feeding a Block viaacceptBlockAt(int, Block)and feeding a single value viaacceptValueAt(int, java.lang.Object)update the same per-column state, so a mixed call sequence is well-defined. -
isEmpty
public boolean isEmpty()True when no columns are being tracked — capture loop should skip block iteration. -
acceptBlockAt
Feeds the block at page positionblockIndexinto the accumulator. Caller's responsibility: indices must match the layout the accumulator was built for. Out-of-range indices are silently ignored. -
acceptNullAt
public void acceptNullAt(int blockIndex) -
acceptBooleanAt
public void acceptBooleanAt(int blockIndex, boolean value) -
acceptIntAt
public void acceptIntAt(int blockIndex, int value) -
acceptLongAt
public void acceptLongAt(int blockIndex, long value) -
acceptDoubleAt
public void acceptDoubleAt(int blockIndex, double value) -
acceptBytesRefAt
public void acceptBytesRefAt(int blockIndex, org.apache.lucene.util.BytesRef value) -
acceptValueAt
Feeds a single already-typed value into the accumulator at column positioncolumnIndex. This is theALL-scope entry point: the row-format readers hand a boxed value parsed straight from the raw record (no outputBlockexists for an unprojected file column). Accepted value shapes match what the readers' type-conversion produces:null— counts towardnullCount.Boolean/Integer/Long/Double/BytesRef— a single value, folded into min/max for tracked types.List— a multi-valued cell; every element folds individually (matching the Block path's per-value contract). An empty list counts as null.
acceptBlockAt(int, org.elasticsearch.compute.data.Block). -
snapshot
Snapshots the current state into an immutableExternalStats.ColumnStatsmap. Safe to call only once per accumulator instance — call it from the iterator's close-time hook.
-