|
|
@ -131,11 +131,36 @@ public class WriteBatchWithIndex extends AbstractWriteBatch { |
|
|
|
public RocksIterator newIteratorWithBase( |
|
|
|
public RocksIterator newIteratorWithBase( |
|
|
|
final ColumnFamilyHandle columnFamilyHandle, |
|
|
|
final ColumnFamilyHandle columnFamilyHandle, |
|
|
|
final RocksIterator baseIterator) { |
|
|
|
final RocksIterator baseIterator) { |
|
|
|
RocksIterator iterator = new RocksIterator(baseIterator.parent_, |
|
|
|
return newIteratorWithBase(columnFamilyHandle, baseIterator, null); |
|
|
|
iteratorWithBase( |
|
|
|
} |
|
|
|
nativeHandle_, columnFamilyHandle.nativeHandle_, baseIterator.nativeHandle_)); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Provides Read-Your-Own-Writes like functionality by |
|
|
|
|
|
|
|
* creating a new Iterator that will use {@link org.rocksdb.WBWIRocksIterator} |
|
|
|
|
|
|
|
* as a delta and baseIterator as a base |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* Updating write batch with the current key of the iterator is not safe. |
|
|
|
|
|
|
|
* We strongly recommand users not to do it. It will invalidate the current |
|
|
|
|
|
|
|
* key() and value() of the iterator. This invalidation happens even before |
|
|
|
|
|
|
|
* the write batch update finishes. The state may recover after Next() is |
|
|
|
|
|
|
|
* called. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param columnFamilyHandle The column family to iterate over |
|
|
|
|
|
|
|
* @param baseIterator The base iterator, |
|
|
|
|
|
|
|
* e.g. {@link org.rocksdb.RocksDB#newIterator()} |
|
|
|
|
|
|
|
* @param readOptions the read options, or null |
|
|
|
|
|
|
|
* @return An iterator which shows a view comprised of both the database |
|
|
|
|
|
|
|
* point-in-time from baseIterator and modifications made in this write batch. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public RocksIterator newIteratorWithBase(final ColumnFamilyHandle columnFamilyHandle, |
|
|
|
|
|
|
|
final RocksIterator baseIterator, /* @Nullable */ final ReadOptions readOptions) { |
|
|
|
|
|
|
|
final RocksIterator iterator = new RocksIterator(baseIterator.parent_, |
|
|
|
|
|
|
|
iteratorWithBase(nativeHandle_, columnFamilyHandle.nativeHandle_, |
|
|
|
|
|
|
|
baseIterator.nativeHandle_, readOptions == null ? 0 : readOptions.nativeHandle_)); |
|
|
|
|
|
|
|
|
|
|
|
// when the iterator is deleted it will also delete the baseIterator
|
|
|
|
// when the iterator is deleted it will also delete the baseIterator
|
|
|
|
baseIterator.disOwnNativeHandle(); |
|
|
|
baseIterator.disOwnNativeHandle(); |
|
|
|
|
|
|
|
|
|
|
|
return iterator; |
|
|
|
return iterator; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -151,7 +176,25 @@ public class WriteBatchWithIndex extends AbstractWriteBatch { |
|
|
|
* point-in-timefrom baseIterator and modifications made in this write batch. |
|
|
|
* point-in-timefrom baseIterator and modifications made in this write batch. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public RocksIterator newIteratorWithBase(final RocksIterator baseIterator) { |
|
|
|
public RocksIterator newIteratorWithBase(final RocksIterator baseIterator) { |
|
|
|
return newIteratorWithBase(baseIterator.parent_.getDefaultColumnFamily(), baseIterator); |
|
|
|
return newIteratorWithBase(baseIterator.parent_.getDefaultColumnFamily(), baseIterator, null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Provides Read-Your-Own-Writes like functionality by |
|
|
|
|
|
|
|
* creating a new Iterator that will use {@link org.rocksdb.WBWIRocksIterator} |
|
|
|
|
|
|
|
* as a delta and baseIterator as a base. Operates on the default column |
|
|
|
|
|
|
|
* family. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param baseIterator The base iterator, |
|
|
|
|
|
|
|
* e.g. {@link org.rocksdb.RocksDB#newIterator()} |
|
|
|
|
|
|
|
* @param readOptions the read options, or null |
|
|
|
|
|
|
|
* @return An iterator which shows a view comprised of both the database |
|
|
|
|
|
|
|
* point-in-timefrom baseIterator and modifications made in this write batch. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public RocksIterator newIteratorWithBase(final RocksIterator baseIterator, |
|
|
|
|
|
|
|
/* @Nullable */ final ReadOptions readOptions) { |
|
|
|
|
|
|
|
return newIteratorWithBase( |
|
|
|
|
|
|
|
baseIterator.parent_.getDefaultColumnFamily(), baseIterator, readOptions); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -200,7 +243,7 @@ public class WriteBatchWithIndex extends AbstractWriteBatch { |
|
|
|
* the results using the DB's merge operator (if the batch contains any |
|
|
|
* the results using the DB's merge operator (if the batch contains any |
|
|
|
* merge requests). |
|
|
|
* merge requests). |
|
|
|
* |
|
|
|
* |
|
|
|
* Setting {@link ReadOptions#setSnapshot(long, long)} will affect what is |
|
|
|
* Setting {@link ReadOptions#setSnapshot(Snapshot)} will affect what is |
|
|
|
* read from the DB but will NOT change which keys are read from the batch |
|
|
|
* read from the DB but will NOT change which keys are read from the batch |
|
|
|
* (the keys in this batch do not yet belong to any snapshot and will be |
|
|
|
* (the keys in this batch do not yet belong to any snapshot and will be |
|
|
|
* fetched regardless). |
|
|
|
* fetched regardless). |
|
|
@ -230,7 +273,7 @@ public class WriteBatchWithIndex extends AbstractWriteBatch { |
|
|
|
* the results using the DB's merge operator (if the batch contains any |
|
|
|
* the results using the DB's merge operator (if the batch contains any |
|
|
|
* merge requests). |
|
|
|
* merge requests). |
|
|
|
* |
|
|
|
* |
|
|
|
* Setting {@link ReadOptions#setSnapshot(long, long)} will affect what is |
|
|
|
* Setting {@link ReadOptions#setSnapshot(Snapshot)} will affect what is |
|
|
|
* read from the DB but will NOT change which keys are read from the batch |
|
|
|
* read from the DB but will NOT change which keys are read from the batch |
|
|
|
* (the keys in this batch do not yet belong to any snapshot and will be |
|
|
|
* (the keys in this batch do not yet belong to any snapshot and will be |
|
|
|
* fetched regardless). |
|
|
|
* fetched regardless). |
|
|
@ -303,8 +346,8 @@ public class WriteBatchWithIndex extends AbstractWriteBatch { |
|
|
|
final boolean overwriteKey); |
|
|
|
final boolean overwriteKey); |
|
|
|
private native long iterator0(final long handle); |
|
|
|
private native long iterator0(final long handle); |
|
|
|
private native long iterator1(final long handle, final long cfHandle); |
|
|
|
private native long iterator1(final long handle, final long cfHandle); |
|
|
|
private native long iteratorWithBase( |
|
|
|
private native long iteratorWithBase(final long handle, final long baseIteratorHandle, |
|
|
|
final long handle, final long baseIteratorHandle, final long cfHandle); |
|
|
|
final long cfHandle, final long readOptionsHandle); |
|
|
|
private native byte[] getFromBatch(final long handle, final long optHandle, |
|
|
|
private native byte[] getFromBatch(final long handle, final long optHandle, |
|
|
|
final byte[] key, final int keyLen); |
|
|
|
final byte[] key, final int keyLen); |
|
|
|
private native byte[] getFromBatch(final long handle, final long optHandle, |
|
|
|
private native byte[] getFromBatch(final long handle, final long optHandle, |
|
|
|