package it.cavallium.dbengine.database; import it.cavallium.buffer.Buf; import it.cavallium.dbengine.client.DbProgress; import it.cavallium.dbengine.client.SSTVerificationProgress; import it.cavallium.dbengine.database.serialization.KVSerializationFunction; import it.cavallium.dbengine.database.serialization.SerializationFunction; import java.util.List; import java.util.function.Function; import java.util.stream.Stream; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @SuppressWarnings("unused") public interface LLDictionary extends LLKeyValueDatabaseStructure { String getColumnName(); Buf get(@Nullable LLSnapshot snapshot, Buf key); Buf put(Buf key, Buf value, LLDictionaryResultType resultType); UpdateMode getUpdateMode(); default Buf update(Buf key, SerializationFunction<@Nullable Buf, @Nullable Buf> updater, UpdateReturnMode updateReturnMode) { LLDelta prev = this.updateAndGetDelta(key, updater); return LLUtils.resolveLLDelta(prev, updateReturnMode); } LLDelta updateAndGetDelta(Buf key, SerializationFunction<@Nullable Buf, @Nullable Buf> updater); void clear(); Buf remove(Buf key, LLDictionaryResultType resultType); Stream getMulti(@Nullable LLSnapshot snapshot, Stream keys); void putMulti(Stream entries); Stream updateMulti(Stream> keys, KVSerializationFunction updateFunction); Stream getRange(@Nullable LLSnapshot snapshot, LLRange range, boolean reverse, boolean smallRange); Stream> getRangeGrouped(@Nullable LLSnapshot snapshot, LLRange range, int prefixLength, boolean smallRange); Stream getRangeKeys(@Nullable LLSnapshot snapshot, LLRange range, boolean reverse, boolean smallRange); Stream> getRangeKeysGrouped(@Nullable LLSnapshot snapshot, LLRange range, int prefixLength, boolean smallRange); Stream getRangeKeyPrefixes(@Nullable LLSnapshot snapshot, LLRange range, int prefixLength, boolean smallRange); Stream> verifyChecksum(LLRange range); void setRange(LLRange range, Stream entries, boolean smallRange); default void replaceRange(LLRange range, boolean canKeysChange, Function<@NotNull LLEntry, @NotNull LLEntry> entriesReplacer, boolean smallRange) { if (canKeysChange) { this.setRange(range, this.getRange(null, range, false, smallRange).map(entriesReplacer), smallRange); } else { this.putMulti(this.getRange(null, range, false, smallRange).map(entriesReplacer)); } } boolean isRangeEmpty(@Nullable LLSnapshot snapshot, LLRange range, boolean fillCache); long sizeRange(@Nullable LLSnapshot snapshot, LLRange range, boolean fast); LLEntry getOne(@Nullable LLSnapshot snapshot, LLRange range); Buf getOneKey(@Nullable LLSnapshot snapshot, LLRange range); LLEntry removeOne(LLRange range); }