当前位置: 首页>>代码示例>>Java>>正文


Java RocksDB.openReadOnly方法代码示例

本文整理汇总了Java中org.rocksdb.RocksDB.openReadOnly方法的典型用法代码示例。如果您正苦于以下问题:Java RocksDB.openReadOnly方法的具体用法?Java RocksDB.openReadOnly怎么用?Java RocksDB.openReadOnly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.rocksdb.RocksDB的用法示例。


在下文中一共展示了RocksDB.openReadOnly方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
  }
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:21,代码来源:RocksDbDataStoreFactory.java

示例2: 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);
  }
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:27,代码来源:RocksDbDataStoreFactory.java

示例3: 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);
  }
}
 
开发者ID:apache,项目名称:samza,代码行数:32,代码来源:RocksDbKeyValueReader.java

示例4: RocksDBNormalizerModel

import org.rocksdb.RocksDB; //导入方法依赖的package包/类
RocksDBNormalizerModel(Path dbPath) {
  RocksDB.loadLibrary();

  try {
    db = RocksDB.openReadOnly(dbPath.toString());
  } catch (RocksDBException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:10,代码来源:RocksDBNormalizerModel.java

示例5: 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);
  }
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:11,代码来源:RocksDbIdentifiers.java

示例6: RocksDbStrings

import org.rocksdb.RocksDB; //导入方法依赖的package包/类
public RocksDbStrings(Path termsPath) {
  RocksDB.loadLibrary();

  try {
    terms = RocksDB.openReadOnly(termsPath.toString());
  } catch (RocksDBException e) {
    // says "if error happens in underlying native library", can't possible hope to handle that.
    throw new RuntimeException(e);
  }
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:11,代码来源:RocksDbStrings.java

示例7: init

import org.rocksdb.RocksDB; //导入方法依赖的package包/类
public RocksDbWrapper init() throws RocksDBException {
    if (!directory.isDirectory() || !directory.exists()) {
        throw new IllegalArgumentException(directory + " does not exist, or not a directory!");
    }

    prepareColumnFamilyDescriptors();

    if (dbOptions == null) {
        dbOptions = RocksDbUtils.buildDbOptions();
        myOwnDbOptions = true;
    } else {
        myOwnDbOptions = false;
    }

    String path = directory.getAbsolutePath();
    List<ColumnFamilyDescriptor> cfdList = new ArrayList<>(columnFamilies);
    List<ColumnFamilyHandle> cfhList = new ArrayList<>();
    if (readOnly) {
        if (readOptions == null) {
            readOptions = RocksDbUtils.buildReadOptions(true);
            myOwnReadOptions = true;
        } else {
            myOwnReadOptions = false;
        }
        rocksDb = RocksDB.openReadOnly(dbOptions, path, cfdList, cfhList);
    } else {
        if (writeOptions == null) {
            /*
             * As of RocksDB v3.10.1, no data lost if process crashes even
             * if sync==false. Data lost only when server/OS crashes. So
             * it's relatively safe to set sync=false for fast write.
             */
            writeOptions = RocksDbUtils.buildWriteOptions(false, false);
            myOwnWriteOptions = true;
        } else {
            myOwnWriteOptions = false;
        }
        if (readOptions == null) {
            readOptions = RocksDbUtils.buildReadOptions(true);
            myOwnReadOptions = true;
        } else {
            myOwnReadOptions = false;
        }
        rocksDb = RocksDB.open(dbOptions, path, cfdList, cfhList);
    }

    for (int i = 0, n = cfdList.size(); i < n; i++) {
        byte[] cfName = cfdList.get(i).columnFamilyName();
        ColumnFamilyHandle cfh = cfhList.get(i);
        columnFamilyHandles.put(new String(cfName, RocksDbUtils.UTF8), cfh);
    }

    return this;
}
 
开发者ID:DDTH,项目名称:ddth-queue,代码行数:55,代码来源:RocksDbWrapper.java

示例8: init

import org.rocksdb.RocksDB; //导入方法依赖的package包/类
public RocksDbWrapper init() throws IOException, RocksDbException {
    if (!directory.exists() && !readOnly) {
        FileUtils.forceMkdir(directory);
    }
    if (!directory.isDirectory() || !directory.exists()) {
        throw new IllegalArgumentException(directory + " does not exist, or not a directory!");
    }

    prepareColumnFamilyDescriptors();

    if (dbOptions == null) {
        dbOptions = RocksDbUtils.buildDbOptions();
        myOwnDbOptions = true;
    } else {
        myOwnDbOptions = false;
    }

    String path = directory.getAbsolutePath();
    List<ColumnFamilyDescriptor> cfdList = new ArrayList<>(columnFamilies);
    List<ColumnFamilyHandle> cfhList = new ArrayList<>();
    try {
        if (readOnly) {
            if (readOptions == null) {
                readOptions = RocksDbUtils.buildReadOptions(true);
                myOwnReadOptions = true;
            } else {
                myOwnReadOptions = false;
            }
            rocksDb = RocksDB.openReadOnly(dbOptions, path, cfdList, cfhList);
        } else {
            if (writeOptions == null) {
                writeOptions = RocksDbUtils.buildWriteOptions();
                myOwnWriteOptions = true;
            } else {
                myOwnWriteOptions = false;
            }
            if (readOptions == null) {
                readOptions = RocksDbUtils.buildReadOptions(true);
                myOwnReadOptions = true;
            } else {
                myOwnReadOptions = false;
            }
            rocksDb = RocksDB.open(dbOptions, path, cfdList, cfhList);
        }
    } catch (Exception e) {
        throw e instanceof RocksDbException ? (RocksDbException) e : new RocksDbException(e);
    }

    for (int i = 0, n = cfdList.size(); i < n; i++) {
        byte[] cfName = cfdList.get(i).columnFamilyName();
        ColumnFamilyHandle cfh = cfhList.get(i);
        columnFamilyHandles.put(new String(cfName, RocksDbUtils.UTF8), cfh);
    }

    return this;
}
 
开发者ID:DDTH,项目名称:ddth-commons,代码行数:57,代码来源:RocksDbWrapper.java


注:本文中的org.rocksdb.RocksDB.openReadOnly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。