Search in sources :

Example 1 with IndexIteratorBridge

use of datawave.query.iterator.logic.IndexIteratorBridge in project datawave by NationalSecurityAgency.

the class IndexFilterIteratorBuilder method build.

@SuppressWarnings("unchecked")
@Override
public NestedIterator<Key> build() {
    if (notNull(range, filter, source, datatypeFilter, keyTform, timeFilter, ivaratorCacheDirs, getField(), getNode())) {
        if (log.isTraceEnabled()) {
            log.trace("Generating ivarator (caching field index iterator) for " + filter + " over " + range);
        }
        // we can't build an ivarator if no ivarator directories have been defined
        if (ivaratorCacheDirs.isEmpty())
            throw new IllegalStateException("No ivarator cache dirs defined");
        // ensure that we are able to create the first ivarator cache dir (the control dir)
        validateIvaratorControlDir(ivaratorCacheDirs.get(0));
        DocumentIterator docIterator = null;
        try {
            // create a field index caching ivarator
            // @formatter:off
            DatawaveFieldIndexFilterIteratorJexl rangeIterator = DatawaveFieldIndexFilterIteratorJexl.builder().withFieldName(new Text(range.getFieldName())).withFilter(filter).withLowerBound(range.getLower().toString()).lowerInclusive(range.isLowerInclusive()).withUpperBound(range.getUpper().toString()).upperInclusive(range.isUpperInclusive()).withTimeFilter(timeFilter).withDatatypeFilter(datatypeFilter).negated(false).withScanThreshold(ivaratorCacheScanPersistThreshold).withScanTimeout(ivaratorCacheScanTimeout).withHdfsBackedSetBufferSize(ivaratorCacheBufferSize).withMaxRangeSplit(maxRangeSplit).withMaxOpenFiles(ivaratorMaxOpenFiles).withMaxResults(maxIvaratorResults).withIvaratorCacheDirs(ivaratorCacheDirs).withNumRetries(ivaratorNumRetries).withPersistOptions(ivaratorPersistOptions).withQueryLock(queryLock).allowDirResuse(true).withReturnKeyType(PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME).withSortedUUIDs(sortedUIDs).withCompositeMetadata(compositeMetadata).withCompositeSeekThreshold(compositeSeekThreshold).withTypeMetadata(typeMetadata).withIteratorEnv(env).withIvaratorSourcePool(ivaratorSourcePool).build();
            if (collectTimingDetails) {
                rangeIterator.setCollectTimingDetails(true);
                rangeIterator.setQuerySpanCollector(this.querySpanCollector);
            }
            rangeIterator.init(source, null, env);
            log.debug("Created a DatawaveFieldIndexFilterIteratorJexl: " + rangeIterator);
            // Add an interator to aggregate documents. This is needed for index only fields.
            DocumentAggregatingIterator aggregatingIterator = new // this.fieldsToKeep == null ? false
            DocumentAggregatingIterator(// this.fieldsToKeep == null ? false
            true, // :this.fieldsToKeep.contains(field),
            this.typeMetadata, keyTform);
            aggregatingIterator.init(rangeIterator, null, null);
            docIterator = aggregatingIterator;
        } catch (IOException e) {
            throw new IllegalStateException("Unable to initialize regex iterator stack", e);
        }
        IndexIteratorBridge itr = new IndexIteratorBridge(docIterator, getNode(), getField());
        range = null;
        filter = null;
        source = null;
        timeFilter = null;
        datatypeFilter = null;
        keyTform = null;
        timeFilter = null;
        ivaratorCacheDirs = null;
        node = null;
        field = null;
        return itr;
    } else {
        StringBuilder msg = new StringBuilder(256);
        msg.append("Cannot build iterator-- a field was null!\n");
        if (filter == null) {
            msg.append("\tFilter was null!\n");
        }
        if (range == null) {
            msg.append("\tRange was null!\n");
        }
        if (source == null) {
            msg.append("\tSource was null!\n");
        }
        msg.setLength(msg.length() - 1);
        throw new IllegalStateException(msg.toString());
    }
}
Also used : DatawaveFieldIndexFilterIteratorJexl(datawave.core.iterators.DatawaveFieldIndexFilterIteratorJexl) DocumentIterator(datawave.query.iterator.DocumentIterator) Text(org.apache.hadoop.io.Text) DocumentAggregatingIterator(datawave.query.iterator.logic.DocumentAggregatingIterator) IOException(java.io.IOException) IndexIteratorBridge(datawave.query.iterator.logic.IndexIteratorBridge)

Example 2 with IndexIteratorBridge

use of datawave.query.iterator.logic.IndexIteratorBridge in project datawave by NationalSecurityAgency.

the class IndexListIteratorBuilder method build.

@SuppressWarnings("unchecked")
@Override
public NestedIterator<Key> build() {
    if (notNull(field, (values != null ? values : fst), negated, source, datatypeFilter, timeFilter, keyTform, ivaratorCacheDirs, getField(), getNode())) {
        if (log.isTraceEnabled()) {
            log.trace("Generating ivarator (caching field index iterator) for " + field + (negated ? "!~" : "=~") + value);
        }
        // we can't build an ivarator if no ivarator directories have been defined
        if (ivaratorCacheDirs.isEmpty())
            throw new IllegalStateException("No ivarator cache dirs defined");
        // ensure that we are able to create the first ivarator cache dir (the control dir)
        validateIvaratorControlDir(ivaratorCacheDirs.get(0));
        DocumentIterator docIterator = null;
        try {
            // create a field index caching ivarator
            // @formatter:off
            DatawaveFieldIndexListIteratorJexl.Builder builder = DatawaveFieldIndexListIteratorJexl.builder().withFieldName(new Text(field)).withTimeFilter(timeFilter).withDatatypeFilter(datatypeFilter).negated(negated).withScanThreshold(ivaratorCacheScanPersistThreshold).withScanTimeout(ivaratorCacheScanTimeout).withHdfsBackedSetBufferSize(ivaratorCacheBufferSize).withMaxRangeSplit(maxRangeSplit).withMaxOpenFiles(ivaratorMaxOpenFiles).withIvaratorCacheDirs(ivaratorCacheDirs).withNumRetries(ivaratorNumRetries).withPersistOptions(ivaratorPersistOptions).withMaxResults(maxIvaratorResults).withQueryLock(queryLock).allowDirResuse(true).withReturnKeyType(PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME).withSortedUUIDs(sortedUIDs).withCompositeMetadata(compositeMetadata).withCompositeSeekThreshold(compositeSeekThreshold).withTypeMetadata(typeMetadata).withIvaratorSourcePool(ivaratorSourcePool).withIteratorEnv(env);
            // @formatter:on
            if (values != null) {
                builder = builder.withValues(values);
            } else {
                builder = builder.withFST(fst);
            }
            DatawaveFieldIndexListIteratorJexl listIterator = builder.build();
            if (collectTimingDetails) {
                listIterator.setCollectTimingDetails(true);
                listIterator.setQuerySpanCollector(this.querySpanCollector);
            }
            listIterator.init(source, null, env);
            log.debug("Created a DatawaveFieldIndexListIteratorJexl: " + listIterator);
            boolean canBuildDocument = this.fieldsToAggregate == null ? false : this.fieldsToAggregate.contains(field);
            if (forceDocumentBuild) {
                canBuildDocument = true;
            }
            // Add an interator to aggregate documents. This is needed for index only fields.
            DocumentAggregatingIterator aggregatingIterator = new DocumentAggregatingIterator(canBuildDocument, this.typeMetadata, keyTform);
            aggregatingIterator.init(listIterator, null, null);
            docIterator = aggregatingIterator;
        } catch (IOException e) {
            throw new IllegalStateException("Unable to initialize list iterator stack", e);
        }
        IndexIteratorBridge itr = new IndexIteratorBridge(docIterator, getNode(), getField());
        field = null;
        value = null;
        negated = null;
        source = null;
        timeFilter = null;
        datatypeFilter = null;
        keyTform = null;
        timeFilter = null;
        ivaratorCacheDirs = null;
        node = null;
        field = null;
        return itr;
    } else {
        StringBuilder msg = new StringBuilder(256);
        msg.append("Cannot build iterator-- a field was null!\n");
        if (field == null) {
            msg.append("\tField was null!\n");
        }
        if (value == null) {
            msg.append("\tValue was null!\n");
        }
        if (source == null) {
            msg.append("\tSource was null!\n");
        }
        msg.setLength(msg.length() - 1);
        throw new IllegalStateException(msg.toString());
    }
}
Also used : DatawaveFieldIndexListIteratorJexl(datawave.core.iterators.DatawaveFieldIndexListIteratorJexl) DocumentIterator(datawave.query.iterator.DocumentIterator) Text(org.apache.hadoop.io.Text) DocumentAggregatingIterator(datawave.query.iterator.logic.DocumentAggregatingIterator) IOException(java.io.IOException) IndexIteratorBridge(datawave.query.iterator.logic.IndexIteratorBridge)

Example 3 with IndexIteratorBridge

use of datawave.query.iterator.logic.IndexIteratorBridge in project datawave by NationalSecurityAgency.

the class IndexRegexIteratorBuilder method build.

@SuppressWarnings("unchecked")
@Override
public NestedIterator<Key> build() {
    if (notNull(field, value, negated, source, datatypeFilter, timeFilter, keyTform, ivaratorCacheDirs, getField(), getNode())) {
        if (log.isTraceEnabled()) {
            log.trace("Generating ivarator (caching field index iterator) for " + field + (negated ? "!~" : "=~") + value);
        }
        // we can't build an ivarator if no ivarator directories have been defined
        if (ivaratorCacheDirs.isEmpty())
            throw new IllegalStateException("No ivarator cache dirs defined");
        // ensure that we are able to create the first ivarator cache dir (the control dir)
        validateIvaratorControlDir(ivaratorCacheDirs.get(0));
        DocumentIterator docIterator = null;
        try {
            // create a field index caching ivarator
            // @formatter:off
            DatawaveFieldIndexRegexIteratorJexl regexIterator = DatawaveFieldIndexRegexIteratorJexl.builder().withFieldName(new Text(field)).withFieldValue(new Text(value)).withTimeFilter(timeFilter).withDatatypeFilter(datatypeFilter).negated(negated).withScanThreshold(ivaratorCacheScanPersistThreshold).withScanTimeout(ivaratorCacheScanTimeout).withHdfsBackedSetBufferSize(ivaratorCacheBufferSize).withMaxRangeSplit(maxRangeSplit).withMaxOpenFiles(ivaratorMaxOpenFiles).withMaxResults(maxIvaratorResults).withIvaratorCacheDirs(ivaratorCacheDirs).withNumRetries(ivaratorNumRetries).withPersistOptions(ivaratorPersistOptions).withQueryLock(queryLock).allowDirResuse(true).withReturnKeyType(PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME).withSortedUUIDs(sortedUIDs).withCompositeMetadata(compositeMetadata).withCompositeSeekThreshold(compositeSeekThreshold).withTypeMetadata(typeMetadata).withIteratorEnv(env).withIvaratorSourcePool(ivaratorSourcePool).build();
            // @formatter:on
            if (collectTimingDetails) {
                regexIterator.setCollectTimingDetails(true);
                regexIterator.setQuerySpanCollector(this.querySpanCollector);
            }
            regexIterator.init(source, null, env);
            log.debug("Created a DatawaveFieldIndexRegexIteratorJexl: " + regexIterator);
            boolean canBuildDocument = this.fieldsToAggregate == null ? false : this.fieldsToAggregate.contains(field);
            if (forceDocumentBuild) {
                canBuildDocument = true;
            }
            // Add an interator to aggregate documents. This is needed for index only fields.
            DocumentAggregatingIterator aggregatingIterator = new DocumentAggregatingIterator(canBuildDocument, this.typeMetadata, keyTform);
            aggregatingIterator.init(regexIterator, null, null);
            docIterator = aggregatingIterator;
        } catch (IOException e) {
            throw new IllegalStateException("Unable to initialize regex iterator stack", e);
        // } catch (JavaRegexParseException e) {
        // throw new IllegalStateException("Unable to parse regex " + value, e);
        }
        IndexIteratorBridge itr = new IndexIteratorBridge(docIterator, getNode(), getField());
        field = null;
        value = null;
        negated = null;
        source = null;
        timeFilter = null;
        datatypeFilter = null;
        keyTform = null;
        timeFilter = null;
        ivaratorCacheDirs = null;
        field = null;
        node = null;
        return itr;
    } else {
        StringBuilder msg = new StringBuilder(256);
        msg.append("Cannot build iterator-- a field was null!\n");
        if (field == null) {
            msg.append("\tField was null!\n");
        }
        if (value == null) {
            msg.append("\tValue was null!\n");
        }
        if (source == null) {
            msg.append("\tSource was null!\n");
        }
        msg.setLength(msg.length() - 1);
        throw new IllegalStateException(msg.toString());
    }
}
Also used : DocumentIterator(datawave.query.iterator.DocumentIterator) Text(org.apache.hadoop.io.Text) DocumentAggregatingIterator(datawave.query.iterator.logic.DocumentAggregatingIterator) DatawaveFieldIndexRegexIteratorJexl(datawave.core.iterators.DatawaveFieldIndexRegexIteratorJexl) IOException(java.io.IOException) IndexIteratorBridge(datawave.query.iterator.logic.IndexIteratorBridge)

Example 4 with IndexIteratorBridge

use of datawave.query.iterator.logic.IndexIteratorBridge in project datawave by NationalSecurityAgency.

the class TermFrequencyIndexBuilder method build.

@SuppressWarnings("unchecked")
public NestedIterator<Key> build() {
    if (notNull(field, range, source, datatypeFilter, timeFilter)) {
        IndexIteratorBridge itr = new IndexIteratorBridge(new TermFrequencyIndexIterator(range, source, this.timeFilter, this.typeMetadata, this.fieldsToAggregate == null ? false : this.fieldsToAggregate.contains(field), this.datatypeFilter, termFrequencyAggregator), getNode(), getField());
        field = null;
        range = null;
        source = null;
        timeFilter = null;
        datatypeFilter = null;
        node = null;
        return itr;
    } else {
        StringBuilder msg = new StringBuilder(256);
        msg.append("Cannot build iterator-- a field was null!\n");
        if (field == null) {
            msg.append("\tField was null!\n");
        }
        if (range == null) {
            msg.append("\tValue was null!\n");
        }
        if (source == null) {
            msg.append("\tSource was null!\n");
        }
        msg.setLength(msg.length() - 1);
        throw new IllegalStateException(msg.toString());
    }
}
Also used : TermFrequencyIndexIterator(datawave.query.iterator.logic.TermFrequencyIndexIterator) IndexIteratorBridge(datawave.query.iterator.logic.IndexIteratorBridge)

Example 5 with IndexIteratorBridge

use of datawave.query.iterator.logic.IndexIteratorBridge in project datawave by NationalSecurityAgency.

the class DelayedNonEventSubTreeVisitor method extractDelayedFields.

private void extractDelayedFields(JexlNode node) {
    // reset the root before processing a a node
    iteratorBuildingVisitor.resetRoot();
    // use the iterator building visitor to build a field to node map for each delayed node
    node.jjtAccept(iteratorBuildingVisitor, null);
    NestedIterator<Key> root = iteratorBuildingVisitor.root();
    if (root != null) {
        for (NestedIterator<Key> leaf : root.leaves()) {
            // only IndexIteratorBridge nodes matter, everything else can be ignored
            if (leaf instanceof IndexIteratorBridge) {
                String fieldName = ((IndexIteratorBridge) leaf).getField();
                if (nonEventFields.contains(fieldName)) {
                    JexlNode leafNode = ((IndexIteratorBridge) leaf).getSourceNode();
                    JexlNode targetNode = leafNode;
                    delayedNonEventFieldMapNodes.put(fieldName, targetNode);
                }
            }
        }
    }
}
Also used : JexlNode(org.apache.commons.jexl2.parser.JexlNode) Key(org.apache.accumulo.core.data.Key) IndexIteratorBridge(datawave.query.iterator.logic.IndexIteratorBridge)

Aggregations

IndexIteratorBridge (datawave.query.iterator.logic.IndexIteratorBridge)8 Text (org.apache.hadoop.io.Text)6 DocumentIterator (datawave.query.iterator.DocumentIterator)4 DocumentAggregatingIterator (datawave.query.iterator.logic.DocumentAggregatingIterator)4 IOException (java.io.IOException)4 DatawaveFieldIndexFilterIteratorJexl (datawave.core.iterators.DatawaveFieldIndexFilterIteratorJexl)1 DatawaveFieldIndexListIteratorJexl (datawave.core.iterators.DatawaveFieldIndexListIteratorJexl)1 DatawaveFieldIndexRangeIteratorJexl (datawave.core.iterators.DatawaveFieldIndexRangeIteratorJexl)1 DatawaveFieldIndexRegexIteratorJexl (datawave.core.iterators.DatawaveFieldIndexRegexIteratorJexl)1 TermFrequencyIndexIterator (datawave.query.iterator.logic.TermFrequencyIndexIterator)1 Key (org.apache.accumulo.core.data.Key)1 JexlNode (org.apache.commons.jexl2.parser.JexlNode)1