本文整理汇总了Java中org.rocksdb.RocksDB.loadLibrary方法的典型用法代码示例。如果您正苦于以下问题:Java RocksDB.loadLibrary方法的具体用法?Java RocksDB.loadLibrary怎么用?Java RocksDB.loadLibrary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.rocksdb.RocksDB
的用法示例。
在下文中一共展示了RocksDB.loadLibrary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: StreamStore
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
public StreamStore(String bootstrapServer, String kafkaTopic, int nodeID, int[] partitionToNode) {
RocksDB.loadLibrary();
if (bootstrapServer == null) bootstrapServer = DEFAULT_BOOTSTRAP_SERVER;
Properties consumerConfig = PartitionHandler.consumerConfig();
Properties producerConfig = PartitionHandler.producerConfig();
consumerConfig.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServer);
producerConfig.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServer);
producer = new KafkaProducer<>(producerConfig);
if (kafkaTopic == null) kafkaTopic = DEFAULT_KAFKA_TOPIC;
if (partitionToNode.length != NUM_PARTITIONS) {
throw new IllegalArgumentException("Expected " + NUM_PARTITIONS + " partitions, got " +
partitionToNode.length);
}
this.handlers = new PartitionHandler[NUM_PARTITIONS];
for (int i = 0; i < NUM_PARTITIONS; i++) {
if (partitionToNode[i] == nodeID) {
TopicPartition topicPartition = new TopicPartition(kafkaTopic, i);
this.handlers[i] = new PartitionHandler(topicPartition, consumerConfig, producer);
} else {
throw new UnsupportedOperationException("TODO multi-node support");
}
}
}
示例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: RocksDbKeyValueReader
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
/**
* Construct the <code>RocksDbKeyValueReader</code> with store's name,
* database's path and Samza's config
*
* @param storeName name of the RocksDb defined in the config file
* @param dbPath path to the db directory
* @param config Samza's config
*/
public RocksDbKeyValueReader(String storeName, String dbPath, Config config) {
// get the key serde and value serde from the config
JavaStorageConfig storageConfig = new JavaStorageConfig(config);
JavaSerializerConfig serializerConfig = new JavaSerializerConfig(config);
keySerde = getSerdeFromName(storageConfig.getStorageKeySerde(storeName), serializerConfig);
valueSerde = getSerdeFromName(storageConfig.getStorageMsgSerde(storeName), serializerConfig);
// get db options
ArrayList<TaskName> taskNameList = new ArrayList<TaskName>();
taskNameList.add(new TaskName("read-rocks-db"));
SamzaContainerContext samzaContainerContext =
new SamzaContainerContext("0", config, taskNameList, new MetricsRegistryMap());
Options options = RocksDbOptionsHelper.options(config, samzaContainerContext);
// open the db
RocksDB.loadLibrary();
try {
db = RocksDB.openReadOnly(options, dbPath);
} catch (RocksDBException e) {
throw new SamzaException("can not open the rocksDb in " + dbPath, e);
}
}
示例7: initialize
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
static void initialize() throws Exception {
RocksDB.loadLibrary();
options = new Options().setCreateIfMissing(true);
try {
ensureDirectories();
transientStateDB = RocksDB.open(options, transientPath.toString());
failedStateDB = RocksDB.open(options, failedPath.toString());
} catch (RocksDBException | IOException e) {
e.printStackTrace();
throw new Exception(e);
}
}
示例8: RocksDBEngine
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
public RocksDBEngine(final String dataFolder) {
dataPath = dataFolder;
// loads the RocksDB C++ library
RocksDB.loadLibrary();
options = new Options()
.setCreateIfMissing(true);
}
示例9: setLabelDb
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
public void setLabelDb(String filename) throws RocksDBException {
if (label_db != null)
label_db.close();
else
RocksDB.loadLibrary();
Options rockopts = new Options().setCreateIfMissing(false);
label_db = RocksDB.open(rockopts, filename);
}
示例10: 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);
}
}
示例11: RocksDBCacheFactory
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
/**
* Creates a new instance of the RocksDBCacheFactory class.
*
* @param config The configuration to use.
*/
public RocksDBCacheFactory(RocksDBConfig config) {
Preconditions.checkNotNull(config, "config");
this.config = config;
this.caches = new HashMap<>();
this.closed = new AtomicBoolean();
RocksDB.loadLibrary();
log.info("{}: Initialized.", LOG_ID);
}
示例12: RocksDBNormalizerModel
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
RocksDBNormalizerModel(Path dbPath) {
RocksDB.loadLibrary();
try {
db = RocksDB.openReadOnly(dbPath.toString());
} catch (RocksDBException e) {
throw new RuntimeException(e);
}
}
示例13: createSuffixDataStore
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
@Override
public SuffixDataStore createSuffixDataStore(int id) {
RocksDB.loadLibrary();
try (Options options = new Options().setCreateIfMissing(true).prepareForBulkLoad()) {
Files.createDirectories(dbPath);
RocksDB rocksDB = RocksDB.open(options, dbPath.resolve(getSuffixesName(id)).toString());
rocksDBS.add(rocksDB);
return new RocksDbSuffixDataStore(rocksDB);
} catch (RocksDBException | IOException e) {
throw new RuntimeException(e);
}
}
示例14: createKnownWordsDataStore
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
@Override
public KnownWordsDataStore createKnownWordsDataStore(int id) {
RocksDB.loadLibrary();
try (Options options = new Options().setCreateIfMissing(true).prepareForBulkLoad()) {
Files.createDirectories(dbPath);
RocksDB rocksDB = RocksDB.open(options, dbPath.resolve(getWordsName(id)).toString());
rocksDBS.add(rocksDB);
RocksDB candidatesDB = RocksDB.open(options, dbPath.resolve(getCandidatesName(id)).toString());
rocksDBS.add(candidatesDB);
return new RocksDbKnownWordsDataStore(rocksDB, candidatesDB);
} catch (RocksDBException | IOException e) {
throw new RuntimeException(e);
}
}
示例15: RocksDbIdentifiers
import org.rocksdb.RocksDB; //导入方法依赖的package包/类
public RocksDbIdentifiers(Path identifiersPath) {
RocksDB.loadLibrary();
try {
indices = RocksDB.openReadOnly(identifiersPath.toString());
} catch (RocksDBException e) {
// says "if error happens in underlying native library", can't possible hope to handle that.
throw new RuntimeException(e);
}
}