Skip to content

Commit 15d3899

Browse files
authored
Merge pull request #7 from datastax/1.x
Set Main as last version
2 parents 9514936 + a6a4cb8 commit 15d3899

File tree

8 files changed

+505
-4
lines changed

8 files changed

+505
-4
lines changed

astra-db-java/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<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">
33
<modelVersion>4.0.0</modelVersion>
4-
<groupId>com.datastax.astra</groupId>
54
<artifactId>astra-db-java</artifactId>
65
<name>Java Client Library for Data API</name>
76
<description>Implementation of a client to the Astra/Stargate Data API written in Java</description>

examples/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
<parent>
1111
<groupId>com.datastax.astra</groupId>
1212
<artifactId>astra-db-java-parent</artifactId>
13-
<version>1.4.3-SNAPSHOT</version>
13+
<version>1.4.6-SNAPSHOT</version>
1414
</parent>
1515

1616
<dependencies>
1717
<dependency>
1818
<groupId>com.datastax.astra</groupId>
1919
<artifactId>astra-db-java</artifactId>
20+
<version>${project.version}</version>
2021
</dependency>
2122
<dependency>
2223
<groupId>ch.qos.logback</groupId>

langchain4j-astradb/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<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">
33
<modelVersion>4.0.0</modelVersion>
4-
<groupId>com.datastax.astra</groupId>
54
<artifactId>langchain4j-astradb</artifactId>
65
<name>LangChain4j :: Integration :: AstraDB</name>
76
<description>Some dependencies have a "Public Domain" license</description>

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
<modules>
1414
<module>astra-db-java</module>
1515
<module>langchain4j-astradb</module>
16+
<module>examples</module>
17+
<module>tools</module>
1618
</modules>
1719

1820
<properties>
@@ -342,6 +344,10 @@
342344
<profiles>
343345
<profile>
344346
<id>release</id>
347+
<modules>
348+
<module>astra-db-java</module>
349+
<module>langchain4j-astradb</module>
350+
</modules>
345351
<build>
346352
<plugins>
347353
<plugin>

tools/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
<parent>
1111
<groupId>com.datastax.astra</groupId>
1212
<artifactId>astra-db-java-parent</artifactId>
13-
<version>1.4.3-SNAPSHOT</version>
13+
<version>1.4.6-SNAPSHOT</version>
1414
</parent>
1515

1616
<dependencies>
1717
<dependency>
1818
<groupId>com.datastax.astra</groupId>
1919
<artifactId>astra-db-java</artifactId>
20+
<version>${project.version}</version>
2021
</dependency>
2122
<dependency>
2223
<groupId>ch.qos.logback</groupId>

tools/src/main/java/com/datastax/astra/tool/loader/csv/CsvLoader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public static void load(String fileName, CsvLoaderSettings settings, Collection<
7171
batch.add(processor.map(rowMap));
7272
if (batch.size() == settings.batchSize) {
7373
final List<Document> batchToInsert = new ArrayList<>(batch);
74+
log.info("Enqueuing {} rows from {}... ", collection, batch.size());
7475
executor.submit(() -> collection.insertMany(batchToInsert));
7576
batch.clear(); // Clear the batch for the next set of rows
7677
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.datastax.astra.samples;
2+
3+
import com.datastax.astra.client.Collection;
4+
import com.datastax.astra.client.DataAPIClient;
5+
import com.datastax.astra.client.Database;
6+
import com.datastax.astra.client.model.Document;
7+
import com.datastax.astra.tool.loader.csv.CsvLoader;
8+
import com.datastax.astra.tool.loader.csv.CsvRowMapper;
9+
import lombok.extern.slf4j.Slf4j;
10+
11+
/**
12+
* Load a CSV to Astra
13+
*/
14+
@Slf4j
15+
public class CsvPhilosophers {
16+
17+
private static final String ASTRA_TOKEN = System.getenv("ASTRA_DB_APPLICATION_TOKEN");
18+
private static final String API_ENDPOINT = "https://ba006059-a932-405c-857d-50921694078a-us-east1.apps.astra.datastax.com";
19+
20+
public static void main(String[] args) throws Exception {
21+
// Get an empty Collection
22+
DataAPIClient client = new DataAPIClient(ASTRA_TOKEN);
23+
Database db = client.getDatabase(API_ENDPOINT);
24+
Collection<Document> collection = db.getCollection("openai_clun");
25+
26+
collection.deleteAll();
27+
28+
// Zou !
29+
String csvFilename = "/Users/cedricklunven/dev/datastax/JAVA/astra-db-java/tools/src/test/resources/philosopher-quotes.csv";
30+
CsvLoader.load(csvFilename, collection, new CsvRowMapper() {
31+
@Override
32+
public Document map(Document csvRow) {
33+
// Tags should be an Array
34+
csvRow.vectorize(csvRow.getString("quote"));
35+
csvRow.append("tags",csvRow.getString("tags").split(";"));
36+
return csvRow;
37+
}
38+
});
39+
Thread.sleep(10000);
40+
41+
}
42+
43+
}

0 commit comments

Comments
 (0)