test_class.file: oak-core/src/test/java/org/apache/jackrabbit/oak/query/ast/AndImplTest.java
test_class.identifier: AndImplTest
test_case.body: @Test
      public void simplifyForUnion() {
          ConstraintImpl and, op1, op2, op3, op4;
          Set<ConstraintImpl> expected;
          
          op1 = mock(ComparisonImpl.class);
          op2 = mock(ComparisonImpl.class);
          and = new AndImpl(op1, op2);
          expected = emptySet();
          assertThat(and.convertToUnion(), is(expected));
  
          op1 = mockConstraint("op1", ComparisonImpl.class);
          op2 = mockConstraint("op2", ComparisonImpl.class);
          op3 = mockConstraint("op3", ComparisonImpl.class);
          and = new AndImpl(new OrImpl(op1, op2), op3);
          expected = of(
              (ConstraintImpl) new AndImpl(op1, op3)
              , (ConstraintImpl) new AndImpl(op2, op3)
          );
          assertThat(and.convertToUnion(), is(expected));
  
          op1 = mockConstraint("op1", ComparisonImpl.class);
          op2 = mockConstraint("op2", ComparisonImpl.class);
          op3 = mockConstraint("op3", ComparisonImpl.class);
          op4 = mockConstraint("op4", ComparisonImpl.class);
          and = new AndImpl(new OrImpl(new OrImpl(op1, op4), op2), op3);
          expected = of(
              (ConstraintImpl) new AndImpl(op1, op3)
              , (ConstraintImpl) new AndImpl(op2, op3)
              , (ConstraintImpl) new AndImpl(op4, op3)
          );
          assertThat(and.convertToUnion(), is(expected));
  }
test_case.class_method_signature: AndImplTest.simplifyForUnion()
test_case.full_signature: @Test public void simplifyForUnion()
test_case.identifier: simplifyForUnion
test_case.invocations: mock mock emptySet assertThat convertToUnion is mockConstraint mockConstraint mockConstraint of assertThat convertToUnion is mockConstraint mockConstraint mockConstraint mockConstraint of assertThat convertToUnion is
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void simplifyForUnion()
focal_class.declarator: constraints
focal_class.modifier: private final
focal_class.original_string: private final List<ConstraintImpl> constraints;
focal_class.type: List<ConstraintImpl>
focal_class.var_name: constraints
focal_class.file: oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AndImpl.java
focal_class.identifier: AndImpl
focal_class.class_method_signature: AndImpl.AndImpl(List<ConstraintImpl> constraints)
focal_class.full_signature: public  AndImpl(List<ConstraintImpl> constraints)
focal_class.identifier: AndImpl
focal_class.modifiers: public
focal_class.parameters: (List<ConstraintImpl> constraints)
focal_class.signature:  AndImpl(List<ConstraintImpl> constraints)
focal_class.class_method_signature: AndImpl.AndImpl(ConstraintImpl constraint1, ConstraintImpl constraint2)
focal_class.full_signature: public  AndImpl(ConstraintImpl constraint1, ConstraintImpl constraint2)
focal_class.identifier: AndImpl
focal_class.modifiers: public
focal_class.parameters: (ConstraintImpl constraint1, ConstraintImpl constraint2)
focal_class.signature:  AndImpl(ConstraintImpl constraint1, ConstraintImpl constraint2)
focal_class.class_method_signature: AndImpl.getConstraints()
focal_class.full_signature: public List<ConstraintImpl> getConstraints()
focal_class.identifier: getConstraints
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: List<ConstraintImpl>
focal_class.signature: List<ConstraintImpl> getConstraints()
focal_class.class_method_signature: AndImpl.simplify()
focal_class.full_signature: @Override public ConstraintImpl simplify()
focal_class.identifier: simplify
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: ConstraintImpl
focal_class.signature: ConstraintImpl simplify()
focal_class.class_method_signature: AndImpl.not()
focal_class.full_signature: @Override ConstraintImpl not()
focal_class.identifier: not
focal_class.modifiers: @Override
focal_class.parameters: ()
focal_class.return: ConstraintImpl
focal_class.signature: ConstraintImpl not()
focal_class.class_method_signature: AndImpl.getPropertyExistenceConditions()
focal_class.full_signature: @Override public Set<PropertyExistenceImpl> getPropertyExistenceConditions()
focal_class.identifier: getPropertyExistenceConditions
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Set<PropertyExistenceImpl>
focal_class.signature: Set<PropertyExistenceImpl> getPropertyExistenceConditions()
focal_class.class_method_signature: AndImpl.getFullTextConstraint(SelectorImpl s)
focal_class.full_signature: @Override public FullTextExpression getFullTextConstraint(SelectorImpl s)
focal_class.identifier: getFullTextConstraint
focal_class.modifiers: @Override public
focal_class.parameters: (SelectorImpl s)
focal_class.return: FullTextExpression
focal_class.signature: FullTextExpression getFullTextConstraint(SelectorImpl s)
focal_class.class_method_signature: AndImpl.getSelectors()
focal_class.full_signature: @Override public Set<SelectorImpl> getSelectors()
focal_class.identifier: getSelectors
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Set<SelectorImpl>
focal_class.signature: Set<SelectorImpl> getSelectors()
focal_class.class_method_signature: AndImpl.evaluate()
focal_class.full_signature: @Override public boolean evaluate()
focal_class.identifier: evaluate
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean evaluate()
focal_class.class_method_signature: AndImpl.evaluateStop()
focal_class.full_signature: @Override public boolean evaluateStop()
focal_class.identifier: evaluateStop
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean evaluateStop()
focal_class.class_method_signature: AndImpl.accept(AstVisitor v)
focal_class.full_signature: @Override boolean accept(AstVisitor v)
focal_class.identifier: accept
focal_class.modifiers: @Override
focal_class.parameters: (AstVisitor v)
focal_class.return: boolean
focal_class.signature: boolean accept(AstVisitor v)
focal_class.class_method_signature: AndImpl.restrict(FilterImpl f)
focal_class.full_signature: @Override public void restrict(FilterImpl f)
focal_class.identifier: restrict
focal_class.modifiers: @Override public
focal_class.parameters: (FilterImpl f)
focal_class.return: void
focal_class.signature: void restrict(FilterImpl f)
focal_class.class_method_signature: AndImpl.restrictPushDown(SelectorImpl s)
focal_class.full_signature: @Override public void restrictPushDown(SelectorImpl s)
focal_class.identifier: restrictPushDown
focal_class.modifiers: @Override public
focal_class.parameters: (SelectorImpl s)
focal_class.return: void
focal_class.signature: void restrictPushDown(SelectorImpl s)
focal_class.class_method_signature: AndImpl.toString()
focal_class.full_signature: @Override public String toString()
focal_class.identifier: toString
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String toString()
focal_class.class_method_signature: AndImpl.equals(Object that)
focal_class.full_signature: @Override public boolean equals(Object that)
focal_class.identifier: equals
focal_class.modifiers: @Override public
focal_class.parameters: (Object that)
focal_class.return: boolean
focal_class.signature: boolean equals(Object that)
focal_class.class_method_signature: AndImpl.hashCode()
focal_class.full_signature: @Override public int hashCode()
focal_class.identifier: hashCode
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int hashCode()
focal_class.class_method_signature: AndImpl.copyOf()
focal_class.full_signature: @Override public AstElement copyOf()
focal_class.identifier: copyOf
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: AstElement
focal_class.signature: AstElement copyOf()
focal_class.class_method_signature: AndImpl.addToUnionList(Set<ConstraintImpl> target)
focal_class.full_signature: public void addToUnionList(Set<ConstraintImpl> target)
focal_class.identifier: addToUnionList
focal_class.modifiers: public
focal_class.parameters: (Set<ConstraintImpl> target)
focal_class.return: void
focal_class.signature: void addToUnionList(Set<ConstraintImpl> target)
focal_class.class_method_signature: AndImpl.getFirstConstraints()
focal_class.full_signature: private ArrayList<ConstraintImpl> getFirstConstraints()
focal_class.identifier: getFirstConstraints
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: ArrayList<ConstraintImpl>
focal_class.signature: ArrayList<ConstraintImpl> getFirstConstraints()
focal_class.class_method_signature: AndImpl.getLastConstraint()
focal_class.full_signature: private ConstraintImpl getLastConstraint()
focal_class.identifier: getLastConstraint
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: ConstraintImpl
focal_class.signature: ConstraintImpl getLastConstraint()
focal_class.class_method_signature: AndImpl.pullOrRight()
focal_class.full_signature: public AndImpl pullOrRight()
focal_class.identifier: pullOrRight
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: AndImpl
focal_class.signature: AndImpl pullOrRight()
focal_class.class_method_signature: AndImpl.getAllAndConditions()
focal_class.full_signature: private ArrayList<ConstraintImpl> getAllAndConditions()
focal_class.identifier: getAllAndConditions
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: ArrayList<ConstraintImpl>
focal_class.signature: ArrayList<ConstraintImpl> getAllAndConditions()
focal_class.class_method_signature: AndImpl.convertToUnion()
focal_class.full_signature: @Override public Set<ConstraintImpl> convertToUnion()
focal_class.identifier: convertToUnion
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Set<ConstraintImpl>
focal_class.signature: Set<ConstraintImpl> convertToUnion()
focal_class.class_method_signature: AndImpl.requiresFullTextIndex()
focal_class.full_signature: @Override public boolean requiresFullTextIndex()
focal_class.identifier: requiresFullTextIndex
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean requiresFullTextIndex()
focal_class.class_method_signature: AndImpl.containsUnfilteredFullTextCondition()
focal_class.full_signature: @Override public boolean containsUnfilteredFullTextCondition()
focal_class.identifier: containsUnfilteredFullTextCondition
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean containsUnfilteredFullTextCondition()
focal_class.superclass: extends ConstraintImpl
focal_method.body: @Override
      public Set<ConstraintImpl> convertToUnion() {
          // use linked hash sets where needed, so that the order of queries
          // within the UNION is always the same (independent of the JVM
          // implementation)
          Set<ConstraintImpl> union = Sets.newLinkedHashSet();
          Set<ConstraintImpl> result = Sets.newLinkedHashSet();
          Set<ConstraintImpl> nonUnion = Sets.newHashSet();
          
          for (ConstraintImpl c : constraints) {
              Set<ConstraintImpl> converted = c.convertToUnion();
              if (converted.isEmpty()) {
                  nonUnion.add(c);
              } else {
                  union.addAll(converted);
                  if (union.size() > QueryImpl.MAX_UNION) {
                      throw QueryImpl.TOO_MANY_UNION;
                  }
              }
          }
          if (!union.isEmpty() && nonUnion.size() == 1) {
              // this is the simplest case where, for example, out of the two AND operands at least
              // one is a non-union. For example WHERE (a OR b OR c) AND d
              ConstraintImpl right = nonUnion.iterator().next();
              for (ConstraintImpl c : union) {
                  result.add(new AndImpl(c, right));
              }
          } else {
              // This could happen when for
              // example: WHERE (a OR b) AND (c OR d).
              // This can be translated into a AND c, a AND d, b AND c, b AND d.
              if (QueryEngineSettings.SQL2_OPTIMIZATION_2) {
                  Set<ConstraintImpl> set = Sets.newLinkedHashSet();
                  addToUnionList(set);
                  if (set.size() == 1) {
                      // not a union: same condition as before
                      return Collections.emptySet();
                  }
                  return set;
              }
          }
          return result;
      }
focal_method.class_method_signature: AndImpl.convertToUnion()
focal_method.full_signature: @Override public Set<ConstraintImpl> convertToUnion()
focal_method.identifier: convertToUnion
focal_method.invocations: newLinkedHashSet newLinkedHashSet newHashSet convertToUnion isEmpty add addAll size isEmpty size next iterator add newLinkedHashSet addToUnionList size emptySet
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: Set<ConstraintImpl>
focal_method.signature: Set<ConstraintImpl> convertToUnion()