Package org.apache.accumulo.server.tabletserver

Examples of org.apache.accumulo.server.tabletserver.NativeMap$ConcurrentIterator


   
    nm.delete();
  }
 
  public void test4() {
    NativeMap nm = new NativeMap();
   
    insertAndVerifyExhaustive(nm, 3, 0);
    insertAndVerifyExhaustive(nm, 3, 1);
   
    nm.delete();
  }
View Full Code Here


   
    nm.delete();
  }
 
  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(nk(1), nv(1));
      assertTrue(false);
    } catch (IllegalStateException e) {
     
    }
   
    try {
      nm.get(nk(1));
      assertTrue(false);
    } catch (IllegalStateException e) {
     
    }
   
    try {
      nm.iterator();
      assertTrue(false);
    } catch (IllegalStateException e) {
     
    }
   
    try {
      nm.iterator(nk(1));
      assertTrue(false);
    } catch (IllegalStateException e) {
     
    }
   
    try {
      nm.size();
      assertTrue(false);
    } catch (IllegalStateException e) {
     
    }
   
View Full Code Here

    }
   
  }
 
  public void test7() {
    NativeMap nm = new NativeMap();
   
    insertAndVerify(nm, 1, 10, 0);
   
    nm.delete();
   
    try {
      nm.delete();
      assertTrue(false);
    } catch (IllegalStateException e) {
     
    }
  }
View Full Code Here

  }
 
  public void test8() {
    // test verifies that native map sorts keys sharing some common prefix properly
   
    NativeMap nm = new NativeMap();
   
    TreeMap<Key,Value> tm = new TreeMap<Key,Value>();
   
    tm.put(new Key(new Text("fo")), new Value("0".getBytes()));
    tm.put(new Key(new Text("foo")), new Value("1".getBytes()));
    tm.put(new Key(new Text("foo1")), new Value("2".getBytes()));
    tm.put(new Key(new Text("foo2")), new Value("3".getBytes()));
   
    for (Entry<Key,Value> entry : tm.entrySet()) {
      nm.put(entry.getKey(), entry.getValue());
    }
   
    Iterator<Entry<Key,Value>> iter = nm.iterator();
   
    for (Entry<Key,Value> entry : tm.entrySet()) {
      assertTrue(iter.hasNext());
      Entry<Key,Value> entry2 = iter.next();
     
      assertEquals(entry.getKey(), entry2.getKey());
      assertEquals(entry.getValue(), entry2.getValue());
    }
   
    assertFalse(iter.hasNext());
   
    nm.delete();
  }
View Full Code Here

   
    nm.delete();
  }
 
  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();
  }
View Full Code Here

 
  public void test10() {
    int start = 1;
    int end = 10000;
   
    NativeMap nm = new NativeMap();
    for (int i = start; i <= end; i++) {
      nm.put(nk(i), nv(i));
    }
   
    long mem1 = nm.getMemoryUsed();
   
    for (int i = start; i <= end; i++) {
      nm.put(nk(i), nv(i));
    }
   
    long mem2 = nm.getMemoryUsed();
   
    if (mem1 != mem2) {
      throw new RuntimeException("Memory changed after inserting duplicate data " + mem1 + " " + mem2);
    }
   
    for (int i = start; i <= end; i++) {
      nm.put(nk(i), nv(i));
    }
   
    long mem3 = nm.getMemoryUsed();
   
    if (mem1 != mem3) {
      throw new RuntimeException("Memory changed after inserting duplicate data " + mem1 + " " + mem3);
    }
   
    byte bigrow[] = new byte[1000000];
    byte bigvalue[] = new byte[bigrow.length];
   
    for (int i = 0; i < bigrow.length; i++) {
      bigrow[i] = (byte) (0xff & (i % 256));
      bigvalue[i] = bigrow[i];
    }
   
    nm.put(new Key(new Text(bigrow)), new Value(bigvalue));
   
    long mem4 = nm.getMemoryUsed();
   
    Value val = nm.get(new Key(new Text(bigrow)));
    if (val == null || !val.equals(new Value(bigvalue))) {
      throw new RuntimeException("Did not get expected big value");
    }
   
    nm.put(new Key(new Text(bigrow)), new Value(bigvalue));
   
    long mem5 = nm.getMemoryUsed();
   
    if (mem4 != mem5) {
      throw new RuntimeException("Memory changed after inserting duplicate data " + mem4 + " " + mem5);
    }
   
    val = nm.get(new Key(new Text(bigrow)));
    if (val == null || !val.equals(new Value(bigvalue))) {
      throw new RuntimeException("Did not get expected big value");
    }
   
    nm.delete();
  }
View Full Code Here

   
    return f;
  }
 
  public void test11() {
    NativeMap nm = new NativeMap();
   
    // insert things with varying field sizes and value sizes
   
    // generate random data
    Random r = new Random(75);
   
    ArrayList<Pair<Key,Value>> testData = new ArrayList<Pair<Key,Value>>();
   
    for (int i = 0; i < 100000; i++) {
     
      Key k = new Key(rlrf(r, 97), rlrf(r, 13), rlrf(r, 31), rlrf(r, 11), (r.nextLong() & 0x7fffffffffffffffl), false, false);
      Value v = new Value(rlrf(r, 511));
     
      testData.add(new Pair<Key,Value>(k, v));
    }
   
    // insert unsorted data
    for (Pair<Key,Value> pair : testData) {
      nm.put(pair.getFirst(), pair.getSecond());
    }
   
    for (int i = 0; i < 2; i++) {
     
      // sort data
      Collections.sort(testData, new Comparator<Pair<Key,Value>>() {
        @Override
        public int compare(Pair<Key,Value> o1, Pair<Key,Value> o2) {
          return o1.getFirst().compareTo(o2.getFirst());
        }
      });
     
      // verify
      Iterator<Entry<Key,Value>> iter1 = nm.iterator();
      Iterator<Pair<Key,Value>> iter2 = testData.iterator();
     
      while (iter1.hasNext() && iter2.hasNext()) {
        Entry<Key,Value> e = iter1.next();
        Pair<Key,Value> p = iter2.next();
       
        if (!e.getKey().equals(p.getFirst()))
          throw new RuntimeException("Keys not equal");
       
        if (!e.getValue().equals(p.getSecond()))
          throw new RuntimeException("Values not equal");
      }
     
      if (iter1.hasNext())
        throw new RuntimeException("Not all of native map consumed");
     
      if (iter2.hasNext())
        throw new RuntimeException("Not all of test data consumed");
     
      System.out.println("test 11 nm mem " + nm.getMemoryUsed());
     
      // insert data again w/ different value
      Collections.shuffle(testData, r);
      // insert unsorted data
      for (Pair<Key,Value> pair : testData) {
        pair.getSecond().set(rlrf(r, 511));
        nm.put(pair.getFirst(), pair.getSecond());
      }
    }
   
    nm.delete();
  }
View Full Code Here

   
    nm.delete();
  }
 
  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();
  }
View Full Code Here

   
    nm.delete();
  }
 
  public void testEmpty() {
    NativeMap nm = new NativeMap();
   
    assertTrue(nm.size() == 0);
    assertTrue(nm.getMemoryUsed() == 0);
   
    nm.delete();
  }
View Full Code Here

   
    nm.delete();
  }
 
  public void testConcurrentIter() throws IOException {
    NativeMap nm = new NativeMap();
   
    nm.put(nk(0), nv(0));
    nm.put(nk(1), nv(1));
    nm.put(nk(3), nv(3));
   
    SortedKeyValueIterator<Key,Value> iter = nm.skvIterator();
   
    // modify map after iter created
    nm.put(nk(2), nv(2));
   
    assertTrue(iter.hasTop());
    assertEquals(iter.getTopKey(), nk(0));
    iter.next();
   
    assertTrue(iter.hasTop());
    assertEquals(iter.getTopKey(), nk(1));
    iter.next();
   
    assertTrue(iter.hasTop());
    assertEquals(iter.getTopKey(), nk(2));
    iter.next();
   
    assertTrue(iter.hasTop());
    assertEquals(iter.getTopKey(), nk(3));
    iter.next();
   
    assertFalse(iter.hasTop());
   
    nm.delete();
  }
View Full Code Here

TOP

Related Classes of org.apache.accumulo.server.tabletserver.NativeMap$ConcurrentIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.