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

io.tarantool.driver.api.space.TarantoolSpaceOperations 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.api.space;

import io.tarantool.driver.api.TarantoolResult;
import io.tarantool.driver.api.conditions.Conditions;
import io.tarantool.driver.api.tuple.TarantoolTuple;
import io.tarantool.driver.exceptions.TarantoolClientException;
import io.tarantool.driver.mappers.ValueConverter;
import io.tarantool.driver.api.tuple.operations.TupleOperations;
import io.tarantool.driver.metadata.TarantoolSpaceMetadata;
import org.msgpack.value.ArrayValue;

import java.util.concurrent.CompletableFuture;

/**
 * Tarantool space operations interface (create, insert, replace, delete...)
 *
 * @author Alexey Kuzin
 */
public interface TarantoolSpaceOperations {

    /**
     * Delete a tuple
     *
     * @param conditions query with options
     * @return a future that will contain removed tuple once completed
     * @throws TarantoolClientException in case if the request failed
     */
    CompletableFuture> delete(Conditions conditions)
            throws TarantoolClientException;

    /**
     * Delete a tuple
     *
     * @param conditions query with options
     * @param tupleMapper the entity-to-object tupleMapper capable of converting MessagePack {@link ArrayValue} into
     *                          an object of type {@code T}
     * @param  result type
     * @return a future that will contain removed tuple once completed
     * @throws TarantoolClientException in case if the request failed
     */
     CompletableFuture> delete(Conditions conditions,
                                                     ValueConverter tupleMapper)
            throws TarantoolClientException;

    /**
     * Inserts tuple into the space, if no tuple with same unique keys exists. Otherwise throw duplicate key error.
     *
     * @param tuple new data
     * @return a future that will contain all corresponding tuples once completed
     * @throws TarantoolClientException in case if request failed
     */
    CompletableFuture> insert(TarantoolTuple tuple) throws TarantoolClientException;

    /**
     * Inserts tuple into the space, if no tuple with same unique keys exists. Otherwise throw duplicate key error.
     *
     * @param tuple new data
     * @param tupleMapper the entity-to-object tupleMapper capable of converting MessagePack {@link ArrayValue} into
     *                    an object of type {@code T}
     * @param  result tuple type
     * @return a future that will contain all corresponding tuples once completed
     * @throws TarantoolClientException in case if request failed
     */
     CompletableFuture> insert(TarantoolTuple tuple, ValueConverter tupleMapper)
            throws TarantoolClientException;

    /**
     * Insert a tuple into the space or replace an existing one.
     *
     * @param tuple new data
     * @return a future that will contain all corresponding tuples once completed
     * @throws TarantoolClientException in case if request failed
     */
    CompletableFuture> replace(TarantoolTuple tuple) throws TarantoolClientException;

    /**
     * Insert a tuple into the space or replace an existing one.
     *
     * @param tuple new data
     * @param tupleMapper the entity-to-object tupleMapper capable of converting MessagePack {@link ArrayValue} into
     *                    an object of type {@code T}
     * @param  result tuple type
     * @return a future that will contain all corresponding tuples once completed
     * @throws TarantoolClientException in case if request failed
     */
     CompletableFuture> replace(TarantoolTuple tuple, ValueConverter tupleMapper)
            throws TarantoolClientException;

    /**
     * Select tuples matching the specified query with options.
     *
     * @param conditions query with options
     * @return a future that will contain all corresponding tuples once completed
     * @throws TarantoolClientException in case if the request failed
     */
    CompletableFuture> select(Conditions conditions) throws TarantoolClientException;

    /**
     * Select tuples matching the specified index query with options.
     *
     * @param conditions query with options
     * @param tupleCLass target tuple class
     * @param  target tuple type
     * @return a future that will contain all corresponding tuples once completed
     * @throws TarantoolClientException in case if the request failed or value converter not found
     */
     CompletableFuture> select(Conditions conditions,
                                                     Class tupleCLass) throws TarantoolClientException;

    /**
     * Select tuples matching the specified query with options.
     *
     * @param conditions query with options
     * @param tupleMapper the entity-to-object tupleMapper capable of converting MessagePack {@link ArrayValue} into
     *                    an object of type {@code T}
     * @param  target tuple type
     * @return a future that will contain all corresponding tuples once completed
     * @throws TarantoolClientException in case if the request failed
     */
     CompletableFuture> select(Conditions conditions,
                                                     ValueConverter tupleMapper)
            throws TarantoolClientException;

    /**
     * Update a tuple
     *
     * @param conditions query with options
     * @param tuple tuple with new field values
     * @return a future that will contain corresponding tuple once completed
     * @throws TarantoolClientException in case if the request failed
     */
    CompletableFuture> update(Conditions conditions, TarantoolTuple tuple);

    /**
     * Update a tuple
     *
     * @param conditions query with options
     * @param operations the list update operations
     * @return a future that will contain corresponding tuple once completed
     * @throws TarantoolClientException in case if the request failed
     */
    CompletableFuture> update(Conditions conditions, TupleOperations operations);

    /**
     * Update a tuple
     *
     * @param conditions query with options
     * @param operations the list update operations
     * @param tupleMapper the entity-to-object tupleMapper capable of converting MessagePack {@link ArrayValue} into
     *                    an object of type {@code T}
     * @param  result type
     * @return a future that will contain corresponding tuple once completed
     * @throws TarantoolClientException in case if the request failed
     */
     CompletableFuture> update(Conditions conditions,
                                                     TupleOperations operations,
                                                     ValueConverter tupleMapper);

    /**
     * Update tuple if it would be found elsewhere try to insert tuple. Always use primary index for key.
     *
     * @param conditions query with options
     * @param tuple new data that will be insert if tuple will be not found
     * @param operations the list of update operations to be performed if the tuple exists
     * @return a future that will empty list
     * @throws TarantoolClientException in case if the request failed
     */
    CompletableFuture> upsert(Conditions conditions,
                                                              TarantoolTuple tuple,
                                                              TupleOperations operations);

    /**
     * Update tuple if it would be found elsewhere try to insert tuple. Always use primary index for key.
     *
     * @param conditions query with options
     * @param tuple new data that will be insert if tuple will be not found
     * @param operations the list of update operations to be performed if the tuple exists
     * @param tupleMapper the entity-to-object tupleMapper capable of converting MessagePack {@link ArrayValue} into
     *                          an object of type {@code T}
     * @param  result type
     * @return a future that will empty list
     * @throws TarantoolClientException in case if the request failed
     */
     CompletableFuture> upsert(Conditions conditions,
                                                     TarantoolTuple tuple,
                                                     TupleOperations operations,
                                                     ValueConverter tupleMapper);

    /**
     * Get metadata associated with this space
     *
     * @return space metadata
     */
    TarantoolSpaceMetadata getMetadata();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy