2021-02-04 00:48:49 +01:00
|
|
|
package it.cavallium.dbengine.database.collections;
|
|
|
|
|
2022-03-16 13:47:56 +01:00
|
|
|
import io.netty5.buffer.api.Buffer;
|
|
|
|
import io.netty5.buffer.api.Resource;
|
|
|
|
import io.netty5.buffer.api.Send;
|
2021-02-04 00:48:49 +01:00
|
|
|
import it.cavallium.dbengine.client.CompositeSnapshot;
|
2022-05-21 01:06:55 +02:00
|
|
|
import it.cavallium.dbengine.database.BufSupplier;
|
2021-02-04 00:48:49 +01:00
|
|
|
import it.cavallium.dbengine.database.LLDictionary;
|
|
|
|
import it.cavallium.dbengine.database.collections.DatabaseEmpty.Nothing;
|
|
|
|
import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength;
|
2021-12-18 18:16:56 +01:00
|
|
|
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
|
2021-02-04 00:48:49 +01:00
|
|
|
import java.util.Map;
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
2021-12-18 18:16:56 +01:00
|
|
|
public class SubStageGetterSet<T> implements
|
|
|
|
SubStageGetter<Object2ObjectSortedMap<T, Nothing>, DatabaseSetDictionary<T>> {
|
2021-02-04 00:48:49 +01:00
|
|
|
|
2021-09-02 17:15:40 +02:00
|
|
|
private final SerializerFixedBinaryLength<T> keySerializer;
|
2021-02-04 00:48:49 +01:00
|
|
|
|
2021-09-02 17:15:40 +02:00
|
|
|
public SubStageGetterSet(SerializerFixedBinaryLength<T> keySerializer) {
|
2021-02-04 00:48:49 +01:00
|
|
|
this.keySerializer = keySerializer;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Mono<DatabaseSetDictionary<T>> subStage(LLDictionary dictionary,
|
|
|
|
@Nullable CompositeSnapshot snapshot,
|
2022-05-21 01:06:55 +02:00
|
|
|
Mono<Buffer> prefixKeyMono) {
|
|
|
|
return prefixKeyMono.map(prefixKey -> DatabaseSetDictionary.tail(dictionary,
|
|
|
|
BufSupplier.ofOwned(prefixKey),
|
|
|
|
keySerializer,
|
|
|
|
null
|
|
|
|
));
|
2021-02-04 00:48:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getKeyBinaryLength() {
|
|
|
|
return keySerializer.getSerializedBinaryLength();
|
|
|
|
}
|
|
|
|
}
|