Search in sources :

Example 1 with LogTiming

use of datawave.query.function.LogTiming in project datawave by NationalSecurityAgency.

the class FieldIndexOnlyQueryIterator method seek.

@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
    if (log.isDebugEnabled()) {
        log.debug("Seek range: " + range);
    }
    this.range = range;
    Iterator<Entry<Key, Document>> fieldIndexDocuments = null;
    try {
        fieldIndexDocuments = getDocumentIterator(range, columnFamilies, inclusive);
    } catch (ConfigException e) {
        throw new IOException("Unable to create document iterator", e);
    } catch (IllegalAccessException e) {
        throw new IOException("Unable to create document iterator", e);
    } catch (InstantiationException e) {
        throw new IOException("Unable to create document iterator", e);
    }
    // Inject the data type as a field if the user requested it
    if (this.includeDatatype) {
        if (collectTimingDetails) {
            fieldIndexDocuments = Iterators.transform(fieldIndexDocuments, new EvaluationTrackingFunction<>(QuerySpan.Stage.DataTypeAsField, trackingSpan, new DataTypeAsField(this.datatypeKey)));
        } else {
            fieldIndexDocuments = Iterators.transform(fieldIndexDocuments, new DataTypeAsField(this.datatypeKey));
        }
    }
    // Filter out masked values if requested
    if (this.filterMaskedValues) {
    // Should we filter here, or not?
    }
    if (collectTimingDetails) {
        // store the timing metadata using the documentRange endKey
        if (fieldIndexDocuments.hasNext() == false) {
            fieldIndexDocuments = Collections.singletonMap(this.range.getEndKey(), new Document()).entrySet().iterator();
        }
        fieldIndexDocuments = Iterators.transform(fieldIndexDocuments, new LogTiming(trackingSpan));
    }
    if (this.getReturnType() == ReturnType.kryo) {
        // Serialize the Document using Kryo
        this.serializedDocuments = Iterators.transform(fieldIndexDocuments, new KryoDocumentSerializer(isReducedResponse(), isCompressResults()));
    } else if (this.getReturnType() == ReturnType.writable) {
        // Use the Writable interface to serialize the Document
        this.serializedDocuments = Iterators.transform(fieldIndexDocuments, new WritableDocumentSerializer(isReducedResponse()));
    } else if (this.getReturnType() == ReturnType.tostring) {
        // Just return a toString() representation of the document
        this.serializedDocuments = Iterators.transform(fieldIndexDocuments, new ToStringDocumentSerializer(isReducedResponse()));
    } else {
        throw new IllegalArgumentException("Unknown return type of: " + this.getReturnType());
    }
    // Determine if we have items to return
    if (this.serializedDocuments.hasNext()) {
        Entry<Key, Value> entry = this.serializedDocuments.next();
        this.key = entry.getKey();
        this.value = entry.getValue();
        entry = null;
    } else {
        this.key = null;
        this.value = null;
    }
}
Also used : ToStringDocumentSerializer(datawave.query.function.serializer.ToStringDocumentSerializer) DataTypeAsField(datawave.query.function.DataTypeAsField) WritableDocumentSerializer(datawave.query.function.serializer.WritableDocumentSerializer) LogTiming(datawave.query.function.LogTiming) ConfigException(org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException) IOException(java.io.IOException) Document(datawave.query.attributes.Document) KryoDocumentSerializer(datawave.query.function.serializer.KryoDocumentSerializer) Entry(java.util.Map.Entry) EvaluationTrackingFunction(datawave.query.iterator.profile.EvaluationTrackingFunction) Value(org.apache.accumulo.core.data.Value) Key(org.apache.accumulo.core.data.Key) GetStartKey(datawave.query.function.GetStartKey) PartialKey(org.apache.accumulo.core.data.PartialKey)

Aggregations

Document (datawave.query.attributes.Document)1 DataTypeAsField (datawave.query.function.DataTypeAsField)1 GetStartKey (datawave.query.function.GetStartKey)1 LogTiming (datawave.query.function.LogTiming)1 KryoDocumentSerializer (datawave.query.function.serializer.KryoDocumentSerializer)1 ToStringDocumentSerializer (datawave.query.function.serializer.ToStringDocumentSerializer)1 WritableDocumentSerializer (datawave.query.function.serializer.WritableDocumentSerializer)1 EvaluationTrackingFunction (datawave.query.iterator.profile.EvaluationTrackingFunction)1 IOException (java.io.IOException)1 Entry (java.util.Map.Entry)1 Key (org.apache.accumulo.core.data.Key)1 PartialKey (org.apache.accumulo.core.data.PartialKey)1 Value (org.apache.accumulo.core.data.Value)1 ConfigException (org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException)1