Search in sources :

Example 1 with NativeMap

use of org.apache.accumulo.tserver.NativeMap in project accumulo by apache.

the class NativeMapIT method test5.

@Test
public void test5() {
    NativeMap nm = new NativeMap();
    insertAndVerify(nm, 1, 10, 0);
    Iterator<Entry<Key, Value>> iter = nm.iterator();
    iter.next();
    nm.delete();
    try {
        nm.put(newKey(1), newValue(1));
        assertTrue(false);
    } catch (IllegalStateException e) {
    }
    try {
        nm.get(newKey(1));
        assertTrue(false);
    } catch (IllegalStateException e) {
    }
    try {
        nm.iterator();
        assertTrue(false);
    } catch (IllegalStateException e) {
    }
    try {
        nm.iterator(newKey(1));
        assertTrue(false);
    } catch (IllegalStateException e) {
    }
    try {
        nm.size();
        assertTrue(false);
    } catch (IllegalStateException e) {
    }
    try {
        iter.next();
        assertTrue(false);
    } catch (IllegalStateException e) {
    }
}
Also used : Entry(java.util.Map.Entry) NativeMap(org.apache.accumulo.tserver.NativeMap) Test(org.junit.Test)

Example 2 with NativeMap

use of org.apache.accumulo.tserver.NativeMap in project accumulo by apache.

the class NativeMapIT method testBinary.

@Test
public void testBinary() {
    NativeMap nm = new NativeMap();
    byte[] emptyBytes = new byte[0];
    for (int i = 0; i < 256; i++) {
        for (int j = 0; j < 256; j++) {
            byte[] row = new byte[] { 'r', (byte) (0xff & i), (byte) (0xff & j) };
            byte[] data = new byte[] { 'v', (byte) (0xff & i), (byte) (0xff & j) };
            Key k = new Key(row, emptyBytes, emptyBytes, emptyBytes, 1);
            Value v = new Value(data);
            nm.put(k, v);
        }
    }
    Iterator<Entry<Key, Value>> iter = nm.iterator();
    for (int i = 0; i < 256; i++) {
        for (int j = 0; j < 256; j++) {
            byte[] row = new byte[] { 'r', (byte) (0xff & i), (byte) (0xff & j) };
            byte[] data = new byte[] { 'v', (byte) (0xff & i), (byte) (0xff & j) };
            Key k = new Key(row, emptyBytes, emptyBytes, emptyBytes, 1);
            Value v = new Value(data);
            assertTrue(iter.hasNext());
            Entry<Key, Value> entry = iter.next();
            assertEquals(k, entry.getKey());
            assertEquals(v, entry.getValue());
        }
    }
    assertFalse(iter.hasNext());
    for (int i = 0; i < 256; i++) {
        for (int j = 0; j < 256; j++) {
            byte[] row = new byte[] { 'r', (byte) (0xff & i), (byte) (0xff & j) };
            byte[] data = new byte[] { 'v', (byte) (0xff & i), (byte) (0xff & j) };
            Key k = new Key(row, emptyBytes, emptyBytes, emptyBytes, 1);
            Value v = new Value(data);
            Value v2 = nm.get(k);
            assertEquals(v, v2);
        }
    }
    nm.delete();
}
Also used : Entry(java.util.Map.Entry) Value(org.apache.accumulo.core.data.Value) NativeMap(org.apache.accumulo.tserver.NativeMap) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 3 with NativeMap

use of org.apache.accumulo.tserver.NativeMap in project accumulo by apache.

the class NativeMapIT method test2.

@Test
public void test2() {
    NativeMap nm = new NativeMap();
    insertAndVerify(nm, 1, 10, 0);
    insertAndVerify(nm, 1, 10, 1);
    insertAndVerify(nm, 1, 10, 2);
    nm.delete();
}
Also used : NativeMap(org.apache.accumulo.tserver.NativeMap) Test(org.junit.Test)

Example 4 with NativeMap

use of org.apache.accumulo.tserver.NativeMap in project accumulo by apache.

the class NativeMapIT method testEmpty.

@Test
public void testEmpty() {
    NativeMap nm = new NativeMap();
    assertTrue(nm.size() == 0);
    assertTrue(nm.getMemoryUsed() == 0);
    nm.delete();
}
Also used : NativeMap(org.apache.accumulo.tserver.NativeMap) Test(org.junit.Test)

Example 5 with NativeMap

use of org.apache.accumulo.tserver.NativeMap in project accumulo by apache.

the class NativeMapIT method test9.

@Test
public void test9() {
    NativeMap nm = new NativeMap();
    Iterator<Entry<Key, Value>> iter = nm.iterator();
    try {
        iter.next();
        assertTrue(false);
    } catch (NoSuchElementException e) {
    }
    insertAndVerify(nm, 1, 1, 0);
    iter = nm.iterator();
    iter.next();
    try {
        iter.next();
        assertTrue(false);
    } catch (NoSuchElementException e) {
    }
    nm.delete();
}
Also used : Entry(java.util.Map.Entry) NativeMap(org.apache.accumulo.tserver.NativeMap) NoSuchElementException(java.util.NoSuchElementException) Test(org.junit.Test)

Aggregations

NativeMap (org.apache.accumulo.tserver.NativeMap)18 Test (org.junit.Test)12 Entry (java.util.Map.Entry)10 Key (org.apache.accumulo.core.data.Key)7 Value (org.apache.accumulo.core.data.Value)7 ArrayList (java.util.ArrayList)4 Random (java.util.Random)4 Text (org.apache.hadoop.io.Text)3 TreeMap (java.util.TreeMap)2 JCommander (com.beust.jcommander.JCommander)1 HashMap (java.util.HashMap)1 NoSuchElementException (java.util.NoSuchElementException)1 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Mutation (org.apache.accumulo.core.data.Mutation)1 OpTimer (org.apache.accumulo.core.util.OpTimer)1 Pair (org.apache.accumulo.core.util.Pair)1