You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2019/08/15 19:28:48 UTC

[tinkerpop] branch TINKERPOP-2279 updated (317ad54 -> c326d6c)

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

spmallette pushed a change to branch TINKERPOP-2279
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git.


    from 317ad54  Cleaned up enum derser for python graphbinary a bit further
     new 9e37ecc  Fixed up BulkSet python graphbinary serialization
     new c326d6c  All GLV tests passing for GraphBinary

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../gremlin/driver/ser/binary/types/PSerializer.java   | 18 ++++++++++++------
 .../binary/GraphBinaryReaderWriterRoundTripTest.java   |  1 +
 gremlin-python/pom.xml                                 |  2 +-
 .../gremlin_python/structure/io/graphbinaryV1.py       | 11 +++++++++--
 .../jython/tests/structure/io/test_graphbinaryV1.py    | 11 ++++++++++-
 5 files changed, 33 insertions(+), 10 deletions(-)


[tinkerpop] 02/02: All GLV tests passing for GraphBinary

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch TINKERPOP-2279
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit c326d6c9ef4c577580843842078dc2e2307ae01f
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Thu Aug 15 15:27:09 2019 -0400

    All GLV tests passing for GraphBinary
    
    Had to make a nubmer of tweaks to get this working. Most specifically PSerializer which wasn't properly accounting for the normalization that java seems to do.
---
 .../gremlin/driver/ser/binary/types/PSerializer.java   | 18 ++++++++++++------
 .../binary/GraphBinaryReaderWriterRoundTripTest.java   |  1 +
 gremlin-python/pom.xml                                 |  2 +-
 .../gremlin_python/structure/io/graphbinaryV1.py       |  9 ++++++++-
 .../jython/tests/structure/io/test_graphbinaryV1.py    | 11 ++++++++++-
 5 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/binary/types/PSerializer.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/binary/types/PSerializer.java
index f83816f..be399f0 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/binary/types/PSerializer.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/binary/types/PSerializer.java
@@ -62,14 +62,15 @@ public class PSerializer<T extends P> extends SimpleTypeSerializer<T> {
             args[i] = context.read(buffer);
             argumentClasses[i] = args[i].getClass();
         }
-
-        if ("and".equals(predicateName)) {
+                    
+        if ("and".equals(predicateName))
             return (T) ((P) args[0]).and((P) args[1]);
-        } else if ("or".equals(predicateName)) {
+        else if ("or".equals(predicateName))
             return (T) ((P) args[0]).or((P) args[1]);
-        }
+        else if ("not".equals(predicateName))
+            return (T) P.not((P) args[0]);
 
-        CheckedFunction<Object[], T> f = getMethod(predicateName, argumentClasses);
+        final CheckedFunction<Object[], T> f = getMethod(predicateName, argumentClasses);
 
         try {
             return f.apply(args);
@@ -99,7 +100,12 @@ public class PSerializer<T extends P> extends SimpleTypeSerializer<T> {
                     try {
                         m = classOfP.getMethod(predicateName, Object.class);
                     } catch (NoSuchMethodException ex2) {
-                        throw new SerializationException(String.format("Can't find predicate method: '%s'", predicateName), ex2);
+                        // finally go for the generics
+                        try {
+                            m = classOfP.getMethod(predicateName, Object.class, Object.class);
+                        } catch (NoSuchMethodException ex3) {
+                            throw new SerializationException(String.format("Can't find predicate method: '%s'", predicateName), ex2);
+                        }
                     }
                 }
             }
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/binary/GraphBinaryReaderWriterRoundTripTest.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/binary/GraphBinaryReaderWriterRoundTripTest.java
index 48e324c..8f7874e 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/binary/GraphBinaryReaderWriterRoundTripTest.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/binary/GraphBinaryReaderWriterRoundTripTest.java
@@ -228,6 +228,7 @@ public class GraphBinaryReaderWriterRoundTripTest {
                 new Object[] {"Por", P.gt(1).or(P.lt(2)), null},
                 new Object[] {"Pnot", P.not(P.lte(1)), null},
                 new Object[] {"Pwithout", P.without(1,2,3,4), null},
+                new Object[] {"Pinside", P.inside(0.0d, 0.6d), null},
                 new Object[] {"TextP", TextP.startingWith("mark"), null},
 
                 // graph
diff --git a/gremlin-python/pom.xml b/gremlin-python/pom.xml
index 48a45b0..4fd9c47 100644
--- a/gremlin-python/pom.xml
+++ b/gremlin-python/pom.xml
@@ -419,7 +419,7 @@ limitations under the License.
                                             <env key="PYTHONPATH" value=""/>
                                             <arg line="setup.py install"/>
                                         </exec>
-                                        <!-- run for graphson 2.0 -->
+                                        <!-- run for graphson 3.0 -->
                                         <exec executable="env/bin/radish" dir="${project.build.directory}/python2"
                                               failonerror="true">
                                             <env key="PYTHONPATH" value=""/>
diff --git a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py
index ce03f40..738cfe7 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py
@@ -16,6 +16,8 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 """
+
+import six
 import datetime
 import calendar
 import struct
@@ -127,7 +129,12 @@ class GraphBinaryWriter(object):
 
     def toDict(self, obj):
         try:
-            return self.serializers[type(obj)].dictify(obj, self)
+            t = type(obj)
+            
+            # coerce unicode to str so the serializer will be found properly in the cache...better way?
+            if not six.PY3:
+                t = str if isinstance(obj, unicode) else t
+            return self.serializers[t].dictify(obj, self)
         except KeyError:
             for key, serializer in self.serializers.items():
                 if isinstance(obj, key):
diff --git a/gremlin-python/src/main/jython/tests/structure/io/test_graphbinaryV1.py b/gremlin-python/src/main/jython/tests/structure/io/test_graphbinaryV1.py
index bcaad3d..917e7f2 100644
--- a/gremlin-python/src/main/jython/tests/structure/io/test_graphbinaryV1.py
+++ b/gremlin-python/src/main/jython/tests/structure/io/test_graphbinaryV1.py
@@ -119,7 +119,16 @@ class TestGraphSONWriter(object):
              987: ["go", "deep", {"here": "!"}]}
         output = self.graphbinary_reader.readObject(self.graphbinary_writer.writeObject(x))
         assert x == output
-        
+
+        x = {"marko": [666], "noone": ["blah"]}
+        output = self.graphbinary_reader.readObject(self.graphbinary_writer.writeObject(x))
+        assert x == output
+
+        x = {"ripple": [], "peter": ["created"], "noone": ["blah"], "vadas": [],
+             "josh": ["created", "created"], "lop": [], "marko": [666, "created", "knows", "knows"]}
+        output = self.graphbinary_reader.readObject(self.graphbinary_writer.writeObject(x))
+        assert x == output
+
     def test_uuid(self):
         x = uuid.UUID("41d2e28a-20a4-4ab0-b379-d810dede3786")
         output = self.graphbinary_reader.readObject(self.graphbinary_writer.writeObject(x))


[tinkerpop] 01/02: Fixed up BulkSet python graphbinary serialization

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch TINKERPOP-2279
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 9e37ecc5436b582965474169359076387e751e8c
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Tue Aug 13 17:16:09 2019 -0400

    Fixed up BulkSet python graphbinary serialization
---
 .../src/main/jython/gremlin_python/structure/io/graphbinaryV1.py        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py
index 5261952..ce03f40 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py
@@ -908,7 +908,7 @@ class BulkSetIO(_GraphBinaryTypeIO):
         the_list = []
         while size > 0:
             itm = r.readObject(b)
-            bulk = cls.read_int(b)
+            bulk = struct.unpack(">q", b.read(8))[0]
             for y in range(bulk):
                 the_list.append(itm)            
             size = size - 1