use of datawave.query.util.IteratorToSortedKeyValueIterator in project datawave by NationalSecurityAgency.
the class AncestorIndexBuildingVisitor method getSourceIterator.
@Override
protected SortedKeyValueIterator<Key, Value> getSourceIterator(final ASTEQNode node, boolean negation) {
SortedKeyValueIterator<Key, Value> kvIter = null;
try {
if (limitLookup && !negation) {
final String identifier = JexlASTHelper.getIdentifier(node);
if (!disableFiEval && fieldsToAggregate.contains(identifier)) {
final SortedKeyValueIterator<Key, Value> baseIterator = source.deepCopy(env);
kvIter = new AncestorChildExpansionIterator(baseIterator, getMembers(), equality);
seekIndexOnlyDocument(kvIter, node);
} else {
kvIter = new IteratorToSortedKeyValueIterator(getNodeEntry(node).iterator());
}
} else {
kvIter = source.deepCopy(env);
seekIndexOnlyDocument(kvIter, node);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return kvIter;
}
use of datawave.query.util.IteratorToSortedKeyValueIterator in project datawave by NationalSecurityAgency.
the class IteratorBuildingVisitor method createExceededCheck.
/**
* This method should only be used when we know it is not a term frequency or index only in the limited case, as we will subsequently evaluate this
* expression during final evaluation
*
* @param identifier
* @param range
* @return
*/
protected NestedIterator<Key> createExceededCheck(String identifier, LiteralRange<?> range, JexlNode rootNode) {
IndexIteratorBuilder builder = null;
try {
builder = iteratorBuilderClass.asSubclass(IndexIteratorBuilder.class).newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
IteratorToSortedKeyValueIterator kvIter = new IteratorToSortedKeyValueIterator(getExceededEntry(identifier, range).iterator());
builder.setQueryId(queryId);
builder.setSource(kvIter);
builder.setValue(null != range.getLower() ? range.getLower().toString() : "null");
builder.setField(identifier);
builder.setTimeFilter(TimeFilter.alwaysTrue());
builder.setTypeMetadata(typeMetadata);
builder.setFieldsToAggregate(fieldsToAggregate);
builder.setDatatypeFilter(datatypeFilter);
builder.setKeyTransform(fiAggregator);
builder.setEnv(env);
builder.setNode(rootNode);
return builder.build();
}
use of datawave.query.util.IteratorToSortedKeyValueIterator in project datawave by NationalSecurityAgency.
the class AncestorChildExpansionIteratorTest method testFamilyMatch.
@Test
public void testFamilyMatch() throws IOException {
baseValues.add(new AbstractMap.SimpleImmutableEntry<>(generateFiKey("a.1"), new Value()));
baseIterator = new IteratorToSortedKeyValueIterator(baseValues.iterator());
iterator = new AncestorChildExpansionIterator(baseIterator, children, equality);
iterator.seek(new Range(), Collections.EMPTY_LIST, false);
Assert.assertTrue(iterator.hasTop());
Key topKey = iterator.getTopKey();
assertKey(topKey, "a.1");
Value topValue = iterator.getTopValue();
Assert.assertNotNull(topValue);
iterator.next();
Assert.assertTrue(iterator.hasTop());
topKey = iterator.getTopKey();
assertKey(topKey, "a.1.1");
topValue = iterator.getTopValue();
Assert.assertNotNull(topValue);
iterator.next();
Assert.assertTrue(iterator.hasTop());
topKey = iterator.getTopKey();
assertKey(topKey, "a.1.2");
topValue = iterator.getTopValue();
Assert.assertNotNull(topValue);
iterator.next();
Assert.assertTrue(iterator.hasTop());
topKey = iterator.getTopKey();
assertKey(topKey, "a.1.2.1");
topValue = iterator.getTopValue();
Assert.assertNotNull(topValue);
iterator.next();
Assert.assertFalse(iterator.hasTop());
}
use of datawave.query.util.IteratorToSortedKeyValueIterator in project datawave by NationalSecurityAgency.
the class AncestorChildExpansionIteratorTest method testMultipleGappedRanges.
@Test
public void testMultipleGappedRanges() throws IOException {
baseValues.add(new AbstractMap.SimpleImmutableEntry<>(generateFiKey("a.1"), new Value()));
baseValues.add(new AbstractMap.SimpleImmutableEntry<>(generateFiKey("a.3"), new Value()));
baseValues.add(new AbstractMap.SimpleImmutableEntry<>(generateFiKey("a.4.1.1"), new Value()));
baseValues.add(new AbstractMap.SimpleImmutableEntry<>(generateFiKey("a.9"), new Value()));
baseIterator = new IteratorToSortedKeyValueIterator(baseValues.iterator());
iterator = new AncestorChildExpansionIterator(baseIterator, children, equality);
iterator.seek(new Range(), Collections.EMPTY_LIST, false);
Assert.assertTrue(iterator.hasTop());
Key topKey = iterator.getTopKey();
assertKey(topKey, "a.1");
Value topValue = iterator.getTopValue();
Assert.assertNotNull(topValue);
iterator.next();
Assert.assertTrue(iterator.hasTop());
topKey = iterator.getTopKey();
assertKey(topKey, "a.1.1");
topValue = iterator.getTopValue();
Assert.assertNotNull(topValue);
iterator.next();
Assert.assertTrue(iterator.hasTop());
topKey = iterator.getTopKey();
assertKey(topKey, "a.1.2");
topValue = iterator.getTopValue();
Assert.assertNotNull(topValue);
iterator.next();
Assert.assertTrue(iterator.hasTop());
topKey = iterator.getTopKey();
assertKey(topKey, "a.1.2.1");
topValue = iterator.getTopValue();
Assert.assertNotNull(topValue);
iterator.next();
Assert.assertTrue(iterator.hasTop());
topKey = iterator.getTopKey();
assertKey(topKey, "a.3");
topValue = iterator.getTopValue();
Assert.assertNotNull(topValue);
iterator.next();
Assert.assertTrue(iterator.hasTop());
topKey = iterator.getTopKey();
assertKey(topKey, "a.4.1.1");
topValue = iterator.getTopValue();
Assert.assertNotNull(topValue);
iterator.next();
Assert.assertTrue(iterator.hasTop());
topKey = iterator.getTopKey();
assertKey(topKey, "a.9");
topValue = iterator.getTopValue();
Assert.assertNotNull(topValue);
iterator.next();
Assert.assertFalse(iterator.hasTop());
}
use of datawave.query.util.IteratorToSortedKeyValueIterator in project datawave by NationalSecurityAgency.
the class AncestorChildExpansionIteratorTest method testFamilyMatchWithOverlaps.
@Test
public void testFamilyMatchWithOverlaps() throws IOException {
baseValues.add(new AbstractMap.SimpleImmutableEntry<>(generateFiKey("a.1"), new Value()));
baseValues.add(new AbstractMap.SimpleImmutableEntry<>(generateFiKey("a.1.1"), new Value()));
baseValues.add(new AbstractMap.SimpleImmutableEntry<>(generateFiKey("a.1.2.1"), new Value()));
baseIterator = new IteratorToSortedKeyValueIterator(baseValues.iterator());
iterator = new AncestorChildExpansionIterator(baseIterator, children, equality);
iterator.seek(new Range(), Collections.EMPTY_LIST, false);
Assert.assertTrue(iterator.hasTop());
Key topKey = iterator.getTopKey();
assertKey(topKey, "a.1");
Value topValue = iterator.getTopValue();
Assert.assertNotNull(topValue);
iterator.next();
Assert.assertTrue(iterator.hasTop());
topKey = iterator.getTopKey();
assertKey(topKey, "a.1.1");
topValue = iterator.getTopValue();
Assert.assertNotNull(topValue);
iterator.next();
Assert.assertTrue(iterator.hasTop());
topKey = iterator.getTopKey();
assertKey(topKey, "a.1.2");
topValue = iterator.getTopValue();
Assert.assertNotNull(topValue);
iterator.next();
Assert.assertTrue(iterator.hasTop());
topKey = iterator.getTopKey();
assertKey(topKey, "a.1.2.1");
topValue = iterator.getTopValue();
Assert.assertNotNull(topValue);
iterator.next();
Assert.assertFalse(iterator.hasTop());
}
Aggregations