Search in sources :

Example 16 with ASTJexlScript

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

the class JexlASTHelperTest method sameJexlNodeEquality.

@Test
public void sameJexlNodeEquality() throws Exception {
    ASTJexlScript query = JexlASTHelper.parseJexlQuery("FOO == '1'");
    Assert.assertTrue(JexlASTHelper.equals(query, query));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) Test(org.junit.Test)

Example 17 with ASTJexlScript

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

the class JexlASTHelperTest method testFindLiteral.

@Test
public void testFindLiteral() throws Throwable {
    ASTJexlScript script = JexlASTHelper.parseJexlQuery("i == 10");
    if (log.isDebugEnabled()) {
        PrintingVisitor.printQuery(script);
    }
    JexlNode literal = JexlASTHelper.findLiteral(script);
    Assert.assertTrue(literal instanceof ASTNumberLiteral);
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) JexlNode(org.apache.commons.jexl2.parser.JexlNode) ASTNumberLiteral(org.apache.commons.jexl2.parser.ASTNumberLiteral) Test(org.junit.Test)

Example 18 with ASTJexlScript

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

the class JexlASTHelperTest method test.

@Test
public void test() throws Exception {
    ASTJexlScript query = JexlASTHelper.parseJexlQuery("FOO == 'bar' and (FOO == 'bar' and FOO == 'bar')");
    List<ASTEQNode> eqNodes = JexlASTHelper.getEQNodes(query);
    for (JexlNode eqNode : eqNodes) {
        Assert.assertFalse(JexlASTHelper.isWithinOr(eqNode));
    }
}
Also used : ASTEQNode(org.apache.commons.jexl2.parser.ASTEQNode) ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) JexlNode(org.apache.commons.jexl2.parser.JexlNode) Test(org.junit.Test)

Example 19 with ASTJexlScript

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

the class JexlASTHelperTest method test2.

@Test
public void test2() throws Exception {
    ASTJexlScript query = JexlASTHelper.parseJexlQuery("FOO == '1' and (FOO == '2' or (FOO == '3' and FOO == '4'))");
    List<ASTEQNode> eqNodes = JexlASTHelper.getEQNodes(query);
    Map<String, Boolean> expectations = Maps.newHashMap();
    expectations.put("1", false);
    expectations.put("2", true);
    expectations.put("3", true);
    expectations.put("4", true);
    for (JexlNode eqNode : eqNodes) {
        String value = JexlASTHelper.getLiteralValue(eqNode).toString();
        Assert.assertTrue(expectations.containsKey(value));
        Assert.assertEquals(expectations.get(value), JexlASTHelper.isWithinOr(eqNode));
    }
}
Also used : ASTEQNode(org.apache.commons.jexl2.parser.ASTEQNode) ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) JexlNode(org.apache.commons.jexl2.parser.JexlNode) Test(org.junit.Test)

Example 20 with ASTJexlScript

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

the class DefaultQueryPlanner method timedPruneGeoWaveTerms.

protected ASTJexlScript timedPruneGeoWaveTerms(QueryStopwatch timers, ASTJexlScript script, MetadataHelper metadataHelper) throws DatawaveQueryException {
    Multimap<String, String> prunedTerms = HashMultimap.create();
    ASTJexlScript finalScript = script;
    script = visitorManager.timedVisit(timers, "Prune GeoWave Terms", () -> GeoWavePruningVisitor.pruneTree(finalScript, prunedTerms, metadataHelper));
    if (log.isDebugEnabled()) {
        log.debug("Pruned the following GeoWave terms: [" + prunedTerms.entries().stream().map(x -> x.getKey() + "==" + x.getValue()).collect(Collectors.joining(",")) + "]");
    }
    return script;
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript)

Aggregations

ASTJexlScript (org.apache.commons.jexl2.parser.ASTJexlScript)458 Test (org.junit.Test)385 Key (org.apache.accumulo.core.data.Key)69 JexlNode (org.apache.commons.jexl2.parser.JexlNode)67 HashSet (java.util.HashSet)50 ShardQueryConfiguration (datawave.query.config.ShardQueryConfiguration)48 MockMetadataHelper (datawave.query.util.MockMetadataHelper)40 ArrayList (java.util.ArrayList)39 Type (datawave.data.type.Type)38 LcNoDiacriticsType (datawave.data.type.LcNoDiacriticsType)37 ExpressionFilter (datawave.query.jexl.visitors.EventDataQueryExpressionVisitor.ExpressionFilter)36 ScannerFactory (datawave.query.tables.ScannerFactory)35 Date (java.util.Date)35 NoOpType (datawave.data.type.NoOpType)34 NumberType (datawave.data.type.NumberType)34 AbstractMap (java.util.AbstractMap)32 Range (org.apache.accumulo.core.data.Range)30 Value (org.apache.accumulo.core.data.Value)29 RangeFactoryForTests.makeTestRange (datawave.common.test.utils.query.RangeFactoryForTests.makeTestRange)26 QueryPlan (datawave.query.planner.QueryPlan)26