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


Java Options类代码示例

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


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

示例1: main

import org.rocksdb.Options; //导入依赖的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);
    }
}
 
开发者ID:isoboroff,项目名称:basekb-search,代码行数:22,代码来源:DumpLabelDb.java

示例2: main

import org.rocksdb.Options; //导入依赖的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);
    }
}
 
开发者ID:isoboroff,项目名称:basekb-search,代码行数:18,代码来源:QueryLabelDb.java

示例3: RocksDbKeyValueReader

import org.rocksdb.Options; //导入依赖的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: buildOptions

import org.rocksdb.Options; //导入依赖的package包/类
/**
 * Builds RocksDb Options.
 * 
 * @param maxBackgroundThreads
 * @param levelZeloFileNumCompactionTrigger
 * @param writeBufferSize
 * @param targetFileSizeBase
 * @return
 */
public static Options buildOptions(int maxBackgroundThreads,
        int levelZeloFileNumCompactionTrigger, long writeBufferSize, long targetFileSizeBase) {
    Options rocksOptions = new Options();
    rocksOptions.setCreateIfMissing(true).getEnv().setBackgroundThreads(1, Env.FLUSH_POOL)
            .setBackgroundThreads(maxBackgroundThreads, Env.COMPACTION_POOL);
    rocksOptions.setMaxBackgroundFlushes(1).setMaxBackgroundCompactions(maxBackgroundThreads);
    rocksOptions.setWriteBufferSize(writeBufferSize).setMinWriteBufferNumberToMerge(2)
            .setLevelZeroFileNumCompactionTrigger(levelZeloFileNumCompactionTrigger)
            .setTargetFileSizeBase(targetFileSizeBase);

    rocksOptions.setMemTableConfig(new SkipListMemTableConfig());
    // rocksOptions.setMemTableConfig(new HashSkipListMemTableConfig());
    // rocksOptions.setMemTableConfig(new HashLinkedListMemTableConfig());

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

示例5: EzRocksDbTable

import org.rocksdb.Options; //导入依赖的package包/类
public EzRocksDbTable(File path, EzRocksDbFactory factory,
		Serde<H> hashKeySerde, Serde<R> rangeKeySerde, Serde<V> valueSerde,
		Comparator<byte[]> hashKeyComparator,
		Comparator<byte[]> rangeKeyComparator) {
	this.hashKeySerde = hashKeySerde;
	this.rangeKeySerde = rangeKeySerde;
	this.valueSerde = valueSerde;
	this.hashKeyComparator = hashKeyComparator;
	this.rangeKeyComparator = rangeKeyComparator;

	this.options = new Options();

	options.setCreateIfMissing(true);
	options.setComparator(new EzRocksDbComparator(hashKeyComparator,
			rangeKeyComparator));

	try {
		this.db = factory.open(path, options);
	} catch (IOException e) {
		throw new DbException(e);
	}
}
 
开发者ID:criccomini,项目名称:ezdb,代码行数:23,代码来源:EzRocksDbTable.java

示例6: buildOptions

import org.rocksdb.Options; //导入依赖的package包/类
/**
 * Builds RocksDb {@link Options}.
 * 
 * @param maxBackgroundThreads
 * @param levelZeloFileNumCompactionTrigger
 * @param writeBufferSize
 * @param targetFileSizeBase
 * @return
 */
public static Options buildOptions(int maxBackgroundThreads,
        int levelZeloFileNumCompactionTrigger, long writeBufferSize, long targetFileSizeBase) {
    Options rocksOptions = new Options();
    rocksOptions.setCreateIfMissing(true).getEnv().setBackgroundThreads(1, Env.FLUSH_POOL)
            .setBackgroundThreads(maxBackgroundThreads, Env.COMPACTION_POOL);
    rocksOptions.setMaxBackgroundFlushes(1).setMaxBackgroundCompactions(maxBackgroundThreads);
    rocksOptions.setWriteBufferSize(writeBufferSize).setMinWriteBufferNumberToMerge(2)
            .setLevelZeroFileNumCompactionTrigger(levelZeloFileNumCompactionTrigger)
            .setTargetFileSizeBase(targetFileSizeBase);

    rocksOptions.setMemTableConfig(new SkipListMemTableConfig());
    // rocksOptions.setMemTableConfig(new HashSkipListMemTableConfig());
    // rocksOptions.setMemTableConfig(new HashLinkedListMemTableConfig());

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

示例7: openDB

import org.rocksdb.Options; //导入依赖的package包/类
private RocksDB openDB(File dir, Options options, int ttl) throws IOException {
    try {
        if (ttl == TTL_NOT_USED) {
            Files.createDirectories(dir.getParentFile().toPath());
            return RocksDB.open(options, dir.getAbsolutePath());
        } else {
            throw new UnsupportedOperationException("Change log is not supported for store " + this.name + " since it is TTL based.");
            // TODO: support TTL with change log?
            // return TtlDB.open(options, dir.toString(), ttl, false);
        }
    } catch (RocksDBException e) {
        throw new ProcessorStateException("Error opening store " + this.name + " at location " + dir.toString(), e);
    }
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:15,代码来源:RocksDBStore.java

示例8: initialize

import org.rocksdb.Options; //导入依赖的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);
    }
}
 
开发者ID:apsaltis,项目名称:StreamingData-Book-Examples,代码行数:14,代码来源:HybridMessageLogger.java

示例9: RocksDBEngine

import org.rocksdb.Options; //导入依赖的package包/类
public RocksDBEngine(final String dataFolder) {
    dataPath = dataFolder;

    // loads the RocksDB C++ library
    RocksDB.loadLibrary();
    options = new Options()
            .setCreateIfMissing(true);
}
 
开发者ID:sciodb,项目名称:sciodb,代码行数:9,代码来源:RocksDBEngine.java

示例10: setLabelDb

import org.rocksdb.Options; //导入依赖的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);
}
 
开发者ID:isoboroff,项目名称:basekb-search,代码行数:9,代码来源:FreebaseSearcher.java

示例11: main

import org.rocksdb.Options; //导入依赖的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);
    }
}
 
开发者ID:isoboroff,项目名称:basekb-search,代码行数:32,代码来源:BuildLabelDb.java

示例12: createDatabaseOptions

import org.rocksdb.Options; //导入依赖的package包/类
private Options createDatabaseOptions() {
    return new Options()
            .setCreateIfMissing(true)
            .setDbLogDir(Paths.get(this.dbDir, DB_LOG_DIR).toString())
            .setWalDir(Paths.get(this.dbDir, DB_WRITE_AHEAD_LOG_DIR).toString())
            .setWalTtlSeconds(0)
            .setWalSizeLimitMB(MAX_WRITE_AHEAD_LOG_SIZE_MB);
}
 
开发者ID:pravega,项目名称:pravega,代码行数:9,代码来源:RocksDBCache.java

示例13: createSuffixDataStore

import org.rocksdb.Options; //导入依赖的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);
  }
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:14,代码来源:RocksDbDataStoreFactory.java

示例14: createKnownWordsDataStore

import org.rocksdb.Options; //导入依赖的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);
  }
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:16,代码来源:RocksDbDataStoreFactory.java

示例15: createRocksDb

import org.rocksdb.Options; //导入依赖的package包/类
@BeforeClass
static public void createRocksDb() throws IOException, RocksDBException {
  if (Files.exists(dirPath)) {
    removeRecursiveDirectory(dirPath);
  }
  Files.createDirectories(dirPath);
  Options options = new Options().setCreateIfMissing(true);
  db = RocksDB.open(options, dirPath.toString());
  db.put("testString".getBytes(), "this is string".getBytes());
  db.put(ByteBuffer.allocate(4).putInt(123).array(), ByteBuffer.allocate(4).putInt(456).array());
}
 
开发者ID:apache,项目名称:samza,代码行数:12,代码来源:TestRocksDbKeyValueReader.java


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