當前位置: 首頁>>代碼示例>>Java>>正文


Java DB.close方法代碼示例

本文整理匯總了Java中org.iq80.leveldb.DB.close方法的典型用法代碼示例。如果您正苦於以下問題:Java DB.close方法的具體用法?Java DB.close怎麽用?Java DB.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.iq80.leveldb.DB的用法示例。


在下文中一共展示了DB.close方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import org.iq80.leveldb.DB; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
  String path = args[0];
  
  Options options = new Options();
  options.createIfMissing(true);
  options.verifyChecksums(true);
  options.paranoidChecks(true);

  DB db = null;

  try {
    db = JniDBFactory.factory.open(new File(path), options);
  } catch (UnsatisfiedLinkError ule) {
    db = Iq80DBFactory.factory.open(new File(path), options);
  }      
  
  db.close();
}
 
開發者ID:cityzendata,項目名稱:warp10-platform,代碼行數:19,代碼來源:WarpInit.java

示例2: submitScore

import org.iq80.leveldb.DB; //導入方法依賴的package包/類
public static boolean submitScore(String username, String score) throws IOException {
    Options options = new Options();
    options.createIfMissing(true);
    DB db = factory.open(new File("database"), options);

    String value = asString(db.get(bytes("scores")));

    org.json.JSONObject scoreJSON;
    if (!value.isEmpty()) { //user score
        scoreJSON = new org.json.JSONObject(value);
    } else {
        scoreJSON = new org.json.JSONObject();
    }

    scoreJSON.put(username, score);

    System.out.println("All Scores: \n" + scoreJSON.toString());

    db.put(bytes("scores"), bytes(scoreJSON.toString()));
    db.close();
    return true;
}
 
開發者ID:kaloni,項目名稱:TheJavaProject,代碼行數:23,代碼來源:DatabaseHelper.java

示例3: getAllScoreAsJsonString

import org.iq80.leveldb.DB; //導入方法依賴的package包/類
public static String getAllScoreAsJsonString() throws IOException {
    Options options = new Options();
    options.createIfMissing(true);
    DB db = factory.open(new File("database"), options);

    String value = asString(db.get(bytes("scores")));
    db.close();
    org.json.JSONObject scoreJSON;
    if (!value.isEmpty()) { //user score
        scoreJSON = new org.json.JSONObject(value);
    } else {
        scoreJSON = new org.json.JSONObject();
    }

    System.out.println("All Scores: \n" + scoreJSON.toString());

    return scoreJSON.toString();
}
 
開發者ID:kaloni,項目名稱:TheJavaProject,代碼行數:19,代碼來源:DatabaseHelper.java

示例4: destroy

import org.iq80.leveldb.DB; //導入方法依賴的package包/類
public static <T extends D_Level> void destroy(String cluster, Class<T> clazz) throws IOException {
	String path = path(cluster, clazz);
	DB db = getDB(path);
	databaseCache.remove(path);
	db.close();
	File f = new File(path);
	JniDBFactory.factory.destroy(f, options);
	f.delete();
}
 
開發者ID:yanfanvip,項目名稱:RedisClusterManager,代碼行數:10,代碼來源:LevelTable.java

示例5: loginSuccessful

import org.iq80.leveldb.DB; //導入方法依賴的package包/類
public static boolean loginSuccessful(String username, String password) throws IOException {
    Options options = new Options();
    options.createIfMissing(true);
    DB db = factory.open(new File(DATABASE_NAME), options);
    String value = asString(db.get(bytes(username)));
    db.close();

    return !password.isEmpty() && password.compareTo(value) == 0;
}
 
開發者ID:kaloni,項目名稱:TheJavaProject,代碼行數:10,代碼來源:DatabaseHelper.java

示例6: signUp

import org.iq80.leveldb.DB; //導入方法依賴的package包/類
public static boolean signUp(String username, String password) throws IOException {
    Options options = new Options();
    options.createIfMissing(true);
    DB db = factory.open(new File("database"), options);

    String value = asString(db.get(bytes(username)));

    if (!value.isEmpty()) { //user already registered
        return false;
    }

    db.put(bytes(username), bytes(password));
    db.close();
    return true;
}
 
開發者ID:kaloni,項目名稱:TheJavaProject,代碼行數:16,代碼來源:DatabaseHelper.java

示例7: generate

import org.iq80.leveldb.DB; //導入方法依賴的package包/類
public static void generate(String path, String name, long seed, Class<? extends Generator> generator, Map<String, String> options) throws IOException {
    if (!new File(path + "/db").exists()) {
        new File(path + "/db").mkdirs();
    }

    CompoundTag levelData = new CompoundTag("")
            .putLong("currentTick", 0)
            .putInt("DayCycleStopTime", -1)
            .putInt("GameType", 0)
            .putInt("Generator", Generator.getGeneratorType(generator))
            .putBoolean("hasBeenLoadedInCreative", false)
            .putLong("LastPlayed", System.currentTimeMillis() / 1000)
            .putString("LevelName", name)
            .putFloat("lightningLevel", 0)
            .putInt("lightningTime", new Random().nextInt())
            .putInt("limitedWorldOriginX", 128)
            .putInt("limitedWorldOriginY", 70)
            .putInt("limitedWorldOriginZ", 128)
            .putInt("Platform", 0)
            .putFloat("rainLevel", 0)
            .putInt("rainTime", new Random().nextInt())
            .putLong("RandomSeed", seed)
            .putByte("spawnMobs", 0)
            .putInt("SpawnX", 128)
            .putInt("SpawnY", 70)
            .putInt("SpawnZ", 128)
            .putInt("storageVersion", 4)
            .putLong("Time", 0)
            .putLong("worldStartCount", ((long) Integer.MAX_VALUE) & 0xffffffffL);

    byte[] data = NBTIO.write(levelData, ByteOrder.LITTLE_ENDIAN);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    outputStream.write(Binary.writeLInt(3));
    outputStream.write(Binary.writeLInt(data.length));
    outputStream.write(data);

    Utils.writeFile(path + "level.dat", new ByteArrayInputStream(outputStream.toByteArray()));

    DB db = Iq80DBFactory.factory.open(new File(path + "/db"), new Options().createIfMissing(true));
    db.close();
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:42,代碼來源:LevelDB.java

示例8: main

import org.iq80.leveldb.DB; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    if (4 != args.length) {
        System.out.println(HELP);
        return;
    }

    String dlUriStr = args[0];
    final String streamName = args[1];
    final String readerId = args[2];
    final String offsetStoreFile = args[3];

    URI uri = URI.create(dlUriStr);
    DistributedLogConfiguration conf = new DistributedLogConfiguration();
    DistributedLogNamespace namespace = DistributedLogNamespaceBuilder.newBuilder()
            .conf(conf)
            .uri(uri)
            .build();

    // open the dlm
    System.out.println("Opening log stream " + streamName);
    DistributedLogManager dlm = namespace.openLog(streamName);

    // open the offset store
    Options options = new Options();
    options.createIfMissing(true);
    final DB offsetDB = factory.open(new File(offsetStoreFile), options);
    final AtomicReference<DLSN> lastDLSN = new AtomicReference<DLSN>(null);
    // offset updater
    final ScheduledExecutorService executorService =
            Executors.newSingleThreadScheduledExecutor();
    executorService.scheduleAtFixedRate(new Runnable() {
        @Override
        public void run() {
            if (null != lastDLSN.get()) {
                offsetDB.put(readerId.getBytes(UTF_8), lastDLSN.get().serializeBytes());
                System.out.println("Updated reader " + readerId + " offset to " + lastDLSN.get());
            }
        }
    }, 10, 10, TimeUnit.SECONDS);
    try {
        byte[] offset = offsetDB.get(readerId.getBytes(UTF_8));
        DLSN dlsn;
        if (null == offset) {
            dlsn = DLSN.InitialDLSN;
        } else {
            dlsn = DLSN.deserializeBytes(offset);
        }
        readLoop(dlm, dlsn, lastDLSN);
    } finally {
        offsetDB.close();
        dlm.close();
        namespace.close();
    }
}
 
開發者ID:twitter,項目名稱:distributedlog,代碼行數:55,代碼來源:ReaderWithOffsets.java


注:本文中的org.iq80.leveldb.DB.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。