Class AerospikeTemplate
- All Implemented Interfaces:
AerospikeOperations
AerospikeOperations.- Author:
- Oliver Gierke, Peter Milne, Anastasiia Smirnova, Igor Ermolenko, Roman Terentiev
-
Constructor Summary
ConstructorsConstructorDescriptionAerospikeTemplate(com.aerospike.client.IAerospikeClient client, String namespace, MappingAerospikeConverter converter, AerospikeMappingContext mappingContext, AerospikeExceptionTranslator exceptionTranslator, QueryEngine queryEngine, IndexRefresher indexRefresher) -
Method Summary
Modifier and TypeMethodDescription<T> TAdd integer/double bin value to existing document bin value, read the new modified document and map it back the the given document class type.<T> TAdd integer/double bin values to existing document bin values, read the new modified document and map it back the the given document class type.<T> Iterable<T>aggregate(com.aerospike.client.query.Filter filter, Class<T> entityClass, String module, String function, List<com.aerospike.client.Value> arguments) Execute query, apply statement's aggregation function, and return result iterator.<T> TAppend bin string value to existing document bin value, read the new modified document and map it back the the given document class type.<T> TAppend bin string values to existing document bin values, read the new modified document and map it back the the given document class type.<T> longReturn the amount of documents in the given entityClass's Aerospike set.longReturn the amount of documents in the given Aerospike set.<T> longReturn the amount of documents in a query results. set name will be determined by the given entityClass.<T> voidcreateIndex(Class<T> entityClass, String indexName, String binName, com.aerospike.client.query.IndexType indexType) Create index by specified name in Aerospike.<T> voidcreateIndex(Class<T> entityClass, String indexName, String binName, com.aerospike.client.query.IndexType indexType, com.aerospike.client.query.IndexCollectionType indexCollectionType) Create index by specified name in Aerospike.<T> voidTruncate/Delete all the documents in the given entity's set.<T> booleanDelete document by id, set name will be determined by the given entityClass.<T> booleandelete(T document) Delete document.<T> voiddeleteIndex(Class<T> entityClass, String indexName) Delete index by specified name from Aerospike.<T> TExecute operation against underlying store.<T> booleanCheck if document exists by providing document id and entityClass (set name will be determined by the given entityClass).<T> boolean<T> Stream<T>Find documents in the given entityClass's set using a query and map them to the given class type.<T> Stream<T>Find all documents in the given entityClass's set and map them to the given class type.<T> Iterable<T>Find all documents in the given entityClass's set using a provided sort and map them to the given class type.<T> TFind a document by id, set name will be determined by the given entityClass.<T> List<T>Find documents by providing multiple ids using a single batch read operation, set name will be determined by the given entityClass.findByIds(GroupedKeys groupedKeys) Executes a single batch request to get results for several entities.<T> Stream<T>findInRange(long offset, long limit, Sort sort, Class<T> entityClass) Find documents in the given entityClass's set using a range (offset, limit) and a sort and map them to the given class type.com.aerospike.client.IAerospikeClientMappingContext<?,?> <T> StringgetSetName(Class<T> entityClass) booleanindexExists(String indexName) Checks whether index by specified name exists in Aerospike.<T> voidinsert(T document) Insert document usingRecordExistsAction.CREATE_ONLYpolicy.<T> voidinsertAll(Collection<? extends T> documents) Insert each document of the given documents using single insert operations.<T> voidpersist(T document, com.aerospike.client.policy.WritePolicy policy) Persist document using specified WritePolicy.<T> TPrepend bin string value to existing document bin value, read the new modified document and map it back the the given document class type.<T> TPrepend bin string values to existing document bin values, read the new modified document and map it back the the given document class type.<T> voidsave(T document) Save document.<T> voidupdate(T document) Update document usingRecordExistsAction.REPLACE_ONLYpolicy taking into consideration the version property of the document if it is present.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.aerospike.core.AerospikeOperations
getMappingContext, getSetName
-
Constructor Details
-
AerospikeTemplate
public AerospikeTemplate(com.aerospike.client.IAerospikeClient client, String namespace, MappingAerospikeConverter converter, AerospikeMappingContext mappingContext, AerospikeExceptionTranslator exceptionTranslator, QueryEngine queryEngine, IndexRefresher indexRefresher)
-
-
Method Details
-
createIndex
public <T> void createIndex(Class<T> entityClass, String indexName, String binName, com.aerospike.client.query.IndexType indexType) Description copied from interface:AerospikeOperationsCreate index by specified name in Aerospike.- Specified by:
createIndexin interfaceAerospikeOperations- Parameters:
entityClass- The class to extract the Aerospike set from. Must not be null.indexName- The index name. Must not be null.binName- The bin name to create the index on. Must not be null.indexType- The type of the index. Must not be null.
-
createIndex
public <T> void createIndex(Class<T> entityClass, String indexName, String binName, com.aerospike.client.query.IndexType indexType, com.aerospike.client.query.IndexCollectionType indexCollectionType) Description copied from interface:AerospikeOperationsCreate index by specified name in Aerospike.- Specified by:
createIndexin interfaceAerospikeOperations- Parameters:
entityClass- The class to extract the Aerospike set from. Must not be null.indexName- The index name. Must not be null.binName- The bin name to create the index on. Must not be null.indexType- The type of the index. Must not be null.indexCollectionType- The collection type of the index. Must not be null.
-
deleteIndex
Description copied from interface:AerospikeOperationsDelete index by specified name from Aerospike.- Specified by:
deleteIndexin interfaceAerospikeOperations- Parameters:
entityClass- The class to extract the Aerospike set from. Must not be null.indexName- The index name. Must not be null.
-
indexExists
Description copied from interface:AerospikeOperationsChecks whether index by specified name exists in Aerospike.- Specified by:
indexExistsin interfaceAerospikeOperations- Parameters:
indexName- The Aerospike index name. Must not be null.- Returns:
- true if exists
-
save
public <T> void save(T document) Description copied from interface:AerospikeOperationsSave document.If document has version property - CAS algorithm is used for updating record. Version property is used for deciding whether to create new record or update existing. If version is set to zero - new record will be created, creation will fail is such record already exists. If version is greater than zero - existing record will be updated with
RecordExistsAction.REPLACE_ONLYpolicy taking into consideration the version property of the document. Version property will be updated with the server's version after successful operation.If document does not have version property - record is updated with
RecordExistsAction.REPLACEpolicy. This means that when such record does not exist it will be created, otherwise updated.- Specified by:
savein interfaceAerospikeOperations- Parameters:
document- The document to save. Must not be null.
-
persist
public <T> void persist(T document, com.aerospike.client.policy.WritePolicy policy) Description copied from interface:AerospikeOperationsPersist document using specified WritePolicy.- Specified by:
persistin interfaceAerospikeOperations- Parameters:
document- The document to persist. Must not be null.policy- The Aerospike write policy for the inner Aerospike put operation. Must not be null.
-
insertAll
Description copied from interface:AerospikeOperationsInsert each document of the given documents using single insert operations.- Specified by:
insertAllin interfaceAerospikeOperations- Parameters:
documents- The documents to insert. Must not be null.
-
insert
public <T> void insert(T document) Description copied from interface:AerospikeOperationsInsert document usingRecordExistsAction.CREATE_ONLYpolicy.If document has version property it will be updated with the server's version after successful operation.
- Specified by:
insertin interfaceAerospikeOperations- Parameters:
document- The document to insert. Must not be null.
-
update
public <T> void update(T document) Description copied from interface:AerospikeOperationsUpdate document usingRecordExistsAction.REPLACE_ONLYpolicy taking into consideration the version property of the document if it is present.If document has version property it will be updated with the server's version after successful operation.
- Specified by:
updatein interfaceAerospikeOperations- Parameters:
document- The document to update. Must not be null.
-
delete
Description copied from interface:AerospikeOperationsTruncate/Delete all the documents in the given entity's set.- Specified by:
deletein interfaceAerospikeOperations- Parameters:
entityClass- The class to extract the Aerospike set from. Must not be null.
-
delete
Description copied from interface:AerospikeOperationsDelete document by id, set name will be determined by the given entityClass.- Specified by:
deletein interfaceAerospikeOperations- Parameters:
id- The id of the document to delete. Must not be null.entityClass- The class to extract the Aerospike set from. Must not be null.- Returns:
- whether the document existed on server before deletion.
-
delete
public <T> boolean delete(T document) Description copied from interface:AerospikeOperationsDelete document.- Specified by:
deletein interfaceAerospikeOperations- Parameters:
document- The document to delete. Must not be null.- Returns:
- whether the document existed on server before deletion.
-
exists
Description copied from interface:AerospikeOperationsCheck if document exists by providing document id and entityClass (set name will be determined by the given entityClass).- Specified by:
existsin interfaceAerospikeOperations- Parameters:
id- The id to check if exists. Must not be null.entityClass- The class to extract the Aerospike set from. Must not be null.- Returns:
- whether the document exists.
-
findAll
Description copied from interface:AerospikeOperationsFind all documents in the given entityClass's set and map them to the given class type.- Specified by:
findAllin interfaceAerospikeOperations- Parameters:
entityClass- The class to extract the Aerospike set from and to map the documents to. Must not be null.- Returns:
- A Stream of matching documents, returned documents will be mapped to entityClass's type.
-
findById
Description copied from interface:AerospikeOperationsFind a document by id, set name will be determined by the given entityClass.Document will be mapped to the given entityClass.
- Specified by:
findByIdin interfaceAerospikeOperations- Parameters:
id- The id of the document to find. Must not be null.entityClass- The class to extract the Aerospike set from and to map the document to. Must not be null.- Returns:
- The document from Aerospike, returned document will be mapped to entityClass's type, if document doesn't exist return null.
-
findByIds
Description copied from interface:AerospikeOperationsFind documents by providing multiple ids using a single batch read operation, set name will be determined by the given entityClass.Documents will be mapped to the given entityClass.
- Specified by:
findByIdsin interfaceAerospikeOperations- Parameters:
ids- The ids of the documents to find. Must not be null.entityClass- The class to extract the Aerospike set from and to map the documents to. Must not be null.- Returns:
- The documents from Aerospike, returned documents will be mapped to entityClass's type, if no document exists return an empty list.
-
findByIds
Description copied from interface:AerospikeOperationsExecutes a single batch request to get results for several entities.Aerospike provides functionality to get documents from different sets in 1 batch request. The methods allows to put grouped keys by entity type as parameter and get result as spring data aerospike entities grouped by entity type.
- Specified by:
findByIdsin interfaceAerospikeOperations- Parameters:
groupedKeys- Must not be null.- Returns:
- grouped entities.
-
aggregate
public <T> Iterable<T> aggregate(com.aerospike.client.query.Filter filter, Class<T> entityClass, String module, String function, List<com.aerospike.client.Value> arguments) Description copied from interface:AerospikeOperationsExecute query, apply statement's aggregation function, and return result iterator.- Specified by:
aggregatein interfaceAerospikeOperations- Parameters:
filter- The filter to pass to the query.entityClass- The class to extract the Aerospike set from. Must not be null.module- server package where user defined function resides.function- aggregation function name.arguments- arguments to pass to function name, if any.- Returns:
- Result iterator.
-
findAll
Description copied from interface:AerospikeOperationsFind all documents in the given entityClass's set using a provided sort and map them to the given class type.- Specified by:
findAllin interfaceAerospikeOperations- Parameters:
sort- The sort to affect the returned iterable documents order.entityClass- The class to extract the Aerospike set from and to map the documents to.- Returns:
- An Iterable of matching documents, returned documents will be mapped to entityClass's type.
-
exists
-
execute
Description copied from interface:AerospikeOperationsExecute operation against underlying store.- Specified by:
executein interfaceAerospikeOperations- Parameters:
supplier- must not be null.- Returns:
- Execution result.
-
count
Description copied from interface:AerospikeOperationsReturn the amount of documents in a query results. set name will be determined by the given entityClass.- Specified by:
countin interfaceAerospikeOperations- Parameters:
query- The query that provides the result set for count.entityClass- entityClass The class to extract the Aerospike set from. Must not be null.- Returns:
- amount of documents that the given query and entity class supplied.
-
find
Description copied from interface:AerospikeOperationsFind documents in the given entityClass's set using a query and map them to the given class type.- Specified by:
findin interfaceAerospikeOperations- Parameters:
query- The query to filter results. Must not be null.entityClass- The class to extract the Aerospike set from and to map the documents to. Must not be null.- Returns:
- A Stream of matching documents, returned documents will be mapped to entityClass's type.
-
findInRange
Description copied from interface:AerospikeOperationsFind documents in the given entityClass's set using a range (offset, limit) and a sort and map them to the given class type.- Specified by:
findInRangein interfaceAerospikeOperations- Parameters:
offset- The offset to start the range from.limit- The limit of the range.sort- The sort to affect the returned Stream of documents order.entityClass- The class to extract the Aerospike set from and to map the documents to. Must not be null.- Returns:
- A Stream of matching documents, returned documents will be mapped to entityClass's type.
-
count
Description copied from interface:AerospikeOperationsReturn the amount of documents in the given entityClass's Aerospike set.- Specified by:
countin interfaceAerospikeOperations- Parameters:
entityClass- The class to extract the Aerospike set from. Must not be null.- Returns:
- amount of documents in the set (of the given entityClass).
-
getAerospikeClient
public com.aerospike.client.IAerospikeClient getAerospikeClient()- Specified by:
getAerospikeClientin interfaceAerospikeOperations- Returns:
- aerospike client in use.
-
count
Description copied from interface:AerospikeOperationsReturn the amount of documents in the given Aerospike set.- Specified by:
countin interfaceAerospikeOperations- Parameters:
setName- The name of the set to count. Must not be null.- Returns:
- amount of documents in the given set.
-
prepend
Description copied from interface:AerospikeOperationsPrepend bin string value to existing document bin value, read the new modified document and map it back the the given document class type.- Specified by:
prependin interfaceAerospikeOperations- Parameters:
document- The document to extract the Aerospike set from and to map the documents to. Must not be null.fieldName- Bin name to use prepend operation on.value- The value to prepend.- Returns:
- Modified document after prepend operation.
-
prepend
Description copied from interface:AerospikeOperationsPrepend bin string values to existing document bin values, read the new modified document and map it back the the given document class type.- Specified by:
prependin interfaceAerospikeOperations- Parameters:
document- The document to extract the Aerospike set from and to map the documents to. Must not be null.values- a Map of bin names and values to prepend. Must not be null.- Returns:
- Modified document after prepend operations.
-
append
Description copied from interface:AerospikeOperationsAppend bin string values to existing document bin values, read the new modified document and map it back the the given document class type.- Specified by:
appendin interfaceAerospikeOperations- Parameters:
document- The document to extract the Aerospike set from and to map the documents to. Must not be null.values- a Map of bin names and values to append. Must not be null.- Returns:
- Modified document after append operations.
-
append
Description copied from interface:AerospikeOperationsAppend bin string value to existing document bin value, read the new modified document and map it back the the given document class type.- Specified by:
appendin interfaceAerospikeOperations- Parameters:
document- The document to extract the Aerospike set from and to map the documents to. Must not be null.binName- Bin name to use append operation on.value- The value to append.- Returns:
- Modified document after append operation.
-
add
Description copied from interface:AerospikeOperationsAdd integer/double bin values to existing document bin values, read the new modified document and map it back the the given document class type.- Specified by:
addin interfaceAerospikeOperations- Parameters:
document- The document to extract the Aerospike set from and to map the documents to. Must not be null.values- a Map of bin names and values to add. Must not be null.- Returns:
- Modified document after add operations.
-
add
Description copied from interface:AerospikeOperationsAdd integer/double bin value to existing document bin value, read the new modified document and map it back the the given document class type.- Specified by:
addin interfaceAerospikeOperations- Parameters:
document- The document to extract the Aerospike set from and to map the documents to. Must not be null.binName- Bin name to use add operation on. Must not be null.value- The value to add.- Returns:
- Modified document after add operation.
-
getSetName
-
getMappingContext
-
getNamespace
-