use of datawave.query.iterator.aggregation.DocumentData in project datawave by NationalSecurityAgency.
the class DocumentDataIterator method next.
@Override
public DocumentData next() {
DocumentData returnDocumentData = documentData.getKey();
findNextDocument();
return returnDocumentData;
}
use of datawave.query.iterator.aggregation.DocumentData in project datawave by NationalSecurityAgency.
the class IndexOnlyKeyToDocumentData method apply.
@Override
public Entry<DocumentData, Document> apply(final Entry<Key, Document> from) {
try {
// Validate the starting entry
if (null == from) {
throw new IllegalArgumentException("Starting key cannot be null");
}
// get the document key
Key docKey = getDocKey(from.getKey());
// Ensure that we have a non-empty colqual
final Key stopKey = new Key(from.getKey().getRow().toString(), from.getKey().getColumnFamily().toString(), from.getKey().getColumnQualifier().toString() + '\u0000' + '\uffff');
// Create the primary range
final Range keyRange = new Range(from.getKey(), true, stopKey, true);
try {
// Trigger the initial seek
this.source.seek(keyRange, COLUMN_FAMILIES, false);
// Assign the start key
this.iteratorStartKey = from.getKey();
// Assign the conversion attributes
this.iteratorConversionAttributes = this.newKeyConversionAttributes();
} catch (IOException e) {
QueryException qe = new QueryException(DatawaveErrorCode.PRIMARY_RANGE_CREATE_ERROR, e);
throw new DatawaveFatalQueryException(qe);
}
// Create a result key
final Key resultKey = this.newResultKey(from);
// Set the default iterator document key using the result key
this.iteratorDocumentKey = resultKey;
// Iterate through the range of tf entries, converting relevant ones into standard field entries
final List<Entry<Key, Value>> attrs;
if (this.seekOnApply) {
attrs = this.newFieldEntriesFromTfEntries(from.getKey());
} else // Otherwise, expect that seeks will be performed incrementally via the Iterator
// hasNext() and next() implementations.
{
attrs = Collections.emptyList();
}
// Try to construct a new document key based on the first converted tf record
if (!attrs.isEmpty()) {
final Entry<Key, Value> firstEntry = attrs.get(0);
final Key fieldKey = firstEntry.getKey();
long timestamp = resultKey.getTimestamp();
this.iteratorDocumentKey = this.newDocumentKey(fieldKey, timestamp);
} else {
this.iteratorDocument = from.getValue();
}
// Set the parent document
this.iteratorDocument = from.getValue();
// Create an entry for the initialized Document
final DocumentData documentData = new DocumentData(this.iteratorDocumentKey, Collections.singleton(docKey), attrs, true);
return Maps.immutableEntry(documentData, this.iteratorDocument);
} catch (DatawaveFatalQueryException e) {
throw e;
} catch (Exception e) {
QueryException qe = new QueryException(DatawaveErrorCode.APPLY_FUNCTION_ERROR, e);
throw new DatawaveFatalQueryException(qe);
}
}
Aggregations