Package org.apache.accumulo.server.tabletserver

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


    m.put(new Text(FastFormat.toZeroPaddedString(c, 3, 10, COL_PREFIX)), ET, v);
  }
 
  static NativeMap create(int numRows, int numCols) {
   
    NativeMap nm = new NativeMap();
   
    populate(0, numRows, numCols, nm);
   
    return nm;
   
View Full Code Here


    jc.parse(args);
    if (opts.help) {
      jc.usage();
      return;
    }
    NativeMap nm = create(opts.rows, opts.cols);
    runTest(nm, opts.rows, opts.cols, opts.threads, opts.writeThreads);
    nm.delete();
  }
View Full Code Here

   
    for (int tCount = 0; tCount < numThreads; tCount++) {
      Runnable r = new Runnable() {
        @Override
        public void run() {
          NativeMap nm = new NativeMap();
         
          Random r = new Random();
         
          OpTimer opTimer = new OpTimer(log, Level.INFO);
         
          opTimer.start("Creating map of size " + mapSizePerThread);
         
          for (int i = 0; i < mapSizePerThread; i++) {
            String row = String.format("r%08d", i);
            String val = row + "v";
            put(nm, row, val, i);
          }
         
          opTimer.stop("Created map of size " + nm.size() + " in %DURATION%");
         
          opTimer.start("Doing " + getsPerThread + " gets()");
         
          for (int i = 0; i < getsPerThread; i++) {
            String row = String.format("r%08d", r.nextInt(mapSizePerThread));
            String val = row + "v";
           
            Value value = nm.get(new Key(new Text(row)));
            if (value == null || !value.toString().equals(val)) {
              log.error("nm.get(" + row + ") failed");
            }
          }
         
          opTimer.stop("Finished " + getsPerThread + " gets in %DURATION%");
         
          int scanned = 0;
         
          opTimer.start("Doing " + getsPerThread + " random iterations");
         
          for (int i = 0; i < getsPerThread; i++) {
            int startRow = r.nextInt(mapSizePerThread);
            String row = String.format("r%08d", startRow);
           
            Iterator<Entry<Key,Value>> iter = nm.iterator(new Key(new Text(row)));
           
            int count = 0;
           
            while (iter.hasNext() && count < 10) {
              String row2 = String.format("r%08d", startRow + count);
              String val2 = row2 + "v";
             
              Entry<Key,Value> entry = iter.next();
              if (!entry.getValue().toString().equals(val2) || !entry.getKey().equals(new Key(new Text(row2)))) {
                log.error("nm.iter(" + row2 + ") failed row = " + row + " count = " + count + " row2 = " + row + " val2 = " + val2);
              }
             
              count++;
            }
           
            scanned += count;
          }
         
          opTimer.stop("Finished " + getsPerThread + " random iterations (scanned = " + scanned + ") in %DURATION%");
         
          nm.delete();
        }
      };
     
      Thread t = new Thread(r);
      t.start();
View Full Code Here

          int inserts = 0;
          int removes = 0;
         
          for (int i = 0; i < mapsPerThread; i++) {
           
            NativeMap nm = new NativeMap();
           
            for (int j = 0; j < insertsPerMapPerThread; j++) {
              String row = String.format("r%08d", j % rowRange);
              String val = row + "v";
              put(nm, row, val, j);
              inserts++;
            }
           
            if (doRemoves) {
              Iterator<Entry<Key,Value>> iter = nm.iterator();
              while (iter.hasNext()) {
                iter.next();
                iter.remove();
                removes++;
              }
            }
           
            nm.delete();
          }
         
          System.out.println("inserts " + inserts + " removes " + removes + " " + Thread.currentThread().getName());
        }
      };
View Full Code Here

          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(Constants.UTF8));
          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(Constants.UTF8));
          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

TOP

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

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.