Package com.dtsx.astra.sdk
Class AstraDB
java.lang.Object
com.dtsx.astra.sdk.AstraDB
Client for AstraDB at database level (crud for collections).
-
Field Summary
Modifier and TypeFieldDescriptionprotected final AstraEnvironment
Hold a reference to target Astra Environment. -
Constructor Summary
ConstructorDescriptionInitialization with endpoint and apikey.Full constructor.Full constructor.AstraDB
(@NonNull String token, @NonNull UUID databaseId, @NonNull String region, @NonNull String keyspace) Full constructor.AstraDB
(@NonNull String token, @NonNull UUID databaseId, String region, @NonNull AstraEnvironment env, String keyspace) Accessing the database with id and region.Initialization with endpoint and apikey. -
Method Summary
Modifier and TypeMethodDescriptioncollection
(@NonNull String storeName) Access the database functions.<T> AstraDBRepository
<T> collectionRepository
(@NonNull String storeName, Class<T> clazz) Access the database functions.createCollection
(io.stargate.sdk.data.domain.CollectionDefinition def) Create the minimal store.<DOC> AstraDBRepository
<DOC> createCollection
(io.stargate.sdk.data.domain.CollectionDefinition def, Class<DOC> clazz) Create the minimal store.createCollection
(String name) Create the minimal store.createCollection
(String name, int vectorDimension) Create the minimal store.createCollection
(String name, int vectorDimension, io.stargate.sdk.data.domain.SimilarityMetric metric) Create the minimal store.<T> AstraDBRepository
<T> createCollection
(String name, int vectorDimension, Class<T> bean) Create the minimal store.<DOC> AstraDBRepository
<DOC> createCollection
(String name, Class<DOC> clazz) Create the minimal store.void
deleteCollection
(String name) Delete a store if it exists.Stream
<io.stargate.sdk.data.domain.CollectionDefinition> List all vector Stores for this environment.Optional
<io.stargate.sdk.data.domain.CollectionDefinition> findCollection
(String name) Return the collection definition if its exists.io.stargate.sdk.data.NamespaceClient
Access the low level Stargate Namespace resource operation.boolean
isCollectionExists
(@NonNull String store) Check if a store exists.
-
Field Details
-
env
Hold a reference to target Astra Environment.
-
-
Constructor Details
-
AstraDB
Initialization with endpoint and apikey.- Parameters:
token
- api tokenapiEndpoint
- api endpoint
-
AstraDB
public AstraDB(@NonNull @NonNull String token, @NonNull @NonNull String apiEndpoint, @NonNull @NonNull String keyspace) Initialization with endpoint and apikey.- Parameters:
token
- api tokenapiEndpoint
- api endpointkeyspace
- keyspace
-
AstraDB
Full constructor.- Parameters:
token
- tokendatabaseId
- database identifier
-
AstraDB
public AstraDB(@NonNull @NonNull String token, @NonNull @NonNull UUID databaseId, @NonNull @NonNull String keyspace) Full constructor.- Parameters:
token
- tokendatabaseId
- database identifierkeyspace
- database keyspace
-
AstraDB
public AstraDB(@NonNull @NonNull String token, @NonNull @NonNull UUID databaseId, @NonNull @NonNull String region, @NonNull @NonNull String keyspace) Full constructor.- Parameters:
token
- tokendatabaseId
- database identifierregion
- database regionkeyspace
- keyspace
-
AstraDB
public AstraDB(@NonNull @NonNull String token, @NonNull @NonNull UUID databaseId, String region, @NonNull @NonNull AstraEnvironment env, String keyspace) Accessing the database with id and region.- Parameters:
token
- astra tokendatabaseId
- database idregion
- database regionenv
- environmentkeyspace
- destination keyspace
-
-
Method Details
-
isCollectionExists
Check if a store exists.- Parameters:
store
- collection name- Returns:
- of the store already exist
-
findAllCollections
List all vector Stores for this environment.- Returns:
- name of all vector store.
-
findCollection
Return the collection definition if its exists.- Parameters:
name
- collection name- Returns:
- collection definition
-
deleteCollection
Delete a store if it exists.- Parameters:
name
- store name
-
createCollection
Create the minimal store.- Parameters:
name
- store name- Returns:
- json vector store
-
createCollection
Create the minimal store.- Type Parameters:
DOC
- type of document in used- Parameters:
name
- store nameclazz
- bean type- Returns:
- json vector store
-
createCollection
Create the minimal store.- Parameters:
name
- store namevectorDimension
- dimension- Returns:
- json vector store
-
createCollection
public AstraDBCollection createCollection(String name, int vectorDimension, io.stargate.sdk.data.domain.SimilarityMetric metric) Create the minimal store.- Parameters:
name
- store namevectorDimension
- dimensionmetric
- similarity metric for the vector- Returns:
- json vector store
-
createCollection
Create the minimal store.- Type Parameters:
T
- object type- Parameters:
name
- store namevectorDimension
- dimensionbean
- class of pojo- Returns:
- vector store instance
-
createCollection
Create the minimal store.- Parameters:
def
- collection definition- Returns:
- json vector store
-
createCollection
public <DOC> AstraDBRepository<DOC> createCollection(io.stargate.sdk.data.domain.CollectionDefinition def, Class<DOC> clazz) Create the minimal store.- Type Parameters:
DOC
- type of document in used- Parameters:
def
- collection definitionclazz
- bean type- Returns:
- json vector store
-
collection
Access the database functions.- Parameters:
storeName
- store identifier- Returns:
- storeName client
-
collectionRepository
public <T> AstraDBRepository<T> collectionRepository(@NonNull @NonNull String storeName, Class<T> clazz) Access the database functions.- Type Parameters:
T
- type of the bean in use- Parameters:
storeName
- store identifierclazz
- type of object used- Returns:
- storeName client
-
getNamespaceClient
public io.stargate.sdk.data.NamespaceClient getNamespaceClient()Access the low level Stargate Namespace resource operation.- Returns:
- raw namespace client
-