Interface StatisticsSource

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface StatisticsSource
Supplies RelationStatistics for a leaf relation by name, the seam through which the CostEstimator obtains cardinality metadata.

Implementations decide how a relation name maps to statistics (typically by resolving the name to a symbol and consulting a statistics map collected during semantic analysis). The default NONE resolves nothing, which makes the estimator fall back to its tier-based heuristics.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final StatisticsSource
    A source that knows nothing about any relation.
  • Method Summary

    Modifier and Type
    Method
    Description
    forRelation(String relationName)
    Returns the statistics for the relation named relationName, or Optional.empty() if none are available.
    of(SymbolTable symbols, Map<String,RelationStatistics> statistics)
    Creates a source that resolves an expression-tree relation name through symbols and looks the resulting canonical name up in statistics — the standard resolution for statistics collected during semantic analysis (as in SemanticModel.statistics()), which are keyed by canonical name while a RelationNode carries the name as written.
  • Field Details

    • NONE

      static final StatisticsSource NONE
      A source that knows nothing about any relation.
  • Method Details

    • forRelation

      Optional<RelationStatistics> forRelation(String relationName)
      Returns the statistics for the relation named relationName, or Optional.empty() if none are available.
      Parameters:
      relationName - the relation name as it appears in the expression tree
      Returns:
      the statistics, or empty if unknown
    • of

      static StatisticsSource of(SymbolTable symbols, Map<String,RelationStatistics> statistics)
      Creates a source that resolves an expression-tree relation name through symbols and looks the resulting canonical name up in statistics — the standard resolution for statistics collected during semantic analysis (as in SemanticModel.statistics()), which are keyed by canonical name while a RelationNode carries the name as written.

      Shared by every consumer of analysis-time statistics — the planner, the optimizer's cost estimator, and StatisticsDistinctnessSource — so the name-to-statistics mapping has exactly one definition.

      Parameters:
      symbols - the symbol table resolving names to symbols; must not be null
      statistics - canonical relation name → statistics; must not be null
      Returns:
      a source over statistics; never null