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


Java DBOptions类代码示例

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


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

示例1: RocksDBKeyedStateBackend2

import org.rocksdb.DBOptions; //导入依赖的package包/类
RocksDBKeyedStateBackend2(
		final String operatorIdentifier,
		final ClassLoader userCodeClassLoader,
		final File instanceBasePath,
		final DBOptions dbOptions,
		final ColumnFamilyOptions columnFamilyOptions,
		final TaskKvStateRegistry kvStateRegistry,
		final TypeSerializer<K> keySerializer,
		final int numberOfKeyGroups,
		final KeyGroupRange keyGroupRange,
		final ExecutionConfig executionConfig) throws Exception {

	super(operatorIdentifier, userCodeClassLoader,
		instanceBasePath,
		dbOptions, columnFamilyOptions, kvStateRegistry, keySerializer,
		numberOfKeyGroups, keyGroupRange, executionConfig, false);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:KVStateRequestSerializerRocksDBTest.java

示例2: init

import org.rocksdb.DBOptions; //导入依赖的package包/类
@Override
public void init() throws StorageException {
    try {
        collections = new ArrayList<>();
        descriptors = new ArrayList<>();

        final File f = new File(dataPath);
        boolean newDB = !f.exists();
        if (newDB) {
            f.mkdirs();
            logger.info("Created database folder : " + dataPath);
            descriptors.add(new ColumnFamilyDescriptor(
                    RocksDB.DEFAULT_COLUMN_FAMILY, new ColumnFamilyOptions()));

        } else {
            final List<byte[]> columns = RocksDB.listColumnFamilies(options, dataPath);
            if (columns != null) {
                for(byte[] column: columns) {
                    descriptors.add(new ColumnFamilyDescriptor(
                                    column, new ColumnFamilyOptions()));
                }
            }

        }

        dbOptions = new DBOptions()
                        .setCreateIfMissing(true);

        db = RocksDB.open(dbOptions, dataPath, descriptors, collections);

    } catch (RocksDBException e) {
        throw new StorageException("Error initialising Storage", e);
    }
}
 
开发者ID:sciodb,项目名称:sciodb,代码行数:35,代码来源:RocksDBEngine.java

示例3: open

import org.rocksdb.DBOptions; //导入依赖的package包/类
public void open() throws RocksDBException {
    if (db != null) throw new IllegalStateException("Database already open");
    storagePath.toFile().mkdirs();
    defaultColumnFamily = addColumnFamily("default", Serdes.stringSerdes()); // must exist

    options = new DBOptions();
    options.setCreateIfMissing(true);
    options.setCreateMissingColumnFamilies(true);
    //options.setBytesPerSync(1024 * 1024);

    List<ColumnFamilyDescriptor> descriptors = new ArrayList<>();
    List<ColumnFamilyHandle> handles = new ArrayList<>();
    List<ColumnFamily<?, ?>> families = new ArrayList<>();
    try {
        for (Map.Entry<String, ColumnFamily<?, ?>> entry : columnFamilies.entrySet()) {
            descriptors.add(new ColumnFamilyDescriptor(entry.getKey().getBytes("UTF-8")));
            families.add(entry.getValue());
        }
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }

    db = RocksDB.open(options, storagePath.toString(), descriptors, handles);
    if (families.size() != handles.size()) {
        throw new IllegalStateException("Unexpected number of column family handles");
    }
    for (int i = 0; i < families.size(); i++) {
        families.get(i).setDBHandle(db, handles.get(i));
    }
    log.info("Opened database {} at path {}", name, storagePath);
}
 
开发者ID:trvedata,项目名称:trvedb,代码行数:32,代码来源:KeyValueStore.java

示例4: testListSerialization

import org.rocksdb.DBOptions; //导入依赖的package包/类
/**
 * Tests list serialization and deserialization match.
 *
 * @see KvStateRequestSerializerTest#testListSerialization()
 * KvStateRequestSerializerTest#testListSerialization() using the heap state back-end
 * test
 */
@Test
public void testListSerialization() throws Exception {
	final long key = 0L;

	// objects for RocksDB state list serialisation
	DBOptions dbOptions = PredefinedOptions.DEFAULT.createDBOptions();
	dbOptions.setCreateIfMissing(true);
	ColumnFamilyOptions columnFamilyOptions = PredefinedOptions.DEFAULT.createColumnOptions();
	final RocksDBKeyedStateBackend2<Long> longHeapKeyedStateBackend =
		new RocksDBKeyedStateBackend2<>(
			"no-op",
			ClassLoader.getSystemClassLoader(),
			temporaryFolder.getRoot(),
			dbOptions,
			columnFamilyOptions,
			mock(TaskKvStateRegistry.class),
			LongSerializer.INSTANCE,
			1, new KeyGroupRange(0, 0),
			new ExecutionConfig()
		);
	longHeapKeyedStateBackend.restore(null);
	longHeapKeyedStateBackend.setCurrentKey(key);

	final InternalListState<VoidNamespace, Long> listState = longHeapKeyedStateBackend
		.createListState(VoidNamespaceSerializer.INSTANCE,
			new ListStateDescriptor<>("test", LongSerializer.INSTANCE));

	KvStateRequestSerializerTest.testListSerialization(key, listState);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:37,代码来源:KVStateRequestSerializerRocksDBTest.java

示例5: testMapSerialization

import org.rocksdb.DBOptions; //导入依赖的package包/类
/**
 * Tests map serialization and deserialization match.
 *
 * @see KvStateRequestSerializerTest#testMapSerialization()
 * KvStateRequestSerializerTest#testMapSerialization() using the heap state back-end
 * test
 */
@Test
public void testMapSerialization() throws Exception {
	final long key = 0L;

	// objects for RocksDB state list serialisation
	DBOptions dbOptions = PredefinedOptions.DEFAULT.createDBOptions();
	dbOptions.setCreateIfMissing(true);
	ColumnFamilyOptions columnFamilyOptions = PredefinedOptions.DEFAULT.createColumnOptions();
	final RocksDBKeyedStateBackend<Long> longHeapKeyedStateBackend =
		new RocksDBKeyedStateBackend<>(
			"no-op",
			ClassLoader.getSystemClassLoader(),
			temporaryFolder.getRoot(),
			dbOptions,
			columnFamilyOptions,
			mock(TaskKvStateRegistry.class),
			LongSerializer.INSTANCE,
			1, new KeyGroupRange(0, 0),
			new ExecutionConfig(),
			false);
	longHeapKeyedStateBackend.restore(null);
	longHeapKeyedStateBackend.setCurrentKey(key);

	final InternalMapState<VoidNamespace, Long, String> mapState = (InternalMapState<VoidNamespace, Long, String>)
			longHeapKeyedStateBackend.getPartitionedState(
					VoidNamespace.INSTANCE,
					VoidNamespaceSerializer.INSTANCE,
					new MapStateDescriptor<>("test", LongSerializer.INSTANCE, StringSerializer.INSTANCE));

	KvStateRequestSerializerTest.testMapSerialization(key, mapState);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:39,代码来源:KVStateRequestSerializerRocksDBTest.java

示例6: getDbOptions

import org.rocksdb.DBOptions; //导入依赖的package包/类
/**
 * Gets the RocksDB {@link DBOptions} to be used for all RocksDB instances.
 */
public DBOptions getDbOptions() {
	// initial options from pre-defined profile
	DBOptions opt = predefinedOptions.createDBOptions();

	// add user-defined options, if specified
	if (optionsFactory != null) {
		opt = optionsFactory.createDBOptions(opt);
	}

	// add necessary default options
	opt = opt.setCreateIfMissing(true);

	return opt;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:RocksDBStateBackend.java

示例7: testCorrectMergeOperatorSet

import org.rocksdb.DBOptions; //导入依赖的package包/类
@Test
public void testCorrectMergeOperatorSet() throws IOException {

	final ColumnFamilyOptions columnFamilyOptions = spy(new ColumnFamilyOptions());
	RocksDBKeyedStateBackend<Integer> test = null;
	try {
		test = new RocksDBKeyedStateBackend<>(
			"test",
			Thread.currentThread().getContextClassLoader(),
			tempFolder.newFolder(),
			mock(DBOptions.class),
			columnFamilyOptions,
			mock(TaskKvStateRegistry.class),
			IntSerializer.INSTANCE,
			1,
			new KeyGroupRange(0, 0),
			new ExecutionConfig(),
			enableIncrementalCheckpointing);

		verify(columnFamilyOptions, Mockito.times(1))
			.setMergeOperatorName(RocksDBKeyedStateBackend.MERGE_OPERATOR_NAME);
	} finally {
		if (test != null) {
			IOUtils.closeQuietly(test);
			test.dispose();
		}
		columnFamilyOptions.close();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:30,代码来源:RocksDBStateBackendTest.java

示例8: testPredefinedOptionsEnum

import org.rocksdb.DBOptions; //导入依赖的package包/类
@Test
public void testPredefinedOptionsEnum() {
	for (PredefinedOptions o : PredefinedOptions.values()) {
		try (DBOptions opt = o.createDBOptions()) {
			assertNotNull(opt);
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:9,代码来源:RocksDBStateBackendConfigTest.java

示例9: testListSerialization

import org.rocksdb.DBOptions; //导入依赖的package包/类
/**
 * Tests list serialization and deserialization match.
 *
 * @see KvStateRequestSerializerTest#testListSerialization()
 * KvStateRequestSerializerTest#testListSerialization() using the heap state back-end
 * test
 */
@Test
public void testListSerialization() throws Exception {
	final long key = 0L;

	// objects for RocksDB state list serialisation
	DBOptions dbOptions = PredefinedOptions.DEFAULT.createDBOptions();
	dbOptions.setCreateIfMissing(true);
	ColumnFamilyOptions columnFamilyOptions = PredefinedOptions.DEFAULT.createColumnOptions();
	final RocksDBKeyedStateBackend2<Long> longHeapKeyedStateBackend =
		new RocksDBKeyedStateBackend2<>(
			"no-op",
			ClassLoader.getSystemClassLoader(),
			temporaryFolder.getRoot(),
			dbOptions,
			columnFamilyOptions,
			mock(TaskKvStateRegistry.class),
			LongSerializer.INSTANCE,
			1, new KeyGroupRange(0, 0),
			new ExecutionConfig()
		);
	longHeapKeyedStateBackend.restore(null);
	longHeapKeyedStateBackend.setCurrentKey(key);

	final InternalListState<VoidNamespace, Long> listState = longHeapKeyedStateBackend
		.createListState(VoidNamespaceSerializer.INSTANCE,
			new ListStateDescriptor<>("test", LongSerializer.INSTANCE));

	KvStateRequestSerializerTest.testListSerialization(key, listState);
	longHeapKeyedStateBackend.dispose();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:38,代码来源:KVStateRequestSerializerRocksDBTest.java

示例10: testMapSerialization

import org.rocksdb.DBOptions; //导入依赖的package包/类
/**
 * Tests map serialization and deserialization match.
 *
 * @see KvStateRequestSerializerTest#testMapSerialization()
 * KvStateRequestSerializerTest#testMapSerialization() using the heap state back-end
 * test
 */
@Test
public void testMapSerialization() throws Exception {
	final long key = 0L;

	// objects for RocksDB state list serialisation
	DBOptions dbOptions = PredefinedOptions.DEFAULT.createDBOptions();
	dbOptions.setCreateIfMissing(true);
	ColumnFamilyOptions columnFamilyOptions = PredefinedOptions.DEFAULT.createColumnOptions();
	final RocksDBKeyedStateBackend<Long> longHeapKeyedStateBackend =
		new RocksDBKeyedStateBackend<>(
			"no-op",
			ClassLoader.getSystemClassLoader(),
			temporaryFolder.getRoot(),
			dbOptions,
			columnFamilyOptions,
			mock(TaskKvStateRegistry.class),
			LongSerializer.INSTANCE,
			1, new KeyGroupRange(0, 0),
			new ExecutionConfig(),
			false);
	longHeapKeyedStateBackend.restore(null);
	longHeapKeyedStateBackend.setCurrentKey(key);

	final InternalMapState<VoidNamespace, Long, String> mapState = (InternalMapState<VoidNamespace, Long, String>)
			longHeapKeyedStateBackend.getPartitionedState(
					VoidNamespace.INSTANCE,
					VoidNamespaceSerializer.INSTANCE,
					new MapStateDescriptor<>("test", LongSerializer.INSTANCE, StringSerializer.INSTANCE));

	KvStateRequestSerializerTest.testMapSerialization(key, mapState);
	longHeapKeyedStateBackend.dispose();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:40,代码来源:KVStateRequestSerializerRocksDBTest.java

示例11: initDb

import org.rocksdb.DBOptions; //导入依赖的package包/类
public void initDb(List<Integer> list) throws Exception {
    LOG.info("Begin to init rocksDB of {}", rootDir);

    DBOptions dbOptions = null;

    List<ColumnFamilyDescriptor> columnFamilyNames = new ArrayList<ColumnFamilyDescriptor>();
    columnFamilyNames.add(new ColumnFamilyDescriptor(RocksDB.DEFAULT_COLUMN_FAMILY));
    for (Integer timeout : list) {
        columnFamilyNames.add(new ColumnFamilyDescriptor(String.valueOf(timeout).getBytes()));
    }

    List<Integer> ttlValues = new ArrayList<Integer>();
    // Default column family with infinite lifetime
    // ATTENSION, the first must be 0, RocksDB.java API has this limitation
    ttlValues.add(0);
    // new column family with list second ttl
    ttlValues.addAll(list);

    try {
        dbOptions = new DBOptions().setCreateMissingColumnFamilies(true).setCreateIfMissing(true);

        List<ColumnFamilyHandle> columnFamilyHandleList = new ArrayList<ColumnFamilyHandle>();

        ttlDB = TtlDB.open(dbOptions, rootDir, columnFamilyNames, columnFamilyHandleList, ttlValues, false);

        for (int i = 0; i < ttlValues.size(); i++) {
            windowHandlers.put(ttlValues.get(i), columnFamilyHandleList.get(i));
        }

        LOG.info("Successfully init rocksDB of {}", rootDir);
    } finally {

        if (dbOptions != null) {
            dbOptions.dispose();
        }
    }
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:38,代码来源:RocksTTLDBCache.java

示例12: buildDbOptions

import org.rocksdb.DBOptions; //导入依赖的package包/类
/**
 * Builds RocksDb DBOptions.
 * 
 * @param maxBackgroundFlushes
 *            high priority threads, usually 1 or 2 would be enough
 * @param maxBackgroundCompactions
 *            low priority threads, between 1 - num_cpu_cores
 * @param maxBackgroundThreads
 *            {@code >= maxBackgroundFlushes, maxBackgroundCompactions}
 * @param maxLogFileSize
 * @return
 */
public static DBOptions buildDbOptions(int maxBackgroundFlushes, int maxBackgroundCompactions,
        int maxBackgroundThreads, long maxLogFileSize) {
    DBOptions dbOptions = new DBOptions();
    dbOptions.setCreateIfMissing(true).setCreateMissingColumnFamilies(true)
            .setErrorIfExists(false);
    dbOptions.setMaxBackgroundFlushes(maxBackgroundFlushes)
            .setMaxBackgroundCompactions(maxBackgroundCompactions)
            .setIncreaseParallelism(maxBackgroundThreads);
    dbOptions.setAllowMmapReads(true).setAllowMmapWrites(true);
    dbOptions.setMaxOpenFiles(-1);
    dbOptions.setKeepLogFileNum(100).setLogFileTimeToRoll(3600)
            .setMaxLogFileSize(maxLogFileSize);
    return dbOptions;
}
 
开发者ID:DDTH,项目名称:ddth-queue,代码行数:27,代码来源:RocksDbUtils.java

示例13: setDbOptions

import org.rocksdb.DBOptions; //导入依赖的package包/类
public RocksDbWrapper setDbOptions(DBOptions dbOptions) {
    if (this.dbOptions != null) {
        RocksDbUtils.closeRocksObjects(this.dbOptions);
    }
    this.dbOptions = dbOptions;
    myOwnDbOptions = false;
    return this;
}
 
开发者ID:DDTH,项目名称:ddth-queue,代码行数:9,代码来源:RocksDbWrapper.java

示例14: main

import org.rocksdb.DBOptions; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    File storageDir = new File("/tmp/rocksdb");
    FileUtils.deleteQuietly(storageDir);
    storageDir.mkdirs();

    DBOptions dbOptions = RocksDbUtils.buildDbOptions().setMaxTotalWalSize(16);

    try (RocksDbWrapper rocksDbWrapper = RocksDbWrapper.openReadWrite(storageDir, dbOptions,
            null, null, null)) {
        System.out.println("ColumnFamilies: " + rocksDbWrapper.getColumnFamilyNames());

        final int NUM_ITEMS = 1000000;

        String cfName = RocksDbWrapper.DEFAULT_COLUMN_FAMILY;
        // ColumnFamilyHandle cfh = rocskDb.getColumnFamilyHandle(cfName);
        long t1 = System.currentTimeMillis();
        for (int i = 0; i < NUM_ITEMS; i++) {
            String key = QueueUtils.IDGEN.generateId128Hex();
            String value = String.valueOf(i + 1);
            rocksDbWrapper.put(cfName, key, value);
        }
        long t2 = System.currentTimeMillis();
        long d = t2 - t1;
        System.out.println("Wrote " + NUM_ITEMS + " in " + d + " ms ("
                + Math.round(NUM_ITEMS * 1000.0 / d) + " items/sec)");

        t1 = System.currentTimeMillis();
        rocksDbWrapper.compactRange();
        System.out.println(
                "Compact Range finished in " + (System.currentTimeMillis() - t1) + "ms");

        System.out.println("Num keys: " + rocksDbWrapper.getEstimateNumKeys("default"));
        System.out.println(rocksDbWrapper.getProperty("default", "rocksdb.stats"));
    }

    try (RocksDbWrapper rocksDbReadonly = RocksDbWrapper.openReadOnly(storageDir)) {
        System.out.println("Num keys: " + rocksDbReadonly.getEstimateNumKeys("default"));
    }
}
 
开发者ID:DDTH,项目名称:ddth-queue,代码行数:40,代码来源:QndRocksDb1milRecords.java

示例15: buildDbOptions

import org.rocksdb.DBOptions; //导入依赖的package包/类
/**
 * Builds RocksDb {@link DBOptions}.
 * 
 * @param maxBackgroundFlushes
 *            high priority threads, usually 1 or 2 would be enough
 * @param maxBackgroundCompactions
 *            low priority threads, between 1 - num_cpu_cores
 * @param maxBackgroundThreads
 *            {@code >= maxBackgroundFlushes, maxBackgroundCompactions}
 * @param maxLogFileSize
 *            if equal to {@code 0}, write all logs to one file and roll by time
 * @return
 */
public static DBOptions buildDbOptions(int maxBackgroundFlushes, int maxBackgroundCompactions,
        int maxBackgroundThreads, long maxLogFileSize) {
    DBOptions dbOptions = new DBOptions();
    dbOptions.setCreateIfMissing(true).setCreateMissingColumnFamilies(true)
            .setErrorIfExists(false);
    dbOptions.setMaxBackgroundFlushes(maxBackgroundFlushes)
            .setMaxBackgroundCompactions(maxBackgroundCompactions)
            .setIncreaseParallelism(maxBackgroundThreads);
    dbOptions.setAllowMmapReads(true).setAllowMmapWrites(true);
    dbOptions.setMaxOpenFiles(-1);
    dbOptions.setKeepLogFileNum(100).setLogFileTimeToRoll(3600)
            .setMaxLogFileSize(maxLogFileSize);
    return dbOptions;
}
 
开发者ID:DDTH,项目名称:ddth-commons,代码行数:28,代码来源:RocksDbUtils.java


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