Examples of NativeMap


Examples of org.apache.accumulo.tserver.NativeMap

    return f;
  }

  @Test
  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

Examples of org.elasticsearch.script.javascript.support.NativeMap

            setJavaPrimitiveWrap(false); // RingoJS does that..., claims its annoying...
        }

        public Scriptable wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticType) {
            if (javaObject instanceof Map) {
                return new NativeMap(scope, (Map) javaObject);
            }
            if (javaObject instanceof List) {
                return new NativeList(scope, (List) javaObject);
            }
            return super.wrapAsJavaObject(cx, scope, javaObject, staticType);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.