Class Arrow

java.lang.Object
org.apache.calcite.util.Arrow

public class Arrow extends Object
Represents one functional dependency (Arrow) between two sets of columns, where each column is identified by its ordinal index.

Arrow models the functional dependency such that the values of the determinants columns uniquely determine the values of the dependents columns. In other words, if two rows have the same values for all determinant columns, they must also have the same values for all dependent columns. Both determinants and dependents are ImmutableBitSet column ordinals.

This structure supports arbitrary cardinality for both determinant and dependent column sets, allowing the representation relationships:

  • One-to-one: {0} → {1}
  • One-to-many: {0} → {1, 2}
  • Many-to-one: {0, 1} → {2}
  • Many-to-many: {0, 1} → {2, 3}

Example:

 Table schema: [emp_id, name, dept, salary]  // ordinals: 0, 1, 2, 3
 Arrow: {0} → {1, 2}
 Functional dependency: emp_id → {name, dept}
 

This indicates that the employee ID uniquely determines both the name and department attributes.

  • Method Details

    • of

      public static Arrow of(ImmutableBitSet determinants, ImmutableBitSet dependents)
      Create Arrow from determinant set to dependent set.
    • of

      public static Arrow of(int determinant, int dependent)
      Create Arrow from single determinant to single dependent.
    • getDeterminants

      public ImmutableBitSet getDeterminants()
    • getDependents

      public ImmutableBitSet getDependents()
    • isTrivial

      public boolean isTrivial()
      Returns true if this Arrow is trivial (dependents ⊆ determinants).
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object