package it.cavallium.dbengine.database; import java.util.List; import java.util.Map.Entry; import java.util.Optional; import java.util.function.Function; import org.jetbrains.annotations.Nullable; import org.warp.commonutils.concurrency.atomicity.NotAtomic; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @SuppressWarnings("unused") @NotAtomic public interface LLDictionary extends LLKeyValueDatabaseStructure { Mono get(@Nullable LLSnapshot snapshot, byte[] key, boolean existsAlmostCertainly); default Mono get(@Nullable LLSnapshot snapshot, byte[] key) { return get(snapshot, key, false); } Mono put(byte[] key, byte[] value, LLDictionaryResultType resultType); Mono update(byte[] key, Function, Optional> updater, boolean existsAlmostCertainly); default Mono update(byte[] key, Function, Optional> updater) { return update(key, updater, false); } Mono clear(); Mono remove(byte[] key, LLDictionaryResultType resultType); Flux> getMulti(@Nullable LLSnapshot snapshot, Flux keys, boolean existsAlmostCertainly); default Flux> getMulti(@Nullable LLSnapshot snapshot, Flux keys) { return getMulti(snapshot, keys, false); } Flux> putMulti(Flux> entries, boolean getOldValues); Flux> getRange(@Nullable LLSnapshot snapshot, LLRange range, boolean existsAlmostCertainly); default Flux> getRange(@Nullable LLSnapshot snapshot, LLRange range) { return getRange(snapshot, range, false); } Flux>> getRangeGrouped(@Nullable LLSnapshot snapshot, LLRange range, int prefixLength, boolean existsAlmostCertainly); default Flux>> getRangeGrouped(@Nullable LLSnapshot snapshot, LLRange range, int prefixLength) { return getRangeGrouped(snapshot, range, prefixLength, false); } Flux getRangeKeys(@Nullable LLSnapshot snapshot, LLRange range); Flux> getRangeKeysGrouped(@Nullable LLSnapshot snapshot, LLRange range, int prefixLength); Flux getRangeKeyPrefixes(@Nullable LLSnapshot snapshot, LLRange range, int prefixLength); Flux> setRange(LLRange range, Flux> entries, boolean getOldValues); default Mono replaceRange(LLRange range, boolean canKeysChange, Function, Mono>> entriesReplacer, boolean existsAlmostCertainly) { return Mono.defer(() -> { if (canKeysChange) { return this .setRange(range, this .getRange(null, range, existsAlmostCertainly) .flatMap(entriesReplacer), false) .then(); } else { return this .putMulti(this .getRange(null, range, existsAlmostCertainly) .flatMap(entriesReplacer), false) .then(); } }); } default Mono replaceRange(LLRange range, boolean canKeysChange, Function, Mono>> entriesReplacer) { return replaceRange(range, canKeysChange, entriesReplacer, false); } Mono isRangeEmpty(@Nullable LLSnapshot snapshot, LLRange range); Mono sizeRange(@Nullable LLSnapshot snapshot, LLRange range, boolean fast); Mono> getOne(@Nullable LLSnapshot snapshot, LLRange range); Mono getOneKey(@Nullable LLSnapshot snapshot, LLRange range); Mono> removeOne(LLRange range); }