You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by va...@apache.org on 2024/06/19 18:47:38 UTC

(tinkerpop) branch valentyn/bytecode-removal-server updated: ...

This is an automated email from the ASF dual-hosted git repository.

valentyn pushed a commit to branch valentyn/bytecode-removal-server
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/valentyn/bytecode-removal-server by this push:
     new 11e94b2851 ...
11e94b2851 is described below

commit 11e94b2851de4c4b7e4bd373cce29896bbeeb8d8
Author: Valentyn Kahamlyk <Va...@improving.com>
AuthorDate: Wed Jun 19 11:47:29 2024 -0700

    ...
---
 .../gremlin/process/traversal/GremlinLang.java          | 17 +++++++++++++----
 .../gremlin/process/traversal/GremlinLangTest.java      |  2 ++
 .../tinkerpop/gremlin/driver/remote/RemoteWorld.java    |  7 +++++++
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/GremlinLang.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/GremlinLang.java
index c07029e934..4d9e4234d7 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/GremlinLang.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/GremlinLang.java
@@ -107,6 +107,9 @@ public class GremlinLang implements Cloneable, Serializable {
             return arg.toString();
         if (arg instanceof Long)
             return String.format("%sL", arg);
+        // todo: BigInteger and BigDecimal format is different in gremlin-lang and gremlin-groovy
+//        if (arg instanceof BigInteger)
+//            return String.format("%sN", arg);
         if (arg instanceof Float) {
             if (NumberHelper.isNaN(arg))
                 return "NaN";
@@ -126,6 +129,8 @@ public class GremlinLang implements Cloneable, Serializable {
                 return "-Infinity";
             return String.format("%sD", arg);
         }
+//        if (arg instanceof BigDecimal)
+//            return String.format("%sM", arg);
 
         if (arg instanceof Date)
             return String.format("datetime(\"%s\")", format(((Date) arg).toInstant()));
@@ -255,10 +260,14 @@ public class GremlinLang implements Cloneable, Serializable {
         final StringBuilder sb = new StringBuilder("[");
         int size = map.size();
 
-        for (Map.Entry<?, ?> entry : map.entrySet()) {
-            sb.append(argAsString(entry.getKey())).append(":").append(argAsString(entry.getValue()));
-            if (--size > 0) {
-                sb.append(',');
+        if (size == 0) {
+            sb.append(":");
+        } else {
+            for (Map.Entry<?, ?> entry : map.entrySet()) {
+                sb.append(argAsString(entry.getKey())).append(":").append(argAsString(entry.getValue()));
+                if (--size > 0) {
+                    sb.append(',');
+                }
             }
         }
 
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/GremlinLangTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/GremlinLangTest.java
index 08a6baef47..f532c3a691 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/GremlinLangTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/GremlinLangTest.java
@@ -37,6 +37,7 @@ import org.junit.runners.Parameterized;
 
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 
 import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal;
@@ -83,6 +84,7 @@ public class GremlinLangTest {
                         "g.inject(datetime(\"2018-03-21T08:35:44.741Z\"))"},
                 {g.inject(asMap("age", VertexProperty.Cardinality.list(33))),
                         "g.inject([\"age\":Cardinality.list(33)])"},
+                {g.inject(new HashMap<>()), "g.inject([:])"},
                 {g.V(1).out("knows").values("name"), "g.V(1).out(\"knows\").values(\"name\")"},
                 {g.V().has(T.label, "person"), "g.V().has(T.label,\"person\")"},
                 {g.addE("knows").from(new DetachedVertex(1, "test1", Collections.emptyList())).to(new DetachedVertex(6, "test2", Collections.emptyList())),
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteWorld.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteWorld.java
index 48e5b8d5c5..acd9e2a2dd 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteWorld.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteWorld.java
@@ -173,5 +173,12 @@ public abstract class RemoteWorld implements World {
 
     public static class GraphBinaryRemoteComputerWorld extends RemoteComputerWorld {
         public GraphBinaryRemoteComputerWorld() { super(createTestCluster(SerializersV4.GRAPHBINARY_V4)); }
+
+        // gremlin lang can't handle VertexProgramStrategy
+//        @Override
+//        public GraphTraversalSource getGraphTraversalSource(final LoadGraphWith.GraphData graphData) {
+//            final GraphTraversalSource g = super.getGraphTraversalSource(graphData);
+//            return g.with("language", "gremlin-lang");
+//        }
     }
 }