2021-04-12 17:53:29 +02:00
|
|
|
package it.cavallium.dbengine.database.collections;
|
|
|
|
|
2022-03-16 13:47:56 +01:00
|
|
|
import io.netty5.buffer.api.Buffer;
|
2022-07-15 02:44:50 +02:00
|
|
|
import io.netty5.util.Resource;
|
|
|
|
import io.netty5.util.Send;
|
2021-04-12 17:53:29 +02:00
|
|
|
import it.cavallium.dbengine.client.CompositeSnapshot;
|
2022-05-21 01:06:55 +02:00
|
|
|
import it.cavallium.dbengine.database.BufSupplier;
|
2021-04-12 17:53:29 +02:00
|
|
|
import it.cavallium.dbengine.database.LLDictionary;
|
2021-11-08 16:33:41 +01:00
|
|
|
import it.cavallium.dbengine.database.LLUtils;
|
2021-04-12 17:53:29 +02:00
|
|
|
import it.cavallium.dbengine.database.collections.DatabaseEmpty.Nothing;
|
|
|
|
import it.cavallium.dbengine.database.serialization.Serializer;
|
|
|
|
import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength;
|
2021-12-18 18:16:56 +01:00
|
|
|
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
|
2021-04-12 17:53:29 +02:00
|
|
|
import java.util.Map;
|
|
|
|
import java.util.function.Function;
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
2021-08-22 18:20:05 +02:00
|
|
|
@SuppressWarnings({"unused", "ClassCanBeRecord"})
|
2021-04-12 17:53:29 +02:00
|
|
|
public class SubStageGetterHashSet<T, TH> implements
|
2021-12-18 18:16:56 +01:00
|
|
|
SubStageGetter<Object2ObjectSortedMap<T, Nothing>, DatabaseSetDictionaryHashed<T, TH>> {
|
2021-04-12 17:53:29 +02:00
|
|
|
|
2022-03-20 14:33:27 +01:00
|
|
|
final Serializer<T> keySerializer;
|
|
|
|
final Function<T, TH> keyHashFunction;
|
|
|
|
final SerializerFixedBinaryLength<TH> keyHashSerializer;
|
2021-04-12 17:53:29 +02:00
|
|
|
|
2021-09-02 17:15:40 +02:00
|
|
|
public SubStageGetterHashSet(Serializer<T> keySerializer,
|
2021-04-12 17:53:29 +02:00
|
|
|
Function<T, TH> keyHashFunction,
|
2021-09-02 17:15:40 +02:00
|
|
|
SerializerFixedBinaryLength<TH> keyHashSerializer) {
|
2021-04-12 17:53:29 +02:00
|
|
|
this.keySerializer = keySerializer;
|
|
|
|
this.keyHashFunction = keyHashFunction;
|
|
|
|
this.keyHashSerializer = keyHashSerializer;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Mono<DatabaseSetDictionaryHashed<T, TH>> subStage(LLDictionary dictionary,
|
|
|
|
@Nullable CompositeSnapshot snapshot,
|
2022-05-21 01:06:55 +02:00
|
|
|
Mono<Buffer> prefixKeyMono) {
|
|
|
|
return prefixKeyMono.map(prefixKey -> DatabaseSetDictionaryHashed.tail(dictionary,
|
|
|
|
BufSupplier.ofOwned(prefixKey),
|
|
|
|
keySerializer,
|
|
|
|
keyHashFunction,
|
|
|
|
keyHashSerializer,
|
|
|
|
null
|
|
|
|
));
|
2021-04-12 17:53:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getKeyHashBinaryLength() {
|
|
|
|
return keyHashSerializer.getSerializedBinaryLength();
|
|
|
|
}
|
|
|
|
}
|