Use optimistic db
This commit is contained in:
parent
28920f2d02
commit
1f04241ac6
@ -45,6 +45,7 @@ import org.rocksdb.DbPath;
|
|||||||
import org.rocksdb.FlushOptions;
|
import org.rocksdb.FlushOptions;
|
||||||
import org.rocksdb.IndexType;
|
import org.rocksdb.IndexType;
|
||||||
import org.rocksdb.OptimisticTransactionDB;
|
import org.rocksdb.OptimisticTransactionDB;
|
||||||
|
import org.rocksdb.OptimisticTransactionOptions;
|
||||||
import org.rocksdb.Options;
|
import org.rocksdb.Options;
|
||||||
import org.rocksdb.RateLimiter;
|
import org.rocksdb.RateLimiter;
|
||||||
import org.rocksdb.RocksDB;
|
import org.rocksdb.RocksDB;
|
||||||
@ -150,7 +151,7 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
|
|||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
// a factory method that returns a RocksDB instance
|
// a factory method that returns a RocksDB instance
|
||||||
this.db = TransactionDB.open(new DBOptions(rocksdbOptions), new TransactionDBOptions(), dbPathString, descriptors, handles);
|
this.db = OptimisticTransactionDB.open(new DBOptions(rocksdbOptions), dbPathString, descriptors, handles);
|
||||||
break;
|
break;
|
||||||
} catch (RocksDBException ex) {
|
} catch (RocksDBException ex) {
|
||||||
switch (ex.getMessage()) {
|
switch (ex.getMessage()) {
|
||||||
@ -452,12 +453,13 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
|
|||||||
|
|
||||||
LinkedList<ColumnFamilyHandle> handles = new LinkedList<>();
|
LinkedList<ColumnFamilyHandle> handles = new LinkedList<>();
|
||||||
|
|
||||||
this.db = TransactionDB.open(options, new TransactionDBOptions(), dbPathString);
|
this.db = RocksDB.open(options, dbPathString);
|
||||||
for (ColumnFamilyDescriptor columnFamilyDescriptor : descriptorsToCreate) {
|
for (ColumnFamilyDescriptor columnFamilyDescriptor : descriptorsToCreate) {
|
||||||
handles.add(db.createColumnFamily(columnFamilyDescriptor));
|
handles.add(db.createColumnFamily(columnFamilyDescriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
flushAndCloseDb(db, handles);
|
flushAndCloseDb(db, handles);
|
||||||
|
this.db = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +147,7 @@ public final class OptimisticRocksDBColumn extends AbstractRocksDBColumn<Optimis
|
|||||||
sentPrevData = prevData == null ? null : prevData.send();
|
sentPrevData = prevData == null ? null : prevData.send();
|
||||||
sentCurData = newData == null ? null : newData.send();
|
sentCurData = newData == null ? null : newData.send();
|
||||||
if (!committedSuccessfully) {
|
if (!committedSuccessfully) {
|
||||||
|
tx.undoGetForUpdate(cfh, keyArray);
|
||||||
if (sentPrevData != null) {
|
if (sentPrevData != null) {
|
||||||
sentPrevData.close();
|
sentPrevData.close();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user