Search in sources :

Example 16 with KeyExtent

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));
}
Also used : KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) Test(org.junit.Test)

Example 17 with KeyExtent

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());
}
Also used : KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) Test(org.junit.Test)

Example 18 with KeyExtent

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());
}
Also used : ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) Value(org.apache.accumulo.core.data.Value) TreeMap(java.util.TreeMap) Range(org.apache.accumulo.core.data.Range) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test) MultiIteratorTest(org.apache.accumulo.core.iterators.system.MultiIteratorTest)

Example 19 with KeyExtent

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());
}
Also used : ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) Value(org.apache.accumulo.core.data.Value) TreeMap(java.util.TreeMap) Range(org.apache.accumulo.core.data.Range) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) Key(org.apache.accumulo.core.data.Key) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Test(org.junit.Test) MultiIteratorTest(org.apache.accumulo.core.iterators.system.MultiIteratorTest)

Example 20 with KeyExtent

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());
}
Also used : ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) Value(org.apache.accumulo.core.data.Value) TreeMap(java.util.TreeMap) Range(org.apache.accumulo.core.data.Range) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test) MultiIteratorTest(org.apache.accumulo.core.iterators.system.MultiIteratorTest)

Aggregations

KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)142 Text (org.apache.hadoop.io.Text)54 Value (org.apache.accumulo.core.data.Value)47 Key (org.apache.accumulo.core.data.Key)43 Test (org.junit.Test)41 ArrayList (java.util.ArrayList)37 HashMap (java.util.HashMap)33 Range (org.apache.accumulo.core.data.Range)32 TreeMap (java.util.TreeMap)27 Scanner (org.apache.accumulo.core.client.Scanner)27 Mutation (org.apache.accumulo.core.data.Mutation)27 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)21 HashSet (java.util.HashSet)20 IOException (java.io.IOException)19 List (java.util.List)19 Table (org.apache.accumulo.core.client.impl.Table)19 MetadataTable (org.apache.accumulo.core.metadata.MetadataTable)19 AccumuloException (org.apache.accumulo.core.client.AccumuloException)18 PartialKey (org.apache.accumulo.core.data.PartialKey)17 TKeyExtent (org.apache.accumulo.core.data.thrift.TKeyExtent)17