Search in sources :

Example 1 with DelayedNonEventIndexContext

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;
}
Also used : DelayedNonEventIndexContext(datawave.query.jexl.DelayedNonEventIndexContext) HitListArithmetic(datawave.query.jexl.HitListArithmetic) ValueTuple(datawave.query.attributes.ValueTuple) Content(datawave.query.attributes.Content) Attributes(datawave.query.attributes.Attributes) ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility) Document(datawave.query.attributes.Document)

Example 2 with DelayedNonEventIndexContext

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;
}
Also used : DelayedNonEventIndexContext(datawave.query.jexl.DelayedNonEventIndexContext) Tuple3(datawave.query.util.Tuple3) DatawaveJexlContext(datawave.query.jexl.DatawaveJexlContext) IndexOnlyFunctionIterator(datawave.query.iterator.IndexOnlyFunctionIterator) Range(org.apache.accumulo.core.data.Range) Key(org.apache.accumulo.core.data.Key)

Aggregations

DelayedNonEventIndexContext (datawave.query.jexl.DelayedNonEventIndexContext)2 Attributes (datawave.query.attributes.Attributes)1 Content (datawave.query.attributes.Content)1 Document (datawave.query.attributes.Document)1 ValueTuple (datawave.query.attributes.ValueTuple)1 IndexOnlyFunctionIterator (datawave.query.iterator.IndexOnlyFunctionIterator)1 DatawaveJexlContext (datawave.query.jexl.DatawaveJexlContext)1 HitListArithmetic (datawave.query.jexl.HitListArithmetic)1 Tuple3 (datawave.query.util.Tuple3)1 Key (org.apache.accumulo.core.data.Key)1 Range (org.apache.accumulo.core.data.Range)1 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)1