Package org.mapdb

Examples of org.mapdb.DB$IdentityWrapper


  extends TestSupport
{
  @Test
  public void createDatabase() throws Exception {
    File file = util.createTempFile("db");
    DB db = DBMaker.newFileDB(file).make();
    try {
      log("Database: {}, file: {}", db, file);
    }
    finally {
      db.close();
    }
  }
View Full Code Here


    checkNotNull(id);
    ensureStarted();

    log.trace("Get: {}", id);

    DB db = database.makeTx();
    try {
      MetadataRecord record = entries(db).get(id);
      if (record != null) {
        return convert(record);
      }
      return null;
    }
    finally {
      db.close();
    }
  }
View Full Code Here

    checkNotNull(state);
    ensureStarted();

    log.trace("Find with state: {}", state);

    final DB db = database.makeTx().snapshot();

    return new AutoClosableIterable<BlobId>()
    {
      private volatile boolean closed = false;

      @Override
      public Iterator<BlobId> iterator() {
        return states(db, state).iterator();
      }

      @Override
      public void close() throws Exception {
        db.close();
        closed = true;
      }

      @Override
      protected void finalize() throws Throwable {
        try {
          if (!closed) {
            log.warn("Leaked database connection: {}", db);
            db.close();
          }
        }
        finally {
          super.finalize();
        }
View Full Code Here

  }

  @Override
  public long getBlobCount() {
    ensureStarted();
    DB db = database.makeTx();
    try {
      return entries(db).sizeLong();
    }
    finally {
      db.close();
    }
  }
View Full Code Here

        protected DbHolder( Supplier<DB> supplier ) {
            this.supplier = supplier;
        }

        public DB get() {
            DB db = reference.get();
            if (db == null) {
                try {
                    lock.lock();
                    // Allocate it ...
                    db = supplier.get();
View Full Code Here

            return db;
        }

        @Override
        public void close() {
            DB db = reference.getAndSet(null);
            if (db != null) {
                db.close();
            }
        }
View Full Code Here

        repository.setAuthenticationManager(sam);
        try {
            uuid = repository.getRepositoryUUID(false);
            File cacheFile = new File(new File(Jenkins.getInstance().getRootDir(), "caches"), "svn-" + uuid + ".db");
            cacheFile.getParentFile().mkdirs();
            DB cache = null;
            while (cache == null) {
                try {
                    cache = DBMaker.newFileDB(cacheFile)
                            .cacheWeakRefEnable()
                            .make();
                } catch (Throwable t) {
                    cacheFile.delete();
                }
            }
            this.cache = cache;
            this.data = this.cache.getHashMap(credentials == null ? "data" : "data-" + credentials.getId());
            cache.commit();
        } catch (SVNException e) {
            repository.closeSession();
            throw e;
        }
    }
View Full Code Here

    public OSM(boolean diskBacked) {
        // Using DB TreeMaps is observed not to be slower than memory.
        // It lets you run in 400MB instead of a few GB.
        if (diskBacked) {
            LOG.info("OSM backed by temporary file.");
            DB db = DBMaker.newTempFileDB()
                    .transactionDisable()
                    .asyncWriteEnable()
                    .compressionEnable()
                    .make();
            nodes = db.getTreeMap("nodes");
            ways = db.getTreeMap("ways");
            relations = db.getTreeMap("relations");
        } else {
            // In-memory version
            nodes = Maps.newHashMap();
            ways = Maps.newHashMap();
            relations = Maps.newHashMap();           
View Full Code Here

public class TestStorageDisk extends TestStorage {
  final private static Number160 locationKey = new Number160(10);
  private static File DIR;

  public Storage createStorage() throws IOException {
    DB db = DBMaker.newFileDB(new File(DIR, "tomp2p")).transactionDisable().closeOnJvmShutdown().cacheDisable().make();
    return new StorageDisk(db, locationKey, DIR, new DSASignatureFactory(), 60 * 1000);
  }
 
View Full Code Here

            for(int j=0;j<3;j++){

                boolean useSmallValues = (j==0);
                boolean valueOutsideOfNodes = (j==2);

                DB db = DBMaker
                        .newFileDB(new File("/mnt/big/adsasd"))
                        .deleteFilesAfterClose()
                        .closeOnJvmShutdown()
                        .transactionDisable()
                        .cacheSize(10) //use small cache size, to simulate much larger store with relatively small cache.
                        .make();


                Map<Long,String> map =
                        (valueOutsideOfNodes?
                                (db.createTreeMap("test").valuesOutsideNodesEnable()):
                                db.createTreeMap("test"))
                    .nodeSize(nodeSize)
                    .make();

                long startTime = System.currentTimeMillis();

                for(int i=0;i<1e6;i++){
                    long key = r.nextLong();
                    String value =  useSmallValues?
                            //small value
                            "abc"+key:
                            //large value
                            "qwdkqwdoqpwfwe-09fewkljklcejewfcklajewjkleawckjlaweklcwelkcwecklwecjwekecklwecklaa"
                                    +"kvlskldvklsdklcklsdvkdflvvvvvvvvvvvvvvvvvvvvvvvsl;kzlkvlksdlkvklsdklvkldsklk"
                                    +key;
                    map.put(key, value);
                }

                System.out.print("    ");
                System.out.print((System.currentTimeMillis()-startTime)/1000+" s");
                System.out.print("   |");
                db.close();
            }
            System.out.println("");
        }
    }
View Full Code Here

TOP

Related Classes of org.mapdb.DB$IdentityWrapper

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.