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 find and Rerank, start reworking the tests
  • Loading branch information
clun committed Mar 27, 2025
commit e2f26686316feddbeefcc747a9a186a42f52c0cc
52 changes: 52 additions & 0 deletions TEST.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

## Run against Local HCD Instance
(_to run locally your must have the data api running locally on op of HCD or DSE_)

```bash
mvn clean test -Ptest_local
```

> **Why it works ?**
>
> - In `pom.xml` the environment variable `ASTRA_DB_JAVA_TEST_ENV` is set to `local`
> - Tests are annotated with
>
> ```java
> @EnabledIfSystemProperty(named = "ASTRA_DB_JAVA_TEST_ENV", matches = "local")
> @DisabledIfSystemProperty(named = "ASTRA_DB_JAVA_TEST_ENV", matches = "(?!local)")
> public class MyTest {
> }
> ```

- To run with IDE make sure to set the environment variable `ASTRA_DB_JAVA_TEST_ENV` to `local` in your Run configuration


## Run against Astra DEV

- `ASTRA_DB_APPLICATION_TOKEN_DEV` should be defined in your environment variables, it is not in the different POM for privacy reasons.

- To run with Maven (AWS,`eu-west-2`)

```bash
mvn clean test -Ptest_astra_dev
```

- To run with Maven on One particular region

```java
mvn clean test -Ptest_astra_dev \
-DASTRA_CLOUD_PROVIDER_DEV=GCP \
-DASTRA_CLOUD_REGION_DEV=us-central-1
```

- To run overriding also the token

```java
mvn clean test \
-Ptest_astra_dev \
-DASTRA_CLOUD_PROVIDER_DEV=GCP \
-DASTRA_CLOUD_REGION_DEV=us-central-1 \
-ASTRA_DB_APPLICATION_TOKEN_DEV=AstraCS:... \
-Dtest="com.datastax.astra.test.integration.*.*Test"
```

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static void main(String[] args) throws Exception {
CsvLoader.load(csvFilename, collection, new CsvRowMapper() {
@Override
public Document map(Document csvRow) {

// Tags should be an Array
csvRow.vectorize(csvRow.getString("quote"));
csvRow.append("tags",csvRow.getString("tags").split(";"));
Expand Down
9 changes: 9 additions & 0 deletions astra-db-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>

<!-- Embedding model in memory for testing -->
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-embeddings-all-minilm-l6-v2</artifactId>
<version>1.0.0-beta2</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.datastax.astra.client.core.options.DataAPIClientOptions;
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.internal.api.AstraApiEndpoint;
import com.datastax.astra.internal.command.AbstractCommandRunner;
import com.datastax.astra.internal.utils.Assert;
Expand Down Expand Up @@ -192,6 +193,14 @@ public FindEmbeddingProvidersResult findEmbeddingProviders() {
return new FindEmbeddingProvidersResult(admin.findEmbeddingProviders().getEmbeddingProviders());
}

/** {@inheritDoc} */
@Override
public FindRerankingProvidersResult findRerankingProviders() {
log.debug("findRerankingProviders");
DataAPIDatabaseAdmin admin = new DataAPIDatabaseAdmin(db, this.options);
return new FindRerankingProvidersResult(admin.findRerankingProviders().getRerankingProviders());
}

/** {@inheritDoc} */
@Override
public void createKeyspace(String keyspace, boolean updateDBKeyspace) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
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.results.FindRerankingProvidersResult;
import com.datastax.astra.client.databases.definition.keyspaces.KeyspaceOptions;
import com.datastax.astra.internal.api.DataAPIResponse;
import com.datastax.astra.internal.command.AbstractCommandRunner;
Expand Down Expand Up @@ -109,6 +111,14 @@ public FindEmbeddingProvidersResult findEmbeddingProviders() {
EmbeddingProvider.class));
}

@Override
public FindRerankingProvidersResult findRerankingProviders() {
DataAPIResponse res = runCommand(Command.create("findRerankingProviders"));
return new FindRerankingProvidersResult(
res.getStatusKeyAsMap("rerankingProviders",
RerankProvider.class));
}

/** {@inheritDoc} */
@Override
public Database getDatabase() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
*/

import com.datastax.astra.client.core.options.BaseOptions;
import com.datastax.astra.client.core.rerank.RerankProvider;
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.results.FindEmbeddingProvidersResult;
import com.datastax.astra.client.databases.commands.results.FindRerankingProvidersResult;
import com.datastax.astra.internal.utils.Assert;

import java.util.Set;
Expand Down Expand Up @@ -81,6 +83,24 @@ public interface DatabaseAdmin {
*/
FindEmbeddingProvidersResult findEmbeddingProviders();

/**
* Retrieve the list of reranking providers available in the current database. Reranking providers are services
* that sort a list of record based on a algorithm (eg bm25) . This method returns a map of provider names to
* {@link RerankProvider} instances, allowing applications
* to access and utilize the reranking services.
*
* <p>Example usage:</p>
* <pre>
* {@code
* // Assuming 'client' is an instance of DataApiClient
* Map<String, EmbeddingProvider> providers = client.findEmbeddingProvidersAsMap());
* }
* </pre>
* @return
* list of available providers
*/
FindRerankingProvidersResult findRerankingProviders();

/**
* Asynchronously retrieves a stream of keyspaces names available in the current database. This method facilitates
* non-blocking operations by allowing the application to continue executing other tasks while the list of keyspace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Filters;
import com.datastax.astra.client.core.query.Projection;
import com.datastax.astra.client.core.reranking.RerankResult;
import com.datastax.astra.client.core.rerank.RerankResult;
import com.datastax.astra.client.core.vector.DataAPIVector;
import com.datastax.astra.client.databases.Database;
import com.datastax.astra.client.exceptions.DataAPIException;
Expand All @@ -73,6 +73,7 @@
import com.datastax.astra.internal.serdes.collections.DocumentSerializer;
import com.datastax.astra.internal.serdes.tables.RowMapper;
import com.datastax.astra.internal.utils.Assert;
import com.datastax.astra.internal.utils.BetaPreview;
import com.datastax.astra.internal.utils.EscapeUtils;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -1082,31 +1083,32 @@ public Page<T> findPage(Filter filter, CollectionFindOptions options) {
* @return
* the find iterable interface
*/
@BetaPreview
public CollectionFindAndRerankCursor<T,T> findAndRerank(Filter filter, CollectionFindAndRerankOptions options) {
return findAndRerank(filter, options, getDocumentClass());
}

@BetaPreview
public <R> CollectionFindAndRerankCursor<T, R> findAndRerank(Filter filter, CollectionFindAndRerankOptions options, Class<R> newRowType) {
return new CollectionFindAndRerankCursor<>(this, filter, options, newRowType);
}

@BetaPreview
public <R> Page<RerankResult<R>> findAndRerankPage(Filter filter, CollectionFindAndRerankOptions options, Class<R> newRowType) {
Command findAndRerankCommand = Command
.create("findAndRerank")
.withFilter(filter);
if (options != null) {
findAndRerankCommand
.withSort(options.getSortArray())
.withProjection(options.getProjectionArray())
.withOptions(new Document()
.appendIfNotNull("rerankOn", options.rerankOn())
.appendIfNotNull("limit", options.limit())
.appendIfNotNull("hybridProjection", options.hybridProjection().getValue())
.appendIfNotNull("hybridLimits", options.hybridLimits())
.appendIfNotNull(INPUT_INCLUDE_SORT_VECTOR, options.includeSortVector())
.appendIfNotNull(INPUT_INCLUDE_SIMILARITY, options.includeSimilarity())
)
;
.withSort(options.getSortArray())
.withProjection(options.getProjectionArray())
.withOptions(new Document()
.appendIfNotNull("rerankOn", options.rerankOn())
.appendIfNotNull("limit", options.limit())
.appendIfNotNull("hybridLimits", options.hybridLimits())
.appendIfNotNull(INPUT_INCLUDE_SORT_VECTOR, options.includeSortVector())
.appendIfNotNull(INPUT_INCLUDE_SCORES, options.includeScores())
.appendIfNotNull(INPUT_INCLUDE_SIMILARITY, options.includeSimilarity()));
}

// Responses MOCK for now
Expand Down Expand Up @@ -1139,10 +1141,6 @@ public <R> Page<RerankResult<R>> findAndRerankPage(Filter filter, CollectionFind
DocumentSerializer serializer = new DocumentSerializer();
R results1 = serializer.convertValue(document, newRowType);

// MAP WITH ROW FUNCTION
Row row = RowMapper.mapAsRow(document);
R result = RowMapper.mapFromRow(row, getSerializer(), newRowType);

// Getting associated document response
Document documentResponse = documentResponses.get(i);
Map<String, Double> scores = documentResponse.getMap("scores", String.class, Double.class);
Expand Down Expand Up @@ -1199,12 +1197,7 @@ public <R> Page<R> findPage(Filter filter, CollectionFindOptions options, Class<
return new Page<>(
apiResponse.getData().getNextPageState(),
apiResponse.getData().getDocuments().stream()
.map(d -> {
Row row = RowMapper.mapAsRow(d);
return mapFromRow(row, getSerializer(), newRowType);
})
// .map(d -> d.map(newRowType))
//.map(d -> RowMapper.mapFromRow(d, getSerializer(), newRowType))
.map(d -> d.map(newRowType))
.collect(Collectors.toList()), sortVector);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Projection;
import com.datastax.astra.client.core.query.Sort;
import com.datastax.astra.client.core.reranking.RerankResult;
import com.datastax.astra.client.core.rerank.RerankResult;
import com.datastax.astra.internal.command.AbstractCursor;
import lombok.Getter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.datastax.astra.client.collections.Collection;
import com.datastax.astra.client.collections.commands.options.CollectionFindOptions;
import com.datastax.astra.client.collections.definition.documents.Document;
import com.datastax.astra.client.core.paging.CursorState;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Projection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.datastax.astra.client.core.commands.CommandType;
import com.datastax.astra.client.core.hybrid.Hybrid;
import com.datastax.astra.client.core.hybrid.HybridLimits;
import com.datastax.astra.client.core.hybrid.HybridProjection;
import com.datastax.astra.client.core.options.BaseOptions;
import com.datastax.astra.client.core.query.Projection;
import com.datastax.astra.client.core.query.Sort;
Expand Down Expand Up @@ -70,7 +69,7 @@ public class CollectionFindAndRerankOptions extends BaseOptions<CollectionFindAn
/**
* Options for hybrid projection
*/
HybridProjection hybridProjection;
Boolean includeScores;

/**
* Flag to include sortVector in the result when operating a semantic search.
Expand Down Expand Up @@ -187,15 +186,5 @@ public CollectionFindAndRerankOptions rerankOn(String rerankOn) {
return this;
}

/**
* Add a hybridProjection clause in the find block
*
* @param hybridProjection value for hybridProjection options
* @return current command
*/
public CollectionFindAndRerankOptions hybridProjection(HybridProjection hybridProjection) {
this.hybridProjection = hybridProjection;
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import com.datastax.astra.client.core.lexical.Analyzer;
import com.datastax.astra.client.core.lexical.AnalyzerTypes;
import com.datastax.astra.client.core.lexical.LexicalOptions;
import com.datastax.astra.client.core.reranking.RerankingOptions;
import com.datastax.astra.client.core.reranking.RerankingServiceOptions;
import com.datastax.astra.client.core.rerank.CollectionRerankOptions;
import com.datastax.astra.client.core.rerank.RerankServiceOptions;
import com.datastax.astra.client.core.vector.SimilarityMetric;
import com.datastax.astra.client.core.vector.VectorOptions;
import com.datastax.astra.client.core.vectorize.VectorServiceOptions;
Expand Down Expand Up @@ -346,6 +346,13 @@ public LexicalOptions getLexical() {
return lexical;
}

public CollectionDefinition disableLexical() {
if (getLexical() == null) {
lexical(new LexicalOptions().enabled(false));
}
return this;
}

/**
* Builder pattern.
*
Expand Down Expand Up @@ -393,27 +400,27 @@ public CollectionDefinition lexical(AnalyzerTypes analyzerType) {
/**
* Reranking options
*/
private RerankingOptions reranking;
private CollectionRerankOptions rerank;

/**
* Gets reranking
*
* @return value of reranking
*/
public RerankingOptions getReranking() {
return reranking;
public CollectionRerankOptions getRerank() {
return rerank;
}

/**
* Builder pattern.
*
* @param rerankingOptions
* @param collectionRerankOptions
* reranking service information
* @return
* self reference
*/
public CollectionDefinition reranking(RerankingOptions rerankingOptions) {
reranking = rerankingOptions;
public CollectionDefinition rerank(CollectionRerankOptions collectionRerankOptions) {
rerank = collectionRerankOptions;
return this;
}

Expand All @@ -424,13 +431,20 @@ public CollectionDefinition reranking(RerankingOptions rerankingOptions) {
* reranker
* @return self reference
*/
public CollectionDefinition reranking(String reranker) {
if (getReranking() == null) {
reranking = new RerankingOptions().enabled(true);
public CollectionDefinition rerank(String reranker) {
if (getRerank() == null) {
rerank = new CollectionRerankOptions().enabled(true);
}
getReranking()
getRerank()
.enabled(true)
.service(new RerankingServiceOptions().provider(reranker));
.service(new RerankServiceOptions().provider(reranker));
return this;
}

public CollectionDefinition disableRerank() {
if (getRerank() == null) {
rerank = new CollectionRerankOptions().enabled(false);
}
return this;
}

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