Esempio n. 1
0
 /**
  * Set the record id of a named object. Named objects are used to store Map views and other well
  * known objects.
  */
 protected synchronized void setNamedObject(String name, long recid) throws IOException {
   long nameDirectory_recid = getRoot(NAME_DIRECTORY_ROOT);
   HTree<String, Long> m = null;
   if (nameDirectory_recid == 0) {
     // does not exists, create it
     m = new HTree<String, Long>(this, null, null, true);
     nameDirectory_recid = insert(m);
     setRoot(NAME_DIRECTORY_ROOT, nameDirectory_recid);
   } else {
     // fetch it
     m = fetch(nameDirectory_recid);
   }
   m.put(name, recid);
 }
Esempio n. 2
0
  /*
  test this issue
  http://code.google.com/p/jdbm2/issues/detail?id=2
   */
  public void testHTreeClear() throws IOException {
    final DBAbstract db = newDBCache();
    final HTree<String, String> tree = (HTree) db.createHashMap("name");

    for (int i = 0; i < 1001; i++) {
      tree.put(String.valueOf(i), String.valueOf(i));
    }
    db.commit();
    System.out.println("finished adding");

    tree.clear();
    db.commit();
    System.out.println("finished clearing");
    assertTrue(tree.isEmpty());
  }