@Test public void testLevelDb() throws IOException { Db storage = new LevelDB(filepath); long max = 100000; for (long i = 0; i < max; i++) { String value = "测试，this is value of "+i; byte[] key = ("key_"+i).getBytes(); storage.put(key, value.getBytes()); } long time = System.currentTimeMillis(); int count = 10000; for (long i = 0; i < count; i++) { long index = (long) (Math.random()*max); byte[] key = ("key_"+index).getBytes(); String value = new String(storage.get(key)); System.out.println(value); } System.out.println("读取 "+count+" 条数据耗时："+(System.currentTimeMillis() - time)+" ms"); storage.close(); }
public LevelDB(String filename) { this(filename, LEVELDB_READ_CACHE_DEFAULT, LEVELDB_WRITE_CACHE_DEFAULT); }
LevelDB implements Db { public LevelDB(String filename) { this(filename, LEVELDB_READ_CACHE_DEFAULT, LEVELDB_WRITE_CACHE_DEFAULT); } }
LevelDB implements Db { public LevelDB(String filename) { this(filename, LEVELDB_READ_CACHE_DEFAULT, LEVELDB_WRITE_CACHE_DEFAULT); } LevelDB(String filename);  LevelDB(String finalname, long leveldbReadCache, int leveldbWriteCache); }
LevelDB implements Db { public LevelDB(String filename) { this(filename, LEVELDB_READ_CACHE_DEFAULT, LEVELDB_WRITE_CACHE_DEFAULT); } LevelDB(String filename);  LevelDB(String finalname, long leveldbReadCache, int leveldbWriteCache); @Override boolean put(byte[] key, byte[] value); @Override byte[] get(byte[] key); @Override boolean delete(byte[] key); @Override void close(); @Override DB getSourceDb(); }
LevelDB implements Db { public LevelDB(String filename) { this(filename, LEVELDB_READ_CACHE_DEFAULT, LEVELDB_WRITE_CACHE_DEFAULT); } LevelDB(String filename);  LevelDB(String finalname, long leveldbReadCache, int leveldbWriteCache); @Override boolean put(byte[] key, byte[] value); @Override byte[] get(byte[] key); @Override boolean delete(byte[] key); @Override void close(); @Override DB getSourceDb();  }