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

94 lines
2.9 KiB
Java
Raw Normal View History

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;
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;
import java.util.List;
import java.util.concurrent.ForkJoinPool;
2021-01-30 00:24:55 +01:00
import java.util.function.Function;
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();
Buf get(@Nullable LLSnapshot snapshot, Buf key);
2021-03-18 16:19:41 +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) {
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
void clear();
2021-03-14 03:13:19 +01:00
Buf remove(Buf key, LLDictionaryResultType resultType);
2020-12-07 22:15:18 +01:00
Stream<OptionalBuf> getMulti(@Nullable LLSnapshot snapshot, Stream<Buf> keys);
2020-12-07 22:15:18 +01:00
void putMulti(Stream<LLEntry> entries);
2020-12-07 22:15:18 +01:00
<K> Stream<Boolean> updateMulti(Stream<SerializedKey<K>> keys,
KVSerializationFunction<K, @Nullable Buf, @Nullable Buf> updateFunction);
2021-07-17 11:52:08 +02:00
Stream<LLEntry> getRange(@Nullable LLSnapshot snapshot,
LLRange range,
2022-03-24 23:56:23 +01:00
boolean reverse,
boolean smallRange);
Stream<List<LLEntry>> getRangeGrouped(@Nullable LLSnapshot snapshot,
LLRange range,
2022-03-24 23:56:23 +01:00
int prefixLength,
boolean smallRange);
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
Stream<List<Buf>> getRangeKeysGrouped(@Nullable LLSnapshot snapshot,
LLRange range,
2022-03-24 23:56:23 +01:00
int prefixLength,
boolean smallRange);
Stream<Buf> getRangeKeyPrefixes(@Nullable LLSnapshot snapshot,
LLRange range,
2022-03-24 23:56:23 +01:00
int prefixLength,
boolean smallRange);
Stream<DbProgress<SSTVerificationProgress>> verifyChecksum(LLRange range);
void setRange(LLRange range, Stream<LLEntry> entries, boolean smallRange);
2020-12-07 22:15:18 +01:00
default void replaceRange(LLRange range,
2021-03-18 16:19:41 +01:00
boolean canKeysChange,
Function<@NotNull LLEntry, @NotNull LLEntry> entriesReplacer,
2022-03-24 23:56:23 +01:00
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));
}
2021-01-30 00:24:55 +01:00
}
2020-12-07 22:15:18 +01:00
boolean isRangeEmpty(@Nullable LLSnapshot snapshot, LLRange range, boolean fillCache);
2020-12-07 22:15:18 +01:00
long sizeRange(@Nullable LLSnapshot snapshot, LLRange range, boolean fast);
2020-12-07 22:15:18 +01:00
LLEntry getOne(@Nullable LLSnapshot snapshot, LLRange range);
Buf getOneKey(@Nullable LLSnapshot snapshot, LLRange range);
LLEntry removeOne(LLRange range);
2020-12-07 22:15:18 +01:00
}