use of datawave.query.iterator.builder.IndexListIteratorBuilder in project datawave by NationalSecurityAgency.
the class IteratorBuildingVisitor method ivarateList.
/**
* Build the iterator stack using the regex ivarator (field index caching regex iterator)
*
* @param rootNode
* the node that was processed to generated this builder
* @param sourceNode
* the source node derived from the root
* @param data
*/
public void ivarateList(JexlNode rootNode, JexlNode sourceNode, Object data) throws IOException {
IvaratorBuilder builder = null;
try {
String id = ExceededOrThresholdMarkerJexlNode.getId(sourceNode);
String field = JexlASTHelper.deconstructIdentifier(ExceededOrThresholdMarkerJexlNode.getField(sourceNode));
ExceededOrThresholdMarkerJexlNode.ExceededOrParams params = ExceededOrThresholdMarkerJexlNode.getParameters(sourceNode);
if (params.getRanges() != null && !params.getRanges().isEmpty()) {
IndexRangeIteratorBuilder rangeIterBuilder = new IndexRangeIteratorBuilder();
builder = rangeIterBuilder;
SortedSet<Range> ranges = params.getSortedAccumuloRanges();
rangeIterBuilder.setSubRanges(params.getSortedAccumuloRanges());
// cache these ranges for use during Jexl Evaluation
if (exceededOrEvaluationCache != null)
exceededOrEvaluationCache.put(id, ranges);
LiteralRange<?> fullRange = new LiteralRange<>(String.valueOf(ranges.first().getStartKey().getRow()), ranges.first().isStartKeyInclusive(), String.valueOf(ranges.last().getEndKey().getRow()), ranges.last().isEndKeyInclusive(), field, NodeOperand.AND);
rangeIterBuilder.setRange(fullRange);
} else {
IndexListIteratorBuilder listIterBuilder = new IndexListIteratorBuilder();
builder = listIterBuilder;
if (params.getValues() != null && !params.getValues().isEmpty()) {
Set<String> values = new TreeSet<>(params.getValues());
listIterBuilder.setValues(values);
// cache these values for use during Jexl Evaluation
if (exceededOrEvaluationCache != null)
exceededOrEvaluationCache.put(id, values);
} else if (params.getFstURI() != null) {
URI fstUri = new URI(params.getFstURI());
FST fst;
// only recompute this if not already set since this is potentially expensive
if (exceededOrEvaluationCache.containsKey(id)) {
fst = (FST) exceededOrEvaluationCache.get(id);
} else {
fst = DatawaveFieldIndexListIteratorJexl.FSTManager.get(new Path(fstUri), hdfsFileCompressionCodec, hdfsFileSystem.getFileSystem(fstUri));
}
listIterBuilder.setFst(fst);
// cache this fst for use during JexlEvaluation.
if (exceededOrEvaluationCache != null)
exceededOrEvaluationCache.put(id, fst);
}
// If this is actually negated, then this will be added to excludes. Do not negate in the ivarator
listIterBuilder.setNegated(false);
}
builder.setField(field);
} catch (IOException | URISyntaxException | NullPointerException e) {
QueryException qe = new QueryException(DatawaveErrorCode.UNPARSEABLE_EXCEEDED_OR_PARAMS, e, MessageFormat.format("Class: {0}", ExceededOrThresholdMarkerJexlNode.class.getSimpleName()));
throw new DatawaveFatalQueryException(qe);
}
builder.negateAsNeeded(data);
builder.forceDocumentBuild(!limitLookup && this.isQueryFullySatisfied);
ivarate(builder, rootNode, sourceNode, data);
}
Aggregations