package it.cavallium.dbengine.database.collections; import io.netty.buffer.ByteBuf; import it.cavallium.dbengine.client.CompositeSnapshot; import it.cavallium.dbengine.database.LLDictionary; import it.cavallium.dbengine.database.collections.DatabaseEmpty.Nothing; import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength; import java.util.HashMap; import java.util.Map; import java.util.Set; import org.jetbrains.annotations.Nullable; import reactor.core.publisher.Mono; @SuppressWarnings("unused") public class DatabaseSetDictionary extends DatabaseMapDictionary { protected DatabaseSetDictionary(LLDictionary dictionary, ByteBuf prefixKey, SerializerFixedBinaryLength keySuffixSerializer) { super(dictionary, prefixKey, keySuffixSerializer, DatabaseEmpty.NOTHING_SERIALIZER); } public static DatabaseSetDictionary simple(LLDictionary dictionary, SerializerFixedBinaryLength keySerializer) { return new DatabaseSetDictionary<>(dictionary, dictionary.getAllocator().buffer(0), keySerializer); } public static DatabaseSetDictionary tail(LLDictionary dictionary, ByteBuf prefixKey, SerializerFixedBinaryLength keySuffixSerializer) { return new DatabaseSetDictionary<>(dictionary, prefixKey, keySuffixSerializer); } public Mono> getKeySet(@Nullable CompositeSnapshot snapshot) { return get(snapshot).map(Map::keySet); } public Mono> setAndGetPreviousKeySet(Set value) { var hm = new HashMap(); for (T t : value) { hm.put(t, DatabaseEmpty.NOTHING); } return setAndGetPrevious(hm).map(Map::keySet); } public Mono> clearAndGetPreviousKeySet() { return clearAndGetPrevious().map(Map::keySet); } }