Skip to content

Update 2.0 Branch #46

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 72 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
242fa57
Update dependent job name
msmygit Nov 21, 2024
040d39f
Merge pull request #30 from datastax/2.0-beta
clun Nov 30, 2024
086aa17
Merge pull request #31 from datastax/2.0-beta
clun Nov 30, 2024
f0c9d0a
reducing to 1838474 warnings
clun Nov 30, 2024
de15941
less warnings
clun Nov 30, 2024
edda748
Add a getTable sample + options
clun Dec 2, 2024
521379a
javadoc
clun Dec 2, 2024
8889da7
Fixing Build
clun Dec 2, 2024
4da67b0
add sample
clun Dec 2, 2024
3ed6293
sample
clun Dec 2, 2024
43931f9
update list tables
clun Dec 3, 2024
4fbb79b
update list tables
clun Dec 3, 2024
163f010
Add Sample + simple syntax for creste index
clun Dec 3, 2024
395f50f
list indexes
clun Dec 3, 2024
b6206e6
Allow operations from the on other keyspace
clun Dec 3, 2024
b0a0eca
update examples
clun Dec 3, 2024
6bc862b
Fix #32: remove accidental debug System.out.println()
tatu-at-datastax Dec 3, 2024
ab80aec
update examples
clun Dec 4, 2024
3f8361e
Merge pull request #34 from tatu-at-datastax/main
clun Dec 4, 2024
98e9de3
update examples
clun Dec 4, 2024
e789bfa
update examples
clun Dec 4, 2024
e39a405
update examples
clun Dec 4, 2024
7e1039b
add samples
clun Dec 4, 2024
38d60ba
Mapping Row=> Bean and deserialization
clun Dec 5, 2024
2386880
Mapping Row=> Bean and deserialization
clun Dec 5, 2024
de5bf9a
double typing cursor and specialization
clun Dec 5, 2024
91ba89c
double typing cursor and specialization
clun Dec 5, 2024
0fa781c
double typing cursor and specialization
clun Dec 5, 2024
acaf500
double typing cursor and specialization
clun Dec 5, 2024
241b110
samples for updateOne
clun Dec 5, 2024
ce35c3c
samples for updateOne
clun Dec 5, 2024
143a3a4
update
clun Dec 6, 2024
6a1eef6
Samples for DataAPIVector
clun Dec 6, 2024
49557db
javadocs, javadoc, javadoc
clun Dec 7, 2024
b366490
javadocs, javadoc, javadoc
clun Dec 7, 2024
c08267d
javadocs, javadoc, javadoc...46 to go
clun Dec 7, 2024
05af2bc
javadocs, javadoc, javadoc...28 to go
clun Dec 8, 2024
97c8ce0
Fix all warnings, javadocs and compiling issue
clun Dec 9, 2024
a5dfb11
fixes
clun Dec 9, 2024
b6db3d5
[maven-release-plugin] prepare release 2.0.0-PREVIEW
clun Dec 9, 2024
9e4539c
[maven-release-plugin] prepare for next development iteration
clun Dec 9, 2024
eac62bc
[maven-release-plugin] rollback the release of 2.0.0-PREVIEW
clun Dec 9, 2024
8a52aca
removing samples and tools from the build
clun Dec 9, 2024
e0d900e
[maven-release-plugin] prepare release 2.0.0-PREVIEW
clun Dec 9, 2024
b433672
[maven-release-plugin] prepare for next development iteration
clun Dec 9, 2024
e2f3482
Split the controls to avoid NPE
clun Dec 9, 2024
02716eb
fixing #35 and aligning version
clun Dec 9, 2024
ecd471f
Remove Sort from deleteOne
clun Dec 10, 2024
15c5e86
Adding controls on serializations
clun Dec 10, 2024
78c7aea
update samples
clun Dec 10, 2024
5233a1c
Adjust the Java dist version to 17 by default
msmygit Jan 6, 2025
0cd195a
test
clun Jan 28, 2025
76fcffd
tmp update cursor and document dot notation
clun Jan 29, 2025
fb1791a
Changing collection to cursor, iprove distinct, fix getSortVector, ad…
clun Jan 30, 2025
762fb0c
remove secret
clun Jan 30, 2025
4dd9849
fix error on update
clun Jan 30, 2025
f606652
fix error on update
clun Jan 30, 2025
fda3b58
ok
clun Feb 11, 2025
52c3cef
update
clun Feb 11, 2025
6dd92a4
[maven-release-plugin] prepare release 2.0.0-PREVIEW1
clun Feb 11, 2025
46a7129
[maven-release-plugin] prepare for next development iteration
clun Feb 11, 2025
266b0a5
push the json loader to the repo
clun Mar 5, 2025
856867a
removing CRTP
clun Mar 7, 2025
d91d707
FindAndRerank
clun Mar 11, 2025
9548ffc
FindAndRerank
clun Mar 11, 2025
1daf15c
FindAndRerank
clun Mar 11, 2025
e32fb25
FindAndRerank
clun Mar 14, 2025
49d5c2e
FindAndRerank
clun Mar 14, 2025
cd00bbb
FindAndRerank
clun Mar 14, 2025
e2f2668
Update find and Rerank, start reworking the tests
clun Mar 27, 2025
c575a1f
test for BYOV
clun Mar 28, 2025
f6c8288
more test
clun Mar 28, 2025
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
Prev Previous commit
Next Next commit
update list tables
  • Loading branch information
clun committed Dec 3, 2024
commit 43931f96be8fc1e0e811aa9f70ba8c9e32a78374
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,15 @@ public List<String> listTableNames() {
* </pre>
*/
public List<String> listTableNames(ListTablesOptions listTablesOptions) {
// Keyspace is part of the database, a new temporary database object is required.
if (listTablesOptions != null && Utils.hasLength(listTablesOptions.getKeyspace())) {
String otherKeyspace = listTablesOptions.getKeyspace();
listTablesOptions.keyspace(null);
return new Database(
this.rootEndpoint,
this.options.clone().keyspace(otherKeyspace))
.listTableNames(listTablesOptions);
}
return runCommand(Command.create("listTables"), listTablesOptions)
.getStatusKeyAsStringStream("tables")
.toList();
Expand Down Expand Up @@ -988,6 +997,15 @@ public List<TableDescriptor> listTables() {
* </pre>
*/
public List<TableDescriptor> listTables(ListTablesOptions listTableOptions) {
// Keyspace is part of the database, a new temporary database object is required.
if (listTableOptions != null && Utils.hasLength(listTableOptions.getKeyspace())) {
String otherKeyspace = listTableOptions.getKeyspace();
listTableOptions.keyspace(null);
return new Database(
this.rootEndpoint,
this.options.clone().keyspace(otherKeyspace))
.listTables(listTableOptions);
}
Command findTables = Command
.create("listTables")
.withOptions(new Document().append("explain", true));
Expand Down Expand Up @@ -1044,7 +1062,8 @@ public boolean tableExists(String tableName) {
public <T> Table<T> getTable(String tableName, Class<T> rowClass, TableOptions tableOptions) {
hasLength(tableName, "tableName");
notNull(rowClass, "rowClass");
return new Table<>(this, tableName, tableOptions, rowClass);
Database db2 = new Database(this.rootEndpoint, this.options.clone());
return new Table<>(db2, tableName, tableOptions, rowClass);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public String getKeyspace() {
public DatabaseOptions clone() {
// Cloning options, token, and serializer
DatabaseOptions cloned = (DatabaseOptions) super.clone();
cloned.token = token;
cloned.keyspace = keyspace;
return cloned;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
import com.datastax.astra.client.collections.commands.options.CollectionFindOptions;
import com.datastax.astra.client.collections.definition.CollectionDefinition;
import com.datastax.astra.client.collections.definition.documents.Document;
import com.datastax.astra.client.core.options.BaseOptions;
import com.datastax.astra.client.core.commands.Command;
import com.datastax.astra.client.core.options.BaseOptions;
import com.datastax.astra.client.core.paging.Page;
import com.datastax.astra.client.tables.cursor.TableCursor;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.databases.Database;
import com.datastax.astra.client.exceptions.DataAPIException;
Expand All @@ -48,6 +47,7 @@
import com.datastax.astra.client.tables.commands.results.TableInsertManyResult;
import com.datastax.astra.client.tables.commands.results.TableInsertOneResult;
import com.datastax.astra.client.tables.commands.results.TableUpdateResult;
import com.datastax.astra.client.tables.cursor.TableCursor;
import com.datastax.astra.client.tables.definition.TableDefinition;
import com.datastax.astra.client.tables.definition.TableDescriptor;
import com.datastax.astra.client.tables.definition.indexes.TableIndexDefinition;
Expand Down Expand Up @@ -83,9 +83,9 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import static com.datastax.astra.client.core.DataAPIKeywords.SORT_VECTOR;
import static com.datastax.astra.client.core.options.DataAPIClientOptions.MAX_CHUNK_SIZE;
import static com.datastax.astra.client.core.options.DataAPIClientOptions.MAX_COUNT;
import static com.datastax.astra.client.core.DataAPIKeywords.SORT_VECTOR;
import static com.datastax.astra.client.exceptions.DataAPIException.ERROR_CODE_INTERRUPTED;
import static com.datastax.astra.client.exceptions.DataAPIException.ERROR_CODE_TIMEOUT;
import static com.datastax.astra.internal.utils.AnsiUtils.cyan;
Expand Down Expand Up @@ -166,6 +166,12 @@ public Table(Database db, String tableName, TableOptions tableOptions, Class<T>
this.database = db;
this.rowClass = rowClass;
this.options.serializer(DEFAULT_TABLE_SERIALIZER);
if (tableOptions.getToken() == null) {
this.options.token(db.getOptions().getToken());
}
if (tableOptions.getDataAPIClientOptions() == null) {
this.options.dataAPIClientOptions(db.getOptions().getDataAPIClientOptions()).clone();
}
if (tableOptions.getKeyspace() != null) {
this.database.useKeyspace(tableOptions.getKeyspace());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,33 @@
*/

import com.datastax.astra.client.core.options.BaseOptions;
import com.datastax.astra.client.core.options.DataAPIClientOptions;
import com.datastax.astra.internal.serdes.tables.RowSerializer;
import lombok.Setter;
import lombok.experimental.Accessors;

import static com.datastax.astra.client.core.commands.CommandType.TABLE_ADMIN;

@Setter
@Accessors(fluent = true, chain = true)
public class ListTablesOptions extends BaseOptions<ListTablesOptions> {

/**
* The keyspace to use for the database.
*/
String keyspace = DataAPIClientOptions.DEFAULT_KEYSPACE;


public ListTablesOptions() {
super(null, TABLE_ADMIN, new RowSerializer(), null);
}

/**
* Gets keyspace
*
* @return value of keyspace
*/
public String getKeyspace() {
return keyspace;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.datastax.astra.internal.api.DataAPIResponse;
import com.datastax.astra.internal.http.RetryHttpClient;
import com.datastax.astra.internal.serdes.DataAPISerializer;
import com.datastax.astra.internal.utils.AnsiUtils;
import com.datastax.astra.internal.utils.Assert;
import com.datastax.astra.internal.utils.CompletableFutures;
import com.evanlennick.retry4j.Status;
Expand Down Expand Up @@ -175,6 +176,7 @@ public AbstractCommandRunner(String apiEndpoint, OPTIONS options) {
@Override
public DataAPIResponse runCommand(Command command, BaseOptions<?> overridingOptions) {

log.debug("Running command: " + AnsiUtils.green("{}"), command.getName());
// Initializing options with the Collection/Table/Database level options
DataAPIClientOptions options = this.options.getDataAPIClientOptions();

Expand Down Expand Up @@ -228,6 +230,9 @@ public DataAPIResponse runCommand(Command command, BaseOptions<?> overridingOpti
if (overridingOptions != null && overridingOptions.getToken() != null) {
token = overridingOptions.getToken();
}
if (token == null) {
throw new IllegalArgumentException("No token provided for the command");
}

// =======================
// === SERIALIZER ===
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.datastax.astra.internal.utils;

/**
* Utility class for internal usage
*/
public class Utils {

/**
* Hide contructors for utilities
*/
private Utils() {
}

public static boolean hasLength(String str) {
return (null != str && !"".equals(str));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.datastax.astra.client.database;

import com.datastax.astra.client.DataAPIClients;
import com.datastax.astra.client.databases.Database;
import com.datastax.astra.client.tables.Game;
import com.datastax.astra.client.tables.Table;
import com.datastax.astra.client.tables.TableOptions;
import com.datastax.astra.client.tables.commands.options.ListTablesOptions;
import com.datastax.astra.client.tables.definition.TableDefinition;
import com.datastax.astra.client.tables.definition.TableDescriptor;
import com.datastax.astra.client.tables.definition.rows.Row;

import java.time.Duration;
import java.util.List;
import java.util.Map;

public class ListTables {

public static void main(String[] args) {
// Database astraDb = new DataAPIClient(token).getDatabase(endpoint);
Database db =
DataAPIClients.localDbWithDefaultKeyspace();

// Default
List<TableDescriptor> tableList = db.listTables();

// Options
db.getDatabaseAdmin().createKeyspace("ks2");
ListTablesOptions options = new ListTablesOptions()
.keyspace("ks2")
.timeout(Duration.ofSeconds(5));
List<TableDescriptor> tableList2 = db.listTables(options);
Table<Row> ts = db.getTable("table_simple", new TableOptions().keyspace("ks2"));
// Expecting an error as table does not exist in ks2
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.datastax.astra.client.database;

import com.datastax.astra.client.DataAPIClients;
import com.datastax.astra.client.databases.Database;
import com.datastax.astra.client.tables.Table;
import com.datastax.astra.client.tables.TableOptions;
import com.datastax.astra.client.tables.commands.options.ListTablesOptions;
import com.datastax.astra.client.tables.definition.TableDescriptor;
import com.datastax.astra.client.tables.definition.rows.Row;

import java.time.Duration;
import java.util.List;

public class ListTablesNames {

public static void main(String[] args) {
// Database astraDb = new DataAPIClient(token).getDatabase(endpoint);
Database db =
DataAPIClients.localDbWithDefaultKeyspace();

// Default
List<String> tableNames = db.listTableNames();

// Options
db.getDatabaseAdmin().createKeyspace("ks2");
ListTablesOptions options = new ListTablesOptions()
.keyspace("ks2")
.timeout(Duration.ofSeconds(5));
List<String> tableList2 = db.listTableNames(options);

}
}
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