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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations