use of datawave.query.jexl.LiteralRange in project datawave by NationalSecurityAgency.
the class TLDIndexBuildingVisitor method getFiRangeForTF.
/**
* Range should be build to encompass the entire TLD
*
* @param range
* non-null literal range to generate an FI range from
* @return
*/
@Override
protected Range getFiRangeForTF(LiteralRange<?> range) {
Key startKey = rangeLimiter.getStartKey();
StringBuilder strBuilder = new StringBuilder("fi");
strBuilder.append(NULL_DELIMETER).append(range.getFieldName());
Text cf = new Text(strBuilder.toString());
strBuilder = new StringBuilder(range.getLower().toString());
strBuilder.append(NULL_DELIMETER).append(startKey.getColumnFamily());
Text cq = new Text(strBuilder.toString());
Key seekBeginKey = new Key(startKey.getRow(), cf, cq, startKey.getTimestamp());
strBuilder = new StringBuilder(range.getUpper().toString());
strBuilder.append(NULL_DELIMETER).append(startKey.getColumnFamily() + Constants.MAX_UNICODE_STRING);
cq = new Text(strBuilder.toString());
Key seekEndKey = new Key(startKey.getRow(), cf, cq, startKey.getTimestamp());
return new Range(seekBeginKey, true, seekEndKey, true);
}
use of datawave.query.jexl.LiteralRange in project datawave by NationalSecurityAgency.
the class WhindexVisitor method getLeafNodes.
/**
* This method checks each of the child nodes, and returns those which are leaf nodes. Range nodes are also considered leaf nodes for our purposes. If the
* root node is a range node, then that node will be returned. Reference, ReferenceExpression, and 'and' or 'or' nodes with a single child are passed
* through in search of the actual leaf node.
*
* @param rootNode
* The node whose children we will check
* @param otherNodes
* Non-leaf child nodes of the root node
* @return A multimap of field name to leaf node
*/
private Multimap<String, JexlNode> getLeafNodes(JexlNode rootNode, Collection<JexlNode> otherNodes) {
Multimap<String, JexlNode> childrenLeafNodes = ArrayListMultimap.create();
if (rootNode instanceof ASTAndNode) {
// check to see if this node is a range node, if so, this is our leaf node
JexlNode leafKid = getLeafNode(rootNode);
if (leafKid != null) {
String kidFieldName;
LiteralRange range = JexlASTHelper.findRange().getRange(leafKid);
kidFieldName = (range != null) ? range.getFieldName() : JexlASTHelper.getIdentifier(leafKid);
childrenLeafNodes.put(kidFieldName, rootNode);
}
}
if (childrenLeafNodes.isEmpty()) {
for (JexlNode child : JexlNodes.children(rootNode)) {
JexlNode leafKid = getLeafNode(child);
if (leafKid != null) {
Set<String> kidFieldNames = new LinkedHashSet<>();
LiteralRange range = JexlASTHelper.findRange().getRange(leafKid);
if (range != null) {
kidFieldNames.add(range.getFieldName());
} else {
if (leafKid instanceof ASTEQNode) {
kidFieldNames.add(JexlASTHelper.getIdentifier(leafKid));
} else if (leafKid instanceof ASTFunctionNode) {
JexlArgumentDescriptor descriptor = JexlFunctionArgumentDescriptorFactory.F.getArgumentDescriptor((ASTFunctionNode) leafKid);
if (descriptor instanceof GeoWaveFunctionsDescriptor.GeoWaveJexlArgumentDescriptor || descriptor instanceof GeoFunctionsDescriptor.GeoJexlArgumentDescriptor) {
kidFieldNames.addAll(descriptor.fields(metadataHelper, Collections.emptySet()));
} else {
if (otherNodes != null) {
otherNodes.add(child);
}
}
}
}
for (String kidFieldName : kidFieldNames) {
// note: we save the actual direct sibling of the and node, including
// any reference nodes. those will be trimmed off later
childrenLeafNodes.put(kidFieldName, child);
}
} else {
if (otherNodes != null)
otherNodes.add(child);
}
}
}
return childrenLeafNodes;
}
use of datawave.query.jexl.LiteralRange in project datawave by NationalSecurityAgency.
the class BoundedRangeDetectionVisitor method visit.
@Override
public Object visit(ASTReference node, Object data) {
if (QueryPropertyMarker.findInstance(node).isType(BoundedRange.class)) {
LiteralRange range = JexlASTHelper.findRange().getRange(node);
try {
if (helper.getNonEventFields(config.getDatatypeFilter()).contains(range.getFieldName())) {
if (null != data) {
AtomicBoolean hasBounded = (AtomicBoolean) data;
hasBounded.set(true);
}
}
} catch (TableNotFoundException e) {
throw new DatawaveFatalQueryException("Cannot access metadata", e);
}
return false;
} else {
return super.visit(node, data);
}
}
Aggregations