CavalliumDBEngine/src/main/java/it/cavallium/dbengine/database/LLDictionary.java

62 lines
2.1 KiB
Java
Raw Normal View History

2020-12-07 22:15:18 +01:00
package it.cavallium.dbengine.database;
import java.util.List;
2020-12-07 22:15:18 +01:00
import java.util.Map.Entry;
2021-01-30 00:24:55 +01:00
import java.util.function.Function;
2020-12-07 22:15:18 +01:00
import org.jetbrains.annotations.Nullable;
import org.warp.commonutils.concurrency.atomicity.NotAtomic;
2021-01-30 00:24:55 +01:00
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
2020-12-07 22:15:18 +01:00
@NotAtomic
public interface LLDictionary extends LLKeyValueDatabaseStructure {
2021-01-30 00:24:55 +01:00
Mono<byte[]> get(@Nullable LLSnapshot snapshot, byte[] key);
2020-12-07 22:15:18 +01:00
2021-01-30 00:24:55 +01:00
Mono<byte[]> put(byte[] key, byte[] value, LLDictionaryResultType resultType);
2020-12-07 22:15:18 +01:00
2021-01-30 00:24:55 +01:00
Mono<byte[]> remove(byte[] key, LLDictionaryResultType resultType);
2020-12-07 22:15:18 +01:00
2021-01-30 00:24:55 +01:00
Flux<Entry<byte[], byte[]>> getMulti(@Nullable LLSnapshot snapshot, Flux<byte[]> keys);
2020-12-07 22:15:18 +01:00
2021-01-30 00:24:55 +01:00
Flux<Entry<byte[], byte[]>> putMulti(Flux<Entry<byte[], byte[]>> entries, boolean getOldValues);
2020-12-07 22:15:18 +01:00
2021-01-30 00:24:55 +01:00
Flux<Entry<byte[], byte[]>> getRange(@Nullable LLSnapshot snapshot, LLRange range);
2020-12-07 22:15:18 +01:00
Flux<List<Entry<byte[], byte[]>>> getRangeGrouped(@Nullable LLSnapshot snapshot, LLRange range, int prefixLength);
Flux<byte[]> getRangeKeys(@Nullable LLSnapshot snapshot, LLRange range);
Flux<List<byte[]>> getRangeKeysGrouped(@Nullable LLSnapshot snapshot, LLRange range, int prefixLength);
2021-01-30 00:24:55 +01:00
Flux<Entry<byte[], byte[]>> setRange(LLRange range, Flux<Entry<byte[], byte[]>> entries, boolean getOldValues);
2020-12-07 22:15:18 +01:00
2021-01-30 00:24:55 +01:00
default Mono<Void> replaceRange(LLRange range, boolean canKeysChange, Function<Entry<byte[], byte[]>, Mono<Entry<byte[], byte[]>>> entriesReplacer) {
return Mono.defer(() -> {
if (canKeysChange) {
return this
.setRange(range, this
.getRange(null, range)
.flatMap(entriesReplacer), false)
.then();
} else {
return this
.putMulti(this
.getRange(null, range)
.flatMap(entriesReplacer), false)
.then();
}
});
2021-01-30 00:24:55 +01:00
}
2020-12-07 22:15:18 +01:00
2021-01-30 00:24:55 +01:00
Mono<Boolean> isRangeEmpty(@Nullable LLSnapshot snapshot, LLRange range);
2020-12-07 22:15:18 +01:00
2021-01-30 00:24:55 +01:00
Mono<Long> sizeRange(@Nullable LLSnapshot snapshot, LLRange range, boolean fast);
2020-12-07 22:15:18 +01:00
Mono<Entry<byte[], byte[]>> getOne(@Nullable LLSnapshot snapshot, LLRange range);
Mono<byte[]> getOneKey(@Nullable LLSnapshot snapshot, LLRange range);
2021-01-30 00:24:55 +01:00
Mono<Entry<byte[], byte[]>> removeOne(LLRange range);
2020-12-07 22:15:18 +01:00
}