Class LatticeSuggester


  • public class LatticeSuggester
    extends java.lang.Object
    Algorithm that suggests a set of lattices.
    • Field Detail

      • PROGRAM

        private static final HepProgram PROGRAM
      • latticeMap

        final java.util.Map<java.lang.String,​Lattice> latticeMap
        Lattices, indexed by digest. Uses LinkedHashMap for determinacy.
      • obsoleteLatticeMap

        private final java.util.Map<Lattice,​Lattice> obsoleteLatticeMap
        Lattices that have been made obsolete. Key is the obsolete lattice, value is the lattice that superseded it.
      • evolve

        private final boolean evolve
        Whether to try to extend an existing lattice when adding a lattice.
    • Constructor Detail

      • LatticeSuggester

        public LatticeSuggester​(FrameworkConfig config)
        Creates a LatticeSuggester.
    • Method Detail

      • getLatticeSet

        public java.util.Set<Lattice> getLatticeSet()
        Returns the minimal set of lattices necessary to cover all of the queries seen. Any lattices that are subsumed by other lattices are not included.
      • addQuery

        public java.util.List<Lattice> addQuery​(RelNode r)
        Adds a query.

        It may fit within an existing lattice (or lattices). Or it may need a new lattice, or an extension to an existing lattice.

        Parameters:
        r - Relational expression for a query
        Returns:
        A list of join graphs: usually 1; more if the query contains a cartesian product; zero if the query graph is cyclic
      • deriveAlias

        private static java.lang.String deriveAlias​(LatticeSuggester.MutableMeasure measure,
                                                    LatticeSuggester.DerivedColRef derivedColRef)
        Derives the alias of an expression that is the argument to a measure.

        For example, if the measure is called "sum_profit" and the aggregate function is "sum", returns "profit".

      • findMatch

        private Lattice findMatch​(Lattice lattice,
                                  MutableNode mutableNode)
        Returns the best match for a lattice. If no match, registers the lattice and returns it. Never returns null.
      • matchQuality

        private int matchQuality​(Lattice lattice,
                                 Lattice target)
      • minus

        private static <E> java.util.Set<E> minus​(java.util.Collection<E> c,
                                                  java.util.Collection<E> c2)