use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class SortedMapIteratorTest method testSampleNotPresent.
@Test
public void testSampleNotPresent() {
SortedMapIterator smi = new SortedMapIterator(new TreeMap<>());
assertThrows(SampleNotPresentException.class, () -> smi.deepCopy(new IteratorEnvironment() {
@Override
public boolean isSamplingEnabled() {
return true;
}
@Override
public SamplerConfiguration getSamplerConfiguration() {
return new SamplerConfiguration(RowSampler.class.getName());
}
}));
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class ColumnFilterTest method test2.
@Test
public void test2() throws Exception {
TreeMap<Key, Value> data = new TreeMap<>();
data.put(newKey("r1", "cf1", "cq1"), new Value(""));
data.put(newKey("r1", "cf2", "cq1"), new Value(""));
data.put(newKey("r1", "cf2", "cq2"), new Value(""));
HashSet<Column> columns = new HashSet<>();
columns.add(newColumn("cf1"));
columns.add(newColumn("cf2", "cq1"));
SortedKeyValueIterator<Key, Value> cf = ColumnQualifierFilter.wrap(new SortedMapIterator(data), columns);
cf.seek(new Range(), Collections.emptySet(), false);
assertTrue(cf.hasTop());
assertEquals(newKey("r1", "cf1", "cq1"), cf.getTopKey());
cf.next();
assertTrue(cf.hasTop());
assertEquals(newKey("r1", "cf2", "cq1"), cf.getTopKey());
cf.next();
assertFalse(cf.hasTop());
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class ColumnFilterTest method test1.
@Test
public void test1() {
TreeMap<Key, Value> data = new TreeMap<>();
data.put(newKey("r1", "cf1", "cq1"), new Value(""));
data.put(newKey("r1", "cf2", "cq1"), new Value(""));
HashSet<Column> columns = new HashSet<>();
columns.add(newColumn("cf1"));
SortedMapIterator smi = new SortedMapIterator(data);
SortedKeyValueIterator<Key, Value> cf = ColumnQualifierFilter.wrap(smi, columns);
assertSame(smi, cf);
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class MultiIteratorTest method test7.
@Test
public void test7() throws IOException {
// TEst setting an endKey
TreeMap<Key, Value> tm1 = new TreeMap<>();
newKeyValue(tm1, 0, 3, false, "1");
newKeyValue(tm1, 0, 2, false, "2");
newKeyValue(tm1, 0, 1, false, "3");
newKeyValue(tm1, 0, 0, false, "4");
newKeyValue(tm1, 1, 2, false, "5");
newKeyValue(tm1, 1, 1, false, "6");
newKeyValue(tm1, 1, 0, false, "7");
newKeyValue(tm1, 2, 1, false, "8");
newKeyValue(tm1, 2, 0, false, "9");
List<SortedKeyValueIterator<Key, Value>> skvil = new ArrayList<>(1);
skvil.add(new SortedMapIterator(tm1));
KeyExtent extent = new KeyExtent(TableId.of("tablename"), newRow(1), newRow(0));
MultiIterator mi = new MultiIterator(skvil, extent);
Range r1 = new Range((Text) null, (Text) null);
mi.seek(r1, EMPTY_COL_FAMS, false);
assertTrue(mi.hasTop());
assertEquals("5", mi.getTopValue().toString());
mi.next();
assertTrue(mi.hasTop());
assertEquals("6", mi.getTopValue().toString());
mi.next();
assertTrue(mi.hasTop());
assertEquals("7", mi.getTopValue().toString());
mi.next();
assertFalse(mi.hasTop());
Range r2 = new Range(newKey(0, 0), true, newKey(1, 1), true);
mi.seek(r2, EMPTY_COL_FAMS, false);
assertTrue(mi.hasTop());
assertEquals("5", mi.getTopValue().toString());
mi.next();
assertTrue(mi.hasTop());
assertEquals("6", mi.getTopValue().toString());
mi.next();
assertFalse(mi.hasTop());
Range r3 = new Range(newKey(0, 0), false, newKey(1, 1), false);
mi.seek(r3, EMPTY_COL_FAMS, false);
assertTrue(mi.hasTop());
assertEquals("5", mi.getTopValue().toString());
mi.next();
assertFalse(mi.hasTop());
Range r4 = new Range(newKey(1, 2), true, newKey(1, 1), false);
mi.seek(r4, EMPTY_COL_FAMS, false);
assertTrue(mi.hasTop());
assertEquals("5", mi.getTopValue().toString());
mi.next();
assertFalse(mi.hasTop());
Range r5 = new Range(newKey(1, 2), false, newKey(1, 1), true);
mi.seek(r5, EMPTY_COL_FAMS, false);
assertTrue(mi.hasTop());
assertEquals("6", mi.getTopValue().toString());
mi.next();
assertFalse(mi.hasTop());
Range r6 = new Range(newKey(2, 1), true, newKey(2, 0), true);
mi.seek(r6, EMPTY_COL_FAMS, false);
assertFalse(mi.hasTop());
Range r7 = new Range(newKey(0, 3), true, newKey(0, 1), true);
mi.seek(r7, EMPTY_COL_FAMS, false);
assertFalse(mi.hasTop());
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class RowFilterTest method test1.
@Test
public void test1() throws Exception {
ColumnFamilySkippingIterator source = new ColumnFamilySkippingIterator(new SortedMapIterator(createKeyValues()));
RowFilter filter = new SummingRowFilter();
filter.init(source, Collections.emptyMap(), new DefaultIteratorEnvironment());
filter.seek(new Range(), Collections.emptySet(), false);
assertEquals(Set.of("2", "3"), getRows(filter));
ByteSequence cf = new ArrayByteSequence("cf2");
filter.seek(new Range(), Set.of(cf), true);
assertEquals(Set.of("1", "3", "0", "4"), getRows(filter));
filter.seek(new Range("0", "4"), Collections.emptySet(), false);
assertEquals(Set.of("2", "3"), getRows(filter));
filter.seek(new Range("2"), Collections.emptySet(), false);
assertEquals(Set.of("2"), getRows(filter));
filter.seek(new Range("4"), Collections.emptySet(), false);
assertEquals(Set.of(), getRows(filter));
filter.seek(new Range("4"), Set.of(cf), true);
assertEquals(Set.of("4"), getRows(filter));
}
Aggregations