use of datawave.query.iterator.NestedIterator in project datawave by NationalSecurityAgency.
the class AndOrIteratorTest method testDeferredNoMatches.
// X AND (Y OR !Z)
@Test
public void testDeferredNoMatches() {
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("z", "z1"), false));
OrIterator childOr = new OrIterator(childIncludes, childExcludes);
Set<NestedIterator<String>> includes = new HashSet<>();
includes.add(childOr);
includes.add(getItr(Lists.newArrayList("z"), false));
NestedIterator iterator = new AndIterator(includes);
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 testAndNegatedOr.
// X AND (!Y OR !Z)
@Test
public void testAndNegatedOr() {
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));
OrIterator childOr = new OrIterator(childIncludes, childExcludes);
Set<NestedIterator<String>> includes = new HashSet<>();
includes.add(childOr);
includes.add(getItr(Lists.newArrayList("a", "b", "c"), false));
NestedIterator iterator = new AndIterator(includes);
iterator.initialize();
Assert.assertFalse(iterator.isContextRequired());
Assert.assertTrue(childOr.isContextRequired());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals("a", iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals("c", iterator.next());
Assert.assertFalse(iterator.hasNext());
}
use of datawave.query.iterator.NestedIterator in project datawave by NationalSecurityAgency.
the class AndOrIteratorTest method testDeferredOr.
// !X OR !Y
@Test(expected = IllegalStateException.class)
public void testDeferredOr() {
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 OrIterator(includes, excludes);
iterator.initialize();
}
use of datawave.query.iterator.NestedIterator in project datawave by NationalSecurityAgency.
the class AndOrIteratorTest method testOrAnd.
// X OR (Y AND Z)
@Test
public void testOrAnd() {
Set<NestedIterator<String>> childIncludes = new HashSet<>();
Set<NestedIterator<String>> childExcludes = new HashSet<>();
childIncludes.add(getItr(Lists.newArrayList("a", "c", "f"), false));
childIncludes.add(getItr(Lists.newArrayList("b", "c", "f"), 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 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("b", iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals("c", iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals("d", iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals("f", iterator.next());
Assert.assertFalse(iterator.hasNext());
}
Aggregations