From 1f04241ac6eed533ea5d4d32c8834256d8cbf2b3 Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Thu, 21 Oct 2021 10:00:39 +0200 Subject: [PATCH] Use optimistic db --- .../dbengine/database/disk/LLLocalKeyValueDatabase.java | 6 ++++-- .../dbengine/database/disk/OptimisticRocksDBColumn.java | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/cavallium/dbengine/database/disk/LLLocalKeyValueDatabase.java b/src/main/java/it/cavallium/dbengine/database/disk/LLLocalKeyValueDatabase.java index 37c8f37..8e3610a 100644 --- a/src/main/java/it/cavallium/dbengine/database/disk/LLLocalKeyValueDatabase.java +++ b/src/main/java/it/cavallium/dbengine/database/disk/LLLocalKeyValueDatabase.java @@ -45,6 +45,7 @@ import org.rocksdb.DbPath; import org.rocksdb.FlushOptions; import org.rocksdb.IndexType; import org.rocksdb.OptimisticTransactionDB; +import org.rocksdb.OptimisticTransactionOptions; import org.rocksdb.Options; import org.rocksdb.RateLimiter; import org.rocksdb.RocksDB; @@ -150,7 +151,7 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase { while (true) { try { // 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; } catch (RocksDBException ex) { switch (ex.getMessage()) { @@ -452,12 +453,13 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase { LinkedList handles = new LinkedList<>(); - this.db = TransactionDB.open(options, new TransactionDBOptions(), dbPathString); + this.db = RocksDB.open(options, dbPathString); for (ColumnFamilyDescriptor columnFamilyDescriptor : descriptorsToCreate) { handles.add(db.createColumnFamily(columnFamilyDescriptor)); } flushAndCloseDb(db, handles); + this.db = null; } } diff --git a/src/main/java/it/cavallium/dbengine/database/disk/OptimisticRocksDBColumn.java b/src/main/java/it/cavallium/dbengine/database/disk/OptimisticRocksDBColumn.java index ada5a47..89d00df 100644 --- a/src/main/java/it/cavallium/dbengine/database/disk/OptimisticRocksDBColumn.java +++ b/src/main/java/it/cavallium/dbengine/database/disk/OptimisticRocksDBColumn.java @@ -147,6 +147,7 @@ public final class OptimisticRocksDBColumn extends AbstractRocksDBColumn