Skip to content

Updating 2.0 with latest #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed File
Empty file.
Empty file removed Preferences...
Empty file.
7 changes: 7 additions & 0 deletions RELEASE.MD
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,11 @@ cd ~/.ssh
ssh-add githubff4j
```

- [x] Deploy

```console
mvn versions:set -DnewVersion=2.0.0-PREVIEW3 -DgenerateBackupPoms=false
git tag 2.0.1 && git push origin 2.0.1
```


Empty file removed Resources
Empty file.
6 changes: 3 additions & 3 deletions astra-db-java-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.datastax.astra</groupId>
<artifactId>astra-db-java-parent</artifactId>
<version>2.0.0-PREVIEW1-SNAPSHOT</version>
<version>2.0.0-PREVIEW3</version>
</parent>

<dependencies>
Expand All @@ -24,12 +24,12 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.12.0</version>
<version>1.14.0</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.9</version>
<version>5.10</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
import com.datastax.astra.client.core.vectorize.VectorServiceOptions;
import com.datastax.astra.client.databases.Database;
import com.datastax.astra.client.databases.DatabaseOptions;
import com.datastax.astra.client.databases.commands.options.CreateKeyspaceOptions;
import com.datastax.astra.client.databases.definition.DatabaseInfo;
import com.datastax.astra.client.databases.definition.keyspaces.KeyspaceDefinition;
import com.datastax.astra.client.tables.Table;
import com.datastax.astra.client.tables.commands.options.CreateTableOptions;
import com.datastax.astra.client.tables.commands.options.CreateVectorIndexOptions;
import com.datastax.astra.client.tables.definition.rows.Row;
import com.datastax.astra.internal.utils.Utils;
import com.datastax.astra.tool.loader.rag.ingestion.RagEmbeddingsModels;
import com.datastax.astra.tool.loader.rag.ingestion.RagIngestionConfig;
import com.datastax.astra.tool.loader.rag.ingestion.RagIngestionJob;
Expand All @@ -24,6 +25,8 @@
import java.util.Optional;
import java.util.UUID;

import static com.datastax.astra.internal.utils.Assert.notNull;

@Slf4j
public class RagRepository {

Expand Down Expand Up @@ -53,7 +56,9 @@ public Database getOrCreateDatabase(UUID tenantId) {
log.info("Database {} does not exists and will be created.", tenantId.toString());
DatabaseAdmin dbAdmin = astraDBAdmin
.createDatabase(tenantId.toString(), cloudProvider, cloudRegion);
dbAdmin.createKeyspace(keyspace, true);
dbAdmin.createKeyspace(
new KeyspaceDefinition().name(keyspace),
new CreateKeyspaceOptions().updateDBKeyspace(true));
return dbAdmin.getDatabase(keyspace);
}
log.info("Database {} already exists.", tenantId);
Expand Down Expand Up @@ -128,8 +133,7 @@ public Table<RagStore> getTableRagStore(UUID tenantId, RagIngestionConfig config
}

public Table<RagStore> getTableRagStore(Database db, String provider, String model, int dimension, VectorServiceOptions options) {
Utils.hasLength(provider);
Utils.hasLength(model);
notNull(provider, "provider");
String tableName = RagStore.getTableName(provider, model);
db.useKeyspace(keyspace);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.datastax.astra.tool.loader.rag.ingestion;

public enum RagEmbeddingsModels {
/** Embedding models */
NVIDIA_NEMO("nvidia", "NV-Embed-QA", 1024),
OPENAI_ADA002("open-ai", "text-embedding-ada-002", 1536),
OPENAI_3_SMALL("open-ai", "text-embedding-3-small", 1536),
Expand Down
6 changes: 4 additions & 2 deletions astra-db-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>astra-db-java</artifactId>
<name>Java Client Library for Data API</name>
<name>Data API Client Java</name>
<packaging>jar</packaging>
<description>Implementation of a client to the Astra/Stargate Data API written in Java</description>

<!-- Reference to parent -->
<parent>
<groupId>com.datastax.astra</groupId>
<artifactId>astra-db-java-parent</artifactId>
<version>2.0.0-PREVIEW2-SNAPSHOT</version>
<version>2.0.0-PREVIEW3</version>
</parent>

<properties>
Expand All @@ -22,6 +23,7 @@
<dependency>
<groupId>com.datastax.astra</groupId>
<artifactId>astra-sdk-devops</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.uuid</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class AdminOptions extends BaseOptions<AdminOptions> {
* Serializer for the collections.
* Defaults to {@link DatabaseSerializer}.
*/
private static final DataAPISerializer DEFAULT_SERIALIZER = new DatabaseSerializer();
public static final DataAPISerializer DEFAULT_SERIALIZER = new DatabaseSerializer();

/**
* Serializer for the collections.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@
import com.datastax.astra.client.DataAPIDestination;
import com.datastax.astra.client.core.options.BaseOptions;
import com.datastax.astra.client.core.options.DataAPIClientOptions;
import com.datastax.astra.client.databases.commands.options.CreateKeyspaceOptions;
import com.datastax.astra.client.databases.commands.options.DropKeyspaceOptions;
import com.datastax.astra.client.databases.commands.results.FindEmbeddingProvidersResult;
import com.datastax.astra.client.databases.DatabaseOptions;
import com.datastax.astra.client.databases.commands.results.FindRerankingProvidersResult;
import com.datastax.astra.client.databases.definition.keyspaces.KeyspaceDefinition;
import com.datastax.astra.internal.api.AstraApiEndpoint;
import com.datastax.astra.internal.command.AbstractCommandRunner;
import com.datastax.astra.internal.utils.Assert;
import com.dtsx.astra.sdk.db.AstraDBOpsClient;
import com.dtsx.astra.sdk.db.DbKeyspacesClient;
import com.dtsx.astra.sdk.db.domain.Database;
import com.dtsx.astra.sdk.db.exception.DatabaseNotFoundException;
import com.dtsx.astra.sdk.utils.AstraEnvironment;
Expand Down Expand Up @@ -203,26 +207,36 @@ public FindRerankingProvidersResult findRerankingProviders() {

/** {@inheritDoc} */
@Override
public void createKeyspace(String keyspace, boolean updateDBKeyspace) {
log.debug("createKeyspace");
devopsDbClient.database(databaseId.toString()).keyspaces().create(keyspace);
public void createKeyspace(String keyspace) {
createKeyspace(
new KeyspaceDefinition().name(keyspace),
new CreateKeyspaceOptions().ifNotExists(true));
}

@Override
public void createKeyspace(KeyspaceDefinition keyspace, CreateKeyspaceOptions options) {
String keyspaceName = keyspace.getName();
DbKeyspacesClient ks = devopsDbClient.database(databaseId.toString()).keyspaces();
if (!ks.exist(keyspaceName) && options.isIfNotExists()) {
ks.create(keyspaceName);
}
}

/** {@inheritDoc} */
@Override
public void dropKeyspace(String keyspace) {
log.debug("dropKeyspace");
try {
devopsDbClient.database(databaseId.toString()).keyspaces().delete(keyspace);
} catch(NullPointerException e) {
// Left blank to parse output from a delete
}
dropKeyspace(keyspace, new DropKeyspaceOptions().ifExists(true));
}

/** {@inheritDoc} */
@Override
public void dropKeyspace(String keyspace, BaseOptions<?> options) {
public void dropKeyspace(String keyspace, DropKeyspaceOptions options) {
log.warn("CommandOptions are not supported for dropKeyspace in Astra MODE");
dropKeyspace(keyspace);
DbKeyspacesClient ks = devopsDbClient.database(databaseId.toString()).keyspaces();
if (ks.exist(keyspace) && options.isIfExists()) {
ks.delete(keyspace);
}
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@
* #L%
*/

import com.datastax.astra.client.core.options.BaseOptions;
import com.datastax.astra.client.core.commands.Command;
import com.datastax.astra.client.core.commands.CommandType;
import com.datastax.astra.client.core.rerank.RerankProvider;
import com.datastax.astra.client.databases.commands.results.FindEmbeddingProvidersResult;
import com.datastax.astra.client.core.vectorize.EmbeddingProvider;
import com.datastax.astra.client.databases.Database;
import com.datastax.astra.client.databases.commands.options.CreateKeyspaceOptions;
import com.datastax.astra.client.databases.commands.options.DropKeyspaceOptions;
import com.datastax.astra.client.databases.commands.results.FindEmbeddingProvidersResult;
import com.datastax.astra.client.databases.commands.results.FindRerankingProvidersResult;
import com.datastax.astra.client.databases.definition.keyspaces.KeyspaceDefinition;
import com.datastax.astra.client.databases.definition.keyspaces.KeyspaceOptions;
import com.datastax.astra.internal.api.DataAPIResponse;
import com.datastax.astra.internal.command.AbstractCommandRunner;
import com.datastax.astra.internal.serdes.DataAPISerializer;
import com.datastax.astra.internal.serdes.collections.DocumentSerializer;
import com.datastax.astra.internal.utils.Assert;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

Expand Down Expand Up @@ -139,14 +140,23 @@ public Database getDatabase(String keyspace, String userToken) {
.keyspace(keyspace));
}

/** {@inheritDoc} */
@Override
public void createKeyspace(String keyspace, boolean updateDBKeyspace) {
Assert.hasLength(keyspace, ARG_KEYSPACE);
createKeyspace(keyspace, KeyspaceOptions.simpleStrategy(1));
if (updateDBKeyspace) {
db.useKeyspace(keyspace);
public void createKeyspace(KeyspaceDefinition keyspace, CreateKeyspaceOptions options) {
notNull(keyspace, ARG_KEYSPACE);
hasLength(keyspace.getName(), ARG_KEYSPACE);
Command createKeyspace = Command
.create("createKeyspace")
.append("name", keyspace.getName());
if (keyspace.getReplication() != null) {
KeyspaceOptions keyspaceOptions = new KeyspaceOptions();
keyspaceOptions.setReplication(keyspace.getReplication());
createKeyspace.withOptions(keyspaceOptions);
}
runCommand(createKeyspace);
if (options != null && options.isUpdateDBKeyspace()) {
db.useKeyspace(keyspace.getName());
}
log.info("Keyspace '" + green("{}") + "' has been created", keyspace.getName());
}

/**
Expand All @@ -169,7 +179,7 @@ public void createKeyspace(String keyspace, KeyspaceOptions options) {
}

@Override
public void dropKeyspace(String keyspace, BaseOptions<?> options) {
public void dropKeyspace(String keyspace, DropKeyspaceOptions options) {
hasLength(keyspace, ARG_KEYSPACE);
Command dropNamespace = Command
.create("dropKeyspace")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@
import com.datastax.astra.client.databases.Database;
import com.datastax.astra.client.core.commands.CommandRunner;
import com.datastax.astra.client.core.vectorize.EmbeddingProvider;
import com.datastax.astra.client.databases.commands.options.CreateKeyspaceOptions;
import com.datastax.astra.client.databases.commands.options.DropKeyspaceOptions;
import com.datastax.astra.client.databases.commands.results.FindEmbeddingProvidersResult;
import com.datastax.astra.client.databases.commands.results.FindRerankingProvidersResult;
import com.datastax.astra.client.databases.definition.keyspaces.KeyspaceDefinition;
import com.datastax.astra.client.databases.definition.keyspaces.KeyspaceInformation;
import com.datastax.astra.internal.utils.Assert;

import java.util.Set;
Expand Down Expand Up @@ -240,7 +244,28 @@ default void dropKeyspace(String keyspace) {
* keyspace does not exist, ensuring consistent behavior.
* @param options The options to use for the operation.
*/
void dropKeyspace(String keyspace, BaseOptions<?> options);
void dropKeyspace(String keyspace, DropKeyspaceOptions options);

/**
* Asynchronously drops (deletes) the specified keyspace from the database. This operation is idempotent, meaning
* it will not produce an error if the keyspace does not exist. Performing this operation asynchronously ensures
* that the calling thread remains responsive, and can be particularly useful for applications that require high
* availability and cannot afford to block on potentially long-running operations. Just like its synchronous counterpart,
* this method should be used with caution as dropping a keyspace will remove all associated data, collections,
* or tables, and this action is irreversible.
*
* This example illustrates the non-blocking nature of dropping a keyspace. It demonstrates the method's utility in
* maintaining application responsiveness, even when performing potentially long-running database operations.
*
* @param keyspace The name of the keyspace to be dropped. This is the target keyspace that will be deleted.
* The asynchronous nature of this method means that it will execute without blocking the calling
* thread, regardless of whether the keyspace exists or not, ensuring a consistent and responsive
* application behavior.
* @param options The options to use for the operation to drop the keyspace like a timeout or if exists.
*/
default void dropKeyspaceAsync(String keyspace, DropKeyspaceOptions options) {
CompletableFuture.runAsync(() -> dropKeyspace(keyspace, options));
}

/**
* Asynchronously drops (deletes) the specified keyspace from the database. This operation is idempotent, meaning
Expand All @@ -263,25 +288,35 @@ default void dropKeyspaceAsync(String keyspace) {
}

/**
* Create a Keyspace providing a name.
* Syntax Sugar, retro compatible.
*
* @param keyspace
* current keyspace.
* @param updateDBKeyspace
* if the keyspace should be updated in the database.
*/
void createKeyspace(String keyspace, boolean updateDBKeyspace);
* current namespace.
**/
default void createKeyspace(String keyspace) {
createKeyspace(new KeyspaceDefinition().name(keyspace), new CreateKeyspaceOptions());
}

/**
* Syntax Sugar, retro compatible.
*
* @param keyspace
* current namespace.
**/
default void createKeyspace(String keyspace) {
createKeyspace(keyspace, false);
default void createKeyspace(KeyspaceDefinition keyspace) {
createKeyspace(keyspace, new CreateKeyspaceOptions());
}

/**
* Create a Keyspace providing a name.
*
* @param keyspace
* keyspace definition
* @param options
* options to create the keyspace
*/
void createKeyspace(KeyspaceDefinition keyspace, CreateKeyspaceOptions options);

/**
* Create a keyspace providing a name.
*
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy