tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [21/50] [abbrv] tinkerpop git commit: TINKERPOP-2034 Registered synchronizedMap() with Gryo CTR
Date Tue, 18 Sep 2018 16:48:39 GMT
TINKERPOP-2034 Registered synchronizedMap() with Gryo CTR

This has no real effect here, but is relevant to continued compatibility with Gryo 1.0 in
3.4.0. Also added Triplet to Gryo as it was added in 3.4.0 as part of repeat() CTR


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

Branch: refs/heads/TINKERPOP-1913
Commit: ec0e6856e9355b3b46be4c7e104a2b55d57d766d
Parents: c029eef
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Wed Sep 12 10:28:03 2018 -0400
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Wed Sep 12 10:28:03 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  2 ++
 .../gremlin/structure/io/gryo/GryoVersion.java  | 14 ++++++++-
 .../structure/io/gryo/UtilSerializers.java      | 33 ++++++++++++++++++++
 3 files changed, 48 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec0e6856/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 158cc7a..8e36d6d 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -32,6 +32,8 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 * Added an system error code for failed plugin installs for Gremlin Server `-i` option.
 * Match numbers in `choose()` options using `NumberHelper` (match values, ignore data type).
 * Added support for GraphSON serialization of `Date` in Javascript.
+* Added synchronized `Map` to Gryo 1.0 registrations.
+* Added `Triple` to Gryo 1.0 registrations.
 * Added better internal processing of `Column` in `by(Function)`.
 * Added support for additional extended types in Gremlin.Net with `decimal`, `TimeSpan`,
`BigInteger`, `byte`, `byte[]`, `char` and `short`.
 * Fixed bug in Java driver where an disorderly shutdown of the server would cause the client
to hang.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec0e6856/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 6d5e99a..5f973e3 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
@@ -84,6 +84,7 @@ import org.apache.tinkerpop.gremlin.util.function.MultiComparator;
 import org.apache.tinkerpop.shaded.kryo.KryoSerializable;
 import org.apache.tinkerpop.shaded.kryo.serializers.JavaSerializer;
 import org.javatuples.Pair;
+import org.javatuples.Triplet;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
@@ -191,6 +192,7 @@ public enum GryoVersion {
             add(GryoTypeReg.of(Collections.singleton(null).getClass(), 54));
             add(GryoTypeReg.of(Collections.singletonList(null).getClass(), 24));
             add(GryoTypeReg.of(Collections.singletonMap(null, null).getClass(), 23));
+            add(GryoTypeReg.of(Types.COLLECTIONS_SYNCHRONIZED_MAP, 185, new UtilSerializers.SynchronizedMapSerializer()));
 // ***LAST ID***
             add(GryoTypeReg.of(Contains.class, 49));
             add(GryoTypeReg.of(Currency.class, 40));
             add(GryoTypeReg.of(Date.class, 38));
@@ -280,6 +282,7 @@ public enum GryoVersion {
             add(GryoTypeReg.of(MapReduce.NullObject.class, 74));
             add(GryoTypeReg.of(AtomicLong.class, 79));
             add(GryoTypeReg.of(Pair.class, 88, new UtilSerializers.PairSerializer()));
+            add(GryoTypeReg.of(Triplet.class, 183, new UtilSerializers.TripletSerializer()));
             add(GryoTypeReg.of(TraversalExplanation.class, 106, new JavaSerializer()));
 
             add(GryoTypeReg.of(Duration.class, 93, new JavaTimeSerializers.DurationSerializer()));
@@ -308,7 +311,7 @@ public enum GryoVersion {
             add(GryoTypeReg.of(OrderGlobalStep.OrderBiOperator.class, 118, new JavaSerializer()));
             add(GryoTypeReg.of(ProfileStep.ProfileBiOperator.class, 119));
             // skip 171, 172 to sync with tp33
-            add(GryoTypeReg.of(IndexedTraverserSet.VertexIndexedTraverserSet.class, 173));
                // ***LAST ID***
+            add(GryoTypeReg.of(IndexedTraverserSet.VertexIndexedTraverserSet.class, 173));
         }};
     }
 
@@ -332,6 +335,8 @@ public enum GryoVersion {
 
         private static final Class HASH_MAP_TREE_NODE;
 
+        private static final Class COLLECTIONS_SYNCHRONIZED_MAP;
+
         static {
             // have to instantiate this via reflection because it is a private inner class
of HashMap
             String className = HashMap.class.getName() + "$Node";
@@ -347,6 +352,13 @@ public enum GryoVersion {
             } catch (Exception ex) {
                 throw new RuntimeException("Could not access " + className, ex);
             }
+
+            className = Collections.class.getName() + "$SynchronizedMap";
+            try {
+                COLLECTIONS_SYNCHRONIZED_MAP = Class.forName(className);
+            } catch (Exception ex) {
+                throw new RuntimeException("Could not access " + className, ex);
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec0e6856/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/UtilSerializers.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/UtilSerializers.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/UtilSerializers.java
index 5182e6c..7aec235 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/UtilSerializers.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/UtilSerializers.java
@@ -28,6 +28,7 @@ import org.apache.tinkerpop.shaded.kryo.Serializer;
 import org.apache.tinkerpop.shaded.kryo.io.Input;
 import org.apache.tinkerpop.shaded.kryo.io.Output;
 import org.javatuples.Pair;
+import org.javatuples.Triplet;
 
 import java.net.InetAddress;
 import java.net.URI;
@@ -35,6 +36,8 @@ import java.nio.ByteBuffer;
 import java.util.AbstractMap;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
@@ -216,6 +219,20 @@ final class UtilSerializers {
         }
     }
 
+    static final class TripletSerializer implements SerializerShim<Triplet> {
+        @Override
+        public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final
O output, final Triplet triplet) {
+            kryo.writeClassAndObject(output, triplet.getValue0());
+            kryo.writeClassAndObject(output, triplet.getValue1());
+            kryo.writeClassAndObject(output, triplet.getValue2());
+        }
+
+        @Override
+        public <I extends InputShim> Triplet read(final KryoShim<I, ?> kryo,
final I input, final Class<Triplet> tripletClass) {
+            return Triplet.with(kryo.readClassAndObject(input), kryo.readClassAndObject(input),
kryo.readClassAndObject(input));
+        }
+    }
+
     static final class EntrySerializer extends Serializer<Map.Entry> {
         @Override
         public void write(final Kryo kryo, final Output output, final Map.Entry entry) {
@@ -228,4 +245,20 @@ final class UtilSerializers {
             return new AbstractMap.SimpleEntry(kryo.readClassAndObject(input), kryo.readClassAndObject(input));
         }
     }
+
+    /**
+     * Serializer for {@code List} instances produced by {@code Arrays.asList()}.
+     */
+    final static class SynchronizedMapSerializer implements SerializerShim<Map> {
+        @Override
+        public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final
O output, final Map map) {
+            final Map m = new LinkedHashMap();
+            map.forEach(m::put);
+            kryo.writeObject(output, m);
+        }
+        @Override
+        public <I extends InputShim> Map read(final KryoShim<I, ?> kryo, final
I input, final Class<Map> clazz) {
+            return Collections.synchronizedMap(kryo.readObject(input, LinkedHashMap.class));
+        }
+    }
 }


Mime
View raw message