Class SourceStatisticsSerializer
java.lang.Object
org.elasticsearch.xpack.esql.datasources.SourceStatisticsSerializer
Serializes and deserializes
SourceStatistics to/from a flat Map<String, Object>
using well-known keys. This allows statistics to flow through the opaque sourceMetadata
map in ExternalSourceExec without requiring
new fields or serialization format changes.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcolumnMaxKey(String columnName) Returns the flat key used for a column's max statistic.static StringcolumnMinKey(String columnName) Returns the flat key used for a column's min statistic.static StringcolumnNullCountKey(String columnName) Returns the flat key used for a column's null count statistic.embedStatistics(Map<String, Object> sourceMetadata, SourceStatistics statistics) Merges statistics entries into a new map that includes both the original sourceMetadata entries and the serialized statistics.extractColumnMax(Map<String, Object> sourceMetadata, String columnName) Extracts the max value for a specific column directly from the sourceMetadata map.extractColumnMin(Map<String, Object> sourceMetadata, String columnName) Extracts the min value for a specific column directly from the sourceMetadata map.static OptionalLongextractColumnNullCount(Map<String, Object> sourceMetadata, String columnName) Extracts the null count for a specific column directly from the sourceMetadata map.static OptionalLongextractRowCount(Map<String, Object> sourceMetadata) Extracts the row count directly from the sourceMetadata map without constructing a full SourceStatistics object.static Optional<SourceStatistics> extractStatistics(Map<String, Object> sourceMetadata) Extracts statistics from the sourceMetadata map.mergeStatistics(List<Map<String, Object>> splitStats) resolveEffectiveMetadata(List<? extends ExternalSplit> splits, Map<String, Object> sourceMetadata) Resolves the effective metadata for a set of splits.
-
Field Details
-
STATS_ROW_COUNT
- See Also:
-
STATS_SIZE_BYTES
- See Also:
-
-
Method Details
-
embedStatistics
public static Map<String,Object> embedStatistics(Map<String, Object> sourceMetadata, SourceStatistics statistics) Merges statistics entries into a new map that includes both the original sourceMetadata entries and the serialized statistics. Returns the original map if statistics are absent. -
extractStatistics
Extracts statistics from the sourceMetadata map. Returns empty if no statistics keys are present. -
extractRowCount
Extracts the row count directly from the sourceMetadata map without constructing a full SourceStatistics object. -
extractColumnNullCount
public static OptionalLong extractColumnNullCount(Map<String, Object> sourceMetadata, String columnName) Extracts the null count for a specific column directly from the sourceMetadata map. -
extractColumnMin
public static Optional<Object> extractColumnMin(Map<String, Object> sourceMetadata, String columnName) Extracts the min value for a specific column directly from the sourceMetadata map. -
extractColumnMax
public static Optional<Object> extractColumnMax(Map<String, Object> sourceMetadata, String columnName) Extracts the max value for a specific column directly from the sourceMetadata map. -
columnNullCountKey
Returns the flat key used for a column's null count statistic. -
columnMinKey
Returns the flat key used for a column's min statistic. -
columnMaxKey
Returns the flat key used for a column's max statistic. -
resolveEffectiveMetadata
public static Map<String,Object> resolveEffectiveMetadata(List<? extends ExternalSplit> splits, Map<String, Object> sourceMetadata) Resolves the effective metadata for a set of splits. For single-split queries returns the given sourceMetadata directly; for multi-split queries merges per-split statistics from eachFileSplit. Returnsnullif any split is not aFileSplitor ifmergeStatistics(java.util.List<java.util.Map<java.lang.String, java.lang.Object>>)cannot produce a valid merged result (e.g. missing or non-numeric row counts). -
mergeStatistics
-