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

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

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

RocksDB.getDefaultColumnFamily介绍

[英]Gets the handle for the default column family
[中]获取默认列族的句柄

代码示例

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

  1. public static RocksDB createWithColumnFamily(Map conf, String rocksDbDir, final Map<String, ColumnFamilyHandle> columnFamilyHandleMap, int ttlTimeSec) throws IOException {
  2. List<ColumnFamilyDescriptor> columnFamilyDescriptors = getExistingColumnFamilyDesc(conf, rocksDbDir);
  3. List<ColumnFamilyHandle> columnFamilyHandles = new ArrayList<>();
  4. DBOptions dbOptions = getDBOptions(conf);
  5. try {
  6. RocksDB rocksDb = ttlTimeSec > 0 ? TtlDB.open(
  7. dbOptions, rocksDbDir, columnFamilyDescriptors, columnFamilyHandles, getTtlValues(ttlTimeSec, columnFamilyDescriptors), false) :
  8. RocksDB.open(dbOptions, rocksDbDir, columnFamilyDescriptors, columnFamilyHandles);
  9. int n = Math.min(columnFamilyDescriptors.size(), columnFamilyHandles.size());
  10. // skip default column
  11. columnFamilyHandleMap.put(DEFAULT_COLUMN_FAMILY, rocksDb.getDefaultColumnFamily());
  12. for (int i = 1; i < n; i++) {
  13. ColumnFamilyDescriptor descriptor = columnFamilyDescriptors.get(i);
  14. columnFamilyHandleMap.put(new String(descriptor.columnFamilyName()), columnFamilyHandles.get(i));
  15. }
  16. LOG.info("Finished loading RocksDB with existing column family={}, dbPath={}, ttlSec={}",
  17. columnFamilyHandleMap.keySet(), rocksDbDir, ttlTimeSec);
  18. // enable compaction
  19. rocksDb.compactRange();
  20. return rocksDb;
  21. } catch (RocksDBException e) {
  22. throw new IOException("Failed to initialize RocksDb.", e);
  23. }
  24. }

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

  1. private StoreMetadataManagerImpl() {
  2. metadataStore = new RocksDBStore(DEFAULT, null /* dropping and creating default is not supported */,
  3. db.getDefaultColumnFamily(), db, stripeCount);
  4. }

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

  1. /**
  2. * Provides Read-Your-Own-Writes like functionality by
  3. * creating a new Iterator that will use {@link org.rocksdb.WBWIRocksIterator}
  4. * as a delta and baseIterator as a base. Operates on the default column
  5. * family.
  6. *
  7. * @param baseIterator The base iterator,
  8. * e.g. {@link org.rocksdb.RocksDB#newIterator()}
  9. * @return An iterator which shows a view comprised of both the database
  10. * point-in-timefrom baseIterator and modifications made in this write batch.
  11. */
  12. public RocksIterator newIteratorWithBase(final RocksIterator baseIterator) {
  13. return newIteratorWithBase(baseIterator.parent_.getDefaultColumnFamily(),
  14. baseIterator);
  15. }

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

  1. /**
  2. * ingestExternalFile will load a list of external SST files (1) into the DB
  3. * We will try to find the lowest possible level that the file can fit in, and
  4. * ingest the file into this level (2). A file that have a key range that
  5. * overlap with the memtable key range will require us to Flush the memtable
  6. * first before ingesting the file.
  7. *
  8. * (1) External SST files can be created using {@link SstFileWriter}
  9. * (2) We will try to ingest the files to the lowest possible level
  10. * even if the file compression doesn't match the level compression
  11. *
  12. * @param filePathList The list of files to ingest
  13. * @param ingestExternalFileOptions the options for the ingestion
  14. *
  15. * @throws RocksDBException thrown if error happens in underlying
  16. * native library.
  17. */
  18. public void ingestExternalFile(final List<String> filePathList,
  19. final IngestExternalFileOptions ingestExternalFileOptions)
  20. throws RocksDBException {
  21. ingestExternalFile(nativeHandle_, getDefaultColumnFamily().nativeHandle_,
  22. filePathList.toArray(new String[filePathList.size()]),
  23. filePathList.size(), ingestExternalFileOptions.nativeHandle_);
  24. }

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

  1. /**
  2. * Gets the handle for the default column family
  3. *
  4. * @return The handle of the default column family
  5. */
  6. public ColumnFamilyHandle getDefaultColumnFamily() {
  7. final ColumnFamilyHandle cfHandle = new ColumnFamilyHandle(this,
  8. getDefaultColumnFamily(nativeHandle_));
  9. cfHandle.disOwnNativeHandle();
  10. return cfHandle;
  11. }

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

  1. /**
  2. * Test that {@code ByteStoreManager#start()} waits until RocksDB lock
  3. * is released
  4. */
  5. @Test
  6. public void testConcurrentOpenSleep() throws Exception {
  7. String dbPath = temporaryFolder.newFolder().getAbsolutePath();
  8. try(ByteStoreManager bsm = new ByteStoreManager(dbPath, false)) {
  9. TestThread tt = new TestThread(bsm);
  10. try(RocksDB db = RocksDB.open(new File(dbPath, ByteStoreManager.CATALOG_STORE_NAME).getAbsolutePath());
  11. ColumnFamilyHandle handle = db.getDefaultColumnFamily()) {
  12. tt.start();
  13. tt.ready.countDown();
  14. // Wait for multiple attempts
  15. TimeUnit.MILLISECONDS.sleep(300);
  16. // Lock should still be in place
  17. assertEquals(1, tt.started.getCount());
  18. assertFalse("RocksDB lock didn't work", tt.result.get());
  19. }
  20. // RocksDB is now closed, lock should be freed
  21. tt.started.await();
  22. assertTrue("RocksDB lock not released properly", tt.result.get());
  23. }
  24. }

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

  1. } finally {
  2. ColumnFamilyHandle handle = rocksDBResource.get().getDefaultColumnFamily();
  3. store = new RocksDBStore("test", new ColumnFamilyDescriptor("test".getBytes(UTF_8)), handle, rocksDBResource.get(), 4);

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

  1. void replaySince(final long transactionNumber, ReplayHandler replayHandler) {
  2. try (ReplayHandlerAdapter handler =
  3. new ReplayHandlerAdapter(db.getDefaultColumnFamily().getID(), replayHandler, handleIdToNameMap);
  4. TransactionLogIterator iterator = db.getUpdatesSince(transactionNumber)) {
  5. while (iterator.isValid()) {
  6. iterator.status();
  7. final TransactionLogIterator.BatchResult result = iterator.getBatch(); // requires isValid and status check
  8. LOGGER.debug("Requested sequence number: {}, iterator sequence number: {}",
  9. transactionNumber, result.sequenceNumber());
  10. result.writeBatch()
  11. .iterate(handler);
  12. if (!iterator.isValid()) {
  13. break;
  14. }
  15. iterator.next(); // requires isValid
  16. }
  17. for (String updatedStore : handler.getUpdatedStores()) {
  18. final long latestTransactionNumber = metadataManager.getLatestTransactionNumber();
  19. metadataManager.setLatestTransactionNumber(updatedStore, latestTransactionNumber, latestTransactionNumber);
  20. }
  21. } catch (RocksDBException e) {
  22. throw new DatastoreException(e);
  23. }
  24. }

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

  1. @Before
  2. public void setUpStore() {
  3. ColumnFamilyHandle handle = rocksDBResource.get().getDefaultColumnFamily();
  4. store = new RocksDBStore("test", new ColumnFamilyDescriptor("test".getBytes(UTF_8)), handle, rocksDBResource.get(), 4);
  5. // Making sure test is repeatable
  6. Random random = new Random(42);
  7. for(int i = 0; i < 1 << 16; i++ ) {
  8. store.put(newRandomValue(random), newRandomValue(random));
  9. }
  10. store.put(specialKey, newRandomValue(random));
  11. }

相关文章