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.TarantoolSpaceMetadata
getMetadata()
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 TupleOperations
makeOperationsFromTuple(T tuple)
Create aTupleOperations
instance from the given tuple of typeT
CompletableFuture<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.String
toString()
CompletableFuture<Void>
truncate()
Truncate space if space would be found.protected abstract MessagePackValueMapper
tupleResultMapper()
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:TarantoolSpaceOperations
Delete a tuple. Only a single primary index value condition is supported.- Specified by:
delete
in 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:TarantoolSpaceOperations
Inserts tuple into the space, if no tuple with same unique keys exists. Otherwise throw duplicate key error.- Specified by:
insert
in 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:TarantoolSpaceOperations
Insert a tuple into the space or replace an existing one.- Specified by:
replace
in 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:TarantoolSpaceOperations
Select tuples matching the specified query with options.- Specified by:
select
in 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:TarantoolSpaceOperations
Update a tuple. Only a single primary index value condition is supported.- Specified by:
update
in 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 aTupleOperations
instance from the given tuple of typeT
- Parameters:
tuple
- tuple of the specified type- Returns:
- new
TupleOperations
instance
-
update
public CompletableFuture<R> update(Conditions conditions, TupleOperations operations)
Description copied from interface:TarantoolSpaceOperations
Update a tuple. Only a single primary index value condition is supported.- Specified by:
update
in 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:TarantoolSpaceOperations
Update tuple if it would be found elsewhere try to insert tuple. Only a single primary index value condition is supported.- Specified by:
upsert
in 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:TarantoolSpaceOperations
Truncate space if space would be found. Otherwise, throw space not found error.- Specified by:
truncate
in 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
ArrayValue
toT
converter
-
getMetadata
public TarantoolSpaceMetadata getMetadata()
Description copied from interface:TarantoolSpaceOperations
Get metadata associated with this space- Specified by:
getMetadata
in interfaceTarantoolSpaceOperations<T extends Packable,R extends Collection<T>>
- Returns:
- space metadata
-
-