package it.cavallium.dbengine.database.collections; import io.netty5.buffer.api.Buffer; import io.netty5.buffer.api.Drop; import io.netty5.buffer.api.Send; import it.cavallium.dbengine.client.CompositeSnapshot; import it.cavallium.dbengine.database.BufSupplier; import it.cavallium.dbengine.database.LLDictionary; import it.cavallium.dbengine.database.LLUtils; import it.cavallium.dbengine.database.collections.DatabaseEmpty.Nothing; import it.cavallium.dbengine.database.serialization.Serializer; import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength; import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.function.Function; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import reactor.core.publisher.Mono; @SuppressWarnings("unused") public class DatabaseSetDictionaryHashed extends DatabaseMapDictionaryHashed { protected DatabaseSetDictionaryHashed(LLDictionary dictionary, @Nullable BufSupplier prefixKeySupplier, Serializer keySuffixSerializer, Function keySuffixHashFunction, SerializerFixedBinaryLength keySuffixHashSerializer, Runnable onClose) { super(dictionary, prefixKeySupplier, keySuffixSerializer, DatabaseEmpty.nothingSerializer(dictionary.getAllocator()), keySuffixHashFunction, keySuffixHashSerializer, onClose ); } public static DatabaseSetDictionaryHashed simple(LLDictionary dictionary, Serializer keySerializer, Function keyHashFunction, SerializerFixedBinaryLength keyHashSerializer, Runnable onClose) { return new DatabaseSetDictionaryHashed<>(dictionary, null, keySerializer, keyHashFunction, keyHashSerializer, onClose ); } public static DatabaseSetDictionaryHashed tail(LLDictionary dictionary, @Nullable BufSupplier prefixKeySupplier, Serializer keySuffixSerializer, Function keyHashFunction, SerializerFixedBinaryLength keyHashSerializer, Runnable onClose) { return new DatabaseSetDictionaryHashed<>(dictionary, prefixKeySupplier, keySuffixSerializer, keyHashFunction, keyHashSerializer, onClose ); } public Mono> getKeySet(@Nullable CompositeSnapshot snapshot) { return get(snapshot).map(Map::keySet); } public Mono> setAndGetPreviousKeySet(Set value) { var hm = new Object2ObjectLinkedOpenHashMap(); for (T t : value) { hm.put(t, DatabaseEmpty.NOTHING); } return setAndGetPrevious(hm).map(Map::keySet); } public Mono> clearAndGetPreviousKeySet() { return clearAndGetPrevious().map(Map::keySet); } }