Search in sources :

Example 1 with DatawaveFieldIndexListIteratorJexl

use of datawave.core.iterators.DatawaveFieldIndexListIteratorJexl 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)

Aggregations

DatawaveFieldIndexListIteratorJexl (datawave.core.iterators.DatawaveFieldIndexListIteratorJexl)1 DocumentIterator (datawave.query.iterator.DocumentIterator)1 DocumentAggregatingIterator (datawave.query.iterator.logic.DocumentAggregatingIterator)1 IndexIteratorBridge (datawave.query.iterator.logic.IndexIteratorBridge)1 IOException (java.io.IOException)1 Text (org.apache.hadoop.io.Text)1