Class SplitStats
- All Implemented Interfaces:
Writeable,SplitStats
Map<String, Object> for wire efficiency:
column names are stored as ordinal references into a shared segment dictionary, and
per-column stats use parallel arrays instead of string-keyed map entries.
Use SplitStats.Builder to construct instances from format reader metadata, and
toMap() for backward-compatible access by consumers that expect the flat
_stats.* key convention from SourceStatisticsSerializer.
Instances are effectively immutable after construction and safe for use within a single request processing thread.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for constructingSplitStatsinstances.Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SplitStatsEmpty stats with zero rows and no columns. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the max value for the column with the given name, ornullif not found or poisoned (unservable).Returns the min value for the column with the given name, ornullif not found or poisoned (unservable).columnName(int ordinal) Resolves the full dotted column name for the given ordinal by joining the path segments from the dictionary.longcolumnNullCount(String name) Returns the null count for the column with the given name under the SPI's "implicit nulls" contract: a column physically absent from this split contributesrowCountimplicit nulls, since every row would deserialize asnull.longcolumnSizeBytes(String name) Returns the size in bytes for the column with the given name, or-1if not found.longcolumnValueCount(String name) Returns the count of non-null values for the column with the given name (multivalue-aware: a multivalued cell contributes one per value), or-1if the column is not present in this split's statistics.booleanintfindColumn(String name) Finds a column ordinal by its full dotted name.booleanReturnstrueiff this split carries a column-family entry forname.inthashCode()max(int col) Returns the max value for the column, ornullif unknown or poisoned (unservable).min(int col) Returns the min value for the column, ornullif unknown or poisoned (unservable).longnullCount(int col) Returns null count for the column, or-1if unknown.static SplitStatsParses a flat_stats.*map (old format) into aSplitStatsinstance.static SplitStatsresolveEffectiveStats(List<? extends ExternalSplit> splits, Map<String, Object> sourceMetadata) Resolves the effectiveSplitStatsfor a set of splits.longrowCount()Total row count for this split.longsizeBytes(int col) Returns size in bytes for the column, or-1if unknown.longReturns size in bytes, or-1if unknown.toMap()Produces a flatMap<String, Object>using the same_stats.*key conventions asSourceStatisticsSerializer, for backward compatibility with all existing consumers.toString()longvalueCount(int col) Returns value count (non-null values, multivalue-aware) for the column, or-1if unknown.voidwriteTo(StreamOutput out) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.xpack.esql.datasources.spi.SplitStats
compressedSizeInBytes
-
Field Details
-
EMPTY
Empty stats with zero rows and no columns.
-
-
Constructor Details
-
SplitStats
- Throws:
IOException
-
-
Method Details
-
writeTo
- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
columnCount
public int columnCount() -
rowCount
public long rowCount()Description copied from interface:SplitStatsTotal row count for this split. Always>= 0.- Specified by:
rowCountin interfaceSplitStats
-
sizeInBytes
public long sizeInBytes()Returns size in bytes, or-1if unknown.- Specified by:
sizeInBytesin interfaceSplitStats
-
columnName
Resolves the full dotted column name for the given ordinal by joining the path segments from the dictionary. Each call allocates a new String; callers that iterate over columns should preferresolveColumnName(int, StringBuilder)to reuse a buffer. -
nullCount
public long nullCount(int col) Returns null count for the column, or-1if unknown. -
valueCount
public long valueCount(int col) Returns value count (non-null values, multivalue-aware) for the column, or-1if unknown. -
min
Returns the min value for the column, ornullif unknown or poisoned (unservable). -
max
Returns the max value for the column, ornullif unknown or poisoned (unservable). -
sizeBytes
public long sizeBytes(int col) Returns size in bytes for the column, or-1if unknown. -
findColumn
Finds a column ordinal by its full dotted name. Returns-1if not found. Matches directly against the segment dictionary without materializing column name strings, keeping the compact representation intact. -
columnNullCount
Returns the null count for the column with the given name under the SPI's "implicit nulls" contract: a column physically absent from this split contributesrowCountimplicit nulls, since every row would deserialize asnull. Format readers (Parquet, ORC) emit at least one column-family stat key (e.g.size_bytes/null_count) for every column they physically contain, sofindColumn(java.lang.String)returning-1is equivalent to "column is not in this file/split".Returns
-1only in the rare case where the column is physically present but the reader could not extract a null count (e.g. Parquet stats disabled at write time). Callers such asPushStatsToExternalSourcerely on this contract so thatCount(col) = rowCount - columnNullCountis correct across UNION_BY_NAME mixes where some files lack the column.- Specified by:
columnNullCountin interfaceSplitStats
-
columnValueCount
Returns the count of non-null values for the column with the given name (multivalue-aware: a multivalued cell contributes one per value), or-1if the column is not present in this split's statistics.-1signals "not available" so the caller falls back torowCount - columnNullCount.- Specified by:
columnValueCountin interfaceSplitStats
-
hasColumn
Returnstrueiff this split carries a column-family entry forname. A column is present in the compact representation only when the reader emitted at least one stat for it (the producer contract documented onSplitStats.columnNullCount(java.lang.String)), so this is exactly "the stats layer observed this column" — the predicate the optimizer uses to tell a harvested-but-all-null text column apart from an unharvested one.- Specified by:
hasColumnin interfaceSplitStats
-
columnMin
Returns the min value for the column with the given name, ornullif not found or poisoned (unservable).- Specified by:
columnMinin interfaceSplitStats
-
columnMax
Returns the max value for the column with the given name, ornullif not found or poisoned (unservable).- Specified by:
columnMaxin interfaceSplitStats
-
columnSizeBytes
Returns the size in bytes for the column with the given name, or-1if not found.- Specified by:
columnSizeBytesin interfaceSplitStats
-
toMap
Produces a flatMap<String, Object>using the same_stats.*key conventions asSourceStatisticsSerializer, for backward compatibility with all existing consumers. -
of
Parses a flat_stats.*map (old format) into aSplitStatsinstance. Returnsnullif the map is null, empty, or missing the required row count key.Column ordering in the result depends on the input map's iteration order: stable (e.g.
LinkedHashMap) inputs produce stable ordinals. ThetoMap()output is always key-equivalent regardless of column ordering. -
resolveEffectiveStats
@Nullable public static SplitStats resolveEffectiveStats(List<? extends ExternalSplit> splits, Map<String, Object> sourceMetadata) Resolves the effectiveSplitStatsfor a set of splits. UsesExternalSplit.splitStats()on each split, which handles bothFileSplitandCoalescedSplittransparently without flattening. For single-split queries the per-split stats (if available) or the sourceMetadata map is used; for multi-split queries aMergedSplitStatsover the per-split stats is returned. Returnsnullif any split lacks stats. -
equals
-
hashCode
public int hashCode() -
toString
-