tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [1/2] tinkerpop git commit: Fixed Gryo serialization of ConnectiveP instances.
Date Fri, 23 Dec 2016 12:37:30 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/master b0102688e -> d6501d328


Fixed Gryo serialization of ConnectiveP instances.

AndP and OrP wasn't serializing properly in certain situations. Merged the two separate serializers
under the standard P serializer. CTR


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/26ffb9a9
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/26ffb9a9
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/26ffb9a9

Branch: refs/heads/master
Commit: 26ffb9a951bbbb4c3bc71e92b1215d7b5aef0c06
Parents: 0bcbc7a
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Fri Dec 23 07:36:16 2016 -0500
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Fri Dec 23 07:36:16 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../structure/io/gryo/GryoClassResolver.java    |  4 ++
 .../structure/io/gryo/GryoSerializers.java      | 43 ++++----------------
 .../gremlin/structure/io/gryo/GryoVersion.java  |  2 -
 4 files changed, 14 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/26ffb9a9/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 36a0cdd..3d10308 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -27,6 +27,7 @@ TinkerPop 3.2.4 (Release Date: NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 * Added `GryoVersion` for future flexibility when introducing a new verison of Gryo and moved
serializer registrations to it.
+* Fixed Gryo serialization of `ConnectiveP` instances.
 * Lessened the severity of Gremlin Server logging when it encounters two or more serializers
addressing the same mime type.
 * Bumped to Netty 4.0.42.final.
 * Added `ByteBuffer`, `InetAddress`, `Timestamp` to the list of Gryo supported classes.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/26ffb9a9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoClassResolver.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoClassResolver.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoClassResolver.java
index 1ee8612..dceda40 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoClassResolver.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoClassResolver.java
@@ -18,7 +18,9 @@
  */
 package org.apache.tinkerpop.gremlin.structure.io.gryo;
 
+import org.apache.tinkerpop.gremlin.process.traversal.P;
 import org.apache.tinkerpop.gremlin.process.traversal.Path;
+import org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP;
 import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.Property;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -117,6 +119,8 @@ public class GryoClassResolver implements ClassResolver {
             type = Class.class;
         else if (InetAddress.class.isAssignableFrom(clazz))
             type = InetAddress.class;
+        else if (ConnectiveP.class.isAssignableFrom(clazz))
+            type = P.class;
         else
             type = clazz;
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/26ffb9a9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializers.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializers.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializers.java
index dbe85ca..416936c 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializers.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializers.java
@@ -174,43 +174,16 @@ public final class GryoSerializers {
         }
     }
 
-    public final static class AndPSerializer implements SerializerShim<AndP> {
-
-        @Override
-        public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final
O output, final AndP p) {
-            final List predicates = new ArrayList(p.getPredicates());
-            kryo.writeObject(output, predicates);
-        }
-
-        @Override
-        public <I extends InputShim> AndP read(final KryoShim<I, ?> kryo, final
I input, final Class<AndP> clazz) {
-            final List<P> predicates = kryo.readObject(input, ArrayList.class);
-            return new AndP(predicates);
-        }
-    }
-
-    public final static class OrPSerializer implements SerializerShim<OrP> {
-
-        @Override
-        public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final
O output, final OrP p) {
-            final List predicates = new ArrayList(p.getPredicates());
-            kryo.writeObject(output, predicates);
-        }
-
-        @Override
-        public <I extends InputShim> OrP read(final KryoShim<I, ?> kryo, final
I input, final Class<OrP> clazz) {
-            final List<P> predicates = kryo.readObject(input, ArrayList.class);
-            return new OrP(predicates);
-        }
-    }
-
     public final static class PSerializer implements SerializerShim<P> {
         @Override
         public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final
O output, final P p) {
-            output.writeString(p.getBiPredicate().toString());
-            if (p.getValue() instanceof Collection) {
+            output.writeString(p instanceof ConnectiveP ?
+                    (p instanceof AndP ? "and" : "or") :
+                    p.getBiPredicate().toString());
+            if (p instanceof ConnectiveP || p.getValue() instanceof Collection) {
                 output.writeByte((byte) 0);
-                final Collection coll = (Collection) p.getValue();
+                final Collection<?> coll = p instanceof ConnectiveP ?
+                        ((ConnectiveP<?>) p).getPredicates() : (Collection) p.getValue();
                 output.writeInt(coll.size());
                 coll.forEach(v -> kryo.writeClassAndObject(output, v));
             } else {
@@ -235,7 +208,9 @@ public final class GryoSerializers {
             }
 
             try {
-                if (value instanceof Collection) {
+                if (predicate.equals("and") || predicate.equals("or"))
+                    return predicate.equals("and") ? new AndP((List<P>) value) : new
OrP((List<P>) value);
+                else  if (value instanceof Collection) {
                     if (predicate.equals("between"))
                         return P.between(((List) value).get(0), ((List) value).get(1));
                     else if (predicate.equals("inside"))

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/26ffb9a9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java
index 0d380b1..0bd9e87 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java
@@ -253,8 +253,6 @@ public enum GryoVersion {
             add(GryoTypeReg.of(Bytecode.Binding.class, 126, new GryoSerializers.BindingSerializer()));
             add(GryoTypeReg.of(Order.class, 127));
             add(GryoTypeReg.of(Scope.class, 128));
-            add(GryoTypeReg.of(AndP.class, 129, new GryoSerializers.AndPSerializer()));
-            add(GryoTypeReg.of(OrP.class, 130, new GryoSerializers.OrPSerializer()));
             add(GryoTypeReg.of(VertexProperty.Cardinality.class, 131));
             add(GryoTypeReg.of(Column.class, 132));
             add(GryoTypeReg.of(Pop.class, 133));


Mime
View raw message