Package io.tarantool.driver.core.space
Class TarantoolSpace<T extends Packable,R extends Collection<T>>
- java.lang.Object
-
- io.tarantool.driver.core.space.TarantoolSpace<T,R>
-
- All Implemented Interfaces:
TarantoolSpaceOperations<T,R>
- Direct Known Subclasses:
TarantoolTupleSpace
public abstract class TarantoolSpace<T extends Packable,R extends Collection<T>> extends Object implements TarantoolSpaceOperations<T,R>
Basic implementation for working with spaces via Tarantool protocol requests
-
-
Constructor Summary
Constructors Constructor Description TarantoolSpace(TarantoolClientConfig config, TarantoolConnectionManager connectionManager, TarantoolMetadataOperations metadataOperations, TarantoolSpaceMetadata spaceMetadata)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description CompletableFuture<R>delete(Conditions conditions)Delete a tuple.TarantoolSpaceMetadatagetMetadata()Get metadata associated with this spaceCompletableFuture<R>insert(T tuple)Inserts tuple into the space, if no tuple with same unique keys exists.protected abstract TupleOperationsmakeOperationsFromTuple(T tuple)Create aTupleOperationsinstance from the given tuple of typeTCompletableFuture<R>replace(T tuple)Insert a tuple into the space or replace an existing one.CompletableFuture<R>select(Conditions conditions)Select tuples matching the specified query with options.StringtoString()CompletableFuture<Void>truncate()Truncate space if space would be found.protected abstract MessagePackValueMappertupleResultMapper()MessagePack value mapper configured with an ArrayValue to tuple converter corresponding to the selected tuple typeCompletableFuture<R>update(Conditions conditions, TupleOperations operations)Update a tuple.CompletableFuture<R>update(Conditions conditions, T tuple)Update a tuple.CompletableFuture<R>upsert(Conditions conditions, T tuple, TupleOperations operations)Update tuple if it would be found elsewhere try to insert tuple.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.tarantool.driver.api.space.TarantoolSpaceOperations
cursor, cursor
-
-
-
-
Constructor Detail
-
TarantoolSpace
public TarantoolSpace(TarantoolClientConfig config, TarantoolConnectionManager connectionManager, TarantoolMetadataOperations metadataOperations, TarantoolSpaceMetadata spaceMetadata)
-
-
Method Detail
-
delete
public CompletableFuture<R> delete(Conditions conditions) throws TarantoolClientException
Description copied from interface:TarantoolSpaceOperationsDelete a tuple. Only a single primary index value condition is supported.- Specified by:
deletein interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Parameters:
conditions- query with options- Returns:
- a future that will contain removed tuple once completed
- Throws:
TarantoolClientException- in case if the request failed
-
insert
public CompletableFuture<R> insert(T tuple) throws TarantoolClientException
Description copied from interface:TarantoolSpaceOperationsInserts tuple into the space, if no tuple with same unique keys exists. Otherwise throw duplicate key error.- Specified by:
insertin interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Parameters:
tuple- new data- Returns:
- a future that will contain all corresponding tuples once completed
- Throws:
TarantoolClientException- in case if request failed
-
replace
public CompletableFuture<R> replace(T tuple) throws TarantoolClientException
Description copied from interface:TarantoolSpaceOperationsInsert a tuple into the space or replace an existing one.- Specified by:
replacein interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Parameters:
tuple- new data- Returns:
- a future that will contain all corresponding tuples once completed
- Throws:
TarantoolClientException- in case if request failed
-
select
public CompletableFuture<R> select(Conditions conditions) throws TarantoolClientException
Description copied from interface:TarantoolSpaceOperationsSelect tuples matching the specified query with options.- Specified by:
selectin interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Parameters:
conditions- query with options- Returns:
- a future that will contain all corresponding tuples once completed
- Throws:
TarantoolClientException- in case if the request failed
-
update
public CompletableFuture<R> update(Conditions conditions, T tuple)
Description copied from interface:TarantoolSpaceOperationsUpdate a tuple. Only a single primary index value condition is supported.- Specified by:
updatein interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Parameters:
conditions- query with optionstuple- tuple with new field values- Returns:
- a future that will contain corresponding tuple once completed
-
makeOperationsFromTuple
protected abstract TupleOperations makeOperationsFromTuple(T tuple)
Create aTupleOperationsinstance from the given tuple of typeT- Parameters:
tuple- tuple of the specified type- Returns:
- new
TupleOperationsinstance
-
update
public CompletableFuture<R> update(Conditions conditions, TupleOperations operations)
Description copied from interface:TarantoolSpaceOperationsUpdate a tuple. Only a single primary index value condition is supported.- Specified by:
updatein interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Parameters:
conditions- query with optionsoperations- the list update operations- Returns:
- a future that will contain corresponding tuple once completed
-
upsert
public CompletableFuture<R> upsert(Conditions conditions, T tuple, TupleOperations operations)
Description copied from interface:TarantoolSpaceOperationsUpdate tuple if it would be found elsewhere try to insert tuple. Only a single primary index value condition is supported.- Specified by:
upsertin interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Parameters:
conditions- query with optionstuple- new data that will be insert if tuple will be not foundoperations- the list of update operations to be performed if the tuple exists- Returns:
- a future that will empty list
-
truncate
public CompletableFuture<Void> truncate() throws TarantoolClientException
Description copied from interface:TarantoolSpaceOperationsTruncate space if space would be found. Otherwise, throw space not found error.- Specified by:
truncatein interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Returns:
- a future that will contain void.
- Throws:
TarantoolClientException- in case if request failed
-
tupleResultMapper
protected abstract MessagePackValueMapper tupleResultMapper()
MessagePack value mapper configured with an ArrayValue to tuple converter corresponding to the selected tuple type- Returns:
- configured mapper with
ArrayValuetoTconverter
-
getMetadata
public TarantoolSpaceMetadata getMetadata()
Description copied from interface:TarantoolSpaceOperationsGet metadata associated with this space- Specified by:
getMetadatain interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>- Returns:
- space metadata
-
-