use of org.apache.commons.jexl2.parser.JexlNode in project datawave by NationalSecurityAgency.
the class JexlNodeSetTest method testClear.
@Test
public void testClear() {
JexlNode node1 = JexlNodeFactory.buildEQNode("FOO", "bar");
JexlNode node2 = JexlNodeFactory.buildEQNode("FOO2", "bar2");
JexlNode node3 = JexlNodeFactory.buildEQNode("FOO3", "bar3");
Collection<JexlNode> nodes = Lists.newArrayList(node1, node2, node3);
JexlNodeSet nodeSet = new JexlNodeSet();
nodeSet.addAll(nodes);
assertTrue(nodeSet.contains(node1));
assertTrue(nodeSet.contains(node2));
assertTrue(nodeSet.contains(node3));
assertFalse(nodeSet.isEmpty());
nodeSet.clear();
assertFalse(nodeSet.contains(node1));
assertFalse(nodeSet.contains(node2));
assertFalse(nodeSet.contains(node3));
assertTrue(nodeSet.isEmpty());
}
use of org.apache.commons.jexl2.parser.JexlNode in project datawave by NationalSecurityAgency.
the class JexlNodeSetTest method testToArray1.
@Test
public void testToArray1() {
JexlNode node = JexlNodeFactory.buildEQNode("FOO", "bar");
JexlNodeSet nodeSet = new JexlNodeSet();
nodeSet.add(node);
Object[] array = nodeSet.toArray();
assertEquals(1, array.length);
}
use of org.apache.commons.jexl2.parser.JexlNode in project datawave by NationalSecurityAgency.
the class JexlNodeSetTest method testGetNodesAndGetNodeKeys.
@Test
public void testGetNodesAndGetNodeKeys() {
JexlNode node = JexlNodeFactory.buildEQNode("FOO", "bar");
String key = "FOO == 'bar'";
JexlNodeSet nodeSet = new JexlNodeSet();
nodeSet.add(node);
assertEquals(Collections.singleton(key), nodeSet.getNodeKeys());
assertEquals(node, nodeSet.getNodes().iterator().next());
}
use of org.apache.commons.jexl2.parser.JexlNode in project datawave by NationalSecurityAgency.
the class JexlNodeSetTest method testDirectAddAll.
// Test exercises the directAddAll() codepath found within the addAll() method.
@Test
public void testDirectAddAll() {
JexlNode node1 = JexlNodeFactory.buildEQNode("FOO", "bar");
JexlNode node2 = JexlNodeFactory.buildEQNode("FOO2", "bar2");
JexlNodeSet nodeSet = new JexlNodeSet();
nodeSet.add(node1);
nodeSet.add(node2);
JexlNode node3 = JexlNodeFactory.buildEQNode("FOO3", "bar3");
JexlNode node4 = JexlNodeFactory.buildEQNode("FOO4", "bar4");
JexlNodeSet otherSet = new JexlNodeSet();
otherSet.add(node3);
otherSet.add(node4);
assertEquals(2, nodeSet.size());
assertEquals(2, otherSet.size());
nodeSet.addAll(otherSet);
assertEquals(4, nodeSet.size());
assertTrue(nodeSet.contains(node1));
assertTrue(nodeSet.contains(node2));
assertTrue(nodeSet.contains(node3));
assertTrue(nodeSet.contains(node4));
}
use of org.apache.commons.jexl2.parser.JexlNode in project datawave by NationalSecurityAgency.
the class RangeStream method containsIndexOnlyFields.
protected boolean containsIndexOnlyFields(JexlNode node) throws TableNotFoundException {
List<ASTIdentifier> identifiers = JexlASTHelper.getIdentifiers(node);
Set<String> indexOnlyFields = metadataHelper.getIndexOnlyFields(config.getDatatypeFilter());
// Hack to get around the extra ASTIdentifier left in the AST by the threshold marker node
Iterator<ASTIdentifier> iter = identifiers.iterator();
while (iter.hasNext()) {
ASTIdentifier id = iter.next();
if (ExceededValueThresholdMarkerJexlNode.label().equals(id.image) || ExceededTermThresholdMarkerJexlNode.label().equals(id.image) || ExceededOrThresholdMarkerJexlNode.label().equals(id.image)) {
iter.remove();
}
}
for (ASTIdentifier identifier : identifiers) {
String fieldName = JexlASTHelper.deconstructIdentifier(identifier);
if (indexOnlyFields.contains(fieldName)) {
return true;
}
}
return false;
}
Aggregations