mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-29 18:33:58 +00:00
fix batchresult handle leak
Summary: This is related to PR https://github.com/facebook/rocksdb/pull/1642 Sorry about this extra PR, as my workflow was messed up when I checked in another work item by accident. Closes https://github.com/facebook/rocksdb/pull/1681 Differential Revision: D4379513 Pulled By: yiwu-arbug fbshipit-source-id: a668d4c
This commit is contained in:
parent
e29bb934f7
commit
af6ec4d78e
|
@ -14,71 +14,60 @@ public abstract class AbstractWriteBatch extends RocksObject
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int count() {
|
public int count() {
|
||||||
assert (isOwningHandle());
|
|
||||||
return count0(nativeHandle_);
|
return count0(nativeHandle_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(byte[] key, byte[] value) {
|
public void put(byte[] key, byte[] value) {
|
||||||
assert (isOwningHandle());
|
|
||||||
put(nativeHandle_, key, key.length, value, value.length);
|
put(nativeHandle_, key, key.length, value, value.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(ColumnFamilyHandle columnFamilyHandle, byte[] key,
|
public void put(ColumnFamilyHandle columnFamilyHandle, byte[] key,
|
||||||
byte[] value) {
|
byte[] value) {
|
||||||
assert (isOwningHandle());
|
|
||||||
put(nativeHandle_, key, key.length, value, value.length,
|
put(nativeHandle_, key, key.length, value, value.length,
|
||||||
columnFamilyHandle.nativeHandle_);
|
columnFamilyHandle.nativeHandle_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void merge(byte[] key, byte[] value) {
|
public void merge(byte[] key, byte[] value) {
|
||||||
assert (isOwningHandle());
|
|
||||||
merge(nativeHandle_, key, key.length, value, value.length);
|
merge(nativeHandle_, key, key.length, value, value.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void merge(ColumnFamilyHandle columnFamilyHandle, byte[] key,
|
public void merge(ColumnFamilyHandle columnFamilyHandle, byte[] key,
|
||||||
byte[] value) {
|
byte[] value) {
|
||||||
assert (isOwningHandle());
|
|
||||||
merge(nativeHandle_, key, key.length, value, value.length,
|
merge(nativeHandle_, key, key.length, value, value.length,
|
||||||
columnFamilyHandle.nativeHandle_);
|
columnFamilyHandle.nativeHandle_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(byte[] key) {
|
public void remove(byte[] key) {
|
||||||
assert (isOwningHandle());
|
|
||||||
remove(nativeHandle_, key, key.length);
|
remove(nativeHandle_, key, key.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(ColumnFamilyHandle columnFamilyHandle, byte[] key) {
|
public void remove(ColumnFamilyHandle columnFamilyHandle, byte[] key) {
|
||||||
assert (isOwningHandle());
|
|
||||||
remove(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_);
|
remove(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putLogData(byte[] blob) {
|
public void putLogData(byte[] blob) {
|
||||||
assert (isOwningHandle());
|
|
||||||
putLogData(nativeHandle_, blob, blob.length);
|
putLogData(nativeHandle_, blob, blob.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
assert (isOwningHandle());
|
|
||||||
clear0(nativeHandle_);
|
clear0(nativeHandle_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSavePoint() {
|
public void setSavePoint() {
|
||||||
assert (isOwningHandle());
|
|
||||||
setSavePoint0(nativeHandle_);
|
setSavePoint0(nativeHandle_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rollbackToSavePoint() throws RocksDBException {
|
public void rollbackToSavePoint() throws RocksDBException {
|
||||||
assert (isOwningHandle());
|
|
||||||
rollbackToSavePoint0(nativeHandle_);
|
rollbackToSavePoint0(nativeHandle_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class TransactionLogIterator extends RocksObject {
|
||||||
public BatchResult(final long sequenceNumber,
|
public BatchResult(final long sequenceNumber,
|
||||||
final long nativeHandle) {
|
final long nativeHandle) {
|
||||||
sequenceNumber_ = sequenceNumber;
|
sequenceNumber_ = sequenceNumber;
|
||||||
writeBatch_ = new WriteBatch(nativeHandle);
|
writeBatch_ = new WriteBatch(nativeHandle, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -59,8 +59,20 @@ public class WriteBatch extends AbstractWriteBatch {
|
||||||
* @param nativeHandle address of native instance.
|
* @param nativeHandle address of native instance.
|
||||||
*/
|
*/
|
||||||
WriteBatch(final long nativeHandle) {
|
WriteBatch(final long nativeHandle) {
|
||||||
|
this(nativeHandle, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Private WriteBatch constructor which is used to construct
|
||||||
|
* WriteBatch instances. </p>
|
||||||
|
*
|
||||||
|
* @param nativeHandle address of native instance.
|
||||||
|
* @param owningNativeHandle whether to own this reference from the C++ side or not
|
||||||
|
*/
|
||||||
|
WriteBatch(final long nativeHandle, final boolean owningNativeHandle) {
|
||||||
super(nativeHandle);
|
super(nativeHandle);
|
||||||
disOwnNativeHandle();
|
if(!owningNativeHandle)
|
||||||
|
disOwnNativeHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected final native void disposeInternal(final long handle);
|
@Override protected final native void disposeInternal(final long handle);
|
||||||
|
|
Loading…
Reference in a new issue