Configurable optimistic transactions

This commit is contained in:
Andrea Cavalli 2021-12-27 17:45:52 +01:00
parent aa04a64c34
commit 9309692062
4 changed files with 9 additions and 4 deletions

View File

@ -8,4 +8,5 @@ import org.jetbrains.annotations.Nullable;
@RecordBuilder
public record DatabaseOptions(List<DatabaseVolume> volumes, Map<String, String> extraFlags, boolean absoluteConsistency,
boolean lowMemory, boolean inMemory, boolean useDirectIO, boolean allowMemoryMapping,
boolean allowNettyDirect, int maxOpenFiles, @Nullable Long memtableMemoryBudgetBytes) {}
boolean allowNettyDirect, boolean optimistic, int maxOpenFiles,
@Nullable Long memtableMemoryBudgetBytes) {}

View File

@ -155,7 +155,11 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
while (true) {
try {
// a factory method that returns a RocksDB instance
this.db = OptimisticTransactionDB.open(new DBOptions(rocksdbOptions), dbPathString, descriptors, handles);
if (databaseOptions.optimistic()) {
this.db = OptimisticTransactionDB.open(new DBOptions(rocksdbOptions), dbPathString, descriptors, handles);
} else {
this.db = TransactionDB.open(new DBOptions(rocksdbOptions), dbPathString, descriptors, handles);
}
break;
} catch (RocksDBException ex) {
switch (ex.getMessage()) {

View File

@ -78,7 +78,7 @@ public class LocalTemporaryDbGenerator implements TemporaryDbGenerator {
conn.getDatabase("testdb",
List.of(Column.dictionary("testmap"), Column.special("ints"), Column.special("longs")),
new DatabaseOptions(List.of(), Map.of(), true, false, true, false,
true, canUseNettyDirect, -1, null)
true, canUseNettyDirect, true, -1, null)
),
conn.getLuceneIndex("testluceneindex1",
1,

View File

@ -49,7 +49,7 @@ public class MemoryTemporaryDbGenerator implements TemporaryDbGenerator {
.zip(
conn.getDatabase("testdb",
List.of(Column.dictionary("testmap"), Column.special("ints"), Column.special("longs")),
new DatabaseOptions(List.of(), Map.of(), true, false, true, false, true, canUseNettyDirect, -1, null)
new DatabaseOptions(List.of(), Map.of(), true, false, true, false, true, canUseNettyDirect, true, -1, null)
),
conn.getLuceneIndex("testluceneindex1",
1,