package it.cavallium.dbengine.database; 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; import it.cavallium.dbengine.database.serialization.KVSerializationFunction; import it.cavallium.dbengine.database.serialization.SerializationFunction; import java.util.List; import java.util.Optional; import java.util.function.Function; import org.jetbrains.annotations.Nullable; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @SuppressWarnings("unused") public interface LLDictionary extends LLKeyValueDatabaseStructure { String getColumnName(); BufferAllocator getAllocator(); Mono> get(@Nullable LLSnapshot snapshot, Mono> key); Mono> put(Mono> key, Mono> value, LLDictionaryResultType resultType); Mono getUpdateMode(); default Mono> update(Mono> key, BinarySerializationFunction updater, UpdateReturnMode updateReturnMode) { return this .updateAndGetDelta(key, updater) .transform(prev -> LLUtils.resolveLLDelta(prev, updateReturnMode)); } Mono> updateAndGetDelta(Mono> key, BinarySerializationFunction updater); Mono clear(); Mono> remove(Mono> key, LLDictionaryResultType resultType); Flux> getMulti(@Nullable LLSnapshot snapshot, Flux> keys); Mono putMulti(Flux> entries); Flux updateMulti(Flux keys, Flux> serializedKeys, KVSerializationFunction, @Nullable Buffer> updateFunction); Flux> getRange(@Nullable LLSnapshot snapshot, Mono> range, boolean reverse, boolean smallRange); Flux>> getRangeGrouped(@Nullable LLSnapshot snapshot, Mono> range, int prefixLength, boolean smallRange); Flux> getRangeKeys(@Nullable LLSnapshot snapshot, Mono> range, boolean reverse, boolean smallRange); Flux>> getRangeKeysGrouped(@Nullable LLSnapshot snapshot, Mono> range, int prefixLength, boolean smallRange); Flux> getRangeKeyPrefixes(@Nullable LLSnapshot snapshot, Mono> range, int prefixLength, boolean smallRange); Flux badBlocks(Mono> range); Mono setRange(Mono> range, Flux> entries, boolean smallRange); default Mono replaceRange(Mono> range, boolean canKeysChange, Function, Mono>> entriesReplacer, boolean smallRange) { return Mono.defer(() -> { if (canKeysChange) { return this .setRange(range, this .getRange(null, range, false, smallRange) .flatMap(entriesReplacer), smallRange); } else { return this.putMulti(this.getRange(null, range, false, smallRange).flatMap(entriesReplacer)); } }); } Mono isRangeEmpty(@Nullable LLSnapshot snapshot, Mono> range, boolean fillCache); Mono sizeRange(@Nullable LLSnapshot snapshot, Mono> range, boolean fast); Mono> getOne(@Nullable LLSnapshot snapshot, Mono> range); Mono> getOneKey(@Nullable LLSnapshot snapshot, Mono> range); Mono> removeOne(Mono> range); }