Search in sources :

Example 96 with SortedMapIterator

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

the class ColumnSliceFilterTest method testBasic.

@Test
public void testBasic() throws IOException {
    ColumnSliceFilter.setSlice(is, "20080202", "20080204");
    assertTrue(columnSliceFilter.validateOptions(is.getOptions()));
    columnSliceFilter.init(new SortedMapIterator(TEST_DATA), is.getOptions(), iteratorEnvironment);
    columnSliceFilter.seek(new Range(), EMPTY_COL_FAMS, true);
    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();
    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 97 with SortedMapIterator

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

the class ColumnSliceFilterTest method testNullEnd.

@Test
public void testNullEnd() throws IOException {
    ColumnSliceFilter.setSlice(is, "20080202", 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_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 98 with SortedMapIterator

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

the class ColumnSliceFilterTest method testBothExclusive.

@Test
public void testBothExclusive() throws IOException {
    ColumnSliceFilter.setSlice(is, "20080202", false, "20080204", false);
    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_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 99 with SortedMapIterator

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

the class ColumnSliceFilterTest method testStartExclusiveEndInclusive.

@Test
public void testStartExclusiveEndInclusive() throws IOException {
    ColumnSliceFilter.setSlice(is, "20080202", false, "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_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)

Example 100 with SortedMapIterator

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

the class ColumnFamilySkippingIteratorTest method test3.

@Test
public void test3() throws Exception {
    // construct test where ColumnFamilySkippingIterator might try to seek past the end of the user
    // supplied range
    TreeMap<Key, Value> tm1 = new TreeMap<>();
    for (int r = 0; r < 3; r++) {
        for (int cf = 4; cf < 1000; cf++) {
            for (int cq = 0; cq < 1; cq++) {
                put(tm1, r, cf, cq, 6, r * cf * cq);
            }
        }
    }
    CountingIterator ci = new CountingIterator(new SortedMapIterator(tm1));
    ColumnFamilySkippingIterator cfi = new ColumnFamilySkippingIterator(ci);
    HashSet<ByteSequence> colfams = new HashSet<>();
    colfams.add(new ArrayByteSequence(String.format("%06d", 4)));
    Range range = new Range(newKey(0, 4, 0, 6), true, newKey(0, 400, 0, 6), true);
    cfi.seek(range, colfams, true);
    assertTrue(cfi.hasTop());
    assertEquals(newKey(0, 4, 0, 6), cfi.getTopKey());
    cfi.next();
    assertFalse(cfi.hasTop());
    colfams.add(new ArrayByteSequence(String.format("%06d", 500)));
    cfi.seek(range, colfams, true);
    assertTrue(cfi.hasTop());
    assertEquals(newKey(0, 4, 0, 6), cfi.getTopKey());
    cfi.next();
    assertFalse(cfi.hasTop());
    range = new Range(newKey(0, 4, 0, 6), true, newKey(1, 400, 0, 6), true);
    cfi.seek(range, colfams, true);
    assertTrue(cfi.hasTop());
    assertEquals(newKey(0, 4, 0, 6), cfi.getTopKey());
    cfi.next();
    assertTrue(cfi.hasTop());
    assertEquals(newKey(0, 500, 0, 6), cfi.getTopKey());
    cfi.next();
    assertTrue(cfi.hasTop());
    assertEquals(newKey(1, 4, 0, 6), cfi.getTopKey());
    cfi.next();
    assertFalse(cfi.hasTop());
// System.out.println(ci.getCount());
}
Also used : ColumnFamilySkippingIterator(org.apache.accumulo.core.iteratorsImpl.system.ColumnFamilySkippingIterator) TreeMap(java.util.TreeMap) SortedMapIterator(org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) CountingIterator(org.apache.accumulo.core.iteratorsImpl.system.CountingIterator) Value(org.apache.accumulo.core.data.Value) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) Key(org.apache.accumulo.core.data.Key) ByteSequence(org.apache.accumulo.core.data.ByteSequence) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) HashSet(java.util.HashSet) 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