本文整理汇总了Java中org.rocksdb.RocksDB.close方法的典型用法代码示例。如果您正苦于以下问题:Java RocksDB.close方法的具体用法?Java RocksDB.close怎么用?Java RocksDB.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.rocksdb.RocksDB
的用法示例。
在下文中一共展示了RocksDB.close方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
public static void main(String[] args) {
RocksDB.loadLibrary();
Options rockopts = new Options().setCreateIfMissing(false);
RocksDB db = null;
try {
db = RocksDB.open(rockopts, args[0]);
RocksIterator iter = db.newIterator();
iter.seekToFirst();
while (iter.isValid()) {
String key = new String(iter.key(), StandardCharsets.UTF_8);
String val = new String(iter.value(), StandardCharsets.UTF_8);
System.out.println(key + " -> " + val);
iter.next();
}
db.close();
} catch (RocksDBException rdbe) {
rdbe.printStackTrace(System.err);
}
}
示例2: main
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
public static void main(String[] args) {
RocksDB.loadLibrary();
Options rockopts = new Options().setCreateIfMissing(false);
RocksDB db = null;
try {
db = RocksDB.open(rockopts, args[0]);
String query = args[1];
byte[] val = db.get(query.getBytes(StandardCharsets.UTF_8));
if (val != null) {
System.out.println(new String(val, StandardCharsets.UTF_8));
}
db.close();
} catch (RocksDBException rdbe) {
rdbe.printStackTrace(System.err);
}
}
示例3: close
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
@Override
public void close() {
if (this.closed.compareAndSet(false, true)) {
RocksDB db = this.database.get();
if (db != null) {
db.close();
this.database.set(null);
}
if (this.writeOptions != null) {
this.writeOptions.close();
}
if (this.databaseOptions != null) {
this.databaseOptions.close();
}
clear(false);
log.info("{}: Closed.", this.logId);
Consumer<String> callback = this.closeCallback;
if (callback != null) {
Callbacks.invokeSafely(callback, this.id, null);
}
}
}
示例4: openSuffixDataStore
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
@Override
public SuffixDataStore openSuffixDataStore(int id) {
RocksDB.loadLibrary();
try {
LOGGER.info("Opening TnT suffix model: {}", id);
RocksDB rocksDB = RocksDB.openReadOnly(dbPath.resolve(getSuffixesName(id)).toString());
RocksDbSuffixDataStore rocksDbSuffixDataStore = new RocksDbSuffixDataStore(rocksDB);
if (inMemory) {
LOGGER.info("Loading TnT suffix model into memory: {}", id);
InMemorySuffixDataStore inMemorySuffixDataStore = rocksDbSuffixDataStore.inMemory();
LOGGER.info("Done loading TnT suffix model into memory: {}", id);
rocksDB.close();
return inMemorySuffixDataStore;
}
rocksDBS.add(rocksDB);
return rocksDbSuffixDataStore;
} catch (RocksDBException e) {
throw new RuntimeException(e);
}
}
示例5: openKnownWordDataStore
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
@Override
public KnownWordsDataStore openKnownWordDataStore(int id) {
RocksDB.loadLibrary();
try {
LOGGER.info("Opening TnT model known word model: {}", id);
RocksDB rocksDB = RocksDB.openReadOnly(dbPath.resolve(getWordsName(id)).toString());
RocksDB candidatesDB = RocksDB.openReadOnly(dbPath.resolve(getCandidatesName(id)).toString());
RocksDbKnownWordsDataStore rocksDbKnownWordsDataStore = new RocksDbKnownWordsDataStore(
rocksDB, candidatesDB);
if (inMemory) {
LOGGER.info("Loading TnT known word model into memory: {}", id);
InMemoryKnownWordDataStore inMemoryKnownWordDataStore = rocksDbKnownWordsDataStore
.inMemory();
LOGGER.info("Done loading TnT known word model into memory: {}", id);
rocksDB.close();
candidatesDB.close();
return inMemoryKnownWordDataStore;
}
rocksDBS.add(rocksDB);
rocksDBS.add(candidatesDB);
return rocksDbKnownWordsDataStore;
} catch (RocksDBException e) {
throw new RuntimeException(e);
}
}
示例6: main
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
public static void main(String[] args) {
RocksDB.loadLibrary();
Options rockopts = new Options().setCreateIfMissing(true);
RocksDB db = null;
int count = 0;
try {
BufferedReader in = new BufferedReader(new FileReader(args[0]));
db = RocksDB.open(rockopts, args[1]);
String line;
while ((line = in.readLine()) != null) {
String[] fields = line.split("\\t+");
if (fields[2].endsWith("@en")) {
byte[] key = fields[0].substring(1, fields[0].length() - 1).getBytes(StandardCharsets.UTF_8);
byte[] value = fields[2].substring(1, fields[2].length() - 4).getBytes(StandardCharsets.UTF_8);
db.put(key, value);
}
count++;
if ((count % 100000) == 0)
System.out.print(".");
}
db.close();
System.out.println();
} catch (RocksDBException rdbe) {
rdbe.printStackTrace(System.err);
} catch (IOException ioe) {
ioe.printStackTrace(System.err);
}
}
示例7: doShutdown
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
@Override
public void doShutdown() throws BiomedicusException {
for (RocksDB rocksDB : rocksDBS) {
rocksDB.close();
}
}
示例8: closeConn
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
public void closeConn() throws Exception
{
RocksDB conn = (RocksDB) m_conn;
conn.close();
}
示例9: main
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
public static void main(String[] args) {
Map conf = JStormHelper.LoadConf(args[0]);
putNum = JStormUtils.parseInt(conf.get("put.number"), 100);
isFlush = JStormUtils.parseBoolean(conf.get("is.flush"), true);
isCheckpoint = JStormUtils.parseBoolean(conf.get("is.checkpoint"), true);
sleepTime = JStormUtils.parseInt(conf.get("sleep.time"), 5000);
compactionInterval = JStormUtils.parseInt(conf.get("compaction.interval"), 30000);
flushInterval = JStormUtils.parseInt(conf.get("flush.interval"), 3000);
isCompaction = JStormUtils.parseBoolean(conf.get("is.compaction"), true);
fileSizeBase = JStormUtils.parseLong(conf.get("file.size.base"), 10 * SizeUnit.KB);
levelNum = JStormUtils.parseInt(conf.get("db.level.num"), 1);
compactionTriggerNum = JStormUtils.parseInt(conf.get("db.compaction.trigger.num"), 4);
LOG.info("Conf={}", conf);
RocksDB db;
File file = new File(cpPath);
file.mkdirs();
List<ColumnFamilyHandle> columnFamilyHandles = new ArrayList<>();
try {
Options options = new Options();
options.setCreateMissingColumnFamilies(true);
options.setCreateIfMissing(true);
options.setTargetFileSizeBase(fileSizeBase);
options.setMaxBackgroundFlushes(2);
options.setMaxBackgroundCompactions(2);
options.setCompactionStyle(CompactionStyle.LEVEL);
options.setNumLevels(levelNum);
options.setLevelZeroFileNumCompactionTrigger(compactionTriggerNum);
DBOptions dbOptions = new DBOptions();
dbOptions.setCreateMissingColumnFamilies(true);
dbOptions.setCreateIfMissing(true);
dbOptions.setMaxBackgroundFlushes(2);
dbOptions.setMaxBackgroundCompactions(2);
ColumnFamilyOptions familyOptions = new ColumnFamilyOptions();
familyOptions.setTargetFileSizeBase(fileSizeBase);
familyOptions.setCompactionStyle(CompactionStyle.LEVEL);
familyOptions.setNumLevels(levelNum);
familyOptions.setLevelZeroFileNumCompactionTrigger(compactionTriggerNum);
List<byte[]> families = RocksDB.listColumnFamilies(options, dbPath);
List<ColumnFamilyDescriptor> columnFamilyDescriptors = new ArrayList<>();
if (families != null) {
for (byte[] bytes : families) {
columnFamilyDescriptors.add(new ColumnFamilyDescriptor(bytes, familyOptions));
LOG.info("Load colum family of {}", new String(bytes));
}
}
if (columnFamilyDescriptors.size() > 0) {
db = RocksDB.open(dbOptions, dbPath, columnFamilyDescriptors, columnFamilyHandles);
} else {
db = RocksDB.open(options, dbPath);
}
} catch (RocksDBException e) {
LOG.error("Failed to open db", e);
return;
}
rocksDbTest(db, columnFamilyHandles);
db.close();
}