use of datawave.query.iterator.NestedIterator in project datawave by NationalSecurityAgency.
the class AndOrIteratorTest method testDeferredAnd.
// !X AND !Y
@Test(expected = IllegalStateException.class)
public void testDeferredAnd() {
Set<NestedIterator<String>> includes = new HashSet<>();
Set<NestedIterator<String>> excludes = new HashSet<>();
excludes.add(getItr(Lists.newArrayList("a", "b", "c", "d"), false));
excludes.add(getItr(Lists.newArrayList("a"), false));
NestedIterator iterator = new AndIterator(includes, excludes);
iterator.initialize();
}
use of datawave.query.iterator.NestedIterator in project datawave by NationalSecurityAgency.
the class AndOrIteratorTest method testNegatedDeferred.
// X AND !(Y OR !Z)
@Test
public void testNegatedDeferred() {
Set<NestedIterator<String>> childIncludes = new HashSet<>();
Set<NestedIterator<String>> childExcludes = new HashSet<>();
childIncludes.add(getItr(Lists.newArrayList("b", "b1", "b2", "b3", "c"), false));
childExcludes.add(getItr(Lists.newArrayList("z1", "z2"), false));
OrIterator childOr = new OrIterator(childIncludes, childExcludes);
Set<NestedIterator<String>> includes = new HashSet<>();
Set<NestedIterator<String>> excludes = new HashSet<>();
includes.add(getItr(Lists.newArrayList("z"), false));
excludes.add(childOr);
NestedIterator iterator = new AndIterator(includes, excludes);
iterator.initialize();
Assert.assertFalse(iterator.isContextRequired());
Assert.assertTrue(childOr.isContextRequired());
Assert.assertFalse(iterator.hasNext());
}
use of datawave.query.iterator.NestedIterator in project datawave by NationalSecurityAgency.
the class AndOrIteratorTest method testOrMixedAnd.
// X OR (Y AND !Z)
@Test
public void testOrMixedAnd() {
Set<NestedIterator<String>> childIncludes = new HashSet<>();
Set<NestedIterator<String>> childExcludes = new HashSet<>();
childIncludes.add(getItr(Lists.newArrayList("a", "b"), false));
childExcludes.add(getItr(Lists.newArrayList("b", "f"), false));
NestedIterator child = new AndIterator(childIncludes, childExcludes);
Set<NestedIterator<String>> includes = new HashSet<>();
includes.add(child);
includes.add(getItr(Lists.newArrayList("c", "d"), false));
NestedIterator iterator = new OrIterator(includes);
iterator.initialize();
Assert.assertFalse(iterator.isContextRequired());
Assert.assertFalse(child.isContextRequired());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals("a", iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals("c", iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals("d", iterator.next());
Assert.assertFalse(iterator.hasNext());
}
use of datawave.query.iterator.NestedIterator in project datawave by NationalSecurityAgency.
the class AndOrIteratorTest method testNegatedNonDeferredInteractionWithDeferred.
// X AND !Y AND (!Z OR !A)
@Test
public void testNegatedNonDeferredInteractionWithDeferred() {
Set<NestedIterator<String>> childIncludes = new HashSet<>();
Set<NestedIterator<String>> childExcludes = new HashSet<>();
childExcludes.add(getItr(Lists.newArrayList("b", "d"), false));
childExcludes.add(getItr(Lists.newArrayList("c"), false));
NestedIterator<String> child = new OrIterator<>(childIncludes, childExcludes);
Set<NestedIterator<String>> includes = new HashSet<>();
Set<NestedIterator<String>> excludes = new HashSet<>();
includes.add(getItr(Lists.newArrayList("a", "b", "c", "d"), false));
excludes.add(getItr(Lists.newArrayList("a"), false));
includes.add(child);
NestedIterator iterator = new AndIterator(includes, excludes);
iterator.initialize();
Assert.assertTrue(child.isContextRequired());
Assert.assertFalse(iterator.isContextRequired());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals("b", iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals("c", iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals("d", iterator.next());
Assert.assertFalse(iterator.hasNext());
}
use of datawave.query.iterator.NestedIterator in project datawave by NationalSecurityAgency.
the class AndOrIteratorTest method testAndNegatedAnd.
// X AND (!Y AND !Z)
@Test
public void testAndNegatedAnd() {
Set<NestedIterator<String>> childIncludes = new HashSet<>();
Set<NestedIterator<String>> childExcludes = new HashSet<>();
childExcludes.add(getItr(Lists.newArrayList("b", "c"), false));
childExcludes.add(getItr(Lists.newArrayList("a", "b"), false));
NestedIterator child = new AndIterator(childIncludes, childExcludes);
Set<NestedIterator<String>> includes = new HashSet<>();
includes.add(child);
includes.add(getItr(Lists.newArrayList("a", "b", "c", "d"), false));
NestedIterator iterator = new AndIterator(includes);
iterator.initialize();
Assert.assertFalse(iterator.isContextRequired());
Assert.assertTrue(child.isContextRequired());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals("d", iterator.next());
Assert.assertFalse(iterator.hasNext());
}
Aggregations