/** * Similar to {@link RocksDB#get(byte[])} but will only * read the key from this batch. * * @param options The database options to use * @param key The key to read the value for * * @return a byte array storing the value associated with the input key if * any. null if it does not find the specified key. * * @throws RocksDBException if the batch does not have enough data to resolve * Merge operations, MergeInProgress status may be returned. */ public byte[] getFromBatch(final DBOptions options, final byte[] key) throws RocksDBException { return getFromBatch(nativeHandle_, options.nativeHandle_, key, key.length); }
public Map<NodeId, DAGNode> getAll(Set<NodeId> nodeIds) { if (nodeIds.isEmpty()) { return ImmutableMap.of(); } Map<NodeId, DAGNode> res = new HashMap<>(); lock.readLock().lock(); try { for (NodeId id : nodeIds) { byte[] key = toKey(id); byte[] val; if (_db == null) { val = batch.getFromBatch(batchOptions, key); } else { val = batch.getFromBatchAndDB(db(), readOptions, key); } Preconditions.checkState(val != null); DAGNode node = decode(val); res.put(id, node); } } catch (RocksDBException e) { throw new RuntimeException(e); } finally { lock.readLock().unlock(); } return res; }
/** * Similar to {@link RocksDB#get(ColumnFamilyHandle, byte[])} but will only * read the key from this batch. * * @param columnFamilyHandle The column family to retrieve the value from * @param options The database options to use * @param key The key to read the value for * * @return a byte array storing the value associated with the input key if * any. null if it does not find the specified key. * * @throws RocksDBException if the batch does not have enough data to resolve * Merge operations, MergeInProgress status may be returned. */ public byte[] getFromBatch(final ColumnFamilyHandle columnFamilyHandle, final DBOptions options, final byte[] key) throws RocksDBException { return getFromBatch(nativeHandle_, options.nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_); }
@Nullable private DAG getInternal(TreeId id, final byte[] key) { DAG dag = null; try { byte[] value = batch.getFromBatch(batchOptions, key); if (value == null && _db != null) { value = _db.get(readOptions, key); } if (null != value) { dag = decode(id, value); } } catch (Exception e) { throw new RuntimeException(e); } return dag; }