Class AstraDBRepository<DOC>

java.lang.Object
com.dtsx.astra.sdk.AstraDBRepository<DOC>
Type Parameters:
DOC - working document

public class AstraDBRepository<DOC> extends Object
Client for AstraDB collection using repository pattern.
  • Method Summary

    Modifier and Type
    Method
    Description
    final int
    Count Document request.
    final int
    count(io.stargate.sdk.data.domain.query.Filter jsonFilter)
    Count Document request.
    boolean
    delete(io.stargate.sdk.data.domain.odm.Document<DOC> document)
    Delete a document from id or vector.
    int
    Delete all documents
    int
    deleteAll(io.stargate.sdk.data.domain.query.DeleteQuery deleteQuery)
    Delete item through a query.
    int
    deleteAll(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documents)
    Use parallelism and async to delete all records.
    boolean
    Delete by vector
    boolean
    deleteByVector(float[] vector)
    Delete by vector
    boolean
    Check existence of a document from its id.
    Stream<io.stargate.sdk.data.domain.odm.DocumentResult<DOC>>
    find(@NonNull io.stargate.sdk.data.domain.query.SelectQuery query)
    Find all item in the collection.
    Stream<io.stargate.sdk.data.domain.odm.DocumentResult<DOC>>
    Find all item in the collection.
    Optional<io.stargate.sdk.data.domain.odm.DocumentResult<DOC>>
    findById(@NonNull String id)
    Find by id.
    Optional<io.stargate.sdk.data.domain.odm.DocumentResult<DOC>>
    findByVector(float[] vector)
    Find by vector
    io.stargate.sdk.core.domain.Page<io.stargate.sdk.data.domain.odm.DocumentResult<DOC>>
    findVector(float[] vector, io.stargate.sdk.data.domain.query.Filter metadataFilter)
    Search similarity from the vector and a limit, if a limit / no paging
    List<io.stargate.sdk.data.domain.odm.DocumentResult<DOC>>
    findVector(float[] vector, io.stargate.sdk.data.domain.query.Filter metadataFilter, Integer limit)
    Search similarity from the vector and a limit, if a limit / no paging
    List<io.stargate.sdk.data.domain.odm.DocumentResult<DOC>>
    findVector(float[] vector, Integer limit)
    Search similarity from the vector and a limit, if a limit / no paging
    io.stargate.sdk.data.domain.DocumentMutationResult<DOC>
    insert(io.stargate.sdk.data.domain.odm.Document<DOC> bean)
    Save a NEW RECORD with a defined id.
    final List<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>>
    insert(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documents)
    Low level insertion of multiple records, they should not exist, or it will fail.
    final List<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>>
    insert(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documents, int chunkSize, int concurrency)
    Low level insertion of multiple records, they should not exist, or it will fail.
    CompletableFuture<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>>
    insertAsync(io.stargate.sdk.data.domain.odm.Document<DOC> bean)
    Save a NEW RECORD with a defined id asynchronously
    final CompletableFuture<List<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>>>
    insertASync(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documents)
    Insert a List asynchronously.
    final CompletableFuture<List<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>>>
    insertASync(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documents, int chunkSize, int concurrency)
    Insert a List asynchronously.
    final io.stargate.sdk.data.domain.DocumentMutationResult<DOC>
    save(@NonNull io.stargate.sdk.data.domain.odm.Document<DOC> current)
    Save by record.
    final List<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>>
    saveAll(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documentList)
    Create a new document a generating identifier.
    final List<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>>
    saveAll(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documentList, int chunkSize, int concurrency)
    Create a new document a generating identifier.
    final CompletableFuture<List<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>>>
    saveAllASync(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documentList)
    Create a new document a generating identifier asynchronously
    final CompletableFuture<List<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>>>
    saveAllASync(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documentList, int chunkSize, int concurrency)
    Create a new document a generating identifier asynchronously
    final CompletableFuture<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>>
    saveASync(@NonNull io.stargate.sdk.data.domain.odm.Document<DOC> current)
    Save by record asynchronously.
    io.stargate.sdk.core.domain.Page<io.stargate.sdk.data.domain.odm.DocumentResult<DOC>>
    searchPage(io.stargate.sdk.data.domain.query.SelectQuery query)
    Find a page in the collection.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • exists

      public boolean exists(String id)
      Check existence of a document from its id. Projection to make it as light as possible.
      Parameters:
      id - document identifier
      Returns:
      existence status
    • insert

      public io.stargate.sdk.data.domain.DocumentMutationResult<DOC> insert(io.stargate.sdk.data.domain.odm.Document<DOC> bean)
      Save a NEW RECORD with a defined id.
      Parameters:
      bean - current object
      Returns:
      generated identifier
    • insertAsync

      public CompletableFuture<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>> insertAsync(io.stargate.sdk.data.domain.odm.Document<DOC> bean)
      Save a NEW RECORD with a defined id asynchronously
      Parameters:
      bean - current object
      Returns:
      generated identifier
    • insert

      public final List<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>> insert(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documents)
      Low level insertion of multiple records, they should not exist, or it will fail.
      Parameters:
      documents - list of documents
      Returns:
      list of ids
    • insertASync

      public final CompletableFuture<List<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>>> insertASync(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documents)
      Insert a List asynchronously.
      Parameters:
      documents - list of documents
      Returns:
      list of ids
    • insert

      public final List<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>> insert(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documents, int chunkSize, int concurrency)
      Low level insertion of multiple records, they should not exist, or it will fail.
      Parameters:
      documents - list of documents
      chunkSize - how many document per chunk
      concurrency - how many thread in parallel
      Returns:
      list of ids
    • insertASync

      public final CompletableFuture<List<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>>> insertASync(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documents, int chunkSize, int concurrency)
      Insert a List asynchronously.
      Parameters:
      documents - list of documents
      chunkSize - split into chunks
      concurrency - number of thread to process the chunks
      Returns:
      list of ids
    • save

      public final io.stargate.sdk.data.domain.DocumentMutationResult<DOC> save(@NonNull @NonNull io.stargate.sdk.data.domain.odm.Document<DOC> current)
      Save by record.
      Parameters:
      current - object Mapping
      Returns:
      an unique identifier for the document
    • saveASync

      public final CompletableFuture<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>> saveASync(@NonNull @NonNull io.stargate.sdk.data.domain.odm.Document<DOC> current)
      Save by record asynchronously.
      Parameters:
      current - object Mapping
      Returns:
      an unique identifier for the document
    • saveAll

      public final List<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>> saveAll(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documentList)
      Create a new document a generating identifier.
      Parameters:
      documentList - object Mapping
      Returns:
      an unique identifier for the document
    • saveAllASync

      public final CompletableFuture<List<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>>> saveAllASync(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documentList)
      Create a new document a generating identifier asynchronously
      Parameters:
      documentList - object Mapping
      Returns:
      an unique identifier for the document
    • saveAll

      public final List<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>> saveAll(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documentList, int chunkSize, int concurrency)
      Create a new document a generating identifier.
      Parameters:
      documentList - object Mapping
      chunkSize - size of the chunk to process items
      concurrency - concurrency to process items
      Returns:
      an unique identifier for the document
    • saveAllASync

      public final CompletableFuture<List<io.stargate.sdk.data.domain.DocumentMutationResult<DOC>>> saveAllASync(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documentList, int chunkSize, int concurrency)
      Create a new document a generating identifier asynchronously
      Parameters:
      documentList - object Mapping
      chunkSize - size of the chunk to process items
      concurrency - concurrency to process items
      Returns:
      an unique identifier for the document
    • count

      public final int count()
      Count Document request.
      Returns:
      number of document.
    • count

      public final int count(io.stargate.sdk.data.domain.query.Filter jsonFilter)
      Count Document request.
      Parameters:
      jsonFilter - a filter for the count
      Returns:
      number of document.
    • findById

      public Optional<io.stargate.sdk.data.domain.odm.DocumentResult<DOC>> findById(@NonNull @NonNull String id)
      Find by id.
      Parameters:
      id - identifier
      Returns:
      object if presents
    • findAll

      public Stream<io.stargate.sdk.data.domain.odm.DocumentResult<DOC>> findAll()
      Find all item in the collection.
      Returns:
      retrieve all items
    • find

      public Stream<io.stargate.sdk.data.domain.odm.DocumentResult<DOC>> find(@NonNull @NonNull io.stargate.sdk.data.domain.query.SelectQuery query)
      Find all item in the collection.
      Parameters:
      query - search with a query
      Returns:
      retrieve all items
    • searchPage

      public io.stargate.sdk.core.domain.Page<io.stargate.sdk.data.domain.odm.DocumentResult<DOC>> searchPage(io.stargate.sdk.data.domain.query.SelectQuery query)
      Find a page in the collection.
      Parameters:
      query - current query
      Returns:
      page of records
    • delete

      public boolean delete(io.stargate.sdk.data.domain.odm.Document<DOC> document)
      Delete a document from id or vector.
      Parameters:
      document - document
      Returns:
      if document has been deleted.
    • deleteAll

      public int deleteAll()
      Delete all documents
      Returns:
      number of document deleted
    • deleteAll

      public int deleteAll(List<io.stargate.sdk.data.domain.odm.Document<DOC>> documents)
      Use parallelism and async to delete all records.
      Parameters:
      documents - list of records
      Returns:
      number of records deleted
    • deleteAll

      public int deleteAll(io.stargate.sdk.data.domain.query.DeleteQuery deleteQuery)
      Delete item through a query.
      Parameters:
      deleteQuery - delete query
      Returns:
      number of records deleted
    • findByVector

      public Optional<io.stargate.sdk.data.domain.odm.DocumentResult<DOC>> findByVector(float[] vector)
      Find by vector
      Parameters:
      vector - vector
      Returns:
      object if presents
    • deleteByVector

      public boolean deleteByVector(float[] vector)
      Delete by vector
      Parameters:
      vector - vector
      Returns:
      if object deleted
    • deleteById

      public boolean deleteById(String id)
      Delete by vector
      Parameters:
      id - id
      Returns:
      if object deleted
    • findVector

      public io.stargate.sdk.core.domain.Page<io.stargate.sdk.data.domain.odm.DocumentResult<DOC>> findVector(float[] vector, io.stargate.sdk.data.domain.query.Filter metadataFilter)
      Search similarity from the vector and a limit, if a limit / no paging
      Parameters:
      vector - vector
      metadataFilter - metadata filtering
      Returns:
      page of results
    • findVector

      public List<io.stargate.sdk.data.domain.odm.DocumentResult<DOC>> findVector(float[] vector, Integer limit)
      Search similarity from the vector and a limit, if a limit / no paging
      Parameters:
      vector - vector
      limit - return count
      Returns:
      page of results
    • findVector

      public List<io.stargate.sdk.data.domain.odm.DocumentResult<DOC>> findVector(float[] vector, io.stargate.sdk.data.domain.query.Filter metadataFilter, Integer limit)
      Search similarity from the vector and a limit, if a limit / no paging
      Parameters:
      vector - vector
      metadataFilter - metadata filtering
      limit - return count
      Returns:
      page of results