Class MergedSplitStats

java.lang.Object
org.elasticsearch.xpack.esql.datasources.MergedSplitStats
All Implemented Interfaces:
SplitStats

public final class MergedSplitStats extends Object implements SplitStats
Lazily merges statistics from a list of child SplitStats instances. Used by CoalescedSplit.splitStats() to expose aggregate statistics for composite splits without eagerly materializing a full SplitStats.

Each accessor method computes its result on demand by iterating the children. This is appropriate because the optimizer calls these methods at most a few times per planning phase, and the child count is typically small (a few dozen splits).

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the list of child stats that this instance merges.
    Returns the maximum of children's max values for the named column under the SPI's "implicit nulls" contract.
    Returns the minimum of children's min values for the named column under the SPI's "implicit nulls" contract: A child that reports a known min value contributes it to the merge via SplitStats.mergedMin(java.lang.Object, java.lang.Object), regardless of its null count.
    long
    Returns the sum of null counts across children for the named column under the SPI's "implicit nulls" contract: a child whose split lacks the column contributes its full row count (every row is an implicit null), and explicit nulls in present columns are summed normally.
    long
    Returns the sum of per-column sizes across children, or -1 if any child returns an unknown size for the column.
    long
    Returns the sum of non-null value counts across children for the named column (multivalue-aware), or -1 if any child returns -1 (the column was not observed in that child's stats).
    long
    Returns the sum of children's compressed sizes, or -1 if any child reports an unknown compressed size.
    boolean
    Returns true only when every child observed the column in its stats.
    long
    Total row count for this split.
    long
    Returns the sum of children's uncompressed sizes, or -1 if any child reports an unknown size.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MergedSplitStats

      public MergedSplitStats(List<SplitStats> children)
  • Method Details

    • children

      public List<SplitStats> children()
      Returns the list of child stats that this instance merges.
    • rowCount

      public long rowCount()
      Description copied from interface: SplitStats
      Total row count for this split. Always >= 0.
      Specified by:
      rowCount in interface SplitStats
    • sizeInBytes

      public long sizeInBytes()
      Returns the sum of children's uncompressed sizes, or -1 if any child reports an unknown size. A single unknown child poisons the aggregate because we cannot give a meaningful partial sum to the optimizer.
      Specified by:
      sizeInBytes in interface SplitStats
    • compressedSizeInBytes

      public long compressedSizeInBytes()
      Returns the sum of children's compressed sizes, or -1 if any child reports an unknown compressed size.
      Specified by:
      compressedSizeInBytes in interface SplitStats
    • columnNullCount

      public long columnNullCount(String name)
      Returns the sum of null counts across children for the named column under the SPI's "implicit nulls" contract: a child whose split lacks the column contributes its full row count (every row is an implicit null), and explicit nulls in present columns are summed normally. Returns -1 only if a child returns -1, which signals the rare "column physically present but stats unknown" case (Parquet stats disabled).
      Specified by:
      columnNullCount in interface SplitStats
    • columnValueCount

      public long columnValueCount(String name)
      Returns the sum of non-null value counts across children for the named column (multivalue-aware), or -1 if any child returns -1 (the column was not observed in that child's stats). A single unavailable child poisons the aggregate because the summed COUNT(col) would otherwise under-count that child's rows; the caller then falls back to rowCount - columnNullCount.
      Specified by:
      columnValueCount in interface SplitStats
    • hasColumn

      public boolean hasColumn(String name)
      Returns true only when every child observed the column in its stats. A single child that lacks the column makes the merged answer "not fully harvested": for a text-format multi-file query where one file's scan harvested the column and another's did not, the merged COUNT(col) cannot be served from stats without under-counting the unharvested file's rows, so the all-children predicate forces a safe-miss. Footer formats never consult this (their AggregatePushdownSupport applies implicit nulls), so genuinely-absent columns in a UNION_BY_NAME mix are unaffected.
      Specified by:
      hasColumn in interface SplitStats
    • columnMin

      @Nullable public Object columnMin(String name)
      Returns the minimum of children's min values for the named column under the SPI's "implicit nulls" contract:
      • A child that reports a known min value contributes it to the merge via SplitStats.mergedMin(java.lang.Object, java.lang.Object), regardless of its null count. A min stat is the minimum of the column's non-null values, so it is a valid extremum candidate even when the child's null count is unknown (columnNullCount(name) < 0) — null count only bears on COUNT, never on MIN/MAX. This is the multi-FILE case where a per-file SplitStats carries a folded min/max but its null_count was poison-dropped during that file's own multi-stripe fold.
      • A child with no min value is then classified by its null count: columnNullCount(name) == child.rowCount() means the column is absent or all-null, so the child has no candidate and is skipped; columnNullCount(name) < 0 (present but stats unknown — e.g. Parquet stats disabled) poisons the aggregate because the child may hold a smaller value we cannot see; a finite null count below the row count with no min is an inconsistent reader output and poisons defensively.
      Incompatible numeric types across known mins poison the aggregate. Returns null when poisoned or when no child contributes a value.
      Specified by:
      columnMin in interface SplitStats
    • columnMax

      @Nullable public Object columnMax(String name)
      Returns the maximum of children's max values for the named column under the SPI's "implicit nulls" contract. Mirrors columnMin(java.lang.String) — a child with a known max contributes it regardless of its null count (null count bears only on COUNT); a child with no max is skipped when the column is absent/all-null and otherwise poisons defensively.
      Specified by:
      columnMax in interface SplitStats
    • columnSizeBytes

      public long columnSizeBytes(String name)
      Returns the sum of per-column sizes across children, or -1 if any child returns an unknown size for the column.
      Specified by:
      columnSizeBytes in interface SplitStats
    • toString

      public String toString()
      Overrides:
      toString in class Object