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;
}
}
Aggregations