use of org.rocksdb.Slice in project alluxio by Alluxio.
the class RocksBlockStore method getLocations.
@Override
public List<BlockLocation> getLocations(long id) {
byte[] startKey = RocksUtils.toByteArray(id, 0);
byte[] endKey = RocksUtils.toByteArray(id, Long.MAX_VALUE);
// Ref: https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html
try (final Slice slice = new Slice(endKey);
final ReadOptions readOptions = new ReadOptions().setIterateUpperBound(slice);
final RocksIterator iter = db().newIterator(mBlockLocationsColumn.get(), readOptions)) {
iter.seek(startKey);
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;
}
}
Aggregations