diff --git a/warehouse/query-core/src/main/java/datawave/query/iterator/AccumuloTreeIterable.java b/warehouse/query-core/src/main/java/datawave/query/iterator/AccumuloTreeIterable.java index 24d1f83bee..f61d1b9301 100644 --- a/warehouse/query-core/src/main/java/datawave/query/iterator/AccumuloTreeIterable.java +++ b/warehouse/query-core/src/main/java/datawave/query/iterator/AccumuloTreeIterable.java @@ -52,11 +52,8 @@ public Iterator> iterator() { } public void seek(Range range, Collection columnFamilies, boolean inclusive) throws IOException { - Iterable> leaves = tree.leaves(); - for (NestedIterator leaf : leaves) { - if (leaf instanceof SeekableIterator) { - ((SeekableIterator) leaf).seek(range, columnFamilies, inclusive); - } + for (NestedIterator leaf : tree.leaves()) { + leaf.seek(range, columnFamilies, inclusive); } seenSeek = true; } diff --git a/warehouse/query-core/src/main/java/datawave/query/iterator/EmptyTreeIterable.java b/warehouse/query-core/src/main/java/datawave/query/iterator/EmptyTreeIterable.java index 174a6dc546..ea170d12fc 100644 --- a/warehouse/query-core/src/main/java/datawave/query/iterator/EmptyTreeIterable.java +++ b/warehouse/query-core/src/main/java/datawave/query/iterator/EmptyTreeIterable.java @@ -1,14 +1,17 @@ package datawave.query.iterator; +import java.io.IOException; import java.util.Collection; import java.util.Collections; +import org.apache.accumulo.core.data.ByteSequence; import org.apache.accumulo.core.data.Key; +import org.apache.accumulo.core.data.Range; import datawave.query.attributes.Document; /** - * + * A stub for the NestedIterator, functionally equivalent to {@link Collections#emptyIterator()} */ public class EmptyTreeIterable implements NestedIterator { @@ -22,14 +25,19 @@ public Key move(Key minimum) { return null; } + @Override + public void seek(Range range, Collection columnFamilies, boolean inclusive) throws IOException { + // no-op + } + @Override public Collection> leaves() { - return Collections.EMPTY_SET; + return Collections.emptySet(); } @Override public Collection> children() { - return Collections.EMPTY_SET; + return Collections.emptySet(); } @Override diff --git a/warehouse/query-core/src/main/java/datawave/query/iterator/EventDataScanNestedIterator.java b/warehouse/query-core/src/main/java/datawave/query/iterator/EventDataScanNestedIterator.java index 357877b0cf..04a23b4338 100644 --- a/warehouse/query-core/src/main/java/datawave/query/iterator/EventDataScanNestedIterator.java +++ b/warehouse/query-core/src/main/java/datawave/query/iterator/EventDataScanNestedIterator.java @@ -18,9 +18,9 @@ import datawave.query.attributes.Document; /** - * + * This iterator supports a full table scan over the event column */ -public class EventDataScanNestedIterator implements NestedIterator, SeekableIterator { +public class EventDataScanNestedIterator implements NestedIterator { private static final Logger log = Logger.getLogger(EventDataScanNestedIterator.class); protected SortedKeyValueIterator source; protected Key topKey = null; diff --git a/warehouse/query-core/src/main/java/datawave/query/iterator/EventFieldIterator.java b/warehouse/query-core/src/main/java/datawave/query/iterator/EventFieldIterator.java index 3bef76f958..94ff29196f 100644 --- a/warehouse/query-core/src/main/java/datawave/query/iterator/EventFieldIterator.java +++ b/warehouse/query-core/src/main/java/datawave/query/iterator/EventFieldIterator.java @@ -4,6 +4,7 @@ import java.util.Collection; import java.util.Collections; +import org.apache.accumulo.core.data.ByteSequence; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.data.Value; @@ -78,6 +79,11 @@ public Key move(Key minimum) { return next(); } + @Override + public void seek(Range range, Collection columnFamilies, boolean inclusive) throws IOException { + source.seek(range, columnFamilies, inclusive); + } + @Override public Collection> leaves() { return Collections.emptySet(); diff --git a/warehouse/query-core/src/main/java/datawave/query/iterator/NestedIterator.java b/warehouse/query-core/src/main/java/datawave/query/iterator/NestedIterator.java index 5a0ca99d85..db7c84ce5a 100644 --- a/warehouse/query-core/src/main/java/datawave/query/iterator/NestedIterator.java +++ b/warehouse/query-core/src/main/java/datawave/query/iterator/NestedIterator.java @@ -1,8 +1,11 @@ package datawave.query.iterator; +import java.io.IOException; import java.util.Collection; import java.util.Iterator; +import org.apache.accumulo.core.data.ByteSequence; +import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.iterators.IteratorEnvironment; import datawave.query.attributes.Document; @@ -33,6 +36,20 @@ public interface NestedIterator extends Iterator { */ T move(T minimum); + /** + * Hook to allow issuing a seek to the underlying source iterator(s) + * + * @param range + * the seek range + * @param columnFamilies + * the column families + * @param inclusive + * true if range is inclusive + * @throws IOException + * for issues with reads + */ + void seek(Range range, Collection columnFamilies, boolean inclusive) throws IOException; + /** * Returns a reference to all of the leaf nodes at or below this. This is useful when we need to call seek on leaf nodes that are * SortedKeyValueIterators. diff --git a/warehouse/query-core/src/main/java/datawave/query/iterator/NestedQueryIterator.java b/warehouse/query-core/src/main/java/datawave/query/iterator/NestedQueryIterator.java index 836636e975..d13b77c4b9 100644 --- a/warehouse/query-core/src/main/java/datawave/query/iterator/NestedQueryIterator.java +++ b/warehouse/query-core/src/main/java/datawave/query/iterator/NestedQueryIterator.java @@ -1,8 +1,10 @@ package datawave.query.iterator; +import java.io.IOException; import java.util.Collection; import java.util.Queue; +import org.apache.accumulo.core.data.ByteSequence; import org.apache.accumulo.core.data.Range; import org.apache.log4j.Logger; @@ -81,16 +83,15 @@ public T next() { @Override public void remove() { currentNest.remove(); - } @Override public void initialize() { if (null == currentNest) { popNextNest(); - } else + } else { currentNest.initialize(); - + } } @Override @@ -98,6 +99,11 @@ public T move(T minimum) { return currentNest.move(minimum); } + @Override + public void seek(Range range, Collection columnFamilies, boolean inclusive) throws IOException { + currentNest.seek(range, columnFamilies, inclusive); + } + @Override public Collection> leaves() { return currentNest.leaves(); diff --git a/warehouse/query-core/src/main/java/datawave/query/iterator/QueryIterator.java b/warehouse/query-core/src/main/java/datawave/query/iterator/QueryIterator.java index f03e1d6f31..a29fc8ca41 100644 --- a/warehouse/query-core/src/main/java/datawave/query/iterator/QueryIterator.java +++ b/warehouse/query-core/src/main/java/datawave/query/iterator/QueryIterator.java @@ -97,7 +97,6 @@ import datawave.query.iterator.profile.QuerySpanCollector; import datawave.query.iterator.profile.SourceTrackingIterator; import datawave.query.jexl.DatawaveJexlContext; -import datawave.query.jexl.JexlASTHelper; import datawave.query.jexl.StatefulArithmetic; import datawave.query.jexl.functions.FieldIndexAggregator; import datawave.query.jexl.functions.IdentityAggregator; @@ -639,7 +638,7 @@ protected NestedIterator buildDocumentIterator(Range documentRange, Range s } // Seek() the boolean logic stuff - ((SeekableIterator) docIter).seek(range, columnFamilies, inclusive); + docIter.seek(range, columnFamilies, inclusive); // now lets start off the nested iterator docIter.initialize(); diff --git a/warehouse/query-core/src/main/java/datawave/query/iterator/SeekableIterator.java b/warehouse/query-core/src/main/java/datawave/query/iterator/SeekableIterator.java index 854f9f38cf..5be72b43e4 100644 --- a/warehouse/query-core/src/main/java/datawave/query/iterator/SeekableIterator.java +++ b/warehouse/query-core/src/main/java/datawave/query/iterator/SeekableIterator.java @@ -9,6 +9,7 @@ /** * */ +@Deprecated(forRemoval = true, since = "7.13.0") public interface SeekableIterator { /** * @see org.apache.accumulo.core.iterators.SortedKeyValueIterator diff --git a/warehouse/query-core/src/main/java/datawave/query/iterator/SeekableNestedIterator.java b/warehouse/query-core/src/main/java/datawave/query/iterator/SeekableNestedIterator.java index 3a48ace5da..e90a7bc9e6 100644 --- a/warehouse/query-core/src/main/java/datawave/query/iterator/SeekableNestedIterator.java +++ b/warehouse/query-core/src/main/java/datawave/query/iterator/SeekableNestedIterator.java @@ -11,11 +11,11 @@ import datawave.query.attributes.Document; /** - * + * This class is a delegate/base class now that the SeekableIterator was merged into the NestedIterator interface */ -public class SeekableNestedIterator implements NestedIterator, SeekableIterator { +public class SeekableNestedIterator implements NestedIterator { private static final Logger log = Logger.getLogger(SeekableNestedIterator.class); - private NestedIterator source; + private final NestedIterator source; protected Range totalRange = null; protected Collection columnFamilies = null; protected boolean inclusive = false; @@ -30,16 +30,7 @@ public void seek(Range range, Collection columnFamilies, boolean i this.totalRange = range; this.columnFamilies = columnFamilies; this.inclusive = inclusive; - if (source instanceof SeekableIterator) { - ((SeekableIterator) source).seek(range, columnFamilies, inclusive); - } else { - Iterable> leaves = source.leaves(); - for (NestedIterator leaf : leaves) { - if (leaf instanceof SeekableIterator) { - ((SeekableIterator) leaf).seek(range, columnFamilies, inclusive); - } - } - } + source.seek(range, columnFamilies, inclusive); } @Override diff --git a/warehouse/query-core/src/main/java/datawave/query/iterator/logic/AndIterator.java b/warehouse/query-core/src/main/java/datawave/query/iterator/logic/AndIterator.java index e15774ab57..a657b015bc 100644 --- a/warehouse/query-core/src/main/java/datawave/query/iterator/logic/AndIterator.java +++ b/warehouse/query-core/src/main/java/datawave/query/iterator/logic/AndIterator.java @@ -24,14 +24,13 @@ import datawave.query.exceptions.DatawaveFatalQueryException; import datawave.query.exceptions.QueryIteratorYieldingException; import datawave.query.iterator.NestedIterator; -import datawave.query.iterator.SeekableIterator; import datawave.query.iterator.Util; import datawave.query.iterator.Util.Transformer; /** * Performs a merge join of the child iterators. It is expected that all child iterators return values in sorted order. */ -public class AndIterator> implements NestedIterator, SeekableIterator { +public class AndIterator> implements NestedIterator { // temporary stores of uninitialized streams of iterators private List> includes, excludes, contextIncludes, contextExcludes; @@ -258,27 +257,23 @@ public void seek(Range range, Collection columnFamilies, boolean i while (include.hasNext()) { NestedIterator child = include.next(); try { - for (NestedIterator itr : child.leaves()) { - if (itr instanceof SeekableIterator) { - try { - ((SeekableIterator) itr).seek(range, columnFamilies, inclusive); - } catch (IterationInterruptedException e2) { - // throw IterationInterrupted exceptions as-is with no modifications so the QueryIterator can handle it - throw e2; - } catch (Exception e2) { - if (itr.isNonEventField()) { - // dropping a non-event term from the query means that the accuracy of the query - // cannot be guaranteed. Thus, a fatal exception. - log.error("Lookup of a non-event field failed, failing query"); - throw new DatawaveFatalQueryException("Lookup of non-event field failed", e2); - } - // otherwise we can safely drop this term from the intersection as the field will get re-introduced - // to the context when the event is aggregated - // Note: even though the precision of the query is affected the accuracy is not. i.e., documents that - // would have been defeated at the field index will now be defeated at evaluation time - throw e2; - } + try { + child.seek(range, columnFamilies, inclusive); + } catch (IterationInterruptedException e2) { + // throw IterationInterrupted exceptions as-is with no modifications so the QueryIterator can handle it + throw e2; + } catch (Exception e2) { + if (child.isNonEventField()) { + // dropping a non-event term from the query means that the accuracy of the query + // cannot be guaranteed. Thus, a fatal exception. + log.error("Lookup of a non-event field failed, failing query"); + throw new DatawaveFatalQueryException("Lookup of non-event field failed", e2); } + // otherwise we can safely drop this term from the intersection as the field will get re-introduced + // to the context when the event is aggregated + // Note: even though the precision of the query is affected the accuracy is not. i.e., documents that + // would have been defeated at the field index will now be defeated at evaluation time + throw e2; } } catch (QueryIteratorYieldingException qye) { throw qye; @@ -286,21 +281,20 @@ public void seek(Range range, Collection columnFamilies, boolean i throw iie; } catch (Exception e) { include.remove(); - if (includes.isEmpty() || e instanceof DatawaveFatalQueryException || e instanceof IterationInterruptedException) { + if (includes.isEmpty() || e instanceof DatawaveFatalQueryException) { throw e; } else { log.warn("Lookup of event field failed, precision of query reduced."); } } } - Iterator> exclude = excludes.iterator(); - while (exclude.hasNext()) { - NestedIterator child = exclude.next(); - for (NestedIterator itr : child.leaves()) { - if (itr instanceof SeekableIterator) { - ((SeekableIterator) itr).seek(range, columnFamilies, inclusive); - } - } + + for (NestedIterator contextInclude : contextIncludes) { + contextInclude.seek(range, columnFamilies, inclusive); + } + + for (NestedIterator exclude : excludes) { + exclude.seek(range, columnFamilies, inclusive); } if (isInitialized()) { diff --git a/warehouse/query-core/src/main/java/datawave/query/iterator/logic/ArrayIterator.java b/warehouse/query-core/src/main/java/datawave/query/iterator/logic/ArrayIterator.java index a7b44846e8..efcef6eea3 100644 --- a/warehouse/query-core/src/main/java/datawave/query/iterator/logic/ArrayIterator.java +++ b/warehouse/query-core/src/main/java/datawave/query/iterator/logic/ArrayIterator.java @@ -1,21 +1,27 @@ package datawave.query.iterator.logic; +import java.io.IOException; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; +import org.apache.accumulo.core.data.ByteSequence; +import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator; + import datawave.query.attributes.Document; import datawave.query.iterator.NestedIterator; /** - * A leaf node in an nested iterator tree. This is supposed to be a sample iterator that returns data from a sorted array. - * - * + * A leaf node in a nested iterator tree. This is supposed to be a sample iterator that returns data from a sorted array. + *

+ * This class is deprecated. A suitable replacement is an {@link IndexIteratorBridge} using a {@link SortedMapIterator}. * * @param * the type of the array iterator */ +@Deprecated(forRemoval = true, since = "7.13.0") public class ArrayIterator> implements NestedIterator { private static final Document doc = new Document(); @@ -58,6 +64,11 @@ public T move(T minimum) { } } + @Override + public void seek(Range range, Collection columnFamilies, boolean inclusive) throws IOException { + throw new UnsupportedOperationException("ArrayIterator does not support seek"); + } + public Collection> leaves() { Collection> c = new LinkedList<>(); c.add(this); diff --git a/warehouse/query-core/src/main/java/datawave/query/iterator/logic/IndexIteratorBridge.java b/warehouse/query-core/src/main/java/datawave/query/iterator/logic/IndexIteratorBridge.java index 36f08fdc5d..9e35ef9aab 100644 --- a/warehouse/query-core/src/main/java/datawave/query/iterator/logic/IndexIteratorBridge.java +++ b/warehouse/query-core/src/main/java/datawave/query/iterator/logic/IndexIteratorBridge.java @@ -17,15 +17,11 @@ import datawave.query.attributes.Document; import datawave.query.iterator.DocumentIterator; import datawave.query.iterator.NestedIterator; -import datawave.query.iterator.SeekableIterator; /** * Wraps an Accumulo iterator with a NestedIterator interface. This bridges the gap between an IndexIterator and a NestedIterator. - * - * - * */ -public class IndexIteratorBridge implements SeekableIterator, NestedIterator, Comparable { +public class IndexIteratorBridge implements NestedIterator, Comparable { private static final Logger log = Logger.getLogger(IndexIteratorBridge.class); /* diff --git a/warehouse/query-core/src/main/java/datawave/query/iterator/logic/OrIterator.java b/warehouse/query-core/src/main/java/datawave/query/iterator/logic/OrIterator.java index 45cafa43dd..9a577874ad 100644 --- a/warehouse/query-core/src/main/java/datawave/query/iterator/logic/OrIterator.java +++ b/warehouse/query-core/src/main/java/datawave/query/iterator/logic/OrIterator.java @@ -1,5 +1,6 @@ package datawave.query.iterator.logic; +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -13,6 +14,9 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.apache.accumulo.core.data.ByteSequence; +import org.apache.accumulo.core.data.Range; + import com.google.common.collect.TreeMultimap; import datawave.query.attributes.Document; @@ -224,6 +228,13 @@ public T move(T minimum) { } } + @Override + public void seek(Range range, Collection columnFamilies, boolean inclusive) throws IOException { + for (NestedIterator child : children()) { + child.seek(range, columnFamilies, inclusive); + } + } + /** * Advances all iterators associated with the supplied key and adds them back into the sorted multimap. If any of the sub-trees returns false, then they are * dropped. diff --git a/warehouse/query-core/src/main/java/datawave/query/iterator/logic/RangeFilterIterator.java b/warehouse/query-core/src/main/java/datawave/query/iterator/logic/RangeFilterIterator.java index cbbc3d1ffa..053f58d4f6 100644 --- a/warehouse/query-core/src/main/java/datawave/query/iterator/logic/RangeFilterIterator.java +++ b/warehouse/query-core/src/main/java/datawave/query/iterator/logic/RangeFilterIterator.java @@ -38,7 +38,7 @@ *

* row fi\x00FIELD : value\x00datatype\x00uid */ -public class RangeFilterIterator implements SeekableIterator, NestedIterator, Comparable { +public class RangeFilterIterator implements NestedIterator, Comparable { private static final Logger log = LoggerFactory.getLogger(RangeFilterIterator.class); diff --git a/warehouse/query-core/src/main/java/datawave/query/iterator/logic/RegexFilterIterator.java b/warehouse/query-core/src/main/java/datawave/query/iterator/logic/RegexFilterIterator.java index 368277f44a..fcb5fc0d13 100644 --- a/warehouse/query-core/src/main/java/datawave/query/iterator/logic/RegexFilterIterator.java +++ b/warehouse/query-core/src/main/java/datawave/query/iterator/logic/RegexFilterIterator.java @@ -40,7 +40,7 @@ *

* row fi\x00FIELD : value\x00datatype\x00uid */ -public class RegexFilterIterator implements SeekableIterator, NestedIterator, Comparable { +public class RegexFilterIterator implements NestedIterator, Comparable { private static final Logger log = LoggerFactory.getLogger(RegexFilterIterator.class); diff --git a/warehouse/query-core/src/main/java/datawave/query/jexl/DelayedNonEventIndexContext.java b/warehouse/query-core/src/main/java/datawave/query/jexl/DelayedNonEventIndexContext.java index 2f0ab81a2b..8d303dae47 100644 --- a/warehouse/query-core/src/main/java/datawave/query/jexl/DelayedNonEventIndexContext.java +++ b/warehouse/query-core/src/main/java/datawave/query/jexl/DelayedNonEventIndexContext.java @@ -21,7 +21,6 @@ import datawave.query.collections.FunctionalSet; import datawave.query.function.Equality; import datawave.query.iterator.NestedIterator; -import datawave.query.iterator.SeekableIterator; import datawave.query.jexl.visitors.IteratorBuildingVisitor; /** @@ -121,9 +120,7 @@ private List fetchOnDemand(String name) throws IOException { for (NestedIterator leaf : leaves) { // init/seek the leaf leaf.initialize(); - if (leaf instanceof SeekableIterator) { - ((SeekableIterator) leaf).seek(docRange, columnFamilies, inclusive); - } + leaf.seek(docRange, columnFamilies, inclusive); // for each value off the leaf add it to the document list as long as equality accepts it while (leaf.hasNext()) { diff --git a/warehouse/query-core/src/test/java/datawave/query/iterator/logic/AndOrIteratorIT.java b/warehouse/query-core/src/test/java/datawave/query/iterator/logic/AndOrIteratorIT.java index c367db8bd2..f82b45dbf3 100644 --- a/warehouse/query-core/src/test/java/datawave/query/iterator/logic/AndOrIteratorIT.java +++ b/warehouse/query-core/src/test/java/datawave/query/iterator/logic/AndOrIteratorIT.java @@ -108,9 +108,6 @@ void testNestedUnionWithNegatedTermBuildDocument() throws IOException { NestedIterator exclude = IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_C", uidsEven, true); OrIterator union = new OrIterator(Collections.singleton(include), Collections.singleton(exclude)); - OrIteratorIT.seekIterators(Collections.singleton(include)); - OrIteratorIT.seekIterators(Collections.singleton(exclude)); - Set> includes = new HashSet<>(); includes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_A", uidsPrime, true)); includes.add(union); @@ -135,8 +132,6 @@ void testNestedUnionOfNegatedTerms() throws IOException { includes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_C", uidsOdd)); OrIterator union = new OrIterator(includes); - OrIteratorIT.seekIterators(includes); - NestedIterator include = IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_A", uidsAll); // uids built using DeMorgan's Law @@ -160,10 +155,6 @@ void testSimpleDoubleNestedUnion() throws IOException { rightIncludes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_C", uidsAll)); OrIterator rightUnion = new OrIterator(rightIncludes); - // init unions - OrIteratorIT.seekIterators(leftIncludes); - OrIteratorIT.seekIterators(rightIncludes); - AndIterator itr = new AndIterator(Sets.newHashSet(leftUnion, rightUnion)); driveIterator(itr, uidsAll); } @@ -180,8 +171,6 @@ void testAllRandomUids() throws IOException { unionIncludes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_C", uidsC)); OrIterator union = new OrIterator(unionIncludes); - OrIteratorIT.seekIterators(unionIncludes); - Set> includes = new HashSet<>(); includes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_A", uidsA)); includes.add(union); @@ -363,9 +352,6 @@ void testNestedUnionWithNegatedIndexOnlyTermIsInterrupted() { Set> unionExcludes = new HashSet<>(); unionExcludes.add(IndexIteratorBridgeTest.createInterruptibleIndexIteratorBridge("FIELD_C", uidsAll, true, 4)); - OrIteratorIT.seekIterators(unionIncludes); - OrIteratorIT.seekIterators(unionExcludes); - OrIterator union = new OrIterator(unionIncludes, unionExcludes); Set> includes = new HashSet<>(); @@ -374,7 +360,6 @@ void testNestedUnionWithNegatedIndexOnlyTermIsInterrupted() { Map indexOnlyCounts = new HashMap<>(); indexOnlyCounts.put("FIELD_A", 1); - // indexOnlyCounts.put("FIELD_B", 2); AndIterator itr = new AndIterator(includes); assertThrows(IterationInterruptedException.class, () -> driveIterator(itr, uidsAll, indexOnlyCounts)); @@ -389,8 +374,6 @@ void testNegatedNestedUnionOfIndexOnlyFieldsIsInterrupted() { unionIncludes.add(IndexIteratorBridgeTest.createInterruptibleIndexIteratorBridge("FIELD_C", uidsOdd, true, 4)); OrIterator union = new OrIterator(unionIncludes); - OrIteratorIT.seekIterators(unionIncludes); - Set> includes = new HashSet<>(); includes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_A", uidsAll, true)); @@ -488,8 +471,6 @@ private void driveIntersectionWithSimpleNestedUnion(SortedSet uidsA, Sor unionIncludes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_C", uidsC, true)); OrIterator union = new OrIterator(unionIncludes); - OrIteratorIT.seekIterators(unionIncludes); - Set> includes = new HashSet<>(); includes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_A", uidsA, true)); includes.add(union); @@ -509,9 +490,6 @@ private void driveIntersectionWithSimpleNestedUnionWithNegatedTerm(SortedSet> includes = new HashSet<>(); includes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_A", uidsA, true)); includes.add(union); @@ -528,7 +506,6 @@ private void driveIntersectionWithNestedUnionOfNegatedTerms(SortedSet ui unionIncludes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_C", uidsC, true)); OrIterator union = new OrIterator(unionIncludes); - OrIteratorIT.seekIterators(unionIncludes); Set> excludes = Collections.singleton(union); Set> includes = new HashSet<>(); @@ -584,9 +561,6 @@ void testCase02() throws IOException { OrIterator union = new OrIterator(unionIncludes, unionExcludes); - OrIteratorIT.seekIterators(unionIncludes); - OrIteratorIT.seekIterators(unionExcludes); - Set> includes = new HashSet<>(); includes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_A", uidsA, true)); includes.add(union); @@ -809,8 +783,8 @@ private void driveIterator(AndIterator itr, SortedSet uids, Map columnFamilies, boolean inclusive) throws IOException { + throw new UnsupportedEncodingException("Not implemented"); + } + @Override public Collection> leaves() { return null; diff --git a/warehouse/query-core/src/test/java/datawave/query/iterator/logic/OrIteratorIT.java b/warehouse/query-core/src/test/java/datawave/query/iterator/logic/OrIteratorIT.java index 13fa0049a6..810d7f8d80 100644 --- a/warehouse/query-core/src/test/java/datawave/query/iterator/logic/OrIteratorIT.java +++ b/warehouse/query-core/src/test/java/datawave/query/iterator/logic/OrIteratorIT.java @@ -3,6 +3,7 @@ import static datawave.query.iterator.logic.TestUtil.randomUids; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; @@ -25,7 +26,6 @@ import datawave.query.attributes.Document; import datawave.query.iterator.NestedIterator; -import datawave.query.iterator.SeekableIterator; class OrIteratorIT { @@ -40,10 +40,7 @@ void testSimpleUnion() { Set> includes = new HashSet<>(); includes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_A", uidsEven)); includes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_B", uidsOdd)); - - seekIterators(includes); - - OrIterator itr = new OrIterator(includes); + OrIterator itr = new OrIterator<>(includes); driveIterator(itr, new TreeSet<>(uidsAll)); } @@ -53,12 +50,10 @@ void testUnionWithIndexOnlyTerm() { includes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_A", uidsEven)); includes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_B", uidsOdd, true)); - seekIterators(includes); - Map indexOnlyCounts = new HashMap<>(); indexOnlyCounts.put("FIELD_B", 5); - OrIterator itr = new OrIterator(includes); + OrIterator itr = new OrIterator<>(includes); driveIterator(itr, uidsAll, indexOnlyCounts); } @@ -68,12 +63,10 @@ void testUnionWithIndexOnlyTermThatIsInterrupted() { includes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_A", uidsEven)); includes.add(IndexIteratorBridgeTest.createInterruptibleIndexIteratorBridge("FIELD_B", uidsOdd, true, 4)); - seekIterators(includes); - Map indexOnlyCounts = new HashMap<>(); indexOnlyCounts.put("FIELD_B", 3); - OrIterator itr = new OrIterator(includes); + OrIterator itr = new OrIterator<>(includes); assertThrows(IterationInterruptedException.class, () -> driveIterator(itr, uidsAll, indexOnlyCounts)); } @@ -86,13 +79,10 @@ void testUnionWithNegatedIndexOnlyTermThatIsInterrupted() { Set> excludes = new HashSet<>(); excludes.add(IndexIteratorBridgeTest.createInterruptibleIndexIteratorBridge("FIELD_B", uidsOdd, true, 4)); - seekIterators(includes); - seekIterators(excludes); - Map indexOnlyCounts = new HashMap<>(); indexOnlyCounts.put("FIELD_B", 3); - OrIterator itr = new OrIterator(includes, excludes); + OrIterator itr = new OrIterator<>(includes, excludes); assertThrows(IllegalStateException.class, () -> driveIterator(itr, uidsAll, indexOnlyCounts)); } @@ -151,7 +141,6 @@ private void driveUnion(SortedSet uidsA, SortedSet uidsB, Sorted includes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_B", uidsB, true)); includes.add(IndexIteratorBridgeTest.createIndexIteratorBridge("FIELD_C", uidsC, true)); - seekIterators(includes); OrIterator orIterator = new OrIterator<>(includes); Map indexOnlyCounts = new HashMap<>(); @@ -181,7 +170,7 @@ private void driveUnion(SortedSet uidsA, SortedSet uidsB, Sorted * @param uids * expected uids */ - private void driveIterator(OrIterator itr, SortedSet uids) { + private void driveIterator(OrIterator itr, SortedSet uids) { driveIterator(itr, uids, Collections.emptyMap()); } @@ -195,7 +184,8 @@ private void driveIterator(OrIterator itr, SortedSet uids) { * @param indexOnlyCounts * the expected index only field counts */ - private void driveIterator(OrIterator itr, SortedSet uids, Map indexOnlyCounts) { + private void driveIterator(OrIterator itr, SortedSet uids, Map indexOnlyCounts) { + seekIterator(itr); itr.initialize(); int count = 0; @@ -206,7 +196,7 @@ private void driveIterator(OrIterator itr, SortedSet uids, Map uids, Map> iterators) { - for (NestedIterator iterator : iterators) { - if (iterator instanceof SeekableIterator) { - try { - ((SeekableIterator) iterator).seek(new Range(), Collections.emptyList(), false); - } catch (IOException e) { - fail("Could not seek iterator during test setup"); - } - } + private void seekIterator(NestedIterator iterator) { + try { + iterator.seek(new Range(), Collections.emptyList(), false); + } catch (IOException e) { + fail("Failed to seek iterators", e); } } } diff --git a/warehouse/query-core/src/test/java/datawave/query/jexl/visitors/IteratorBuildingVisitorTest.java b/warehouse/query-core/src/test/java/datawave/query/jexl/visitors/IteratorBuildingVisitorTest.java index 8701e24f7a..15bf4653f6 100644 --- a/warehouse/query-core/src/test/java/datawave/query/jexl/visitors/IteratorBuildingVisitorTest.java +++ b/warehouse/query-core/src/test/java/datawave/query/jexl/visitors/IteratorBuildingVisitorTest.java @@ -899,7 +899,7 @@ private void eval(ASTJexlScript query, Range docRange, Key docKeyHit, List