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

io.tarantool.driver.core.proxy.ReplaceManyProxyOperation Maven / Gradle / Ivy

Go to download

Tarantool Cartridge driver for Tarantool versions 1.10+ based on Netty framework

There is a newer version: 0.14.0
Show newest version
package io.tarantool.driver.core.proxy;

import io.tarantool.driver.api.SingleValueCallResult;
import io.tarantool.driver.api.TarantoolCallOperations;
import io.tarantool.driver.api.space.options.ReplaceManyOptions;
import io.tarantool.driver.mappers.CallResultMapper;
import io.tarantool.driver.mappers.MessagePackObjectMapper;
import io.tarantool.driver.protocol.Packable;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;

/**
 * Proxy operation for replacing many records at once
 *
 * @param  result type
 * @param  result collection type
 * @author Alexey Kuzin
 */
public final class ReplaceManyProxyOperation>
    extends AbstractProxyOperation {

    ReplaceManyProxyOperation(
        TarantoolCallOperations client,
        String functionName,
        List arguments,
        MessagePackObjectMapper argumentsMapper,
        CallResultMapper> resultMapper) {
        super(client, functionName, arguments, argumentsMapper, resultMapper);
    }

    /**
     * The builder for this class.
     */
    public static final class Builder>
        extends GenericOperationsBuilder> {
        private Collection tuples;

        public Builder() {
        }

        @Override
        Builder self() {
            return this;
        }

        public Builder withTuples(Collection tuples) {
            this.tuples = tuples;
            return this;
        }

        public ReplaceManyProxyOperation build() {
            if (tuples == null) {
                throw new IllegalArgumentException("Tuples must be specified for batch replace operation");
            }

            CRUDBatchOptions requestOptions = new CRUDBatchOptions.Builder()
                .withTimeout(options.getTimeout())
                .withStopOnError(options.getStopOnError())
                .withRollbackOnError(options.getRollbackOnError())
                .withFields(options.getFields())
                .build();

            List arguments = Arrays.asList(spaceName, tuples, requestOptions.asMap());

            return new ReplaceManyProxyOperation<>(
                this.client, this.functionName, arguments, this.argumentsMapper, this.resultMapper);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy