Class BooleanNormalizer


  • @API(INTERNAL)
    public class BooleanNormalizer
    extends Object
    A normalizer of a tree of QueryComponent predicates into disjunctive normal form.

    The full normal form has a single Or at the root, all of whose children are And, none of whose children have other Boolean operators. This is abbreviated to exclude parent Boolean nodes with only one child. The intermediate form for the normalizer is a list of lists.

    The size of a Boolean expression in disjunctive normal form (DNF) is the number of terms in the outermost Or [O'Donnell 2014]. The BooleanNormalizer will not normalize a QueryComponent if the normalized form would have a size that exceeds the size limit. This limit is useful to avoid wastefully normalizing expressions with a very large DNF. In some cases, such as a large expression in conjunctive normal form (CNF), attempting to normalize such an expression will cause out-of-memory errors.

    • Field Detail

      • DEFAULT_SIZE_LIMIT

        public static final int DEFAULT_SIZE_LIMIT
        The default limit on the size of the DNF that will be produced by the normalizer.
        See Also:
        Constant Field Values
    • Method Detail

      • withLimit

        @Nonnull
        public static BooleanNormalizer withLimit​(int sizeLimit)
        Obtain a normalizer with the given size limit.
        Parameters:
        sizeLimit - a limit on the size of DNF that this normalizer will produce
        Returns:
        a normalizer with the given size limit
      • forConfiguration

        public static BooleanNormalizer forConfiguration​(RecordQueryPlannerConfiguration configuration)
        Obtain a normalizer for the given planner configuration.
        Parameters:
        configuration - a a planner configuration specifying the DNF limit that this normalizer will produce
        Returns:
        a normalizer for the given planner configuration
      • getSizeLimit

        public int getSizeLimit()
        Get the limit on the size of the DNF that this normalizer will produce.
        Returns:
        size limit
      • isCheckForDuplicateConditions

        public boolean isCheckForDuplicateConditions()
        Get whether this normalizer attempts to remove redundant conditions.
        Returns:
        true if some redundant conditions
      • normalizeIfPossible

        @Nullable
        public QueryComponent normalizeIfPossible​(@Nullable
                                                  QueryComponent predicate)
        Convert the given predicate to disjunctive normal form, if necessary. If the size of the DNF would exceed the size limit, return the un-normalized predicate.
        Parameters:
        predicate - the query predicate to be normalized
        Returns:
        the predicate in disjunctive normal form if it does not exceed the size limit or the predicate otherwise