Search in sources :

Example 76 with JexlNode

use of org.apache.commons.jexl2.parser.JexlNode in project datawave by NationalSecurityAgency.

the class PushdownNegationVisitorTest method testPartialBoundedRangePropagation.

@Test
public void testPartialBoundedRangePropagation() throws ParseException {
    ASTJexlScript query = JexlASTHelper.parseJexlQuery("F3 == 'v3' || !((_Bounded_ = true) && (F1 >= 'v1' && F2 <= 'v2'))");
    JexlNode result = PushdownNegationVisitor.pushdownNegations(query);
    Assert.assertEquals("F3 == 'v3' || !((_Bounded_ = true) && (F1 >= 'v1' && F2 <= 'v2'))", JexlStringBuildingVisitor.buildQuery(result));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) JexlNode(org.apache.commons.jexl2.parser.JexlNode) Test(org.junit.Test)

Example 77 with JexlNode

use of org.apache.commons.jexl2.parser.JexlNode in project datawave by NationalSecurityAgency.

the class PushdownNegationVisitorTest method testGuarantees.

/**
 * Same as testNestedAnd but validate that the original is not modified
 *
 * @throws ParseException
 */
@Test
public void testGuarantees() throws ParseException {
    ASTJexlScript query = JexlASTHelper.parseJexlQuery("!(F1 == 'v1' && F2 == 'v2' && (F3 == 'v3' || F4 == 'v4'))");
    String orig = JexlStringBuildingVisitor.buildQuery(query);
    JexlNode result = PushdownNegationVisitor.pushdownNegations(query);
    Assert.assertEquals("((!(F1 == 'v1') || !(F2 == 'v2') || (((!(F3 == 'v3') && !(F4 == 'v4'))))))", JexlStringBuildingVisitor.buildQuery(result));
    Assert.assertNotEquals(orig, JexlStringBuildingVisitor.buildQuery(result));
    Assert.assertEquals(orig, JexlStringBuildingVisitor.buildQuery(query));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) JexlNode(org.apache.commons.jexl2.parser.JexlNode) Test(org.junit.Test)

Example 78 with JexlNode

use of org.apache.commons.jexl2.parser.JexlNode in project datawave by NationalSecurityAgency.

the class PushdownNegationVisitorTest method testNestedAnd.

@Test
public void testNestedAnd() throws ParseException {
    ASTJexlScript query = JexlASTHelper.parseJexlQuery("!(F1 == 'v1' && F2 == 'v2' && (F3 == 'v3' || F4 == 'v4'))");
    JexlNode result = PushdownNegationVisitor.pushdownNegations(query);
    Assert.assertEquals("((!(F1 == 'v1') || !(F2 == 'v2') || (((!(F3 == 'v3') && !(F4 == 'v4'))))))", JexlStringBuildingVisitor.buildQuery(result));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) JexlNode(org.apache.commons.jexl2.parser.JexlNode) Test(org.junit.Test)

Example 79 with JexlNode

use of org.apache.commons.jexl2.parser.JexlNode in project datawave by NationalSecurityAgency.

the class PushdownNegationVisitorTest method testNestedAndMixedCancels.

@Test
public void testNestedAndMixedCancels() throws ParseException {
    ASTJexlScript query = JexlASTHelper.parseJexlQuery("!(F1 != 'v1' && !F2 == 'v2' && (F3 == 'v3' || F4 == 'v4'))");
    JexlNode result = PushdownNegationVisitor.pushdownNegations(query);
    Assert.assertEquals("(((F1 == 'v1') || (F2 == 'v2') || (((!(F3 == 'v3') && !(F4 == 'v4'))))))", JexlStringBuildingVisitor.buildQuery(result));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) JexlNode(org.apache.commons.jexl2.parser.JexlNode) Test(org.junit.Test)

Example 80 with JexlNode

use of org.apache.commons.jexl2.parser.JexlNode in project datawave by NationalSecurityAgency.

the class PushdownNegationVisitorTest method testExceededTermPropertyMarkerPropagate.

@Test
public void testExceededTermPropertyMarkerPropagate() throws ParseException {
    ASTJexlScript query = JexlASTHelper.parseJexlQuery("!((_Term_ = true) && (F1 == 'v1' || F2 == 'v2'))");
    JexlNode result = PushdownNegationVisitor.pushdownNegations(query);
    Assert.assertEquals("!((_Term_ = true) && (F1 == 'v1' || F2 == 'v2'))", JexlStringBuildingVisitor.buildQuery(result));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) JexlNode(org.apache.commons.jexl2.parser.JexlNode) Test(org.junit.Test)

Aggregations

JexlNode (org.apache.commons.jexl2.parser.JexlNode)327 Test (org.junit.Test)124 ASTJexlScript (org.apache.commons.jexl2.parser.ASTJexlScript)64 ExceededValueThresholdMarkerJexlNode (datawave.query.jexl.nodes.ExceededValueThresholdMarkerJexlNode)57 ArrayList (java.util.ArrayList)51 ASTAndNode (org.apache.commons.jexl2.parser.ASTAndNode)37 ExceededTermThresholdMarkerJexlNode (datawave.query.jexl.nodes.ExceededTermThresholdMarkerJexlNode)34 JexlNode (org.apache.commons.jexl3.parser.JexlNode)34 ASTEQNode (org.apache.commons.jexl2.parser.ASTEQNode)29 ASTOrNode (org.apache.commons.jexl2.parser.ASTOrNode)29 ASTReference (org.apache.commons.jexl2.parser.ASTReference)27 ExceededOrThresholdMarkerJexlNode (datawave.query.jexl.nodes.ExceededOrThresholdMarkerJexlNode)25 ASTIdentifier (org.apache.commons.jexl2.parser.ASTIdentifier)24 HashSet (java.util.HashSet)23 ASTReferenceExpression (org.apache.commons.jexl2.parser.ASTReferenceExpression)19 ASTFunctionNode (org.apache.commons.jexl2.parser.ASTFunctionNode)17 DatawaveFatalQueryException (datawave.query.exceptions.DatawaveFatalQueryException)16 IndexHoleMarkerJexlNode (datawave.query.jexl.nodes.IndexHoleMarkerJexlNode)15 ASTERNode (org.apache.commons.jexl2.parser.ASTERNode)15 LiteralRange (datawave.query.jexl.LiteralRange)13