Search in sources :

Example 56 with SortedMapIterator

use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.

the class VisibilityFilterTest method testEmptyAuths.

@Test
public void testEmptyAuths() throws IOException {
    TreeMap<Key, Value> tm = new TreeMap<>();
    tm.put(new Key("r1", "cf1", "cq1", ""), new Value());
    tm.put(new Key("r1", "cf1", "cq2", "C"), new Value());
    tm.put(new Key("r1", "cf1", "cq3", ""), new Value());
    SortedKeyValueIterator<Key, Value> filter = VisibilityFilter.wrap(new SortedMapIterator(tm), Authorizations.EMPTY, "".getBytes());
    filter.seek(new Range(), new HashSet<>(), false);
    assertTrue(filter.hasTop());
    assertEquals(new Key("r1", "cf1", "cq1", ""), filter.getTopKey());
    filter.next();
    assertTrue(filter.hasTop());
    assertEquals(new Key("r1", "cf1", "cq3", ""), filter.getTopKey());
    filter.next();
    assertFalse(filter.hasTop());
}
Also used : Value(org.apache.accumulo.core.data.Value) TreeMap(java.util.TreeMap) SortedMapIterator(org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Key(org.apache.accumulo.core.data.Key) Test(org.junit.jupiter.api.Test)

Example 57 with SortedMapIterator

use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.

the class ColumnSliceFilterTest method testStartEqualToEndBothInclusive.

@Test
public void testStartEqualToEndBothInclusive() throws IOException {
    ColumnSliceFilter.setSlice(is, "20080202", true, "20080202", true);
    columnSliceFilter.validateOptions(is.getOptions());
    columnSliceFilter.init(new SortedMapIterator(TEST_DATA), is.getOptions(), iteratorEnvironment);
    columnSliceFilter.seek(new Range(), EMPTY_COL_FAMS, false);
    assertTrue(columnSliceFilter.hasTop());
    assertEquals(columnSliceFilter.getTopKey(), KEY_2);
    columnSliceFilter.next();
    assertFalse(columnSliceFilter.hasTop());
}
Also used : SortedMapIterator(org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Test(org.junit.jupiter.api.Test)

Example 58 with SortedMapIterator

use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.

the class ColumnSliceFilterTest method testNullStart.

@Test
public void testNullStart() throws IOException {
    ColumnSliceFilter.setSlice(is, null, "20080204");
    columnSliceFilter.validateOptions(is.getOptions());
    columnSliceFilter.init(new SortedMapIterator(TEST_DATA), is.getOptions(), iteratorEnvironment);
    columnSliceFilter.seek(new Range(), EMPTY_COL_FAMS, false);
    assertTrue(columnSliceFilter.hasTop());
    assertEquals(columnSliceFilter.getTopKey(), KEY_2);
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertEquals(columnSliceFilter.getTopKey(), KEY_1);
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertEquals(columnSliceFilter.getTopKey(), KEY_3);
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertEquals(columnSliceFilter.getTopKey(), KEY_6);
    columnSliceFilter.next();
    assertFalse(columnSliceFilter.hasTop());
}
Also used : SortedMapIterator(org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Test(org.junit.jupiter.api.Test)

Example 59 with SortedMapIterator

use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.

the class ColumnSliceFilterTest method testBothNull.

@Test
public void testBothNull() throws IOException {
    ColumnSliceFilter.setSlice(is, null, null);
    columnSliceFilter.validateOptions(is.getOptions());
    columnSliceFilter.init(new SortedMapIterator(TEST_DATA), is.getOptions(), iteratorEnvironment);
    columnSliceFilter.seek(new Range(), EMPTY_COL_FAMS, false);
    assertTrue(columnSliceFilter.hasTop());
    assertEquals(columnSliceFilter.getTopKey(), KEY_2);
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertEquals(columnSliceFilter.getTopKey(), KEY_1);
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertEquals(columnSliceFilter.getTopKey(), KEY_3);
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertEquals(columnSliceFilter.getTopKey(), KEY_6);
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertEquals(columnSliceFilter.getTopKey(), KEY_4);
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertEquals(columnSliceFilter.getTopKey(), KEY_5);
    columnSliceFilter.next();
    assertFalse(columnSliceFilter.hasTop());
}
Also used : SortedMapIterator(org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Test(org.junit.jupiter.api.Test)

Example 60 with SortedMapIterator

use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.

the class ColumnSliceFilterTest method testBothInclusive.

@Test
public void testBothInclusive() throws IOException {
    ColumnSliceFilter.setSlice(is, "20080202", true, "20080204", true);
    columnSliceFilter.validateOptions(is.getOptions());
    columnSliceFilter.init(new SortedMapIterator(TEST_DATA), is.getOptions(), iteratorEnvironment);
    columnSliceFilter.seek(new Range(), EMPTY_COL_FAMS, false);
    assertTrue(columnSliceFilter.hasTop());
    assertEquals(columnSliceFilter.getTopKey(), KEY_2);
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertEquals(columnSliceFilter.getTopKey(), KEY_3);
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertEquals(columnSliceFilter.getTopKey(), KEY_6);
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertEquals(columnSliceFilter.getTopKey(), KEY_4);
    columnSliceFilter.next();
    assertFalse(columnSliceFilter.hasTop());
}
Also used : SortedMapIterator(org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Test(org.junit.jupiter.api.Test)

Aggregations

SortedMapIterator (org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator)109 Test (org.junit.jupiter.api.Test)97 Range (org.apache.accumulo.core.data.Range)93 Key (org.apache.accumulo.core.data.Key)89 Value (org.apache.accumulo.core.data.Value)89 TreeMap (java.util.TreeMap)82 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)38 Text (org.apache.hadoop.io.Text)29 PartialKey (org.apache.accumulo.core.data.PartialKey)16 Combiner (org.apache.accumulo.core.iterators.Combiner)12 LongCombiner (org.apache.accumulo.core.iterators.LongCombiner)12 TypedValueCombiner (org.apache.accumulo.core.iterators.TypedValueCombiner)12 ArrayList (java.util.ArrayList)11 HashSet (java.util.HashSet)9 DefaultIteratorEnvironment (org.apache.accumulo.core.iterators.DefaultIteratorEnvironment)8 ColumnFamilySkippingIterator (org.apache.accumulo.core.iteratorsImpl.system.ColumnFamilySkippingIterator)8 MultiIterator (org.apache.accumulo.core.iteratorsImpl.system.MultiIterator)8 ByteSequence (org.apache.accumulo.core.data.ByteSequence)7 SortedKeyValueIterator (org.apache.accumulo.core.iterators.SortedKeyValueIterator)7 SourceSwitchingIterator (org.apache.accumulo.core.iteratorsImpl.system.SourceSwitchingIterator)7