Interface AerospikeOperations

All Known Implementing Classes:
AerospikeTemplate

public interface AerospikeOperations
Aerospike specific data access operations.
Author:
Oliver Gierke, Peter Milne, Anastasiia Smirnova, Roman Terentiev
  • Method Summary

    Modifier and Type Method Description
    <T> T add​(T objectToAddTo, String binName, long value)  
    <T> T add​(T objectToAddTo, Map<String,​Long> values)  
    <T> Iterable<T> aggregate​(com.aerospike.client.query.Filter filter, Class<T> entityClass, String module, String function, List<com.aerospike.client.Value> arguments)  
    <T> T append​(T objectToAppendTo, String binName, String value)  
    <T> T append​(T objectToAppendTo, Map<String,​String> values)  
    <T> long count​(Class<T> entityClass)
    Returns the amount of records in the given entityClass's Aerospike set and AerospikeTemplate configured namespace.
    <T> long count​(String setName)
    Returns the amount of records in the given Aerospike set and AerospikeTemplate configured namespace.
    <T> long count​(Query query, Class<T> entityClass)
    Returns the amount of records in a query results.
    <T> void createIndex​(Class<T> entityClass, String indexName, String binName, com.aerospike.client.query.IndexType indexType)
    Creates index by specified name in Aerospike.
    <T> void createIndex​(Class<T> entityClass, String indexName, String binName, com.aerospike.client.query.IndexType indexType, com.aerospike.client.query.IndexCollectionType indexCollectionType)
    Creates index by specified name in Aerospike.
    <T> void delete​(Class<T> entityClass)  
    <T> boolean delete​(Object id, Class<T> entityClass)  
    <T> boolean delete​(T objectToDelete)  
    <T> void deleteIndex​(Class<T> entityClass, String indexName)
    Deletes index by specified name from Aerospike.
    <T> T execute​(Supplier<T> supplier)
    Execute operation against underlying store.
    <T> boolean exists​(Object id, Class<T> entityClass)  
    <T> Stream<T> find​(Query query, Class<T> entityClass)  
    <T> Stream<T> findAll​(Class<T> entityClass)  
    <T> Iterable<T> findAll​(Sort sort, Class<T> entityClass)  
    <T> T findById​(Object id, Class<T> entityClass)  
    <T> List<T> findByIds​(Iterable<?> ids, Class<T> entityClass)  
    GroupedEntities findByIds​(GroupedKeys groupedKeys)  
    <T> Stream<T> findInRange​(long offset, long limit, Sort sort, Class<T> entityClass)  
    com.aerospike.client.IAerospikeClient getAerospikeClient()  
    MappingContext<?,​?> getMappingContext()  
    <T> String getSetName​(Class<T> entityClass)
    Returns the Set name used for the specified class by this template.
    boolean indexExists​(String indexName)
    Deprecated.
    This operation is deprecated due to complications that are required for guaranteed index existence response.
    <T> void insert​(T document)
    Insert operation using RecordExistsAction.CREATE_ONLY policy.
    <T> void persist​(T document, com.aerospike.client.policy.WritePolicy writePolicy)
    Persist document using specified WritePolicy.
    <T> T prepend​(T objectToPrependTo, String binName, String value)  
    <T> T prepend​(T objectToPrependTo, Map<String,​String> values)  
    <T> void save​(T document)
    Save operation.
    <T> void update​(T objectToUpdate)
    Update operation using RecordExistsAction.REPLACE_ONLY policy taking into consideration the version property of the document if it is present.
  • Method Details

    • getSetName

      <T> String getSetName​(Class<T> entityClass)
      Returns the Set name used for the specified class by this template.
      Parameters:
      entityClass - must not be null.
      Returns:
      The set name used for the specified class.
    • insert

      <T> void insert​(T document)
      Insert operation using RecordExistsAction.CREATE_ONLY policy. If document has version property it will be updated with the server's version after successful operation.
      Parameters:
      document - The document to insert.
    • getMappingContext

      MappingContext<?,​?> getMappingContext()
      Returns:
      mapping context in use.
    • save

      <T> void save​(T document)
      Save operation. 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_ONLY policy 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.REPLACE policy. This means that when such record does not exist it will be created, otherwise updated.
      Parameters:
      document - The document to save.
    • persist

      <T> void persist​(T document, com.aerospike.client.policy.WritePolicy writePolicy)
      Persist document using specified WritePolicy.
      Parameters:
      document - The document to persist.
      writePolicy - The Aerospike write policy for the inner Aerospike put operation.
    • update

      <T> void update​(T objectToUpdate)
      Update operation using RecordExistsAction.REPLACE_ONLY policy 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.
      Parameters:
      objectToUpdate - The object to update.
    • delete

      <T> void delete​(Class<T> entityClass)
    • delete

      <T> boolean delete​(Object id, Class<T> entityClass)
    • delete

      <T> boolean delete​(T objectToDelete)
    • exists

      <T> boolean exists​(Object id, Class<T> entityClass)
    • find

      <T> Stream<T> find​(Query query, Class<T> entityClass)
    • findAll

      <T> Stream<T> findAll​(Class<T> entityClass)
    • findById

      <T> T findById​(Object id, Class<T> entityClass)
    • findByIds

      <T> List<T> findByIds​(Iterable<?> ids, Class<T> entityClass)
    • findByIds

      GroupedEntities findByIds​(GroupedKeys groupedKeys)
    • add

      <T> T add​(T objectToAddTo, Map<String,​Long> values)
    • add

      <T> T add​(T objectToAddTo, String binName, long value)
    • append

      <T> T append​(T objectToAppendTo, Map<String,​String> values)
    • append

      <T> T append​(T objectToAppendTo, String binName, String value)
    • prepend

      <T> T prepend​(T objectToPrependTo, Map<String,​String> values)
    • prepend

      <T> T prepend​(T objectToPrependTo, String binName, String value)
    • aggregate

      <T> Iterable<T> aggregate​(com.aerospike.client.query.Filter filter, Class<T> entityClass, String module, String function, List<com.aerospike.client.Value> arguments)
    • execute

      <T> T execute​(Supplier<T> supplier)
      Execute operation against underlying store.
      Parameters:
      supplier - must not be null.
      Returns:
      Execution result.
    • findAll

      <T> Iterable<T> findAll​(Sort sort, Class<T> entityClass)
    • findInRange

      <T> Stream<T> findInRange​(long offset, long limit, Sort sort, Class<T> entityClass)
    • count

      <T> long count​(Query query, Class<T> entityClass)
      Returns the amount of records in a query results.
      Parameters:
      query - The query that provides the result set for count.
      entityClass - The class to provide for the query.
      Returns:
      amount of records that the given query and entity class provided.
    • count

      <T> long count​(String setName)
      Returns the amount of records in the given Aerospike set and AerospikeTemplate configured namespace.
      Returns:
      amount of records in the set (in the configured namespace).
    • count

      <T> long count​(Class<T> entityClass)
      Returns the amount of records in the given entityClass's Aerospike set and AerospikeTemplate configured namespace.
      Parameters:
      entityClass - The class to extract the Aerospike set from.
      Returns:
      amount of records in the set (in the configured namespace).
    • createIndex

      <T> void createIndex​(Class<T> entityClass, String indexName, String binName, com.aerospike.client.query.IndexType indexType)
      Creates index by specified name in Aerospike.
    • createIndex

      <T> void createIndex​(Class<T> entityClass, String indexName, String binName, com.aerospike.client.query.IndexType indexType, com.aerospike.client.query.IndexCollectionType indexCollectionType)
      Creates index by specified name in Aerospike.
    • deleteIndex

      <T> void deleteIndex​(Class<T> entityClass, String indexName)
      Deletes index by specified name from Aerospike.
    • indexExists

      @Deprecated boolean indexExists​(String indexName)
      Deprecated.
      This operation is deprecated due to complications that are required for guaranteed index existence response.

      If you need to conditionally create index — replace this method (indexExists) with createIndex(java.lang.Class<T>, java.lang.String, java.lang.String, com.aerospike.client.query.IndexType) and catch IndexAlreadyExistsException.

      More information can be found at: https://github.com/aerospike/aerospike-client-java/pull/149

      Checks whether index by specified name exists in Aerospike.
      Parameters:
      indexName - The Aerospike index name
      Returns:
      true if exists
    • getAerospikeClient

      com.aerospike.client.IAerospikeClient getAerospikeClient()