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 examples
  • Loading branch information
clun committed Dec 4, 2024
commit 98e9de352cbcbe7cd94ea9c7bd077d765a321ad6
Original file line number Diff line number Diff line change
Expand Up @@ -1008,26 +1008,17 @@ public Row mapAsRow(T input) {
if (input == null || input instanceof Row) {
return (Row) input;
}
EntityTable annTable = input.getClass().getAnnotation(EntityTable.class);
// Custom Serialization with annotations
if (annTable != null) {
if (Utils.hasLength(annTable.value()) && !annTable.value().equals(tableName)) {
throw new IllegalArgumentException("Table name mismatch, expected '" + tableName + "' but got '" + annTable.value() + "'");
EntityBeanDefinition<?> bean = new EntityBeanDefinition<>(input.getClass());
Row row = new Row();
bean.getFields().forEach((name, field) -> {
try {
row.put(field.getColumnName() != null ? field.getColumnName() : name,
field.getGetter().invoke(input));
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
EntityBeanDefinition<?> bean = new EntityBeanDefinition<>(input.getClass());
Row row = new Row();
bean.getFields().forEach((name, field) -> {
try {
row.put(field.getColumnName(), field.getGetter().invoke(input));
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
});
return row;
} else {
// Defaults mapping as a Row
return getSerializer().convertValue(input, Row.class);
}
});
return row;
}

// ------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,94 +139,122 @@ public Row add(final String key, final Object value) {
columnMap.put(key, value);
return this;
}

public Row addText(final String key, final String value) {
return add(key, value);
}

public Row addAscii(final String key, final String value) {
return addText(key, value);
}

public Row addVectorize(final String key, final String value) {
return add(key, value);
}

// Integers

public Row addVarInt(final String key, final BigInteger value) {
return add(key, value);
}

public Row addBigInt(final String key, final Long value) {
return add(key, value);
}

public Row addInt(final String key, final Integer value) {
return add(key, value);
}

public Row addSmallInt(final String key, final Short value) {
return add(key, value);
}

public Row addTinyInt(final String key, final Byte value) {
return add(key, value);
}

public Row addBoolean(final String key, final Boolean value) {
return add(key, value);
}

public Row addBlob(final String key, final byte[] value) {
return add(key, value);
}

public Row addFloat(final String key, final Float value) {
return add(key, value);
}

public Row addDecimal(String pDecimal, BigDecimal big) {
return add(pDecimal, big);
}

public Row addDouble(final String key, final Double value) {
return add(key, value);
}

public Row addDate(final String key, final Date value) {
return add(key, value);
}

public Row addDate(final String key, final LocalDate localDate) {
if (localDate == null) {
return add(key, null);
}
return addDate(key, Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
}

public Row addInet(final String key, final InetAddress value) {
return add(key, value);
}

public Row addDuration(final String key, final Duration value) {
return add(key, TableDuration.of(Period.ZERO, value));
}

public Row addDuration(final String key, final Period period, final Duration duration) {
return add(key, TableDuration.of(period, duration));
}

public Row addDuration(final String key, final Period period) {
return add(key, TableDuration.of(period, Duration.ZERO));
}

public Row addTableDuration(final String key, final TableDuration value) {
return add(key, value);
}

public Row addUUID(final String key, final UUID value) {
return add(key, value);
}

public Row addTimeStamp(String key, Instant instant) {
return add(key, instant);
}

public Row addTime(String key, LocalTime ltime) {
return add(key, ltime);
}

public Row addVector(String key, DataAPIVector vector) {
return add(key, vector);
}

public Row addVector(String key, float[] vector) {
return add(key, new DataAPIVector(vector));
}

public <T> Row addList(String key, List<T> list) {
return add(key, list);
}

public <T> Row addSet(String key, Set<T> set) {
return add(key, set);
}

public <K,V> Row addMap(String key, Map<K, V> myMap) {
return add(key, myMap);
}

/**
* Gets the value of the given key, casting it to the given {@code Class<T>}. This is useful to avoid having casts in client code,
* though the effect is the same. So to get the value of a key that is of type String, you would write {@code String name =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ public EntityBeanDefinition(Class<T> clazz) {

// Table Name
EntityTable tableAnn = clazz.getAnnotation(EntityTable.class);
if (tableAnn == null) {
throw new IllegalArgumentException("Invalid class: It should be annotated with @Table(name=\"table_name\")");
if (tableAnn != null) {
this.name = tableAnn.value();
} else {
this.name = clazz.getSimpleName().toLowerCase();
}
this.name = tableAnn.value();

// Find properties
List<BeanPropertyDefinition> properties = OBJECT_MAPPER
Expand Down Expand Up @@ -145,8 +146,6 @@ public EntityBeanDefinition(Class<T> clazz) {
}
field.setDimension(column.dimension());
field.setMetric(column.metric());
} else {
log.warn("Field {} is not annotated with @Column", field.getName());
}

PartitionBy partitionBy = annfield.getAnnotated().getAnnotation(PartitionBy.class);
Expand Down
70 changes: 68 additions & 2 deletions examples/src/main/java/com/datastax/astra/client/tables/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

import com.datastax.astra.client.core.vector.DataAPIVector;
import com.datastax.astra.client.tables.mapping.Column;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.time.Instant;
import java.util.Set;
import java.util.UUID;

@Data
@Setter
@Accessors(fluent = true, chain = true)
@NoArgsConstructor

public class Game {

@Column(name ="match_id")
Expand All @@ -28,4 +32,66 @@ public class Game {
@Column(name ="m_vector")
private DataAPIVector vector;

/**
* Gets matchId
*
* @return value of matchId
*/
public String getMatchId() {
return matchId;
}

/**
* Gets round
*
* @return value of round
*/
public Integer getRound() {
return round;
}

/**
* Gets score
*
* @return value of score
*/
public Integer getScore() {
return score;
}

/**
* Gets when
*
* @return value of when
*/
public Instant getWhen() {
return when;
}

/**
* Gets winner
*
* @return value of winner
*/
public String getWinner() {
return winner;
}

/**
* Gets fighters
*
* @return value of fighters
*/
public Set<UUID> getFighters() {
return fighters;
}

/**
* Gets vector
*
* @return value of vector
*/
public DataAPIVector getVector() {
return vector;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.datastax.astra.client.tables;

import com.datastax.astra.client.DataAPIClients;
import com.datastax.astra.client.core.vector.DataAPIVector;
import com.datastax.astra.client.databases.Database;
import com.datastax.astra.client.tables.definition.TableDefinition;
import com.datastax.astra.client.tables.definition.columns.ColumnTypes;
import com.datastax.astra.client.tables.definition.rows.Row;
import com.datastax.astra.internal.serdes.tables.RowSerializer;

import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

public class WorkingWithRows {

public static void main(String[] args) {
insertFullRow();
}

public static void workingWithList() {
Database db = DataAPIClients.localDbWithDefaultKeyspace();
TableDefinition def = new TableDefinition()
.addColumnSet("set_column", ColumnTypes.INT);
Table<Row> table = db.createTable("TABLE_NAME", def);
table.insertOne(new Row().addSet("set_column", Set.of(9,8,7)));
}

public static void workingWithSet() {
Database db = DataAPIClients.localDbWithDefaultKeyspace();
TableDefinition def = new TableDefinition()
.addColumnList("list_column", ColumnTypes.TEXT);
Table<Row> table = db.createTable("TABLE_NAME", def);
table.insertOne(new Row().addList("list_column", List.of("Hello", "World")));
}

public static void workingWithMap() {
Database db = DataAPIClients.localDbWithDefaultKeyspace();
TableDefinition def = new TableDefinition()
.addColumnMap("map_column", ColumnTypes.TEXT, ColumnTypes.INT);
Table<Row> table = db.createTable("TABLE_NAME", def);
table.insertOne(new Row().addMap("map_column", Map.of("key1", 1)));
}

public static void insertFullRow() {
Database db = DataAPIClients.localDbWithDefaultKeyspace();
Table<Row> table = db.getTable("games");
// table.insertOne(new Row()
// .addText("match_id", "mtch_0")
// .addInt("round", 1)
// .addVector("m_vector", new DataAPIVector(new float[]{0.4f, -0.6f, 0.2f}))
// .addInt("score", 18)
// .addTimeStamp("when", Instant.now())
// .addText("winner", "Victor")
// .addSet("fighters", Set.of(UUID.fromString("0193539a-2770-8c09-a32a-111111111111"))));

// Leveraging object mapping
Table<Game> table2 = db.getTable("games", Game.class);

Game match1 = new Game()
.matchId("mtch_1")
.round(2)
.score(20)
.when(Instant.now())
.winner("Victor")
.fighters(Set.of(UUID.fromString("0193539a-2770-8c09-a32a-111111111111")))
.vector(new DataAPIVector(new float[]{0.4f, -0.6f, 0.2f}));
Row row = new RowSerializer().convertValue(match1, Row.class);
System.out.println(row.get("vector"));
System.out.println(((Map<String, Object>) row.get("vector")).get("$binary").getClass());
System.out.println();
//table2.insertOne(match1);
}

}
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