2020-12-07 22:15:18 +01:00
|
|
|
package it.cavallium.dbengine.database;
|
|
|
|
|
|
|
|
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
|
|
|
|
2021-01-30 19:27:59 +01:00
|
|
|
Flux<byte[]> getRangeKeys(@Nullable LLSnapshot snapshot, LLRange range);
|
|
|
|
|
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) {
|
|
|
|
Flux<Entry<byte[], byte[]>> replacedFlux = this.getRange(null, range).flatMap(entriesReplacer);
|
|
|
|
if (canKeysChange) {
|
|
|
|
return this
|
|
|
|
.setRange(range, replacedFlux, false)
|
|
|
|
.then();
|
|
|
|
} else {
|
|
|
|
return this
|
|
|
|
.putMulti(replacedFlux, false)
|
|
|
|
.then();
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
2021-01-30 00:24:55 +01:00
|
|
|
Mono<Entry<byte[], byte[]>> removeOne(LLRange range);
|
2020-12-07 22:15:18 +01:00
|
|
|
}
|