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));
}
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);
}
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));
}
}
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));
}
}
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;
}
Aggregations