Package org.apache.calcite.util
Class ArrowSet
java.lang.Object
org.apache.calcite.util.ArrowSet
Represents a set of functional dependencies. Each functional dependency is an
Arrow.
An ArrowSet models a set of functional dependencies that may hold in a relation.
This class provides implementations for several core algorithms in functional dependency theory,
such as closure computation and candidate key discovery.
For theory background, see:
Functional dependency (Wikipedia)
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()dependents(ImmutableBitSet ordinals) Computes the closure of a given set of column ordinals with respect to this ArrowSet.determinants(ImmutableBitSet ordinals) Finds all minimal determinant sets for a given set of column ordinals based on this ArrowSet.booleancom.google.common.collect.ImmutableList<Arrow>Returns all arrows (functional dependencies) in this ArrowSet.booleanimplies(ImmutableBitSet determinants, ImmutableBitSet dependents) Returns true if, from this ArrowSet, one can deduce thatdeterminantsdeterminedependents.toString()Returns a new ArrowSet that is the union of this and another ArrowSet.
-
Field Details
-
EMPTY
-
-
Constructor Details
-
ArrowSet
-
-
Method Details
-
dependents
Computes the closure of a given set of column ordinals with respect to this ArrowSet.The closure is the maximal set of attributes such that X → X⁺ can be inferred through transitive application of Armstrong's axioms
Example:
// Given functional dependencies: // {0} → {1} // {1} → {2} // dependents(ImmutableBitSet.of(0)) = {0, 1, 2}Time complexity: O(m + n), m = arrow count, n = ordinal count. For interactive use, keep n below a few hundred for performance.
- Parameters:
ordinals- the set of column ordinals whose closure is to be computed- Returns:
- an immutable set of column ordinals that can be determined from the input
-
determinants
Finds all minimal determinant sets for a given set of column ordinals based on this ArrowSet.Example:
// Given functional dependencies: // {0} → {1} // {1} → {2} // {2} → {3} // The ordinals is {0, 1, 2, 3}: // determinants(ImmutableBitSet.of(0, 1, 2, 3)) returns [{0}]- Parameters:
ordinals- a set of attribute ordinals for which to find determinant sets- Returns:
- the determinant sets, each represented as an ImmutableBitSet
-
union
Returns a new ArrowSet that is the union of this and another ArrowSet. -
getArrows
Returns all arrows (functional dependencies) in this ArrowSet. -
clone
-
equalTo
-
toString
-
implies
Returns true if, from this ArrowSet, one can deduce thatdeterminantsdeterminedependents. That is, ifdependents⊆ closure(determinants).
-