Package io.stargate.sdk.doc
Class CollectionClient
java.lang.Object
io.stargate.sdk.doc.CollectionClient
Work on a dedicated collection without using the Pojo className.
- Author:
- Cedrick LUNVEN (@clunven)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumUpdate Types.static interfacefind next page during a findAll -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringRead document id./v2/schemas/namespaces/{namespace}/collections/{collection}/batch/v2/schemas/namespaces/{namespace}/collections/{collection}/json-schemaprotected StringCollection name./v2/schemas/namespaces/{namespace}/collections/{collection}/v2/schemas/namespaces/{namespace}/collections/{collection}/upgrade?raw=truestatic final StringRead document id.protected NamespaceClientNamespace. -
Constructor Summary
ConstructorsConstructorDescriptionCollectionClient(LoadBalancedHttpClient stargateHttpClient, NamespaceClient namespaceClient, String collectionName) Full constructor. -
Method Summary
Modifier and TypeMethodDescriptionbatchInsert(List<DOC> records) Insert multiple record with a single resource.batchInsert(List<DOC> records, String idPath) Use the resource batch to insert massively in the DB.batchInsertRaw(List<String> records) Insert multiple record with a single resource.batchInsertRaw(List<String> records, String idPath) Use the resource batch to insert massively in the DB.longcount()Count items in a collection, it can be slow as we iterate over pages limitating payload and marshalling as much as possible.voidcreate()Create the collection.<DOC> Stringcreate(DOC doc) Create a new document from any serializable object.Create a new document from any serializable object.voiddelete()Deleting the collectionMove to document Resourcebooleanexist()Check if the collection exist.find()Get metadata of the collection.findAll()This function will retrieve all documents in the Collection without any mapping.findAll(RecordMapper<DOC> documentMapper) This function will retrieve all documents in the Collection providing a custom mapping logic.Find all document matching the query.findAll(Query query, RecordMapper<DOC> documentMapper) Find all document matching the query.Find all document matching the query.This function will retrieve all documents in the Collection with automatic marshalling (jackson).findPage()Search for a page (without marshalling).findPage(RecordMapper<DOC> documentMapper) Find a page and marshall using a mapper.findPage(PageableQuery query) Find a page given some search (without marshalling the documents).findPage(PageableQuery query, RecordMapper<DOC> documentMapper) Find a page and marshall using a mapper.findPage(PageableQuery query, Class<DOC> beanClass) Find a page given some search.Default query, find first page.Getter accessor for attribute 'collectionName'.voidUpdate a collection to SAI.voidUpgrade the collection.
-
Field Details
-
DOCUMENT_ID
Read document id.- See Also:
-
BATCH_ID_PATH
Read document id.- See Also:
-
namespaceClient
Namespace. -
collectionName
Collection name. -
collectionResource
/v2/schemas/namespaces/{namespace}/collections/{collection} -
collectionUpgradeResource
/v2/schemas/namespaces/{namespace}/collections/{collection}/upgrade?raw=true -
collectionBatchResource
/v2/schemas/namespaces/{namespace}/collections/{collection}/batch -
collectionJsonSchemaResource
/v2/schemas/namespaces/{namespace}/collections/{collection}/json-schema
-
-
Constructor Details
-
CollectionClient
public CollectionClient(LoadBalancedHttpClient stargateHttpClient, NamespaceClient namespaceClient, String collectionName) Full constructor.- Parameters:
stargateHttpClient- http clientnamespaceClient- NamespaceClientcollectionName- String
-
-
Method Details
-
find
Get metadata of the collection. There is no dedicated resources we use the list and filter with what we need.- Returns:
- metadata of the collection if its exist or empty
- See Also:
-
exist
public boolean exist()Check if the collection exist.- Returns:
- if the collection exists.
-
create
public void create()Create the collection.- See Also:
-
upgradeSAI
public void upgradeSAI()Upgrade the collection. This is not relevant in ASTRA. -
upgrade
Update a collection to SAI.- Parameters:
index- collection SAI
-
delete
public void delete()Deleting the collection- See Also:
-
create
Create a new document from any serializable object. The doc could be a the String value.- Type Parameters:
DOC- working bean type- Parameters:
doc- working bean instance- Returns:
- created document id
- See Also:
-
create
Create a new document from any serializable object. The doc could be a the String value.- Parameters:
doc- working bean instance- Returns:
- created document id
- See Also:
-
batchInsert
Use the resource batch to insert massively in the DB.- Type Parameters:
DOC- working document- Parameters:
records- list of recordsidPath- id path to enforced ids- Returns:
- list of inserted ids
-
batchInsertRaw
Use the resource batch to insert massively in the DB.- Parameters:
records- list of recordsidPath- id path to enforced ids- Returns:
- list of inserted ids
-
batchInsert
Insert multiple record with a single resource.- Type Parameters:
DOC- working document- Parameters:
records- list of records- Returns:
- list of inserted ids
-
batchInsertRaw
Insert multiple record with a single resource.- Parameters:
records- list of records- Returns:
- list of inserted ids
-
count
public long count()Count items in a collection, it can be slow as we iterate over pages limitating payload and marshalling as much as possible.- Returns:
- number of record
-
findAll
This function will retrieve all documents in the Collection without any mapping. USE WITH CAUTION. Default behaviour is using paging, here we are fetching all pages until no more.- Returns:
- all items in the the collection
-
findAll
This function will retrieve all documents in the Collection providing a custom mapping logic. USE WITH CAUTION. Default behaviour is using paging, here we are fetching all pages until no more.- Type Parameters:
DOC- generic for working bean- Parameters:
documentMapper- mapper from a record to the document bean- Returns:
- all items in the the collection
-
findAll
This function will retrieve all documents in the Collection with automatic marshalling (jackson). USE WITH CAUTION. Default behaviour is using paging, here we are fetching all pages until no more.- Type Parameters:
DOC- generic for working bean- Parameters:
beanClass- class for working bean- Returns:
- all items in the the collection
-
findAll
Find all document matching the query. USE WITH CAUTION. Default behaviour is using paging, here we are fetching all pages until no more.- Parameters:
query- list of filters- Returns:
- all items matchin criteria
-
findAll
Find all document matching the query. USE WITH CAUTION. Default behaviour is using paging, here we are fetching all pages until no more.- Type Parameters:
DOC- generic for working bean- Parameters:
query- list of filtersdocumentMapper- custom mapping implementation- Returns:
- all items matchin criteria
-
findAll
Find all document matching the query. USE WITH CAUTION. Default behaviour is using paging, here we are fetching all pages until no more.- Type Parameters:
DOC- generic for working bean- Parameters:
query- list of filtersbeanClass- class for working bean- Returns:
- all items matchin criteria
-
findPage
Search for a page (without marshalling). There is no filter either.- Returns:
- a page of results
-
findPage
Find a page given some search (without marshalling the documents).- Parameters:
query- query- Returns:
- output
-
findPage
Default query, find first page.- Type Parameters:
DOC- working class- Parameters:
beanClass- working bean- Returns:
- the page of records
-
findPage
Find a page given some search.- Type Parameters:
DOC- generic for working bean- Parameters:
query- filters for the querybeanClass- class for working bean- Returns:
- a page of results
-
findPage
Find a page and marshall using a mapper.- Type Parameters:
DOC- current bean- Parameters:
documentMapper- document mapper- Returns:
- page of results
-
findPage
Find a page and marshall using a mapper.- Type Parameters:
DOC- current bean- Parameters:
query- current querydocumentMapper- document mapper- Returns:
- page of results
-
document
Move to document Resource- Parameters:
docId- String- Returns:
- DocumentClient
-
getCollectionName
Getter accessor for attribute 'collectionName'.- Returns:
- current value of 'collectionName'
-