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

106 lines
3.5 KiB
Java
Raw Normal View History

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;
import it.cavallium.dbengine.client.BadBlock;
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;
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-03-24 21:14:17 +01:00
Mono<Send<Buffer>> get(@Nullable LLSnapshot snapshot, Mono<Send<Buffer>> key);
2020-12-07 22:15:18 +01:00
2021-08-29 23:18:03 +02:00
Mono<Send<Buffer>> put(Mono<Send<Buffer>> key, Mono<Send<Buffer>> value, LLDictionaryResultType resultType);
2020-12-07 22:15:18 +01:00
2021-05-02 19:18:15 +02:00
Mono<UpdateMode> getUpdateMode();
2021-08-29 23:18:03 +02:00
default Mono<Send<Buffer>> update(Mono<Send<Buffer>> key,
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
}
Mono<Send<LLDelta>> updateAndGetDelta(Mono<Send<Buffer>> key, BinarySerializationFunction updater);
2021-02-06 19:21:31 +01:00
2021-03-14 03:13:19 +01:00
Mono<Void> clear();
2021-08-29 23:18:03 +02:00
Mono<Send<Buffer>> remove(Mono<Send<Buffer>> key, LLDictionaryResultType resultType);
2020-12-07 22:15:18 +01:00
2022-03-24 21:14:17 +01:00
Flux<Optional<Buffer>> getMulti(@Nullable LLSnapshot snapshot, Flux<Send<Buffer>> keys);
2020-12-07 22:15:18 +01:00
2022-01-26 19:03:51 +01:00
Mono<Void> putMulti(Flux<Send<LLEntry>> entries);
2020-12-07 22:15:18 +01:00
2021-11-08 10:49:59 +01:00
<K> Flux<Boolean> updateMulti(Flux<K> keys, Flux<Send<Buffer>> serializedKeys,
2021-11-08 16:33:41 +01:00
KVSerializationFunction<K, @Nullable Send<Buffer>, @Nullable Buffer> updateFunction);
2021-07-17 11:52:08 +02:00
2022-03-24 23:56:23 +01:00
Flux<Send<LLEntry>> getRange(@Nullable LLSnapshot snapshot,
Mono<Send<LLRange>> range,
boolean reverse,
boolean smallRange);
Flux<List<Send<LLEntry>>> getRangeGrouped(@Nullable LLSnapshot snapshot,
Mono<Send<LLRange>> range,
int prefixLength,
boolean smallRange);
Flux<Send<Buffer>> getRangeKeys(@Nullable LLSnapshot snapshot,
Mono<Send<LLRange>> range,
boolean reverse,
boolean smallRange);
Flux<List<Send<Buffer>>> getRangeKeysGrouped(@Nullable LLSnapshot snapshot,
Mono<Send<LLRange>> range,
int prefixLength,
boolean smallRange);
Flux<Send<Buffer>> getRangeKeyPrefixes(@Nullable LLSnapshot snapshot,
Mono<Send<LLRange>> range,
int prefixLength,
boolean smallRange);
2021-08-29 23:18:03 +02:00
Flux<BadBlock> badBlocks(Mono<Send<LLRange>> range);
2022-03-24 23:56:23 +01:00
Mono<Void> setRange(Mono<Send<LLRange>> range, Flux<Send<LLEntry>> entries, boolean smallRange);
2020-12-07 22:15:18 +01:00
2021-08-29 23:18:03 +02:00
default Mono<Void> replaceRange(Mono<Send<LLRange>> range,
2021-03-18 16:19:41 +01:00
boolean canKeysChange,
2021-08-29 23:18:03 +02:00
Function<Send<LLEntry>, Mono<Send<LLEntry>>> entriesReplacer,
2022-03-24 23:56:23 +01:00
boolean smallRange) {
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);
} else {
2022-03-24 23:56:23 +01:00
return this.putMulti(this.getRange(null, range, false, smallRange).flatMap(entriesReplacer));
}
});
2021-01-30 00:24:55 +01:00
}
2020-12-07 22:15:18 +01:00
Mono<Boolean> isRangeEmpty(@Nullable LLSnapshot snapshot, Mono<Send<LLRange>> range, boolean fillCache);
2020-12-07 22:15:18 +01:00
2021-08-29 23:18:03 +02:00
Mono<Long> sizeRange(@Nullable LLSnapshot snapshot, Mono<Send<LLRange>> range, boolean fast);
2020-12-07 22:15:18 +01:00
2021-08-29 23:18:03 +02:00
Mono<Send<LLEntry>> getOne(@Nullable LLSnapshot snapshot, Mono<Send<LLRange>> range);
2021-08-29 23:18:03 +02:00
Mono<Send<Buffer>> getOneKey(@Nullable LLSnapshot snapshot, Mono<Send<LLRange>> range);
2021-08-29 23:18:03 +02:00
Mono<Send<LLEntry>> removeOne(Mono<Send<LLRange>> range);
2020-12-07 22:15:18 +01:00
}