use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.
the class MergeInfoTest method testOverlaps_DoesNotNeedChopping.
@Test
public void testOverlaps_DoesNotNeedChopping() {
KeyExtent keyExtent2 = createMock(KeyExtent.class);
expect(keyExtent.overlaps(keyExtent2)).andReturn(false);
expect(keyExtent.getTableId()).andReturn(Table.ID.of("table1"));
replay(keyExtent);
expect(keyExtent2.getTableId()).andReturn(Table.ID.of("table2"));
replay(keyExtent2);
mi = new MergeInfo(keyExtent, MergeInfo.Operation.MERGE);
assertFalse(mi.overlaps(keyExtent2));
}
use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.
the class KeyExtentTest method testKeyExtentsForSimpleRange.
@SuppressWarnings("deprecation")
@Test
public void testKeyExtentsForSimpleRange() {
Collection<KeyExtent> results;
results = KeyExtent.getKeyExtentsForRange(null, null, null);
assertTrue("Non-empty set returned from no extents", results.isEmpty());
results = KeyExtent.getKeyExtentsForRange(null, null, Collections.emptySet());
assertTrue("Non-empty set returned from no extents", results.isEmpty());
KeyExtent t = nke("t", null, null);
results = KeyExtent.getKeyExtentsForRange(null, null, Collections.singleton(t));
assertEquals("Single tablet should always be returned", 1, results.size());
assertEquals(t, results.iterator().next());
}
use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.
the class IteratorUtilTest method test3.
@Test
public void test3() throws IOException {
// change the load order, so it squares and then adds
ConfigurationCopy conf = new ConfigurationCopy();
TreeMap<Key, Value> tm = new TreeMap<>();
MultiIteratorTest.newKeyValue(tm, 1, 0, false, "1");
MultiIteratorTest.newKeyValue(tm, 2, 0, false, "2");
SortedMapIterator source = new SortedMapIterator(tm);
conf.set(Property.TABLE_ITERATOR_PREFIX + IteratorScope.minc.name() + ".addIter", "2," + AddingIter.class.getName());
conf.set(Property.TABLE_ITERATOR_PREFIX + IteratorScope.minc.name() + ".sqIter", "1," + SquaringIter.class.getName());
SortedKeyValueIterator<Key, Value> iter = IteratorUtil.loadIterators(IteratorScope.minc, source, new KeyExtent(Table.ID.of("tab"), null, null), conf, new DefaultIteratorEnvironment(conf));
iter.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(iter.hasTop());
assertTrue(iter.getTopKey().equals(MultiIteratorTest.newKey(1, 0)));
assertTrue(iter.getTopValue().toString().equals("2"));
iter.next();
assertTrue(iter.hasTop());
assertTrue(iter.getTopKey().equals(MultiIteratorTest.newKey(2, 0)));
assertTrue(iter.getTopValue().toString().equals("5"));
iter.next();
assertFalse(iter.hasTop());
}
use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.
the class IteratorUtilTest method test4.
@Test
public void test4() throws IOException {
// try loading for a different scope
AccumuloConfiguration conf = new ConfigurationCopy();
TreeMap<Key, Value> tm = new TreeMap<>();
MultiIteratorTest.newKeyValue(tm, 1, 0, false, "1");
MultiIteratorTest.newKeyValue(tm, 2, 0, false, "2");
SortedMapIterator source = new SortedMapIterator(tm);
SortedKeyValueIterator<Key, Value> iter = IteratorUtil.loadIterators(IteratorScope.majc, source, new KeyExtent(Table.ID.of("tab"), null, null), conf, new DefaultIteratorEnvironment(conf));
iter.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(iter.hasTop());
assertTrue(iter.getTopKey().equals(MultiIteratorTest.newKey(1, 0)));
assertTrue(iter.getTopValue().toString().equals("1"));
iter.next();
assertTrue(iter.hasTop());
assertTrue(iter.getTopKey().equals(MultiIteratorTest.newKey(2, 0)));
assertTrue(iter.getTopValue().toString().equals("2"));
iter.next();
assertFalse(iter.hasTop());
}
use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.
the class IteratorUtilTest method test2.
@Test
public void test2() throws IOException {
ConfigurationCopy conf = new ConfigurationCopy();
// create an iterator that adds 1 and then squares
conf.set(Property.TABLE_ITERATOR_PREFIX + IteratorScope.minc.name() + ".addIter", "1," + AddingIter.class.getName());
conf.set(Property.TABLE_ITERATOR_PREFIX + IteratorScope.minc.name() + ".addIter.opt.amount", "7");
conf.set(Property.TABLE_ITERATOR_PREFIX + IteratorScope.minc.name() + ".sqIter", "2," + SquaringIter.class.getName());
TreeMap<Key, Value> tm = new TreeMap<>();
MultiIteratorTest.newKeyValue(tm, 1, 0, false, "1");
MultiIteratorTest.newKeyValue(tm, 2, 0, false, "2");
SortedMapIterator source = new SortedMapIterator(tm);
SortedKeyValueIterator<Key, Value> iter = IteratorUtil.loadIterators(IteratorScope.minc, source, new KeyExtent(Table.ID.of("tab"), null, null), conf, new DefaultIteratorEnvironment(conf));
iter.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(iter.hasTop());
assertTrue(iter.getTopKey().equals(MultiIteratorTest.newKey(1, 0)));
assertTrue(iter.getTopValue().toString().equals("64"));
iter.next();
assertTrue(iter.hasTop());
assertTrue(iter.getTopKey().equals(MultiIteratorTest.newKey(2, 0)));
assertTrue(iter.getTopValue().toString().equals("81"));
iter.next();
assertFalse(iter.hasTop());
}
Aggregations