Class AstraDB

java.lang.Object
com.dtsx.astra.sdk.AstraDB

public class AstraDB extends Object
Client for AstraDB at database level (crud for collections).
  • Field Details

    • env

      protected final AstraEnvironment env
      Hold a reference to target Astra Environment.
  • Constructor Details

    • AstraDB

      public AstraDB(String token, String apiEndpoint)
      Initialization with endpoint and apikey.
      Parameters:
      token - api token
      apiEndpoint - 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 token
      apiEndpoint - api endpoint
      keyspace - keyspace
    • AstraDB

      public AstraDB(@NonNull @NonNull String token, @NonNull @NonNull UUID databaseId)
      Full constructor.
      Parameters:
      token - token
      databaseId - database identifier
    • AstraDB

      public AstraDB(@NonNull @NonNull String token, @NonNull @NonNull UUID databaseId, @NonNull @NonNull String keyspace)
      Full constructor.
      Parameters:
      token - token
      databaseId - database identifier
      keyspace - 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 - token
      databaseId - database identifier
      region - database region
      keyspace - 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 token
      databaseId - database id
      region - database region
      env - environment
      keyspace - destination keyspace
  • Method Details

    • isCollectionExists

      public boolean isCollectionExists(@NonNull @NonNull String store)
      Check if a store exists.
      Parameters:
      store - collection name
      Returns:
      of the store already exist
    • findAllCollections

      public Stream<io.stargate.sdk.data.domain.CollectionDefinition> findAllCollections()
      List all vector Stores for this environment.
      Returns:
      name of all vector store.
    • findCollection

      public Optional<io.stargate.sdk.data.domain.CollectionDefinition> findCollection(String name)
      Return the collection definition if its exists.
      Parameters:
      name - collection name
      Returns:
      collection definition
    • deleteCollection

      public void deleteCollection(String name)
      Delete a store if it exists.
      Parameters:
      name - store name
    • createCollection

      public AstraDBCollection createCollection(String name)
      Create the minimal store.
      Parameters:
      name - store name
      Returns:
      json vector store
    • createCollection

      public <DOC> AstraDBRepository<DOC> createCollection(String name, Class<DOC> clazz)
      Create the minimal store.
      Type Parameters:
      DOC - type of document in used
      Parameters:
      name - store name
      clazz - bean type
      Returns:
      json vector store
    • createCollection

      public AstraDBCollection createCollection(String name, int vectorDimension)
      Create the minimal store.
      Parameters:
      name - store name
      vectorDimension - 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 name
      vectorDimension - dimension
      metric - similarity metric for the vector
      Returns:
      json vector store
    • createCollection

      public <T> AstraDBRepository<T> createCollection(String name, int vectorDimension, Class<T> bean)
      Create the minimal store.
      Type Parameters:
      T - object type
      Parameters:
      name - store name
      vectorDimension - dimension
      bean - class of pojo
      Returns:
      vector store instance
    • createCollection

      public AstraDBCollection createCollection(io.stargate.sdk.data.domain.CollectionDefinition def)
      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 definition
      clazz - bean type
      Returns:
      json vector store
    • collection

      public AstraDBCollection collection(@NonNull @NonNull String storeName)
      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 identifier
      clazz - 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