use of datawave.query.jexl.DelayedNonEventIndexContext in project datawave by NationalSecurityAgency.
the class JexlEvaluation method apply.
@Override
public boolean apply(Tuple3<Key, Document, DatawaveJexlContext> input) {
Object o = script.execute(input.third());
if (log.isTraceEnabled()) {
log.trace("Evaluation of " + query + " against " + input.third() + " returned " + o);
}
boolean matched = isMatched(o);
// Add delayed info to document
if (matched && input.third() instanceof DelayedNonEventIndexContext) {
((DelayedNonEventIndexContext) input.third()).populateDocument(input.second());
}
if (arithmetic instanceof HitListArithmetic) {
HitListArithmetic hitListArithmetic = (HitListArithmetic) arithmetic;
if (matched) {
Document document = input.second();
Attributes attributes = new Attributes(input.second().isToKeep());
for (ValueTuple hitTuple : hitListArithmetic.getHitTuples()) {
ColumnVisibility cv = null;
String term = hitTuple.getFieldName() + ':' + hitTuple.getValue();
if (hitTuple.getSource() != null) {
cv = hitTuple.getSource().getColumnVisibility();
}
// fall back to extracting column visibility from document
if (cv == null) {
// get the visibility for the record with this hit
cv = HitListArithmetic.getColumnVisibilityForHit(document, term);
// if no visibility computed, then there were no hits that match fields still in the document......
}
if (cv != null) {
// unused
// will force an update to make the metadata valid
long timestamp = document.getTimestamp();
Content content = new Content(term, document.getMetadata(), document.isToKeep());
content.setColumnVisibility(cv);
attributes.add(content);
}
}
if (attributes.size() > 0) {
document.put(HIT_TERM_FIELD, attributes);
}
}
hitListArithmetic.clear();
}
return matched;
}
use of datawave.query.jexl.DelayedNonEventIndexContext in project datawave by NationalSecurityAgency.
the class IndexOnlyContextCreator method newDatawaveJexlContext.
@Override
protected DatawaveJexlContext newDatawaveJexlContext(final Tuple3<Key, Document, Map<String, Object>> from) {
final DatawaveJexlContext parentContext = super.newDatawaveJexlContext(from);
DatawaveJexlContext newContext;
if (this.createIndexOnlyJexlContext) {
final Key key = from.first();
final IndexOnlyFunctionIterator<Tuple3<Key, Document, DatawaveJexlContext>> iterator = new IndexOnlyFunctionIterator<>(this.documentSpecificSource, this, key);
newContext = new IndexOnlyJexlContext<>(parentContext, iterator);
} else {
newContext = parentContext;
}
// see if there are any delayed nodes that need to be processed
if (delayedNonEventFieldMap != null && !delayedNonEventFieldMap.isEmpty()) {
// build the current document range from the document Key to end of the document, even though for some query logics this may be too large a range,
// it will be narrowed with equality later
Key startKey = new Key(from.first().getRow(), from.first().getColumnFamily());
Key endKey = new Key(startKey.getRow().toString(), startKey.getColumnFamily() + Constants.MAX_UNICODE_STRING);
Range docRange = new Range(startKey, true, endKey, false);
newContext = new DelayedNonEventIndexContext(newContext, iteratorBuildingVisitor, delayedNonEventFieldMap, docRange, columnFamilies, inclusive, equality);
}
return newContext;
}
Aggregations