Search in sources :

Example 36 with SortedMapIterator

use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.

the class VisibilityFilterTest method testEmptyAuths.

public void testEmptyAuths() throws IOException {
    TreeMap<Key, Value> tm = new TreeMap<>();
    tm.put(new Key("r1", "cf1", "cq1", ""), new Value(new byte[0]));
    tm.put(new Key("r1", "cf1", "cq2", "C"), new Value(new byte[0]));
    tm.put(new Key("r1", "cf1", "cq3", ""), new Value(new byte[0]));
    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.iterators.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Key(org.apache.accumulo.core.data.Key)

Example 37 with SortedMapIterator

use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.

the class BigDecimalCombinerTest method testMax.

@Test
public void testMax() throws IOException {
    ai = new BigDecimalCombiner.BigDecimalMaxCombiner();
    IteratorSetting is = new IteratorSetting(1, BigDecimalCombiner.BigDecimalMaxCombiner.class);
    Combiner.setColumns(is, columns);
    ai.init(new SortedMapIterator(tm1), is.getOptions(), CombinerTest.SCAN_IE);
    ai.seek(new Range(), EMPTY_COL_FAMS, false);
    assertTrue(ai.hasTop());
    assertEquals(CombinerTest.newKey(1, 1, 1, 3), ai.getTopKey());
    assertEquals(2.3, encoder.decode(ai.getTopValue().get()).doubleValue(), delta);
    verify();
}
Also used : IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) SortedMapIterator(org.apache.accumulo.core.iterators.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Example 38 with SortedMapIterator

use of org.apache.accumulo.core.iterators.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());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_2));
    columnSliceFilter.next();
    assertFalse(columnSliceFilter.hasTop());
}
Also used : SortedMapIterator(org.apache.accumulo.core.iterators.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Example 39 with SortedMapIterator

use of org.apache.accumulo.core.iterators.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());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_2));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_1));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_3));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_6));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_4));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_5));
    columnSliceFilter.next();
    assertFalse(columnSliceFilter.hasTop());
}
Also used : SortedMapIterator(org.apache.accumulo.core.iterators.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Example 40 with SortedMapIterator

use of org.apache.accumulo.core.iterators.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());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_2));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_3));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_6));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_4));
    columnSliceFilter.next();
    assertFalse(columnSliceFilter.hasTop());
}
Also used : SortedMapIterator(org.apache.accumulo.core.iterators.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Aggregations

SortedMapIterator (org.apache.accumulo.core.iterators.SortedMapIterator)100 Range (org.apache.accumulo.core.data.Range)86 Key (org.apache.accumulo.core.data.Key)82 Value (org.apache.accumulo.core.data.Value)82 TreeMap (java.util.TreeMap)74 Test (org.junit.Test)61 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)10 HashSet (java.util.HashSet)9 DefaultIteratorEnvironment (org.apache.accumulo.core.iterators.DefaultIteratorEnvironment)8 SortedKeyValueIterator (org.apache.accumulo.core.iterators.SortedKeyValueIterator)7 IOException (java.io.IOException)6 ByteSequence (org.apache.accumulo.core.data.ByteSequence)6 HashMap (java.util.HashMap)5 ArrayByteSequence (org.apache.accumulo.core.data.ArrayByteSequence)5