2020-12-07 22:15:18 +01:00
|
|
|
package it.cavallium.dbengine.database;
|
|
|
|
|
2023-03-06 12:19:08 +01:00
|
|
|
import it.cavallium.buffer.Buf;
|
2023-10-10 00:39:41 +02:00
|
|
|
import it.cavallium.dbengine.client.DbProgress;
|
|
|
|
import it.cavallium.dbengine.client.SSTVerificationProgress;
|
2021-11-08 10:49:59 +01:00
|
|
|
import it.cavallium.dbengine.database.serialization.KVSerializationFunction;
|
2023-03-27 22:00:32 +02:00
|
|
|
import it.cavallium.dbengine.database.serialization.SerializationFunction;
|
2021-02-02 00:09:46 +01:00
|
|
|
import java.util.List;
|
2024-04-18 14:48:16 +02:00
|
|
|
import java.util.concurrent.ForkJoinPool;
|
2021-01-30 00:24:55 +01:00
|
|
|
import java.util.function.Function;
|
2023-02-09 23:34:25 +01:00
|
|
|
import java.util.stream.Stream;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
2020-12-07 22:15:18 +01:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
|
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();
|
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
Buf get(@Nullable LLSnapshot snapshot, Buf key);
|
2021-03-18 16:19:41 +01:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
Buf put(Buf key, Buf value, LLDictionaryResultType resultType);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2022-09-12 20:14:56 +02:00
|
|
|
UpdateMode getUpdateMode();
|
2021-05-02 19:18:15 +02:00
|
|
|
|
2023-03-27 22:00:32 +02:00
|
|
|
default Buf update(Buf key, SerializationFunction<@Nullable Buf, @Nullable Buf> updater, UpdateReturnMode updateReturnMode) {
|
2023-02-09 23:34:25 +01:00
|
|
|
LLDelta prev = this.updateAndGetDelta(key, updater);
|
|
|
|
return LLUtils.resolveLLDelta(prev, updateReturnMode);
|
2021-05-08 03:09:00 +02:00
|
|
|
}
|
|
|
|
|
2023-03-27 22:00:32 +02:00
|
|
|
LLDelta updateAndGetDelta(Buf key, SerializationFunction<@Nullable Buf, @Nullable Buf> updater);
|
2021-02-06 19:21:31 +01:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
void clear();
|
2021-03-14 03:13:19 +01:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
Buf remove(Buf key, LLDictionaryResultType resultType);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
Stream<OptionalBuf> getMulti(@Nullable LLSnapshot snapshot, Stream<Buf> keys);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
void putMulti(Stream<LLEntry> entries);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2023-02-24 17:19:25 +01:00
|
|
|
<K> Stream<Boolean> updateMulti(Stream<SerializedKey<K>> keys,
|
2023-02-09 23:34:25 +01:00
|
|
|
KVSerializationFunction<K, @Nullable Buf, @Nullable Buf> updateFunction);
|
2021-07-17 11:52:08 +02:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
Stream<LLEntry> getRange(@Nullable LLSnapshot snapshot,
|
|
|
|
LLRange range,
|
2022-03-24 23:56:23 +01:00
|
|
|
boolean reverse,
|
|
|
|
boolean smallRange);
|
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
Stream<List<LLEntry>> getRangeGrouped(@Nullable LLSnapshot snapshot,
|
|
|
|
LLRange range,
|
2022-03-24 23:56:23 +01:00
|
|
|
int prefixLength,
|
|
|
|
boolean smallRange);
|
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
Stream<Buf> getRangeKeys(@Nullable LLSnapshot snapshot,
|
|
|
|
LLRange range,
|
2022-03-24 23:56:23 +01:00
|
|
|
boolean reverse,
|
2023-02-22 16:59:35 +01:00
|
|
|
boolean smallRange);
|
2022-03-24 23:56:23 +01:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
Stream<List<Buf>> getRangeKeysGrouped(@Nullable LLSnapshot snapshot,
|
|
|
|
LLRange range,
|
2022-03-24 23:56:23 +01:00
|
|
|
int prefixLength,
|
|
|
|
boolean smallRange);
|
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
Stream<Buf> getRangeKeyPrefixes(@Nullable LLSnapshot snapshot,
|
|
|
|
LLRange range,
|
2022-03-24 23:56:23 +01:00
|
|
|
int prefixLength,
|
|
|
|
boolean smallRange);
|
2021-02-02 00:09:46 +01:00
|
|
|
|
2023-10-10 00:39:41 +02:00
|
|
|
Stream<DbProgress<SSTVerificationProgress>> verifyChecksum(LLRange range);
|
2021-06-27 11:58:12 +02:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
void setRange(LLRange range, Stream<LLEntry> entries, boolean smallRange);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
default void replaceRange(LLRange range,
|
2021-03-18 16:19:41 +01:00
|
|
|
boolean canKeysChange,
|
2023-02-09 23:34:25 +01:00
|
|
|
Function<@NotNull LLEntry, @NotNull LLEntry> entriesReplacer,
|
2022-03-24 23:56:23 +01:00
|
|
|
boolean smallRange) {
|
2023-02-09 23:34:25 +01:00
|
|
|
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));
|
|
|
|
}
|
2021-01-30 00:24:55 +01:00
|
|
|
}
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
boolean isRangeEmpty(@Nullable LLSnapshot snapshot, LLRange range, boolean fillCache);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
long sizeRange(@Nullable LLSnapshot snapshot, LLRange range, boolean fast);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
LLEntry getOne(@Nullable LLSnapshot snapshot, LLRange range);
|
2021-02-02 15:36:11 +01:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
Buf getOneKey(@Nullable LLSnapshot snapshot, LLRange range);
|
2021-02-02 15:36:11 +01:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
LLEntry removeOne(LLRange range);
|
2020-12-07 22:15:18 +01:00
|
|
|
}
|