Package org.apache.accumulo.server.tabletserver

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


          int inserts = 0;
         
          for (int i = 0; i < insertsPerThread / 100.0; i++) {
            int map = r.nextInt(numMaps);
           
            NativeMap nm;
           
            synchronized (nativeMaps) {
              nm = nativeMaps.get(map);
              if (nm == null) {
                nm = new NativeMap();
                nativeMaps.put(map, nm);
               
              }
            }
           
View Full Code Here


  }
 
  static void runPerformanceTest(int numRows, int numCols, int numLookups, String mapType) {
   
    SortedMap<Key,Value> tm = null;
    NativeMap nm = null;
   
    if (mapType.equals("SKIP_LIST"))
      tm = new ConcurrentSkipListMap<Key,Value>();
    else if (mapType.equals("TREE_MAP"))
      tm = Collections.synchronizedSortedMap(new TreeMap<Key,Value>());
    else if (mapType.equals("NATIVE_MAP"))
      nm = new NativeMap();
    else
      throw new IllegalArgumentException(" map type must be SKIP_LIST, TREE_MAP, or NATIVE_MAP");
   
    Random rand = new Random(19);
   
    // puts
    long tps = System.currentTimeMillis();
   
    if (nm != null) {
      for (int i = 0; i < numRows; i++) {
        int row = rand.nextInt(1000000000);
        Mutation m = nm(row);
        for (int j = 0; j < numCols; j++) {
          int col = rand.nextInt(1000000);
          Value val = new Value("test".getBytes());
          pc(m, col, val);
        }
        nm.mutate(m, i);
      }
    } else {
      for (int i = 0; i < numRows; i++) {
        int row = rand.nextInt(1000000000);
        for (int j = 0; j < numCols; j++) {
          int col = rand.nextInt(1000000);
          Key key = nk(row, col);
          Value val = new Value("test".getBytes());
          tm.put(key, val);
        }
      }
    }
   
    long tpe = System.currentTimeMillis();
   
    // Iteration
    Iterator<Entry<Key,Value>> iter;
    if (nm != null) {
      iter = nm.iterator();
    } else {
      iter = tm.entrySet().iterator();
    }
   
    long tis = System.currentTimeMillis();
   
    while (iter.hasNext()) {
      iter.next();
    }
   
    long tie = System.currentTimeMillis();
   
    rand = new Random(19);
    int rowsToLookup[] = new int[numLookups];
    int colsToLookup[] = new int[numLookups];
    for (int i = 0; i < Math.min(numLookups, numRows); i++) {
      int row = rand.nextInt(1000000000);
      int col = -1;
      for (int j = 0; j < numCols; j++) {
        col = rand.nextInt(1000000);
      }
     
      rowsToLookup[i] = row;
      colsToLookup[i] = col;
    }
   
    // get
   
    long tgs = System.currentTimeMillis();
    if (nm != null) {
      for (int i = 0; i < numLookups; i++) {
        Key key = nk(rowsToLookup[i], colsToLookup[i]);
        if (nm.get(key) == null) {
          throw new RuntimeException("Did not find " + rowsToLookup[i] + " " + colsToLookup[i] + " " + i);
        }
      }
    } else {
      for (int i = 0; i < numLookups; i++) {
        Key key = nk(rowsToLookup[i], colsToLookup[i]);
        if (tm.get(key) == null) {
          throw new RuntimeException("Did not find " + rowsToLookup[i] + " " + colsToLookup[i] + " " + i);
        }
      }
    }
    long tge = System.currentTimeMillis();
   
    long memUsed = 0;
    if (nm != null) {
      memUsed = nm.getMemoryUsed();
    }
   
    int size = (nm == null ? tm.size() : nm.size());
   
    // delete
    long tds = System.currentTimeMillis();
   
    if (nm != null)
      nm.delete();
   
    long tde = System.currentTimeMillis();
   
    if (tm != null)
      tm.clear();
View Full Code Here

   
    assertEquals(num * num * num * num * num * 2, nm.size());
  }
 
  public void test1() {
    NativeMap nm = new NativeMap();
    Iterator<Entry<Key,Value>> iter = nm.iterator();
    assertFalse(iter.hasNext());
    nm.delete();
  }
View Full Code Here

    assertFalse(iter.hasNext());
    nm.delete();
  }
 
  public void test2() {
    NativeMap nm = new NativeMap();
   
    insertAndVerify(nm, 1, 10, 0);
    insertAndVerify(nm, 1, 10, 1);
    insertAndVerify(nm, 1, 10, 2);
   
    nm.delete();
  }
View Full Code Here

   
    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

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.