Search in sources :

Example 11 with NestedIterator

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();
}
Also used : NestedIterator(datawave.query.iterator.NestedIterator) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 12 with NestedIterator

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());
}
Also used : NestedIterator(datawave.query.iterator.NestedIterator) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 13 with NestedIterator

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());
}
Also used : NestedIterator(datawave.query.iterator.NestedIterator) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 14 with NestedIterator

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());
}
Also used : NestedIterator(datawave.query.iterator.NestedIterator) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 15 with NestedIterator

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());
}
Also used : NestedIterator(datawave.query.iterator.NestedIterator) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

NestedIterator (datawave.query.iterator.NestedIterator)19 HashSet (java.util.HashSet)17 Test (org.junit.Test)16 Document (datawave.query.attributes.Document)2 SeekableNestedIterator (datawave.query.iterator.SeekableNestedIterator)2 Key (org.apache.accumulo.core.data.Key)2 ASTJexlScript (org.apache.commons.jexl2.parser.ASTJexlScript)2 Predicate (com.google.common.base.Predicate)1 Predicates (com.google.common.base.Predicates)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 DatawaveFieldIndexListIteratorJexl (datawave.core.iterators.DatawaveFieldIndexListIteratorJexl)1 FileSystemCache (datawave.core.iterators.filesystem.FileSystemCache)1 QueryLock (datawave.core.iterators.querylock.QueryLock)1 NoOpType (datawave.data.type.NoOpType)1 Constants (datawave.query.Constants)1 Attribute (datawave.query.attributes.Attribute)1 AttributeFactory (datawave.query.attributes.AttributeFactory)1 ValueTuple (datawave.query.attributes.ValueTuple)1