@Test
  public void testCNF() throws Exception {
    assertEquals("leaf-1", SearchArgumentImpl.BuilderImpl.convertToCNF(leaf(1)).
        toOldString());
    assertEquals("NO", SearchArgumentImpl.BuilderImpl.convertToCNF(
        constant(TruthValue.NO)).toString());
    assertEquals("(not leaf-1)", SearchArgumentImpl.BuilderImpl.convertToCNF(
        not(leaf(1))).toOldString());
    assertEquals("(and leaf-1 leaf-2)", SearchArgumentImpl.BuilderImpl.
        convertToCNF(
            and(leaf(1), leaf(2))).toOldString());
    assertEquals("(or (not leaf-1) leaf-2)", SearchArgumentImpl.BuilderImpl.
        convertToCNF(
            or(not(leaf(1)), leaf(2))).toOldString());
    assertEquals("(and (or leaf-1 leaf-2) (not leaf-3))",
        SearchArgumentImpl.BuilderImpl.convertToCNF(
            and(or(leaf(1), leaf(2)), not(leaf(3)))).toOldString());
    assertEquals("(and (or leaf-1 leaf-3) (or leaf-2 leaf-3)" +
        " (or leaf-1 leaf-4) (or leaf-2 leaf-4))",
        SearchArgumentImpl.BuilderImpl.convertToCNF(
            or(and(leaf(1), leaf(2)), and(leaf(3), leaf(4)))).toOldString());
    assertEquals("(and" +
        " (or leaf-1 leaf-5) (or leaf-2 leaf-5)" +
        " (or leaf-3 leaf-5) (or leaf-4 leaf-5)" +
        " (or leaf-1 leaf-6) (or leaf-2 leaf-6)" +
        " (or leaf-3 leaf-6) (or leaf-4 leaf-6))",
        SearchArgumentImpl.BuilderImpl.convertToCNF(
            or(and(leaf(1), leaf(2), leaf(3), leaf(4)),
                and(leaf(5), leaf(6)))).toOldString());
    assertEquals("(and" +
        " (or leaf-5 leaf-6 (not leaf-7) leaf-1 leaf-3)" +
        " (or leaf-5 leaf-6 (not leaf-7) leaf-2 leaf-3)" +
        " (or leaf-5 leaf-6 (not leaf-7) leaf-1 leaf-4)" +
        " (or leaf-5 leaf-6 (not leaf-7) leaf-2 leaf-4))",
        SearchArgumentImpl.BuilderImpl.convertToCNF(
            or(and(leaf(1), leaf(2)),
                and(leaf(3), leaf(4)),
                or(leaf(5), leaf(6)),
                not(leaf(7)))).toOldString());
    assertEquals("(and" +
        " (or leaf-8 leaf-0 leaf-3 leaf-6)" +
        " (or leaf-8 leaf-1 leaf-3 leaf-6)" +
        " (or leaf-8 leaf-2 leaf-3 leaf-6)" +
        " (or leaf-8 leaf-0 leaf-4 leaf-6)" +
        " (or leaf-8 leaf-1 leaf-4 leaf-6)" +
        " (or leaf-8 leaf-2 leaf-4 leaf-6)" +
        " (or leaf-8 leaf-0 leaf-5 leaf-6)" +
        " (or leaf-8 leaf-1 leaf-5 leaf-6)" +
        " (or leaf-8 leaf-2 leaf-5 leaf-6)" +
        " (or leaf-8 leaf-0 leaf-3 leaf-7)" +
        " (or leaf-8 leaf-1 leaf-3 leaf-7)" +
        " (or leaf-8 leaf-2 leaf-3 leaf-7)" +
        " (or leaf-8 leaf-0 leaf-4 leaf-7)" +
        " (or leaf-8 leaf-1 leaf-4 leaf-7)" +
        " (or leaf-8 leaf-2 leaf-4 leaf-7)" +
        " (or leaf-8 leaf-0 leaf-5 leaf-7)" +
        " (or leaf-8 leaf-1 leaf-5 leaf-7)" +
        " (or leaf-8 leaf-2 leaf-5 leaf-7))",
        SearchArgumentImpl.BuilderImpl.convertToCNF(or(and(leaf(0), leaf(1),
                leaf(2)),
            and(leaf(3), leaf(4), leaf(5)),
            and(leaf(6), leaf(7)),
            leaf(8))).toOldString());
    assertEquals("YES_NO_NULL", SearchArgumentImpl.BuilderImpl.
        convertToCNF(or(and(leaf(0), leaf(1)),
            and(leaf(2), leaf(3)),
            and(leaf(4), leaf(5)),
            and(leaf(6), leaf(7)),
            and(leaf(8), leaf(9)),
            and(leaf(10), leaf(11)),
            and(leaf(12), leaf(13)),
            and(leaf(14), leaf(15)),
            and(leaf(16), leaf(17)))).toString());
    assertEquals("(and leaf-100 YES_NO_NULL)", SearchArgumentImpl.BuilderImpl.
        convertToCNF(and(leaf(100),
            or(and(leaf(0), leaf(1)),
                and(leaf(2), leaf(3)),
                and(leaf(4), leaf(5)),
                and(leaf(6), leaf(7)),
                and(leaf(8), leaf(9)),
                and(leaf(10), leaf(11)),
                and(leaf(12), leaf(13)),
                and(leaf(14), leaf(15)),
                and(leaf(16), leaf(17))))).toOldString());
    assertNoSharedNodes(SearchArgumentImpl.BuilderImpl.
        convertToCNF(or(and(leaf(0), leaf(1), leaf(2)),
            and(leaf(3), leaf(4), leaf(5)),
            and(leaf(6), leaf(7)),
            leaf(8))), Sets.<ExpressionTree>newIdentityHashSet());
  }
Create a predicate leaf. This is used by another test.
ql/src/test/org/apache/hadoop/hive/ql/io/sarg/TestSearchArgumentImpl.java