@Override public Iterator<Block> iterator() { RocksIterator iter = mDb.newIterator(mBlockMetaColumn, new ReadOptions().setPrefixSameAsStart(true)); iter.seekToFirst(); return new Iterator<Block>() { @Override public boolean hasNext() { return iter.isValid(); } @Override public Block next() { try { return new Block(Longs.fromByteArray(iter.key()), BlockMeta.parseFrom(iter.value())); } catch (Exception e) { throw new RuntimeException(e); } finally { iter.next(); } } }; }
@Override public List<BlockLocation> getLocations(long id) { RocksIterator iter = mDb.newIterator(mBlockLocationsColumn, new ReadOptions().setPrefixSameAsStart(true)); iter.seek(Longs.toByteArray(id)); List<BlockLocation> locations = new ArrayList<>(); for (; iter.isValid(); iter.next()) { try { locations.add(BlockLocation.parseFrom(iter.value())); } catch (Exception e) { throw new RuntimeException(e); } } return locations; }
/** * Creates and initializes a rocks block store. * * @param args inode store arguments */ public RocksInodeStore(InodeStoreArgs args) { mConf = args.getConf(); mBaseDir = mConf.get(PropertyKey.MASTER_METASTORE_DIR); RocksDB.loadLibrary(); mDisableWAL = new WriteOptions().setDisableWAL(true); mReadPrefixSameAsStart = new ReadOptions().setPrefixSameAsStart(true); try { initDb(); } catch (RocksDBException e) { throw new RuntimeException(e); } }
readOpts = readOpts.setPrefixSameAsStart(true) .setVerifyChecksums(false);
/** * Scan records by key prefix from a table */ @Override public BackendColumnIterator scan(String table, byte[] prefix) { assert !this.hasChanges(); ReadOptions options = new ReadOptions(); // NOTE: Options.prefix_extractor is a prerequisite options.setPrefixSameAsStart(true); RocksIterator itor = rocksdb().newIterator(cf(table), options); return new ColumnIterator(table, itor, prefix, null, SCAN_PREFIX_WITH_BEGIN); }
@Override public RocksDbReadOptions setPrefixSameAsStart(boolean prefixSameAsStart) { super.setPrefixSameAsStart(prefixSameAsStart); return this; }
/** * Enforce that the iterator only iterates over the same prefix as the seek. * This option is effective only for prefix seeks, i.e. prefix_extractor is * non-null for the column family and {@link #totalOrderSeek()} is false. * Unlike iterate_upper_bound, {@link #setPrefixSameAsStart(boolean)} only * works within a prefix but in both directions. * * @param prefixSameAsStart if true, then the iterator only iterates over the * same prefix as the seek * @return the reference to the current ReadOptions. */ public ReadOptions setPrefixSameAsStart(final boolean prefixSameAsStart) { assert(isOwningHandle()); setPrefixSameAsStart(nativeHandle_, prefixSameAsStart); return this; }
private CloseableIterator<GeoWaveMetadata> prefixIterator(final byte[] prefix) { final ReadOptions options = new ReadOptions().setPrefixSameAsStart(true); final RocksIterator it = db.newIterator(options); it.seek(prefix); return new RocksDBMetadataIterator(options, it, requiresTimestamp, visibilityEnabled); }
/** * Scan records by key prefix from a table */ @Override public BackendColumnIterator scan(String table, byte[] prefix) { assert !this.hasChanges(); ReadOptions options = new ReadOptions(); // NOTE: Options.prefix_extractor is a prerequisite options.setPrefixSameAsStart(true); RocksIterator itor = rocksdb().newIterator(cf(table), options); return new ColumnIterator(table, itor, prefix, null, SCAN_PREFIX_WITH_BEGIN); }