This commit is contained in:
Andrea Cavalli 2021-05-12 19:02:51 +02:00
parent f4242218da
commit d29ac00c24
8 changed files with 253 additions and 157 deletions

View File

@ -37,7 +37,11 @@ public class LLRange {
}
public static LLRange single(ByteBuf single) {
return new LLRange(single, single);
try {
return new LLRange(single.retain(), single.retain());
} finally {
single.release();
}
}
public static LLRange of(ByteBuf min, ByteBuf max) {

View File

@ -61,13 +61,15 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
@Override
public Mono<Map<T, U>> get(@Nullable CompositeSnapshot snapshot, boolean existsAlmostCertainly) {
return dictionary
.getRange(resolveSnapshot(snapshot), range.retain(), existsAlmostCertainly)
return Flux
.defer(() -> dictionary.getRange(resolveSnapshot(snapshot), range.retain(), existsAlmostCertainly))
.collectMap(
entry -> deserializeSuffix(stripPrefix(entry.getKey(), false)),
entry -> deserialize(entry.getValue()),
HashMap::new)
.filter(map -> !map.isEmpty());
.filter(map -> !map.isEmpty())
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
}
@Override
@ -84,7 +86,9 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
.entry(this.toKey(serializeSuffix(entry.getKey())), serialize(entry.getValue()))
)
)
);
)
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
}
@Override
@ -95,19 +99,28 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
@Override
public Mono<Long> leavesCount(@Nullable CompositeSnapshot snapshot, boolean fast) {
return dictionary.sizeRange(resolveSnapshot(snapshot), range.retain(), fast);
return Mono.defer(() -> dictionary.sizeRange(resolveSnapshot(snapshot), range.retain(), fast))
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
}
@Override
public Mono<Boolean> isEmpty(@Nullable CompositeSnapshot snapshot) {
return dictionary.isRangeEmpty(resolveSnapshot(snapshot), range.retain());
return Mono.defer(() -> dictionary.isRangeEmpty(resolveSnapshot(snapshot), range.retain()))
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
}
@Override
public Mono<DatabaseStageEntry<U>> at(@Nullable CompositeSnapshot snapshot, T keySuffix) {
return Mono
.fromSupplier(() -> new DatabaseSingle<>(dictionary, toKey(serializeSuffix(keySuffix)), Serializer.noop()))
.<DatabaseStageEntry<U>>map(entry -> new DatabaseSingleMapped<>(entry, valueSerializer));
.using(
() -> toKey(serializeSuffix(keySuffix)),
keyBuf -> Mono
.fromSupplier(() -> new DatabaseSingle<>(dictionary, keyBuf.retain(), Serializer.noop()))
.<DatabaseStageEntry<U>>map(entry -> new DatabaseSingleMapped<>(entry, valueSerializer)),
ReferenceCounted::release
);
}
@Override
@ -124,17 +137,24 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
@Override
public Mono<Void> putValue(T keySuffix, U value) {
ByteBuf keySuffixBuf = serializeSuffix(keySuffix);
ByteBuf keyBuf = toKey(keySuffixBuf.retain());
ByteBuf valueBuf = serialize(value);
return dictionary
return Mono
.using(
() -> serializeSuffix(keySuffix),
keySuffixBuf -> Mono
.using(
() -> toKey(keySuffixBuf.retain()),
keyBuf -> Mono
.using(
() -> serialize(value),
valueBuf -> dictionary
.put(keyBuf.retain(), valueBuf.retain(), LLDictionaryResultType.VOID)
.doOnNext(ReferenceCounted::release)
.doFinally(s -> {
keyBuf.release();
keySuffixBuf.release();
valueBuf.release();
})
.doOnNext(ReferenceCounted::release),
ReferenceCounted::release
),
ReferenceCounted::release
),
ReferenceCounted::release
)
.then();
}
@ -200,34 +220,48 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
@Override
public Mono<U> putValueAndGetPrevious(T keySuffix, U value) {
ByteBuf keySuffixBuf = serializeSuffix(keySuffix);
ByteBuf keyBuf = toKey(keySuffixBuf.retain());
ByteBuf valueBuf = serialize(value);
return dictionary
return Mono
.using(
() -> serializeSuffix(keySuffix),
keySuffixBuf -> Mono
.using(
() -> toKey(keySuffixBuf.retain()),
keyBuf -> Mono
.using(
() -> serialize(value),
valueBuf -> dictionary
.put(keyBuf.retain(), valueBuf.retain(), LLDictionaryResultType.PREVIOUS_VALUE)
.map(this::deserialize)
.doFinally(s -> {
keyBuf.release();
keySuffixBuf.release();
valueBuf.release();
});
.map(this::deserialize),
ReferenceCounted::release
),
ReferenceCounted::release
),
ReferenceCounted::release
);
}
@Override
public Mono<Boolean> putValueAndGetChanged(T keySuffix, U value) {
ByteBuf keySuffixBuf = serializeSuffix(keySuffix);
ByteBuf keyBuf = toKey(keySuffixBuf.retain());
ByteBuf valueBuf = serialize(value);
return dictionary
return Mono
.using(
() -> serializeSuffix(keySuffix),
keySuffixBuf -> Mono
.using(
() -> toKey(keySuffixBuf.retain()),
keyBuf -> Mono
.using(
() -> serialize(value),
valueBuf -> dictionary
.put(keyBuf.retain(), valueBuf.retain(), LLDictionaryResultType.PREVIOUS_VALUE)
.map(this::deserialize)
.map(oldValue -> !Objects.equals(oldValue, value))
.defaultIfEmpty(value != null)
.doFinally(s -> {
keyBuf.release();
keySuffixBuf.release();
valueBuf.release();
});
.defaultIfEmpty(value != null),
ReferenceCounted::release
),
ReferenceCounted::release
),
ReferenceCounted::release
);
}
@Override
@ -318,9 +352,8 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
@Override
public Flux<Entry<T, DatabaseStageEntry<U>>> getAllStages(@Nullable CompositeSnapshot snapshot) {
return dictionary
.getRangeKeys(resolveSnapshot(snapshot), range.retain())
.map(key -> {
return Flux.defer(() -> dictionary.getRangeKeys(resolveSnapshot(snapshot), range.retain()))
.<Entry<T, DatabaseStageEntry<U>>>map(key -> {
ByteBuf keySuffixWithExt = stripPrefix(key, false);
// Don't use "key" under this point ---
try {
@ -333,13 +366,14 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
} finally {
keySuffixWithExt.release();
}
});
})
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
}
@Override
public Flux<Entry<T, U>> getAllValues(@Nullable CompositeSnapshot snapshot) {
return dictionary
.getRange(resolveSnapshot(snapshot), range.retain())
return Flux.defer(() -> dictionary.getRange(resolveSnapshot(snapshot), range.retain()))
.map(serializedEntry -> Map.entry(
deserializeSuffix(stripPrefix(serializedEntry.getKey(), false)),
valueSerializer.deserialize(serializedEntry.getValue())
@ -349,7 +383,9 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
var castedEntry = (Entry<ByteBuf, ByteBuf>) entry;
castedEntry.getKey().release();
castedEntry.getValue().release();
});
})
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
}
@Override
@ -364,7 +400,9 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
Map.entry(toKey(serializeSuffix(entry.getKey())), serialize(entry.getValue()))
)
)
);
)
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
}
@Override
@ -373,13 +411,17 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
return dictionary
.clear();
} else if (range.isSingle()) {
return dictionary
.remove(range.getSingle().retain(), LLDictionaryResultType.VOID)
return Mono
.defer(() -> dictionary.remove(range.getSingle().retain(), LLDictionaryResultType.VOID))
.doOnNext(ReferenceCounted::release)
.then();
.then()
.doFirst(() -> range.getSingle().retain())
.doFinally(s -> range.getSingle().release());
} else {
return dictionary
.setRange(range.retain(), Flux.empty());
return Mono
.defer(() -> dictionary.setRange(range.retain(), Flux.empty()))
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
}
}

View File

@ -365,12 +365,17 @@ public class DatabaseMapDictionaryDeep<T, U, US extends DatabaseStage<U>> implem
@Override
public Mono<Long> leavesCount(@Nullable CompositeSnapshot snapshot, boolean fast) {
return Mono.defer(() -> dictionary.sizeRange(resolveSnapshot(snapshot), range.retain(), fast));
return Mono
.defer(() -> dictionary.sizeRange(resolveSnapshot(snapshot), range.retain(), fast))
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
}
@Override
public Mono<Boolean> isEmpty(@Nullable CompositeSnapshot snapshot) {
return Mono.defer(() -> dictionary.isRangeEmpty(resolveSnapshot(snapshot), range.retain()));
return Mono.defer(() -> dictionary.isRangeEmpty(resolveSnapshot(snapshot), range.retain()))
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
}
@Override

View File

@ -1,6 +1,7 @@
package it.cavallium.dbengine.database.collections;
import io.netty.buffer.ByteBuf;
import io.netty.util.ReferenceCounted;
import it.cavallium.dbengine.client.CompositeSnapshot;
import it.cavallium.dbengine.database.Delta;
import it.cavallium.dbengine.database.LLDictionary;
@ -42,61 +43,91 @@ public class DatabaseSingle<U> implements DatabaseStageEntry<U> {
@Override
public Mono<U> get(@Nullable CompositeSnapshot snapshot, boolean existsAlmostCertainly) {
return dictionary.get(resolveSnapshot(snapshot), key.retain(), existsAlmostCertainly).map(this::deserialize);
return Mono
.defer(() -> dictionary.get(resolveSnapshot(snapshot), key.retain(), existsAlmostCertainly))
.map(this::deserialize)
.doFirst(() -> key.retain())
.doFinally(s -> key.release());
}
@Override
public Mono<U> setAndGetPrevious(U value) {
ByteBuf valueByteBuf = serialize(value);
return dictionary
return Mono
.using(
() -> serialize(value),
valueByteBuf -> dictionary
.put(key.retain(), valueByteBuf.retain(), LLDictionaryResultType.PREVIOUS_VALUE)
.map(this::deserialize)
.doFinally(s -> valueByteBuf.release());
.map(this::deserialize),
ReferenceCounted::release
)
.doFirst(() -> key.retain())
.doFinally(s -> key.release());
}
@Override
public Mono<U> update(Function<@Nullable U, @Nullable U> updater,
UpdateReturnMode updateReturnMode,
boolean existsAlmostCertainly) {
return dictionary.update(key.retain(), (oldValueSer) -> {
return Mono
.defer(() -> dictionary.update(key.retain(), (oldValueSer) -> {
var result = updater.apply(oldValueSer == null ? null : this.deserialize(oldValueSer));
if (result == null) {
return null;
} else {
return this.serialize(result);
}
}, updateReturnMode, existsAlmostCertainly).map(this::deserialize);
}, updateReturnMode, existsAlmostCertainly))
.map(this::deserialize)
.doFirst(() -> key.retain())
.doFinally(s -> key.release());
}
@Override
public Mono<Delta<U>> updateAndGetDelta(Function<@Nullable U, @Nullable U> updater,
boolean existsAlmostCertainly) {
return dictionary.updateAndGetDelta(key.retain(), (oldValueSer) -> {
return Mono
.defer(() -> dictionary.updateAndGetDelta(key.retain(), (oldValueSer) -> {
var result = updater.apply(oldValueSer == null ? null : this.deserialize(oldValueSer));
if (result == null) {
return null;
} else {
return this.serialize(result);
}
}, existsAlmostCertainly).transform(mono -> LLUtils.mapDelta(mono, this::deserialize));
}, existsAlmostCertainly).transform(mono -> LLUtils.mapDelta(mono, this::deserialize)))
.doFirst(() -> key.retain())
.doFinally(s -> key.release());
}
@Override
public Mono<U> clearAndGetPrevious() {
return dictionary.remove(key.retain(), LLDictionaryResultType.PREVIOUS_VALUE).map(this::deserialize);
return Mono
.defer(() -> dictionary
.remove(key.retain(), LLDictionaryResultType.PREVIOUS_VALUE)
)
.map(this::deserialize)
.doFirst(() -> key.retain())
.doFinally(s -> key.release());
}
@Override
public Mono<Long> leavesCount(@Nullable CompositeSnapshot snapshot, boolean fast) {
return dictionary
return Mono
.defer(() -> dictionary
.isRangeEmpty(resolveSnapshot(snapshot), LLRange.single(key.retain()))
.map(empty -> empty ? 0L : 1L);
)
.map(empty -> empty ? 0L : 1L)
.doFirst(() -> key.retain())
.doFinally(s -> key.release());
}
@Override
public Mono<Boolean> isEmpty(@Nullable CompositeSnapshot snapshot) {
return dictionary
.isRangeEmpty(resolveSnapshot(snapshot), LLRange.single(key.retain()));
return Mono
.defer(() -> dictionary
.isRangeEmpty(resolveSnapshot(snapshot), LLRange.single(key.retain()))
)
.doFirst(() -> key.retain())
.doFinally(s -> key.release());
}
//todo: temporary wrapper. convert the whole class to buffers

View File

@ -34,10 +34,13 @@ public class SubStageGetterSet<T> implements SubStageGetter<Map<T, Nothing>, Dat
@Nullable CompositeSnapshot snapshot,
ByteBuf prefixKey,
List<ByteBuf> debuggingKeys) {
try {
return Mono
.defer(() -> {
if (assertsEnabled) {
return checkKeyFluxConsistency(prefixKey.retain(), debuggingKeys);
return checkKeyFluxConsistency(prefixKey.retain(), debuggingKeys)
.doFirst(() -> prefixKey.retain())
.doFinally(s -> prefixKey.release());
} else {
return Mono
.fromCallable(() -> {
@ -57,7 +60,11 @@ public class SubStageGetterSet<T> implements SubStageGetter<Map<T, Nothing>, Dat
)
)
)
.doFirst(() -> prefixKey.retain())
.doFinally(s -> prefixKey.release());
} finally {
prefixKey.release();
}
}
@Override

View File

@ -33,6 +33,7 @@ public class SubStageGetterSingle<T> implements SubStageGetter<T, DatabaseStageE
@Nullable CompositeSnapshot snapshot,
ByteBuf keyPrefix,
List<ByteBuf> debuggingKeys) {
try {
return Mono
.fromCallable(() -> {
try {
@ -51,7 +52,11 @@ public class SubStageGetterSingle<T> implements SubStageGetter<T, DatabaseStageE
.then(Mono
.<DatabaseStageEntry<T>>fromSupplier(() -> new DatabaseSingle<>(dictionary, keyPrefix.retain(), serializer))
)
.doFirst(() -> keyPrefix.retain())
.doFinally(s -> keyPrefix.release());
} finally {
keyPrefix.release();
}
}
@Override

View File

@ -219,7 +219,7 @@ public class LLLocalDictionary implements LLDictionary {
})
.onErrorMap(cause -> new IOException("Failed to read " + LLUtils.toString(key), cause))
.subscribeOn(dbScheduler)
.doOnSubscribe(s -> key.retain())
.doFirst(() -> key.retain())
.doFinally(s -> key.release());
} finally {
key.release();
@ -368,13 +368,15 @@ public class LLLocalDictionary implements LLDictionary {
return Mono
.defer(() -> {
if (range.isSingle()) {
return containsKey(snapshot, range.getSingle().retain());
return this
.containsKey(snapshot, range.getSingle().retain());
} else {
return containsRange(snapshot, range.retain());
return this
.containsRange(snapshot, range.retain());
}
})
.map(isContained -> !isContained)
.doOnSubscribe(s -> range.retain())
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
} finally {
range.release();
@ -423,7 +425,7 @@ public class LLLocalDictionary implements LLDictionary {
})
.onErrorMap(cause -> new IOException("Failed to read range " + range.toString(), cause))
.subscribeOn(dbScheduler)
.doOnSubscribe(s -> range.retain())
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
} finally {
range.release();
@ -464,7 +466,7 @@ public class LLLocalDictionary implements LLDictionary {
})
.onErrorMap(cause -> new IOException("Failed to read " + LLUtils.toString(key), cause))
.subscribeOn(dbScheduler)
.doOnSubscribe(s -> key.retain())
.doFirst(() -> key.retain())
.doFinally(s -> key.release());
} finally {
key.release();
@ -504,7 +506,7 @@ public class LLLocalDictionary implements LLDictionary {
.onErrorMap(cause -> new IOException("Failed to write " + LLUtils.toString(key), cause))
)
.singleOrEmpty()
.doOnSubscribe(s -> {
.doFirst(() -> {
key.retain();
value.retain();
})
@ -646,7 +648,7 @@ public class LLLocalDictionary implements LLDictionary {
})
.onErrorMap(cause -> new IOException("Failed to read or write " + (key.refCnt() > 0 ? LLUtils.toString(key) : "(released)"), cause))
.subscribeOn(dbScheduler)
.doOnSubscribe(s -> key.retain())
.doFirst(() -> key.retain())
.doFinally(s -> key.release());
} finally {
key.release();
@ -767,7 +769,7 @@ public class LLLocalDictionary implements LLDictionary {
})
.onErrorMap(cause -> new IOException("Failed to read or write " + (key.refCnt() > 0 ? LLUtils.toString(key) : "(released)"), cause))
.subscribeOn(dbScheduler)
.doOnSubscribe(s -> key.retain())
.doFirst(() -> key.retain())
.doFinally(s -> key.release());
} finally {
key.release();
@ -825,7 +827,7 @@ public class LLLocalDictionary implements LLDictionary {
.then(Mono.empty())
)
.singleOrEmpty()
.doOnSubscribe(s -> key.retain())
.doFirst(() -> key.retain())
.doFinally(s -> key.release());
} finally {
key.release();
@ -890,7 +892,7 @@ public class LLLocalDictionary implements LLDictionary {
return Mono.error(new IllegalStateException("Unexpected value: " + resultType));
}
})
.doOnSubscribe(s -> key.retain())
.doFirst(() -> key.retain())
.doFinally(s -> key.release());
} finally {
key.release();
@ -1079,7 +1081,7 @@ public class LLLocalDictionary implements LLDictionary {
return getRangeMulti(snapshot, range.retain());
}
})
.doOnSubscribe(s -> range.retain())
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
} finally {
range.release();
@ -1099,7 +1101,7 @@ public class LLLocalDictionary implements LLDictionary {
return getRangeMultiGrouped(snapshot, range.retain(), prefixLength);
}
})
.doOnSubscribe(s -> range.retain())
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
} finally {
range.release();
@ -1112,7 +1114,7 @@ public class LLLocalDictionary implements LLDictionary {
.defer(() -> this.get(snapshot, key.retain(), existsAlmostCertainly))
.map(value -> Map.entry(key.retain(), value))
.flux()
.doOnSubscribe(s -> key.retain())
.doFirst(() -> key.retain())
.doFinally(s -> key.release());
} finally {
key.release();
@ -1134,7 +1136,7 @@ public class LLLocalDictionary implements LLDictionary {
castedEntry.getValue().release();
})
.subscribeOn(dbScheduler)
.doOnSubscribe(s -> range.retain())
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
} finally {
range.release();
@ -1157,7 +1159,7 @@ public class LLLocalDictionary implements LLDictionary {
LLLocalGroupedReactiveRocksIterator::release
)
.subscribeOn(dbScheduler)
.doOnSubscribe(s -> range.retain())
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
} finally {
range.release();
@ -1175,7 +1177,7 @@ public class LLLocalDictionary implements LLDictionary {
return this.getRangeKeysMulti(snapshot, range.retain());
}
})
.doOnSubscribe(s -> range.retain())
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
} finally {
range.release();
@ -1199,7 +1201,7 @@ public class LLLocalDictionary implements LLDictionary {
LLLocalGroupedReactiveRocksIterator::release
)
.subscribeOn(dbScheduler)
.doOnSubscribe(s -> range.retain())
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
} finally {
range.release();
@ -1224,7 +1226,7 @@ public class LLLocalDictionary implements LLDictionary {
LLLocalKeyPrefixReactiveRocksIterator::release
)
.subscribeOn(dbScheduler)
.doOnSubscribe(s -> range.retain())
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
} finally {
range.release();
@ -1244,7 +1246,7 @@ public class LLLocalDictionary implements LLDictionary {
}
})
.doOnDiscard(ByteBuf.class, ReferenceCounted::release)
.doOnSubscribe(s -> key.retain())
.doFirst(() -> key.retain())
.doFinally(s -> key.release());
} finally {
key.release();
@ -1261,7 +1263,7 @@ public class LLLocalDictionary implements LLDictionary {
)
.doOnDiscard(ByteBuf.class, ReferenceCounted::release)
.subscribeOn(dbScheduler)
.doOnSubscribe(s -> range.retain())
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
} finally {
range.release();
@ -1385,7 +1387,7 @@ public class LLLocalDictionary implements LLDictionary {
)
.then()
.onErrorMap(cause -> new IOException("Failed to write range", cause))
.doOnSubscribe(s -> range.retain())
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
} else {
if (USE_WRITE_BATCHES_IN_SET_RANGE) {
@ -1413,7 +1415,7 @@ public class LLLocalDictionary implements LLDictionary {
.then(Mono.<Void>empty())
)
.onErrorMap(cause -> new IOException("Failed to write range", cause))
.doOnSubscribe(s -> range.retain())
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
}
} finally {
@ -1682,7 +1684,7 @@ public class LLLocalDictionary implements LLDictionary {
+ range.toString(), cause))
.subscribeOn(dbScheduler);
}
return result.doOnSubscribe(s -> range.retain()).doFinally(s -> range.release());
return result.doFirst(() -> range.retain()).doFinally(s -> range.release());
} finally {
range.release();
}
@ -1736,7 +1738,7 @@ public class LLLocalDictionary implements LLDictionary {
}
})
.subscribeOn(dbScheduler)
.doOnSubscribe(s -> range.retain())
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
} finally {
range.release();
@ -1783,7 +1785,7 @@ public class LLLocalDictionary implements LLDictionary {
}
})
.subscribeOn(dbScheduler)
.doOnSubscribe(s -> range.retain())
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
} finally {
range.release();
@ -1932,7 +1934,7 @@ public class LLLocalDictionary implements LLDictionary {
})
.onErrorMap(cause -> new IOException("Failed to delete " + range.toString(), cause))
.subscribeOn(dbScheduler)
.doOnSubscribe(s -> range.retain())
.doFirst(() -> range.retain())
.doFinally(s -> range.release());
} finally {
range.release();

View File

@ -224,9 +224,9 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
options.setAllowFAllocate(true);
options.setRateLimiter(new RateLimiter(10L * 1024L * 1024L)); // 10MiB/s max compaction write speed
options.setDbPaths(List.of(new DbPath(databasesDirPath.resolve(path.getFileName() + "_hot"),
50L * 1024L * 1024L * 1024L), // 50GiB
10L * 1024L * 1024L * 1024L), // 10GiB
new DbPath(databasesDirPath.resolve(path.getFileName() + "_cold"),
400L * 1024L * 1024L * 1024L), // 400GiB
100L * 1024L * 1024L * 1024L), // 100GiB
new DbPath(databasesDirPath.resolve(path.getFileName() + "_colder"),
600L * 1024L * 1024L * 1024L))); // 600GiB
// Direct I/O parameters. Removed because they use too much disk.