Interface DistinctnessSource

All Known Implementing Classes:
GeneratorDistinctnessSource, StatisticsDistinctnessSource
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 DistinctnessSource
Supplies whether a leaf relation is inherently duplicate-free — the one piece of distinctness that is not structural but depends on what the leaf actually is. It is the distinctness analogue of BoundednessSource.

PropertyDeriver derives distinctness structurally for operators, but a leaf RelationNode is conservatively non-distinct unless a source says otherwise — a generator that declares itself duplicate-free (Range, Naturals, Primes), or a base relation with a declared key (StatisticsDistinctnessSource). Both kinds are consulted together via anyOf(DistinctnessSource...). The default NONE reports nothing as distinct, so it is a safe no-op where no producer is wired in.

Used by DistinctEliminationPass (DIST-001): δ(R) → R when R is duplicate-free — which, for an unbounded distinct generator, also dissolves the δ unbounded-retained-state hazard.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final DistinctnessSource
    A source under which no leaf is known to be duplicate-free.
  • Method Summary

    Modifier and Type
    Method
    Description
    Combines several sources into one that reports a leaf duplicate-free when any constituent does — the correct composition, since each source knows about a disjoint kind of leaf (a generator declares itself distinct; a base relation is distinct by virtue of a declared key) and none can refute another's claim.
    boolean
    duplicateFreeLeaf(String relationName)
     
  • Field Details

    • NONE

      static final DistinctnessSource NONE
      A source under which no leaf is known to be duplicate-free.
  • Method Details

    • duplicateFreeLeaf

      boolean duplicateFreeLeaf(String relationName)
      Parameters:
      relationName - the leaf relation name; never null
      Returns:
      true if that leaf is inherently duplicate-free
    • anyOf

      static DistinctnessSource anyOf(DistinctnessSource... sources)
      Combines several sources into one that reports a leaf duplicate-free when any constituent does — the correct composition, since each source knows about a disjoint kind of leaf (a generator declares itself distinct; a base relation is distinct by virtue of a declared key) and none can refute another's claim.

      Sources are consulted in order and the scan short-circuits on the first true. With no arguments the result is NONE.

      Parameters:
      sources - the sources to combine; must not be null, nor contain null
      Returns:
      a source reporting the disjunction of its constituents; never null