Package io.stargate.sdk.data
Class CollectionRepository<DOC>
java.lang.Object
io.stargate.sdk.data.CollectionRepository<DOC>
- Type Parameters:
DOC- java bean representing a document
Client implementing repository pattern for a collection.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CollectionClientRaw collection client.Keep ref to the generic. -
Constructor Summary
ConstructorsConstructorDescriptionCollectionRepository(CollectionClient col, Class<DOC> clazz) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal intcount()Count Document request.final intCount Document request.booleanDelete a document from id or vector .Delete all documentsdeleteAll(DeleteQuery deleteQuery) Delete item through a query.intUse parallelism and async to delete all records.deleteAllChunked(DeleteQuery deleteQuery, int concurrency) Delete item through a query.booleandeleteById(String id) Delete by vectorbooleandeleteByVector(float[] vector) Delete by vectordeletePage(DeleteQuery deleteQuery) Delete item through a query.booleanCheck existence of a document from its id.find(@NonNull SelectQuery query) Find by id.Find by id.findByVector(float[] vector) Find by vectorfindVector(float[] vector, Filter metadataFilter) Search similarity from the vector and a limit, if a limit / no pagingfindVector(float[] vector, Filter metadataFilter, Integer limit) Search similarity from the vector and a limit, if a limit / no pagingfindVector(float[] vector, Integer limit) Search similarity from the vector and a limit, if a limit / no paginggetName()Return name of the store.Save a NEW RECORD with a defined id.final List<DocumentMutationResult<DOC>> Low level insertion of multiple records, they should not exist, or it will fail.final List<DocumentMutationResult<DOC>> Low level insertion of multiple records, they should not exist, or it will fail.insertASync(Document<DOC> bean) Save a NEW RECORD with a defined id.final CompletableFuture<List<DocumentMutationResult<DOC>>> insertASync(List<Document<DOC>> documents) Low level insertion of multiple records, they should not exist, or it will fail.final CompletableFuture<List<DocumentMutationResult<DOC>>> insertASync(List<Document<DOC>> documents, int chunkSize, int concurrency) Low level insertion of multiple records, they should not exist, or it will fail.final DocumentMutationResult<DOC> Upsert a recordfinal List<DocumentMutationResult<DOC>> Create a new document a generating identifier.final List<DocumentMutationResult<DOC>> Create a new document a generating identifier.final CompletableFuture<List<DocumentMutationResult<DOC>>> saveAllASync(List<Document<DOC>> documentList) Create a new document a generating identifier asynchronouslyfinal CompletableFuture<List<DocumentMutationResult<DOC>>> saveAllASync(List<Document<DOC>> documentList, int chunkSize, int concurrency) Create a new document a generating identifier asynchronouslyUpsert a recordsearch()Find all item in the collection.search(SelectQuery query) Find all item in the collection.searchPage(SelectQuery query) Find a page in the collection.
-
Field Details
-
collectionClient
Raw collection client. -
docClass
Keep ref to the generic.
-
-
Constructor Details
-
CollectionRepository
Default constructor.- Parameters:
col- collection client parentclazz- working bean class
-
-
Method Details
-
getName
Return name of the store.- Returns:
- store name
-
exists
Check existence of a document from its id. Projection to make it as light as possible.- Parameters:
id- document identifier- Returns:
- existence status
-
insert
Save a NEW RECORD with a defined id.- Parameters:
bean- current object- Returns:
- generated identifier
-
insertASync
Save a NEW RECORD with a defined id.- Parameters:
bean- current object- Returns:
- generated identifier
-
insert
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<DocumentMutationResult<DOC>>> insertASync(List<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
-
insert
public final List<DocumentMutationResult<DOC>> insert(List<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 documentschunkSize- how many document per chunkconcurrency- how many thread in parallel- Returns:
- list of ids
-
insertASync
public final CompletableFuture<List<DocumentMutationResult<DOC>>> insertASync(List<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 documentschunkSize- how many document per chunkconcurrency- how many thread in parallel- Returns:
- list of ids
-
save
Upsert a record- Parameters:
current- object Mapping- Returns:
- an unique identifier for the document
-
saveASync
Upsert a record- Parameters:
current- object Mapping- Returns:
- an unique identifier for the document
-
saveAll
Create a new document a generating identifier.- Parameters:
documentList- object Mapping- Returns:
- an unique identifier for the document
-
saveAllASync
public final CompletableFuture<List<DocumentMutationResult<DOC>>> saveAllASync(List<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<DocumentMutationResult<DOC>> saveAll(List<Document<DOC>> documentList, int chunkSize, int concurrency) Create a new document a generating identifier.- Parameters:
documentList- object MappingchunkSize- size of the chunk to process itemsconcurrency- concurrency to process items- Returns:
- an unique identifier for the document
-
saveAllASync
public final CompletableFuture<List<DocumentMutationResult<DOC>>> saveAllASync(List<Document<DOC>> documentList, int chunkSize, int concurrency) Create a new document a generating identifier asynchronously- Parameters:
documentList- object MappingchunkSize- size of the chunk to process itemsconcurrency- concurrency to process items- Returns:
- an unique identifier for the document
-
count
public final int count()Count Document request.- Returns:
- number of document.
-
count
Count Document request.- Parameters:
jsonFilter- a filter for the count- Returns:
- number of document.
-
find
Find by id.- Parameters:
query- query to retrieve documents and vector- Returns:
- object if presents
-
findById
Find by id.- Parameters:
id- identifier- Returns:
- object if presents
-
search
Find all item in the collection.- Returns:
- retrieve all items
-
search
Find all item in the collection.- Parameters:
query- search with a query- Returns:
- retrieve all items
-
searchPage
Find a page in the collection.- Parameters:
query- current query- Returns:
- page of records
-
delete
Delete a document from id or vector .- Parameters:
document- document- Returns:
- if document has been deleted.
-
deleteAll
Delete all documents- Returns:
- number of document deleted
-
deleteAll
Use parallelism and async to delete all records.- Parameters:
documents- list of records- Returns:
- number of records deleted
-
deleteAll
Delete item through a query.- Parameters:
deleteQuery- delete query- Returns:
- number of records deleted
-
deleteAllChunked
Delete item through a query.- Parameters:
deleteQuery- delete queryconcurrency- how many chunks processed in parallel- Returns:
- number of records deleted
-
deletePage
Delete item through a query.- Parameters:
deleteQuery- delete query- Returns:
- number of records deleted
-
findByVector
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
Delete by vector- Parameters:
id- id- Returns:
- if object deleted
-
findVector
Search similarity from the vector and a limit, if a limit / no paging- Parameters:
vector- vectormetadataFilter- metadata filtering- Returns:
- page of results
-
findVector
Search similarity from the vector and a limit, if a limit / no paging- Parameters:
vector- vectorlimit- return count- Returns:
- page of results
-
findVector
Search similarity from the vector and a limit, if a limit / no paging- Parameters:
vector- vectormetadataFilter- metadata filteringlimit- return count- Returns:
- page of results
-