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


Java DB.createWriteBatch方法代碼示例

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


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

示例1: replace

import org.iq80.leveldb.DB; //導入方法依賴的package包/類
public static <T extends D_Level> void replace(String cluster, Class<T> clazz, List<T> data) throws IOException {
	DB db = getDB(path(cluster, clazz));
	ReadOptions readOptions = new ReadOptions().snapshot(db.getSnapshot());
	DBIterator iterator = db.iterator(readOptions);
	WriteBatch write = db.createWriteBatch();
	try {
		iterator.seekToFirst();
		iterator.forEachRemaining(entry ->{
			byte[] key = entry.getKey();
			write.delete(key);
		});
		data.forEach(t->{
			write.put(t.key().getBytes(), t.value());
		});
		db.write(write, new WriteOptions().sync(true));
	} finally {
		iterator.close();
		write.close();
	}
}
 
開發者ID:yanfanvip,項目名稱:RedisClusterManager,代碼行數:21,代碼來源:LevelTable.java

示例2: deletePrev

import org.iq80.leveldb.DB; //導入方法依賴的package包/類
public static <T extends D_TimeLine> void deletePrev(String cluster, Class<T> clazz, Long start) throws IOException {
	DB db = getDB(path(cluster, clazz));
	ReadOptions readOptions = new ReadOptions().snapshot(db.getSnapshot());
	DBIterator iterator = db.iterator(readOptions);
	WriteBatch write = db.createWriteBatch();
	try {
		iterator.seek((start + "").getBytes());
		while(iterator.hasPrev()){
			byte[] key = iterator.prev().getKey();
			write.delete(key);
		}
		db.write(write, new WriteOptions().sync(true));
	} finally {
		iterator.close();
		write.close();
	}
}
 
開發者ID:yanfanvip,項目名稱:RedisClusterManager,代碼行數:18,代碼來源:LevelTable.java

示例3: put

import org.iq80.leveldb.DB; //導入方法依賴的package包/類
public static <T extends D_Level> void put(String cluster, Class<T> clazz, List<T> data) throws IOException {
	DB db = getDB(path(cluster, clazz));
	WriteBatch bitch = db.createWriteBatch();
	try {
		for (T t : data) {
			bitch.put(t.key().getBytes(), t.value());
		}
		db.write(bitch, new WriteOptions().sync(true));
	} finally {
		bitch.close();
	}
}
 
開發者ID:yanfanvip,項目名稱:RedisClusterManager,代碼行數:13,代碼來源:LevelTable.java

示例4: EzLevelDbBatch

import org.iq80.leveldb.DB; //導入方法依賴的package包/類
public EzLevelDbBatch(DB db, Serde<H> hashKeySerde, Serde<R> rangeKeySerde,
		Serde<V> valueSerde) {
	this.db = db;
	this.writeBatch = db.createWriteBatch();
	this.hashKeySerde = hashKeySerde;
	this.rangeKeySerde = rangeKeySerde;
	this.valueSerde = valueSerde;
}
 
開發者ID:criccomini,項目名稱:ezdb,代碼行數:9,代碼來源:EzLevelDbBatch.java


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