org.rocksdb.RocksDB.createColumnFamily()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(11.7k)|赞(0)|评价(0)|浏览(526)

本文整理了Java中org.rocksdb.RocksDB.createColumnFamily方法的一些代码示例,展示了RocksDB.createColumnFamily的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RocksDB.createColumnFamily方法的具体详情如下:
包路径:org.rocksdb.RocksDB
类名称:RocksDB
方法名:createColumnFamily

RocksDB.createColumnFamily介绍

[英]Creates a new column family with the name columnFamilyName and allocates a ColumnFamilyHandle within an internal structure. The ColumnFamilyHandle is automatically disposed with DB disposal.
[中]创建名为columnFamilyName的新列族,并在内部结构中分配ColumnFamilyHandle。ColumnFamilyHandle通过DB Disposition自动处理。

代码示例

代码示例来源:origin: alibaba/jstorm

  1. private synchronized ColumnFamilyHandle getOrCreateColumnFamily(String kvStoreId) throws IOException {
  2. ColumnFamilyHandle columnFamily = columnFamilies.get(kvStoreId);
  3. if (columnFamily == null) {
  4. ColumnFamilyDescriptor columnDescriptor =
  5. new ColumnFamilyDescriptor(kvStoreId.getBytes(), columnOptions);
  6. try {
  7. columnFamily = rocksDB.createColumnFamily(columnDescriptor);
  8. columnFamilies.put(kvStoreId, columnFamily);
  9. } catch (RocksDBException e) {
  10. throw new IOException("Error creating ColumnFamilyHandle.", e);
  11. }
  12. }
  13. return columnFamily;
  14. }

代码示例来源:origin: alibaba/jstorm

  1. private ColumnFamilyHandle getOrCreateColumnFamily(String kvStoreId) throws IOException {
  2. ColumnFamilyHandle columnFamily = columnFamilies.get(kvStoreId);
  3. // TODO: verify existing column family is compatible with the request.
  4. if (columnFamily == null) {
  5. ColumnFamilyDescriptor columnDescriptor =
  6. new ColumnFamilyDescriptor(kvStoreId.getBytes(), columnOptions);
  7. try {
  8. columnFamily = rocksDB.createColumnFamily(columnDescriptor);
  9. columnFamilies.put(kvStoreId, columnFamily);
  10. } catch (RocksDBException e) {
  11. throw new IOException("Error creating ColumnFamilyHandle.", e);
  12. }
  13. }
  14. return columnFamily;
  15. }

代码示例来源:origin: apache/flink

  1. /**
  2. * Creates a column family handle for use with a k/v state.
  3. */
  4. private ColumnFamilyHandle createColumnFamily(String stateName) {
  5. byte[] nameBytes = stateName.getBytes(ConfigConstants.DEFAULT_CHARSET);
  6. Preconditions.checkState(!Arrays.equals(RocksDB.DEFAULT_COLUMN_FAMILY, nameBytes),
  7. "The chosen state name 'default' collides with the name of the default column family!");
  8. ColumnFamilyDescriptor columnDescriptor = new ColumnFamilyDescriptor(nameBytes, columnOptions);
  9. try {
  10. return db.createColumnFamily(columnDescriptor);
  11. } catch (RocksDBException e) {
  12. throw new FlinkRuntimeException("Error creating ColumnFamilyHandle.", e);
  13. }
  14. }

代码示例来源:origin: brianfrankcooper/YCSB

  1. private void createColumnFamily(final String name) throws RocksDBException {
  2. COLUMN_FAMILY_LOCKS.putIfAbsent(name, new ReentrantLock());
  3. final Lock l = COLUMN_FAMILY_LOCKS.get(name);
  4. l.lock();
  5. try {
  6. if(!COLUMN_FAMILIES.containsKey(name)) {
  7. final ColumnFamilyOptions cfOptions = new ColumnFamilyOptions().optimizeLevelStyleCompaction();
  8. final ColumnFamilyHandle cfHandle = rocksDb.createColumnFamily(
  9. new ColumnFamilyDescriptor(name.getBytes(UTF_8), cfOptions)
  10. );
  11. COLUMN_FAMILIES.put(name, new ColumnFamily(cfHandle, cfOptions));
  12. }
  13. } finally {
  14. l.unlock();
  15. }
  16. }

代码示例来源:origin: alibaba/jstorm

  1. handler2 = handlers.get(2);
  2. } else {
  3. handler1 = db.createColumnFamily(new ColumnFamilyDescriptor("test1".getBytes()));
  4. handler2 = db.createColumnFamily(new ColumnFamilyDescriptor("test2".getBytes()));

代码示例来源:origin: apache/flink

  1. private ColumnFamilyHandle getOrRegisterColumnFamilyHandle(
  2. ColumnFamilyDescriptor columnFamilyDescriptor,
  3. ColumnFamilyHandle columnFamilyHandle,
  4. StateMetaInfoSnapshot stateMetaInfoSnapshot) throws RocksDBException {
  5. Tuple2<ColumnFamilyHandle, RegisteredStateMetaInfoBase> registeredStateMetaInfoEntry =
  6. stateBackend.kvStateInformation.get(stateMetaInfoSnapshot.getName());
  7. if (null == registeredStateMetaInfoEntry) {
  8. // create a meta info for the state on restore;
  9. // this allows us to retain the state in future snapshots even if it wasn't accessed
  10. RegisteredStateMetaInfoBase stateMetaInfo =
  11. RegisteredStateMetaInfoBase.fromMetaInfoSnapshot(stateMetaInfoSnapshot);
  12. registeredStateMetaInfoEntry =
  13. new Tuple2<>(
  14. columnFamilyHandle != null ? columnFamilyHandle : stateBackend.db.createColumnFamily(columnFamilyDescriptor),
  15. stateMetaInfo);
  16. stateBackend.registerKvStateInformation(
  17. stateMetaInfoSnapshot.getName(),
  18. registeredStateMetaInfoEntry);
  19. }
  20. return registeredStateMetaInfoEntry.f0;
  21. }

代码示例来源:origin: voldemort/voldemort

  1. @Override
  2. public void truncate() {
  3. try {
  4. rocksDB.dropColumnFamily(storeHandle);
  5. storeHandle.dispose();
  6. storeHandle = rocksDB.createColumnFamily(new ColumnFamilyDescriptor(getName().getBytes(), storeOptions));
  7. } catch (RocksDBException e) {
  8. throw new VoldemortException("Failed to truncate DB", e);
  9. }
  10. }

代码示例来源:origin: apache/flink

  1. rocksDBKeyedStateBackend.columnOptions);
  2. ColumnFamilyHandle columnFamily = rocksDBKeyedStateBackend.db.createColumnFamily(columnFamilyDescriptor);

代码示例来源:origin: hugegraph/hugegraph

  1. @Override
  2. public void createTable(String table) throws RocksDBException {
  3. if (this.cfs.containsKey(table)) {
  4. return;
  5. }
  6. this.checkValid();
  7. // Should we use options.setCreateMissingColumnFamilies() to create CF
  8. ColumnFamilyDescriptor cfd = new ColumnFamilyDescriptor(encode(table));
  9. ColumnFamilyOptions options = cfd.columnFamilyOptions();
  10. initOptions(this.conf, null, options, options);
  11. this.cfs.put(table, this.rocksdb.createColumnFamily(cfd));
  12. ingestExternalFile();
  13. }

代码示例来源:origin: com.palantir.atlasdb/atlasdb-rocksdb

  1. public synchronized void create(String tableName) throws RocksDBException {
  2. ColumnFamily cf = cfs.get(tableName);
  3. if (cf == null) {
  4. ColumnFamilyDescriptor descriptor = cfFactory.apply(tableName);
  5. ColumnFamilyHandle handle = db.createColumnFamily(descriptor);
  6. cfs.put(tableName, new ColumnFamily(0, handle));
  7. }
  8. }

代码示例来源:origin: jwplayer/southpaw

  1. protected void createKeySpace(ByteArray handleName) {
  2. ColumnFamilyDescriptor cfDescriptor = new ColumnFamilyDescriptor(handleName.getBytes());
  3. ColumnFamilyHandle cfHandle;
  4. try {
  5. cfHandle = this.rocksDB.createColumnFamily(cfDescriptor);
  6. } catch (RocksDBException ex) {
  7. throw new RuntimeException(ex);
  8. }
  9. cfHandles.put(handleName, cfHandle);
  10. dataBatches.put(handleName, new HashMap<>());
  11. }

代码示例来源:origin: com.palantir.atlasdb/atlasdb-rocksdb

  1. public synchronized void truncate(String tableName) throws InterruptedException, RocksDBException {
  2. ColumnFamily oldCf = cfs.get(tableName);
  3. if (oldCf == null) {
  4. throw new IllegalArgumentException("Table " + tableName + " does not exist.");
  5. }
  6. long newIndex = (oldCf.index + 1) % 2;
  7. String realTableName = String.format("%s__%d", tableName, newIndex);
  8. ColumnFamilyDescriptor descriptor = cfFactory.apply(realTableName);
  9. ColumnFamilyHandle handle = db.createColumnFamily(descriptor);
  10. cfs.put(tableName, new ColumnFamily(newIndex, handle));
  11. while (oldCf.refCount.get() > 0) {
  12. Thread.sleep(10);
  13. }
  14. db.dropColumnFamily(oldCf.handle);
  15. oldCf.handle.dispose();
  16. }
  17. }

代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb_2.11

  1. /**
  2. * Creates a column family handle for use with a k/v state.
  3. */
  4. private ColumnFamilyHandle createColumnFamily(String stateName) {
  5. byte[] nameBytes = stateName.getBytes(ConfigConstants.DEFAULT_CHARSET);
  6. Preconditions.checkState(!Arrays.equals(RocksDB.DEFAULT_COLUMN_FAMILY, nameBytes),
  7. "The chosen state name 'default' collides with the name of the default column family!");
  8. ColumnFamilyDescriptor columnDescriptor = new ColumnFamilyDescriptor(nameBytes, columnOptions);
  9. try {
  10. return db.createColumnFamily(columnDescriptor);
  11. } catch (RocksDBException e) {
  12. throw new FlinkRuntimeException("Error creating ColumnFamilyHandle.", e);
  13. }
  14. }

代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb

  1. /**
  2. * Creates a column family handle for use with a k/v state.
  3. */
  4. private ColumnFamilyHandle createColumnFamily(String stateName) {
  5. byte[] nameBytes = stateName.getBytes(ConfigConstants.DEFAULT_CHARSET);
  6. Preconditions.checkState(!Arrays.equals(RocksDB.DEFAULT_COLUMN_FAMILY, nameBytes),
  7. "The chosen state name 'default' collides with the name of the default column family!");
  8. ColumnFamilyDescriptor columnDescriptor = new ColumnFamilyDescriptor(nameBytes, columnOptions);
  9. try {
  10. return db.createColumnFamily(columnDescriptor);
  11. } catch (RocksDBException e) {
  12. throw new FlinkRuntimeException("Error creating ColumnFamilyHandle.", e);
  13. }
  14. }

代码示例来源:origin: dremio/dremio-oss

  1. private ByteStore newStore(String name) throws RocksDBException {
  2. if (inMemory) {
  3. return new MapStore(name);
  4. } else {
  5. final ColumnFamilyDescriptor columnFamilyDescriptor = new ColumnFamilyDescriptor(name.getBytes(UTF_8));
  6. ColumnFamilyHandle handle = db.createColumnFamily(columnFamilyDescriptor);
  7. handleIdToNameMap.put(handle.getID(), name);
  8. metadataManager.createEntry(name, false);
  9. return new RocksDBStore(name, columnFamilyDescriptor, handle, db, stripeCount);
  10. }
  11. }

代码示例来源:origin: com.baidu.hugegraph/hugegraph-rocksdb

  1. @Override
  2. public void createTable(String table) throws RocksDBException {
  3. if (this.cfs.containsKey(table)) {
  4. return;
  5. }
  6. this.checkValid();
  7. // Should we use options.setCreateMissingColumnFamilies() to create CF
  8. ColumnFamilyDescriptor cfd = new ColumnFamilyDescriptor(encode(table));
  9. ColumnFamilyOptions options = cfd.columnFamilyOptions();
  10. initOptions(this.conf, null, options, options);
  11. this.cfs.put(table, this.rocksdb.createColumnFamily(cfd));
  12. ingestExternalFile();
  13. }

代码示例来源:origin: org.rocksdb/rocksdbjni

  1. /**
  2. * Creates a new column family with the name columnFamilyName and
  3. * allocates a ColumnFamilyHandle within an internal structure.
  4. * The ColumnFamilyHandle is automatically disposed with DB disposal.
  5. *
  6. * @param columnFamilyDescriptor column family to be created.
  7. * @return {@link org.rocksdb.ColumnFamilyHandle} instance.
  8. *
  9. * @throws RocksDBException thrown if error happens in underlying
  10. * native library.
  11. */
  12. public ColumnFamilyHandle createColumnFamily(
  13. final ColumnFamilyDescriptor columnFamilyDescriptor)
  14. throws RocksDBException {
  15. return new ColumnFamilyHandle(this, createColumnFamily(nativeHandle_,
  16. columnFamilyDescriptor.columnFamilyName(),
  17. columnFamilyDescriptor.columnFamilyOptions().nativeHandle_));
  18. }

代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb_2.11

  1. private ColumnFamilyHandle getOrRegisterColumnFamilyHandle(
  2. ColumnFamilyDescriptor columnFamilyDescriptor,
  3. ColumnFamilyHandle columnFamilyHandle,
  4. StateMetaInfoSnapshot stateMetaInfoSnapshot) throws RocksDBException {
  5. Tuple2<ColumnFamilyHandle, RegisteredStateMetaInfoBase> registeredStateMetaInfoEntry =
  6. stateBackend.kvStateInformation.get(stateMetaInfoSnapshot.getName());
  7. if (null == registeredStateMetaInfoEntry) {
  8. // create a meta info for the state on restore;
  9. // this allows us to retain the state in future snapshots even if it wasn't accessed
  10. RegisteredStateMetaInfoBase stateMetaInfo =
  11. RegisteredStateMetaInfoBase.fromMetaInfoSnapshot(stateMetaInfoSnapshot);
  12. registeredStateMetaInfoEntry =
  13. new Tuple2<>(
  14. columnFamilyHandle != null ? columnFamilyHandle : stateBackend.db.createColumnFamily(columnFamilyDescriptor),
  15. stateMetaInfo);
  16. stateBackend.registerKvStateInformation(
  17. stateMetaInfoSnapshot.getName(),
  18. registeredStateMetaInfoEntry);
  19. }
  20. return registeredStateMetaInfoEntry.f0;
  21. }

代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb

  1. private ColumnFamilyHandle getOrRegisterColumnFamilyHandle(
  2. ColumnFamilyDescriptor columnFamilyDescriptor,
  3. ColumnFamilyHandle columnFamilyHandle,
  4. StateMetaInfoSnapshot stateMetaInfoSnapshot) throws RocksDBException {
  5. Tuple2<ColumnFamilyHandle, RegisteredStateMetaInfoBase> registeredStateMetaInfoEntry =
  6. stateBackend.kvStateInformation.get(stateMetaInfoSnapshot.getName());
  7. if (null == registeredStateMetaInfoEntry) {
  8. // create a meta info for the state on restore;
  9. // this allows us to retain the state in future snapshots even if it wasn't accessed
  10. RegisteredStateMetaInfoBase stateMetaInfo =
  11. RegisteredStateMetaInfoBase.fromMetaInfoSnapshot(stateMetaInfoSnapshot);
  12. registeredStateMetaInfoEntry =
  13. new Tuple2<>(
  14. columnFamilyHandle != null ? columnFamilyHandle : stateBackend.db.createColumnFamily(columnFamilyDescriptor),
  15. stateMetaInfo);
  16. stateBackend.registerKvStateInformation(
  17. stateMetaInfoSnapshot.getName(),
  18. registeredStateMetaInfoEntry);
  19. }
  20. return registeredStateMetaInfoEntry.f0;
  21. }

代码示例来源:origin: dremio/dremio-oss

  1. @Override
  2. @VisibleForTesting
  3. public void deleteAllValues() throws IOException {
  4. exclusively((deferred) -> {
  5. synchronized(this) {
  6. deleteAllIterators(deferred);
  7. try {
  8. db.dropColumnFamily(handle);
  9. } catch(RocksDBException ex) {
  10. deferred.addException(ex);
  11. }
  12. deferred.suppressingClose(handle);
  13. try {
  14. this.handle = db.createColumnFamily(family);
  15. } catch (Exception ex) {
  16. deferred.addException(ex);
  17. }
  18. }
  19. });
  20. }

相关文章