2020-12-07 22:15:18 +01:00
|
|
|
package it.cavallium.dbengine.database;
|
|
|
|
|
2022-03-16 13:47:56 +01:00
|
|
|
import io.netty5.buffer.api.Buffer;
|
|
|
|
import io.netty5.buffer.api.BufferAllocator;
|
|
|
|
import io.netty5.buffer.api.Send;
|
2021-06-27 11:58:12 +02:00
|
|
|
import it.cavallium.dbengine.client.BadBlock;
|
2022-04-01 01:30:56 +02:00
|
|
|
import it.cavallium.dbengine.database.disk.BinarySerializationFunction;
|
2021-11-08 10:49:59 +01:00
|
|
|
import it.cavallium.dbengine.database.serialization.KVSerializationFunction;
|
2021-08-22 21:23:22 +02:00
|
|
|
import it.cavallium.dbengine.database.serialization.SerializationFunction;
|
2021-02-02 00:09:46 +01:00
|
|
|
import java.util.List;
|
2021-07-23 15:20:33 +02:00
|
|
|
import java.util.Optional;
|
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;
|
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
|
|
|
|
2021-02-03 14:37:02 +01:00
|
|
|
@SuppressWarnings("unused")
|
2020-12-07 22:15:18 +01:00
|
|
|
public interface LLDictionary extends LLKeyValueDatabaseStructure {
|
|
|
|
|
2021-06-26 02:35:33 +02:00
|
|
|
String getColumnName();
|
|
|
|
|
2021-08-29 23:18:03 +02:00
|
|
|
BufferAllocator getAllocator();
|
2021-03-18 16:19:41 +01:00
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Mono<Buffer> get(@Nullable LLSnapshot snapshot, Mono<Buffer> key);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Mono<Buffer> put(Mono<Buffer> key, Mono<Buffer> value, LLDictionaryResultType resultType);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2021-05-02 19:18:15 +02:00
|
|
|
Mono<UpdateMode> getUpdateMode();
|
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
default Mono<Buffer> update(Mono<Buffer> key,
|
2022-04-01 01:30:56 +02:00
|
|
|
BinarySerializationFunction updater,
|
2022-03-02 18:33:58 +01:00
|
|
|
UpdateReturnMode updateReturnMode) {
|
2021-05-08 03:09:00 +02:00
|
|
|
return this
|
2022-03-02 18:33:58 +01:00
|
|
|
.updateAndGetDelta(key, updater)
|
2021-08-29 23:18:03 +02:00
|
|
|
.transform(prev -> LLUtils.resolveLLDelta(prev, updateReturnMode));
|
2021-05-08 03:09:00 +02:00
|
|
|
}
|
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Mono<LLDelta> updateAndGetDelta(Mono<Buffer> key, BinarySerializationFunction updater);
|
2021-02-06 19:21:31 +01:00
|
|
|
|
2021-03-14 03:13:19 +01:00
|
|
|
Mono<Void> clear();
|
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Mono<Buffer> remove(Mono<Buffer> key, LLDictionaryResultType resultType);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Flux<Optional<Buffer>> getMulti(@Nullable LLSnapshot snapshot, Flux<Buffer> keys);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Mono<Void> putMulti(Flux<LLEntry> entries);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
<K> Flux<Boolean> updateMulti(Flux<K> keys, Flux<Buffer> serializedKeys,
|
|
|
|
KVSerializationFunction<K, @Nullable Buffer, @Nullable Buffer> updateFunction);
|
2021-07-17 11:52:08 +02:00
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Flux<LLEntry> getRange(@Nullable LLSnapshot snapshot,
|
|
|
|
Mono<LLRange> range,
|
2022-03-24 23:56:23 +01:00
|
|
|
boolean reverse,
|
|
|
|
boolean smallRange);
|
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Flux<List<LLEntry>> getRangeGrouped(@Nullable LLSnapshot snapshot,
|
|
|
|
Mono<LLRange> range,
|
2022-03-24 23:56:23 +01:00
|
|
|
int prefixLength,
|
|
|
|
boolean smallRange);
|
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Flux<Buffer> getRangeKeys(@Nullable LLSnapshot snapshot,
|
|
|
|
Mono<LLRange> range,
|
2022-03-24 23:56:23 +01:00
|
|
|
boolean reverse,
|
|
|
|
boolean smallRange);
|
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Flux<List<Buffer>> getRangeKeysGrouped(@Nullable LLSnapshot snapshot,
|
|
|
|
Mono<LLRange> range,
|
2022-03-24 23:56:23 +01:00
|
|
|
int prefixLength,
|
|
|
|
boolean smallRange);
|
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Flux<Buffer> getRangeKeyPrefixes(@Nullable LLSnapshot snapshot,
|
|
|
|
Mono<LLRange> range,
|
2022-03-24 23:56:23 +01:00
|
|
|
int prefixLength,
|
|
|
|
boolean smallRange);
|
2021-02-02 00:09:46 +01:00
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Flux<BadBlock> badBlocks(Mono<LLRange> range);
|
2021-06-27 11:58:12 +02:00
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Mono<Void> setRange(Mono<LLRange> range, Flux<LLEntry> entries, boolean smallRange);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
default Mono<Void> replaceRange(Mono<LLRange> range,
|
2021-03-18 16:19:41 +01:00
|
|
|
boolean canKeysChange,
|
2022-05-20 10:20:00 +02:00
|
|
|
Function<LLEntry, Mono<LLEntry>> entriesReplacer,
|
2022-03-24 23:56:23 +01:00
|
|
|
boolean smallRange) {
|
2021-02-02 00:09:46 +01:00
|
|
|
return Mono.defer(() -> {
|
|
|
|
if (canKeysChange) {
|
|
|
|
return this
|
|
|
|
.setRange(range, this
|
2022-03-24 23:56:23 +01:00
|
|
|
.getRange(null, range, false, smallRange)
|
|
|
|
.flatMap(entriesReplacer), smallRange);
|
2021-02-02 00:09:46 +01:00
|
|
|
} else {
|
2022-03-24 23:56:23 +01:00
|
|
|
return this.putMulti(this.getRange(null, range, false, smallRange).flatMap(entriesReplacer));
|
2021-02-02 00:09:46 +01:00
|
|
|
}
|
|
|
|
});
|
2021-01-30 00:24:55 +01:00
|
|
|
}
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Mono<Boolean> isRangeEmpty(@Nullable LLSnapshot snapshot, Mono<LLRange> range, boolean fillCache);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Mono<Long> sizeRange(@Nullable LLSnapshot snapshot, Mono<LLRange> range, boolean fast);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Mono<LLEntry> getOne(@Nullable LLSnapshot snapshot, Mono<LLRange> range);
|
2021-02-02 15:36:11 +01:00
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Mono<Buffer> getOneKey(@Nullable LLSnapshot snapshot, Mono<LLRange> range);
|
2021-02-02 15:36:11 +01:00
|
|
|
|
2022-05-20 10:20:00 +02:00
|
|
|
Mono<LLEntry> removeOne(Mono<LLRange> range);
|
2020-12-07 22:15:18 +01:00
|
|
|
}
|