Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/maven/org.apache.maven.plugins-…
Browse files Browse the repository at this point in the history
…maven-source-plugin-3.3.1
  • Loading branch information
gkorland authored Oct 14, 2024
2 parents 1b9fb41 + b431610 commit 8c0f01f
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 42 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
# Label used to access the service container
falkordb:
# Docker Hub image
image: falkordb/falkordb:latest
image: falkordb/falkordb:edge
# Map port 6379 on the Docker host to port 6379 on the FalkorDB container
ports:
- 6379:6379
Expand All @@ -45,12 +45,12 @@ jobs:
run: mvn -B package --file pom.xml

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.5.0
uses: codecov/codecov-action@v4.6.0
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

# Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Maven Dependency Tree Dependency Submission
if: github.token.permissions.contents == 'write'
uses: advanced-security/[email protected].0
uses: advanced-security/[email protected].1

3 changes: 3 additions & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=17.0.12-graal
50 changes: 19 additions & 31 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<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">
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">

<parent>
<groupId>org.sonatype.oss</groupId>
Expand All @@ -12,7 +11,7 @@
<packaging>jar</packaging>
<groupId>com.falkordb</groupId>
<artifactId>jfalkordb</artifactId>
<version>0.3.1-SNAPSHOT</version>
<version>0.4.0-SNAPSHOT</version>

<name>JFalkorDB</name>
<description>Official client for falkordb</description>
Expand Down Expand Up @@ -50,9 +49,9 @@
<version>3.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.11.0</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.12.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand All @@ -66,36 +65,25 @@
<version>2.0.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.11.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>3.16.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencies>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.test.source>8</maven.test.source>
<maven.test.target>8</maven.test.target>
</properties>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
Expand All @@ -118,14 +106,14 @@
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.6.0</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
<waitUntil>published</waitUntil>
</configuration>
</plugin>
</plugins>
Expand All @@ -152,7 +140,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<version>3.6.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down
21 changes: 19 additions & 2 deletions src/main/java/com/falkordb/impl/resultset/ResultSetImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import redis.clients.jedis.exceptions.JedisDataException;

import java.util.*;
import java.util.stream.Collectors;

public class ResultSetImpl implements ResultSet {

Expand All @@ -25,7 +26,7 @@ public class ResultSetImpl implements ResultSet {
/**
* @param rawResponse the raw representation of response is at most 3 lists of
* objects. The last list is the statistics list.
* @param graph the graph connection
* @param graph the graph connection
* @param cache the graph local cache
*/
@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -157,7 +158,7 @@ private Node deserializeNode(List<Object> rawNodeData) {

/**
* @param graphEntity graph entity
* @param id entity id to be set to the graph entity
* @param id entity id to be set to the graph entity
*/
private void deserializeGraphEntityId(GraphEntity graphEntity, long id) {
graphEntity.setId(id);
Expand Down Expand Up @@ -246,6 +247,8 @@ private Object deserializeScalar(List<Object> rawScalarData) {
return deserializeMap(obj);
case VALUE_POINT:
return deserializePoint(obj);
case VALUE_VECTORF32:
return deserializeVector(obj);
case VALUE_UNKNOWN:
default:
return obj;
Expand All @@ -256,6 +259,20 @@ private Object deserializePoint(Object rawScalarData) {
return new Point(BuilderFactory.DOUBLE_LIST.build(rawScalarData));
}

private List<Float> deserializeVector(Object rawScalarData) {
List<byte[]> array = (List<byte[]>) rawScalarData;
return array.stream()
.map(val -> {
try {
return Float.parseFloat(SafeEncoder.encode(val));
} catch (NumberFormatException e) {
// Handle the exception appropriately
throw new GraphException("Invalid float value in vector data", e);
}
})
.collect(Collectors.toList());
}

@SuppressWarnings("unchecked")
private Map<String, Object> deserializeMap(Object rawScalarData) {
List<Object> keyTypeValueEntries = (List<Object>) rawScalarData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ enum ResultSetScalarTypes {
VALUE_NODE,
VALUE_PATH,
VALUE_MAP,
VALUE_POINT;
VALUE_POINT,
VALUE_VECTORF32;

private static final ResultSetScalarTypes[] values = values();

Expand Down
35 changes: 30 additions & 5 deletions src/test/java/com/falkordb/GraphAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public void testRecord() {
+ "doubleValue=Property{name='doubleValue', value=3.14}, "
+ "age=Property{name='age', value=32}}}",
expectedNode.toString());
Assert.assertEquals( 4, expectedNode.getNumberOfProperties());
Assert.assertEquals(4, expectedNode.getNumberOfProperties());

Edge expectedEdge = new Edge();
expectedEdge.setId(0);
Expand All @@ -238,7 +238,7 @@ public void testRecord() {
+ "place=Property{name='place', value=TLV}, "
+ "doubleValue=Property{name='doubleValue', value=3.14}, "
+ "since=Property{name='since', value=2000}}}", expectedEdge.toString());
Assert.assertEquals( 4, expectedEdge.getNumberOfProperties());
Assert.assertEquals(4, expectedEdge.getNumberOfProperties());

Map<String, Object> params = new HashMap<>();
params.put("name", name);
Expand Down Expand Up @@ -798,6 +798,31 @@ public void test64bitnumber() {
Assert.assertEquals(Long.valueOf(value), r.getValue(0));
}

@Test
public void testVecf32() {
ResultSet resultSet = client.query("RETURN vecf32([2.1, -0.82, 1.3, 4.5]) AS vector");
Assert.assertEquals(1, resultSet.size());
Record r = resultSet.iterator().next();
List<Object> vector = r.getValue(0);
Assert.assertEquals(4, vector.size());
Object res = vector.get(0);

// The result can be either Double or Float depending on the server version
if ( res instanceof Double) {
List<Double> v = r.getValue(0);
Assert.assertEquals(2.1, v.get(0), 0.01);
Assert.assertEquals(-0.82, v.get(1), 0.01);
Assert.assertEquals(1.3, v.get(2), 0.01);
Assert.assertEquals(4.5, v.get(3), 0.01);
} else {
List<Float> v = r.getValue(0);
Assert.assertEquals(2.1f, v.get(0), 0.01);
Assert.assertEquals(-0.82f, v.get(1), 0.01);
Assert.assertEquals(1.3f, v.get(2), 0.01);
Assert.assertEquals(4.5f, v.get(3), 0.01);
}
}

@Test
public void testCachedExecution() {
client.query("CREATE (:N {val:1}), (:N {val:2})");
Expand Down Expand Up @@ -873,7 +898,7 @@ private void assertTestGeoPoint() {
Assert.assertEquals(Collections.singletonList("restaurant"), record.keys());
Node node = record.getValue(0);
Property<?> property = node.getProperty("location");
Point result = (Point)property.getValue();
Point result = (Point) property.getValue();

Point point = new Point(30.27822306, -97.75134723);
Assert.assertEquals(point, result);
Expand Down Expand Up @@ -929,8 +954,8 @@ public void testSimpleReadOnlyWithTimeOut() {
client.query("CREATE (:person{name:'filipe',age:30})");
try {
client.readOnlyQuery(
"WITH 1000000 as n RETURN reduce(f = 1, x IN range(1, n) | f * x) AS result",
1L);
"WITH 1000000 as n RETURN reduce(f = 1, x IN range(1, n) | f * x) AS result",
1L);

fail("Expected Timeout Exception was not thrown.");
} catch (GraphException e) {
Expand Down

0 comments on commit 8c0f01f

Please sign in to comment.