All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.redis.runtime.datasource.ReactiveTransactionalTopKCommandsImpl Maven / Gradle / Ivy

There is a newer version: 3.18.0.CR1
Show newest version
package io.quarkus.redis.runtime.datasource;

import java.util.Map;

import io.quarkus.redis.datasource.topk.ReactiveTransactionalTopKCommands;
import io.quarkus.redis.datasource.transactions.ReactiveTransactionalRedisDataSource;
import io.smallrye.mutiny.Uni;
import io.vertx.mutiny.redis.client.Response;

public class ReactiveTransactionalTopKCommandsImpl extends AbstractTransactionalCommands
        implements ReactiveTransactionalTopKCommands {

    private final ReactiveTopKCommandsImpl reactive;

    public ReactiveTransactionalTopKCommandsImpl(ReactiveTransactionalRedisDataSource ds,
            ReactiveTopKCommandsImpl reactive, TransactionHolder tx) {
        super(ds, tx);
        this.reactive = reactive;
    }

    @Override
    public Uni topkAdd(K key, V item) {
        this.tx.enqueue(r -> reactive.marshaller.decodeAsList(r, reactive.typeOfValue).get(0)); // Uni
        return this.reactive._topkAdd(key, item).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni topkAdd(K key, V... items) {
        this.tx.enqueue(r -> reactive.marshaller.decodeAsList(r, reactive.typeOfValue)); // Uni>
        return this.reactive._topkAdd(key, items).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni topkIncrBy(K key, V item, int increment) {
        this.tx.enqueue(r -> reactive.marshaller.decodeAsList(r, reactive.typeOfValue).get(0)); // Uni
        return this.reactive._topkIncrBy(key, item, increment).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni topkIncrBy(K key, Map couples) {
        this.tx.enqueue(r -> reactive.decodeAsMapVV(couples, r)); // Uni>
        return this.reactive._topkIncrBy(key, couples).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni topkList(K key) {
        this.tx.enqueue(r -> reactive.marshaller.decodeAsList(r, reactive.typeOfValue)); // Uni>
        return this.reactive._topkList(key).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni topkListWithCount(K key) {
        this.tx.enqueue(reactive::decodeAsMapVInt); // Uni>
        return this.reactive._topkListWithCount(key).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni topkQuery(K key, V item) {
        this.tx.enqueue(r -> reactive.marshaller.decodeAsList(r, Response::toBoolean).get(0)); // Uni
        return this.reactive._topkQuery(key, item).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni topkQuery(K key, V... items) {
        this.tx.enqueue(r -> reactive.marshaller.decodeAsList(r, Response::toBoolean)); // Uni>
        return this.reactive._topkQuery(key, items).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni topkReserve(K key, int topk) {
        this.tx.enqueue(r -> null); // Uni
        return this.reactive._topkReserve(key, topk).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni topkReserve(K key, int topk, int width, int depth, double decay) {
        this.tx.enqueue(r -> null); // Uni
        return this.reactive._topkReserve(key, topk, width, depth, decay).invoke(this::queuedOrDiscard).replaceWithVoid();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy