Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2AAFD200CE7 for ; Wed, 12 Jul 2017 18:52:00 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 295BF16967F; Wed, 12 Jul 2017 16:52:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id F0D29169636 for ; Wed, 12 Jul 2017 18:51:55 +0200 (CEST) Received: (qmail 92612 invoked by uid 500); 12 Jul 2017 16:51:55 -0000 Mailing-List: contact commits-help@tinkerpop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tinkerpop.apache.org Delivered-To: mailing list commits@tinkerpop.apache.org Received: (qmail 92585 invoked by uid 99); 12 Jul 2017 16:51:55 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Jul 2017 16:51:55 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AA297F3243; Wed, 12 Jul 2017 16:51:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dkuppitz@apache.org To: commits@tinkerpop.apache.org Date: Wed, 12 Jul 2017 16:52:12 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [19/50] [abbrv] tinkerpop git commit: TINKERPOP-1698 Metrics serializer for gryo 3.0 and abstract ClassResolver archived-at: Wed, 12 Jul 2017 16:52:00 -0000 TINKERPOP-1698 Metrics serializer for gryo 3.0 and abstract ClassResolver Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/dc9a87b3 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/dc9a87b3 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/dc9a87b3 Branch: refs/heads/TINKERPOP-1682 Commit: dc9a87b3927901d67c4547c9f16b5f5bd39b1a33 Parents: 87ca1e3 Author: Stephen Mallette Authored: Sat Jun 24 09:55:20 2017 -0400 Committer: Stephen Mallette Committed: Mon Jul 10 14:13:37 2017 -0400 ---------------------------------------------------------------------- CHANGELOG.asciidoc | 2 + .../tinkerpop/gremlin/jsr223/CoreImports.java | 6 +- .../io/gryo/AbstractGryoClassResolver.java | 188 +++++++++++++++ .../structure/io/gryo/GryoClassResolver.java | 227 ------------------- .../io/gryo/GryoClassResolverV1d0.java | 79 +++++++ .../io/gryo/GryoClassResolverV3d0.java | 85 +++++++ .../gremlin/structure/io/gryo/GryoMapper.java | 8 +- .../structure/io/gryo/GryoSerializersV1d0.java | 1 - .../structure/io/gryo/GryoSerializersV3d0.java | 70 ++++++ .../gremlin/structure/io/gryo/GryoVersion.java | 24 +- .../structure/io/gryo/GryoMapperTest.java | 2 +- .../ser/GryoBaseMessageSerializerV1d0Test.java | 4 +- gremlin-tools/gremlin-io-test/pom.xml | 2 +- .../structure/io/gryo/_3_3_0/metrics-v3d0.kryo | Bin 187 -> 184 bytes .../io/gryo/_3_3_0/traversalmetrics-v3d0.kryo | Bin 294 -> 308 bytes .../tinkergraph/structure/TinkerGraphTest.java | 4 +- 16 files changed, 456 insertions(+), 246 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc9a87b3/CHANGELOG.asciidoc ---------------------------------------------------------------------- diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index bfdd43d..2fe7094 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -26,6 +26,8 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima TinkerPop 3.3.0 (Release Date: NOT OFFICIALLY RELEASED YET) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* `GryoVersion` now includes a default `ClassResolver` to supply to the `GryoMapper`. +* `GryoClassResolver` renamed to `GryoClassResolverV1d0` which has an abstract class that for providers to extend in `AbstractGryoClassResolver`. * Removed previously deprecated `TraversalSource.Builder` class. * Removed previously deprecated `ConnectiveP`, `AndP`, `OrP` constructors. * Removed previously deprecated `TraversalScriptFunction` class. http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc9a87b3/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java index 1296cfe..7f82834 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java @@ -112,7 +112,8 @@ import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion; import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter; import org.apache.tinkerpop.gremlin.structure.io.graphson.LegacyGraphSONReader; -import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoClassResolver; +import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoClassResolverV1d0; +import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoClassResolverV3d0; import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo; import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper; import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader; @@ -192,7 +193,8 @@ public final class CoreImports { CLASS_IMPORTS.add(GraphSONVersion.class); CLASS_IMPORTS.add(GraphSONWriter.class); CLASS_IMPORTS.add(LegacyGraphSONReader.class); - CLASS_IMPORTS.add(GryoClassResolver.class); + CLASS_IMPORTS.add(GryoClassResolverV1d0.class); + CLASS_IMPORTS.add(GryoClassResolverV3d0.class); CLASS_IMPORTS.add(GryoIo.class); CLASS_IMPORTS.add(GryoMapper.class); CLASS_IMPORTS.add(GryoReader.class); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc9a87b3/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/AbstractGryoClassResolver.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/AbstractGryoClassResolver.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/AbstractGryoClassResolver.java new file mode 100644 index 0000000..4f400ab --- /dev/null +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/AbstractGryoClassResolver.java @@ -0,0 +1,188 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tinkerpop.gremlin.structure.io.gryo; + +import org.apache.tinkerpop.shaded.kryo.ClassResolver; +import org.apache.tinkerpop.shaded.kryo.Kryo; +import org.apache.tinkerpop.shaded.kryo.KryoException; +import org.apache.tinkerpop.shaded.kryo.Registration; +import org.apache.tinkerpop.shaded.kryo.io.Input; +import org.apache.tinkerpop.shaded.kryo.io.Output; +import org.apache.tinkerpop.shaded.kryo.util.IdentityObjectIntMap; +import org.apache.tinkerpop.shaded.kryo.util.IntMap; +import org.apache.tinkerpop.shaded.kryo.util.ObjectMap; + +import static org.apache.tinkerpop.shaded.kryo.util.Util.getWrapperClass; + +/** + * This mapper implementation of the {@code ClassResolver} helps ensure that all Vertex and Edge concrete classes + * get properly serialized and deserialized by stripping them of their concrete class name so that they are treated + * generically. See the {@link #getRegistration(Class)} method for the core of this logic. + * + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +public abstract class AbstractGryoClassResolver implements ClassResolver { + static public final byte NAME = -1; + + protected Kryo kryo; + + protected final IntMap idToRegistration = new IntMap<>(); + protected final ObjectMap classToRegistration = new ObjectMap<>(); + + protected IdentityObjectIntMap classToNameId; + protected IntMap nameIdToClass; + protected ObjectMap nameToClass; + protected int nextNameId; + + private int memoizedClassId = -1; + private Registration memoizedClassIdValue; + private Class memoizedClass; + private Registration memoizedClassValue; + + @Override + public void setKryo(Kryo kryo) { + this.kryo = kryo; + } + + @Override + public Registration register(final Registration registration) { + if (null == registration) throw new IllegalArgumentException("Registration cannot be null."); + if (registration.getId() != NAME) idToRegistration.put(registration.getId(), registration); + + classToRegistration.put(registration.getType(), registration); + if (registration.getType().isPrimitive()) + classToRegistration.put(getWrapperClass(registration.getType()), registration); + return registration; + } + + @Override + public Registration registerImplicit(final Class type) { + return register(new Registration(type, kryo.getDefaultSerializer(type), NAME)); + } + + /** + * Called from {@link #getRegistration(Class)} to determine the actual type. + */ + public abstract Class coerceType(final Class clazz); + + @Override + public Registration getRegistration(final Class clazz) { + final Class type = coerceType(clazz); + + if (type == memoizedClass) return memoizedClassValue; + final Registration registration = classToRegistration.get(type); + if (registration != null) { + memoizedClass = type; + memoizedClassValue = registration; + } + + return registration; + } + + @Override + public Registration getRegistration(final int classID) { + return idToRegistration.get(classID); + } + + @Override + public Registration writeClass(final Output output, final Class type) { + if (null == type) { + output.writeVarInt(Kryo.NULL, true); + return null; + } + + final Registration registration = kryo.getRegistration(type); + if (registration.getId() == NAME) + writeName(output, type); + else + output.writeVarInt(registration.getId() + 2, true); + + return registration; + } + + protected void writeName(final Output output, final Class type) { + output.writeVarInt(NAME + 2, true); + if (classToNameId != null) { + final int nameId = classToNameId.get(type, -1); + if (nameId != -1) { + output.writeVarInt(nameId, true); + return; + } + } + // Only write the class name the first time encountered in object graph. + final int nameId = nextNameId++; + if (classToNameId == null) classToNameId = new IdentityObjectIntMap<>(); + classToNameId.put(type, nameId); + output.writeVarInt(nameId, true); + output.writeString(type.getName()); + } + + @Override + public Registration readClass(final Input input) { + final int classID = input.readVarInt(true); + switch (classID) { + case Kryo.NULL: + return null; + case NAME + 2: // Offset for NAME and NULL. + return readName(input); + } + + if (classID == memoizedClassId) return memoizedClassIdValue; + final Registration registration = idToRegistration.get(classID - 2); + if (registration == null) throw new KryoException("Encountered unregistered class ID: " + (classID - 2)); + memoizedClassId = classID; + memoizedClassIdValue = registration; + return registration; + } + + protected Registration readName(final Input input) { + final int nameId = input.readVarInt(true); + if (nameIdToClass == null) nameIdToClass = new IntMap<>(); + Class type = nameIdToClass.get(nameId); + if (type == null) { + // Only read the class name the first time encountered in object graph. + final String className = input.readString(); + type = getTypeByName(className); + if (type == null) { + try { + type = Class.forName(className, false, kryo.getClassLoader()); + } catch (ClassNotFoundException ex) { + throw new KryoException("Unable to find class: " + className, ex); + } + if (nameToClass == null) nameToClass = new ObjectMap<>(); + nameToClass.put(className, type); + } + nameIdToClass.put(nameId, type); + } + return kryo.getRegistration(type); + } + + protected Class getTypeByName(final String className) { + return nameToClass != null ? nameToClass.get(className) : null; + } + + @Override + public void reset() { + if (!kryo.isRegistrationRequired()) { + if (classToNameId != null) classToNameId.clear(); + if (nameIdToClass != null) nameIdToClass.clear(); + nextNameId = 0; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc9a87b3/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 deleted file mode 100644 index dceda40..0000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoClassResolver.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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; -import org.apache.tinkerpop.gremlin.structure.VertexProperty; -import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge; -import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPath; -import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedProperty; -import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; -import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty; -import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdge; -import org.apache.tinkerpop.gremlin.structure.util.reference.ReferencePath; -import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceProperty; -import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex; -import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexProperty; -import org.apache.tinkerpop.gremlin.util.function.Lambda; -import org.apache.tinkerpop.shaded.kryo.ClassResolver; -import org.apache.tinkerpop.shaded.kryo.Kryo; -import org.apache.tinkerpop.shaded.kryo.KryoException; -import org.apache.tinkerpop.shaded.kryo.Registration; -import org.apache.tinkerpop.shaded.kryo.io.Input; -import org.apache.tinkerpop.shaded.kryo.io.Output; -import org.apache.tinkerpop.shaded.kryo.util.IdentityObjectIntMap; -import org.apache.tinkerpop.shaded.kryo.util.IntMap; -import org.apache.tinkerpop.shaded.kryo.util.ObjectMap; - -import java.net.InetAddress; -import java.nio.ByteBuffer; - -import static org.apache.tinkerpop.shaded.kryo.util.Util.getWrapperClass; - -/** - * This mapper implementation of the {@code ClassResolver} helps ensure that all Vertex and Edge concrete classes - * get properly serialized and deserialized by stripping them of their concrete class name so that they are treated - * generically. See the {@link #getRegistration(Class)} method for the core of this logic. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - */ -public class GryoClassResolver implements ClassResolver { - static public final byte NAME = -1; - - protected Kryo kryo; - - protected final IntMap idToRegistration = new IntMap<>(); - protected final ObjectMap classToRegistration = new ObjectMap<>(); - - protected IdentityObjectIntMap classToNameId; - protected IntMap nameIdToClass; - protected ObjectMap nameToClass; - protected int nextNameId; - - private int memoizedClassId = -1; - private Registration memoizedClassIdValue; - private Class memoizedClass; - private Registration memoizedClassValue; - - @Override - public void setKryo(Kryo kryo) { - this.kryo = kryo; - } - - @Override - public Registration register(final Registration registration) { - if (null == registration) throw new IllegalArgumentException("Registration cannot be null."); - if (registration.getId() != NAME) idToRegistration.put(registration.getId(), registration); - - classToRegistration.put(registration.getType(), registration); - if (registration.getType().isPrimitive()) - classToRegistration.put(getWrapperClass(registration.getType()), registration); - return registration; - } - - @Override - public Registration registerImplicit(final Class type) { - return register(new Registration(type, kryo.getDefaultSerializer(type), NAME)); - } - - @Override - public Registration getRegistration(final Class clazz) { - // force all instances of Vertex, Edge, VertexProperty, etc. to their respective interface - final Class type; - if (!ReferenceVertex.class.isAssignableFrom(clazz) && !DetachedVertex.class.isAssignableFrom(clazz) && Vertex.class.isAssignableFrom(clazz)) - type = Vertex.class; - else if (!ReferenceEdge.class.isAssignableFrom(clazz) && !DetachedEdge.class.isAssignableFrom(clazz) && Edge.class.isAssignableFrom(clazz)) - type = Edge.class; - else if (!ReferenceVertexProperty.class.isAssignableFrom(clazz) && !DetachedVertexProperty.class.isAssignableFrom(clazz) && VertexProperty.class.isAssignableFrom(clazz)) - type = VertexProperty.class; - else if (!ReferenceProperty.class.isAssignableFrom(clazz) && !DetachedProperty.class.isAssignableFrom(clazz) && !DetachedVertexProperty.class.isAssignableFrom(clazz) && Property.class.isAssignableFrom(clazz)) - type = Property.class; - else if (!ReferencePath.class.isAssignableFrom(clazz) && !DetachedPath.class.isAssignableFrom(clazz) && Path.class.isAssignableFrom(clazz)) - type = Path.class; - else if (Lambda.class.isAssignableFrom(clazz)) - type = Lambda.class; - else if (ByteBuffer.class.isAssignableFrom(clazz)) - type = ByteBuffer.class; - else if (Class.class.isAssignableFrom(clazz)) - type = Class.class; - else if (InetAddress.class.isAssignableFrom(clazz)) - type = InetAddress.class; - else if (ConnectiveP.class.isAssignableFrom(clazz)) - type = P.class; - else - type = clazz; - - if (type == memoizedClass) return memoizedClassValue; - final Registration registration = classToRegistration.get(type); - if (registration != null) { - memoizedClass = type; - memoizedClassValue = registration; - } - - return registration; - } - - @Override - public Registration getRegistration(final int classID) { - return idToRegistration.get(classID); - } - - @Override - public Registration writeClass(final Output output, final Class type) { - if (null == type) { - output.writeVarInt(Kryo.NULL, true); - return null; - } - - final Registration registration = kryo.getRegistration(type); - if (registration.getId() == NAME) - writeName(output, type); - else - output.writeVarInt(registration.getId() + 2, true); - - return registration; - } - - protected void writeName(final Output output, final Class type) { - output.writeVarInt(NAME + 2, true); - if (classToNameId != null) { - final int nameId = classToNameId.get(type, -1); - if (nameId != -1) { - output.writeVarInt(nameId, true); - return; - } - } - // Only write the class name the first time encountered in object graph. - final int nameId = nextNameId++; - if (classToNameId == null) classToNameId = new IdentityObjectIntMap<>(); - classToNameId.put(type, nameId); - output.writeVarInt(nameId, true); - output.writeString(type.getName()); - } - - @Override - public Registration readClass(final Input input) { - final int classID = input.readVarInt(true); - switch (classID) { - case Kryo.NULL: - return null; - case NAME + 2: // Offset for NAME and NULL. - return readName(input); - } - - if (classID == memoizedClassId) return memoizedClassIdValue; - final Registration registration = idToRegistration.get(classID - 2); - if (registration == null) throw new KryoException("Encountered unregistered class ID: " + (classID - 2)); - memoizedClassId = classID; - memoizedClassIdValue = registration; - return registration; - } - - protected Registration readName(final Input input) { - final int nameId = input.readVarInt(true); - if (nameIdToClass == null) nameIdToClass = new IntMap<>(); - Class type = nameIdToClass.get(nameId); - if (type == null) { - // Only read the class name the first time encountered in object graph. - final String className = input.readString(); - type = getTypeByName(className); - if (type == null) { - try { - type = Class.forName(className, false, kryo.getClassLoader()); - } catch (ClassNotFoundException ex) { - throw new KryoException("Unable to find class: " + className, ex); - } - if (nameToClass == null) nameToClass = new ObjectMap<>(); - nameToClass.put(className, type); - } - nameIdToClass.put(nameId, type); - } - return kryo.getRegistration(type); - } - - protected Class getTypeByName(final String className) { - return nameToClass != null ? nameToClass.get(className) : null; - } - - @Override - public void reset() { - if (!kryo.isRegistrationRequired()) { - if (classToNameId != null) classToNameId.clear(); - if (nameIdToClass != null) nameIdToClass.clear(); - nextNameId = 0; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc9a87b3/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoClassResolverV1d0.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoClassResolverV1d0.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoClassResolverV1d0.java new file mode 100644 index 0000000..12a9bfb --- /dev/null +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoClassResolverV1d0.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +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; +import org.apache.tinkerpop.gremlin.structure.VertexProperty; +import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge; +import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPath; +import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedProperty; +import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; +import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty; +import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdge; +import org.apache.tinkerpop.gremlin.structure.util.reference.ReferencePath; +import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceProperty; +import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex; +import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexProperty; +import org.apache.tinkerpop.gremlin.util.function.Lambda; + +import java.net.InetAddress; +import java.nio.ByteBuffer; + +/** + * {@link AbstractGryoClassResolver} for Gryo 1.0. + * + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +public class GryoClassResolverV1d0 extends AbstractGryoClassResolver { + + @Override + public Class coerceType(final Class clazz) { + // force all instances of Vertex, Edge, VertexProperty, etc. to their respective interface + final Class type; + if (!ReferenceVertex.class.isAssignableFrom(clazz) && !DetachedVertex.class.isAssignableFrom(clazz) && Vertex.class.isAssignableFrom(clazz)) + type = Vertex.class; + else if (!ReferenceEdge.class.isAssignableFrom(clazz) && !DetachedEdge.class.isAssignableFrom(clazz) && Edge.class.isAssignableFrom(clazz)) + type = Edge.class; + else if (!ReferenceVertexProperty.class.isAssignableFrom(clazz) && !DetachedVertexProperty.class.isAssignableFrom(clazz) && VertexProperty.class.isAssignableFrom(clazz)) + type = VertexProperty.class; + else if (!ReferenceProperty.class.isAssignableFrom(clazz) && !DetachedProperty.class.isAssignableFrom(clazz) && !DetachedVertexProperty.class.isAssignableFrom(clazz) && Property.class.isAssignableFrom(clazz)) + type = Property.class; + else if (!ReferencePath.class.isAssignableFrom(clazz) && !DetachedPath.class.isAssignableFrom(clazz) && Path.class.isAssignableFrom(clazz)) + type = Path.class; + else if (Lambda.class.isAssignableFrom(clazz)) + type = Lambda.class; + else if (ByteBuffer.class.isAssignableFrom(clazz)) + type = ByteBuffer.class; + else if (Class.class.isAssignableFrom(clazz)) + type = Class.class; + else if (InetAddress.class.isAssignableFrom(clazz)) + type = InetAddress.class; + else if (ConnectiveP.class.isAssignableFrom(clazz)) + type = P.class; + else + type = clazz; + + return type; + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc9a87b3/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoClassResolverV3d0.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoClassResolverV3d0.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoClassResolverV3d0.java new file mode 100644 index 0000000..9b0f726 --- /dev/null +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoClassResolverV3d0.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +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.process.traversal.util.Metrics; +import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics; +import org.apache.tinkerpop.gremlin.structure.Edge; +import org.apache.tinkerpop.gremlin.structure.Property; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.structure.VertexProperty; +import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge; +import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPath; +import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedProperty; +import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; +import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty; +import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdge; +import org.apache.tinkerpop.gremlin.structure.util.reference.ReferencePath; +import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceProperty; +import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex; +import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexProperty; +import org.apache.tinkerpop.gremlin.util.function.Lambda; + +import java.net.InetAddress; +import java.nio.ByteBuffer; + +/** + * {@link AbstractGryoClassResolver} for Gryo 3.0. + * + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +public class GryoClassResolverV3d0 extends AbstractGryoClassResolver { + + @Override + public Class coerceType(final Class clazz) { + // force all instances of Vertex, Edge, VertexProperty, etc. to their respective interface + final Class type; + if (!ReferenceVertex.class.isAssignableFrom(clazz) && !DetachedVertex.class.isAssignableFrom(clazz) && Vertex.class.isAssignableFrom(clazz)) + type = Vertex.class; + else if (!ReferenceEdge.class.isAssignableFrom(clazz) && !DetachedEdge.class.isAssignableFrom(clazz) && Edge.class.isAssignableFrom(clazz)) + type = Edge.class; + else if (!ReferenceVertexProperty.class.isAssignableFrom(clazz) && !DetachedVertexProperty.class.isAssignableFrom(clazz) && VertexProperty.class.isAssignableFrom(clazz)) + type = VertexProperty.class; + else if (!ReferenceProperty.class.isAssignableFrom(clazz) && !DetachedProperty.class.isAssignableFrom(clazz) && !DetachedVertexProperty.class.isAssignableFrom(clazz) && Property.class.isAssignableFrom(clazz)) + type = Property.class; + else if (!ReferencePath.class.isAssignableFrom(clazz) && !DetachedPath.class.isAssignableFrom(clazz) && Path.class.isAssignableFrom(clazz)) + type = Path.class; + else if (Lambda.class.isAssignableFrom(clazz)) + type = Lambda.class; + else if (ByteBuffer.class.isAssignableFrom(clazz)) + type = ByteBuffer.class; + else if (Class.class.isAssignableFrom(clazz)) + type = Class.class; + else if (InetAddress.class.isAssignableFrom(clazz)) + type = InetAddress.class; + else if (ConnectiveP.class.isAssignableFrom(clazz)) + type = P.class; + else if (Metrics.class.isAssignableFrom(clazz)) + type = Metrics.class; + else if (TraversalMetrics.class.isAssignableFrom(clazz)) + type = TraversalMetrics.class; + else + type = clazz; + + return type; + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc9a87b3/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java index 48b670c..2db34b4 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java @@ -88,7 +88,7 @@ public final class GryoMapper implements Mapper { this.registrationRequired = builder.registrationRequired; this.referenceTracking = builder.referenceTracking; - this.classResolver = builder.classResolver; + this.classResolver = null == builder.classResolver ? version.getClassResolverMaker() : builder.classResolver; } @Override @@ -155,7 +155,7 @@ public final class GryoMapper implements Mapper { private boolean registrationRequired = true; private boolean referenceTracking = true; - private Supplier classResolver = GryoClassResolver::new; + private Supplier classResolver; private Builder() { } @@ -182,8 +182,8 @@ public final class GryoMapper implements Mapper { /** * Provides a custom Kryo {@code ClassResolver} to be supplied to a {@code Kryo} instance. If this value is - * not supplied then it will default to the {@link GryoClassResolver}. To ensure compatibility with Gryo it - * is highly recommended that objects passed to this method extend that class. + * not supplied then it will default to the {@code ClassResolver} of the provided {@link GryoVersion}. To + * ensure compatibility with Gryo it is highly recommended that objects passed to this method extend that class. *

* If the {@code ClassResolver} implementation share state, then the {@link Supplier} should typically create * new instances when requested, as the {@link Supplier} will be called for each {@link Kryo} instance created. http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc9a87b3/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializersV1d0.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializersV1d0.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializersV1d0.java index 2851baa..ca7c241 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializersV1d0.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializersV1d0.java @@ -41,7 +41,6 @@ import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedProperty; import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty; import org.apache.tinkerpop.gremlin.util.function.Lambda; -import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; import java.util.ArrayList; import java.util.Collection; http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc9a87b3/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializersV3d0.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializersV3d0.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializersV3d0.java index eb940ff..580bc86 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializersV3d0.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializersV3d0.java @@ -25,11 +25,16 @@ import org.apache.tinkerpop.gremlin.process.traversal.Path; import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource; import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; import org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP; +import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalMetrics; +import org.apache.tinkerpop.gremlin.process.traversal.util.Metrics; +import org.apache.tinkerpop.gremlin.process.traversal.util.MutableMetrics; import org.apache.tinkerpop.gremlin.process.traversal.util.OrP; +import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics; import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Property; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.VertexProperty; +import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; import org.apache.tinkerpop.gremlin.structure.io.gryo.kryoshim.InputShim; import org.apache.tinkerpop.gremlin.structure.io.gryo.kryoshim.KryoShim; import org.apache.tinkerpop.gremlin.structure.io.gryo.kryoshim.OutputShim; @@ -45,7 +50,10 @@ import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; /** * This class holds serializers for graph-based objects such as vertices, edges, properties, and paths. These objects @@ -377,4 +385,66 @@ public final class GryoSerializersV3d0 { return new DefaultRemoteTraverser<>(o, input.readLong()); } } + + public final static class TraversalMetricsSerializer implements SerializerShim { + @Override + public void write(final KryoShim kryo, final O output, final TraversalMetrics object) { + output.writeDouble(object.getDuration(TimeUnit.NANOSECONDS) / 1000000d); + final Collection metrics = object.getMetrics(); + output.writeInt(metrics.size()); + metrics.forEach(m -> kryo.writeObject(output, m)); + } + + @Override + public TraversalMetrics read(final KryoShim kryo, final I input, final Class clazz) { + final double duration = input.readDouble(); + final int size = input.readInt(); + + final List orderedMetrics = new ArrayList<>(); + for (int ix = 0; ix < size; ix++) { + orderedMetrics.add(kryo.readObject(input, MutableMetrics.class)); + } + + return new DefaultTraversalMetrics(Math.round(duration * 1000000), orderedMetrics); + } + } + + public final static class MetricsSerializer implements SerializerShim { + @Override + public void write(final KryoShim kryo, final O output, final Metrics object) { + output.writeString(object.getId()); + output.writeString(object.getName()); + output.writeDouble(object.getDuration(TimeUnit.NANOSECONDS) / 1000000d); + kryo.writeObject(output, object.getCounts()); + kryo.writeObject(output, object.getAnnotations()); + + // kryo might have a problem with LinkedHashMap value collections. can't recreate it independently but + // it gets fixed with standard collections for some reason. + final List nested = new ArrayList<>(object.getNested()); + kryo.writeObject(output, nested); + } + + @Override + public Metrics read(final KryoShim kryo, final I input, final Class clazz) { + final MutableMetrics m = new MutableMetrics(input.readString(), input.readString()); + + m.setDuration(Math.round(input.readDouble() * 1000000), TimeUnit.NANOSECONDS); + + final Map counts = (Map) kryo.readObject(input, HashMap.class); + for (Map.Entry count : counts.entrySet()) { + m.setCount(count.getKey(), count.getValue()); + } + + final Map annotations = (Map) kryo.readObject(input, HashMap.class); + for (Map.Entry count : annotations.entrySet()) { + m.setAnnotation(count.getKey(), count.getValue()); + } + + final List nesteds = (List) kryo.readObject(input, ArrayList.class); + for (MutableMetrics nested : nesteds) { + m.addNested(nested); + } + return m; + } + } } http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc9a87b3/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 c0ed3e5..e06f5b3 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 @@ -77,8 +77,10 @@ import org.apache.tinkerpop.gremlin.process.traversal.traverser.ProjectedTravers import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.TraverserSet; import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalMetrics; import org.apache.tinkerpop.gremlin.process.traversal.util.ImmutableMetrics; +import org.apache.tinkerpop.gremlin.process.traversal.util.Metrics; import org.apache.tinkerpop.gremlin.process.traversal.util.MutableMetrics; import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalExplanation; +import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics; import org.apache.tinkerpop.gremlin.structure.Column; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Edge; @@ -103,6 +105,7 @@ import org.apache.tinkerpop.gremlin.util.function.FunctionUtils; import org.apache.tinkerpop.gremlin.util.function.HashSetSupplier; import org.apache.tinkerpop.gremlin.util.function.Lambda; import org.apache.tinkerpop.gremlin.util.function.MultiComparator; +import org.apache.tinkerpop.shaded.kryo.ClassResolver; import org.apache.tinkerpop.shaded.kryo.KryoSerializable; import org.apache.tinkerpop.shaded.kryo.serializers.JavaSerializer; import org.javatuples.Pair; @@ -153,11 +156,12 @@ import java.util.function.Supplier; * @author Stephen Mallette (http://stephen.genoprime.com) */ public enum GryoVersion { - V1_0("1.0", initV1d0Registrations()), - V3_0("3.0", initV3d0Registrations()); + V1_0("1.0", initV1d0Registrations(), GryoClassResolverV1d0::new), + V3_0("3.0", initV3d0Registrations(), GryoClassResolverV3d0::new); private final String versionNumber; private final List> registrations; + private final Supplier classResolverMaker; /** * Creates a new {@link GryoVersion}. @@ -165,8 +169,9 @@ public enum GryoVersion { * @param versionNumber the user facing string representation of the version which should follow an {@code x.y} * pattern * @param registrations the list of registrations for this version + * @param classResolverMaker providers the default {@code ClassResolver} for a particular version of Gryo */ - GryoVersion(final String versionNumber, final List> registrations) { + GryoVersion(final String versionNumber, final List> registrations, final Supplier classResolverMaker) { // Validate the default registrations // For justification of these default registration rules, see TinkerPopKryoRegistrator for (TypeRegistration tr : registrations) { @@ -184,6 +189,7 @@ public enum GryoVersion { this.versionNumber = versionNumber; this.registrations = registrations; + this.classResolverMaker = classResolverMaker; } public List> cloneRegistrations() { @@ -194,6 +200,10 @@ public enum GryoVersion { return Collections.unmodifiableList(registrations); } + public Supplier getClassResolverMaker() { + return classResolverMaker; + } + public String getVersion() { return versionNumber; } @@ -326,9 +336,11 @@ public enum GryoVersion { add(GryoTypeReg.of(Tree.class, 61)); add(GryoTypeReg.of(HashSet.class, 62)); add(GryoTypeReg.of(BulkSet.class, 64)); - add(GryoTypeReg.of(MutableMetrics.class, 69)); - add(GryoTypeReg.of(ImmutableMetrics.class, 115)); - add(GryoTypeReg.of(DefaultTraversalMetrics.class, 70)); + add(GryoTypeReg.of(Metrics.class, 69, new GryoSerializersV3d0.MetricsSerializer())); + add(GryoTypeReg.of(TraversalMetrics.class, 70, new GryoSerializersV3d0.TraversalMetricsSerializer())); + //add(GryoTypeReg.of(MutableMetrics.class, 69, )); + //add(GryoTypeReg.of(ImmutableMetrics.class, 115)); + //add(GryoTypeReg.of(DefaultTraversalMetrics.class, 70, new GryoSerializersV3d0.TraversalSerializer())); add(GryoTypeReg.of(MapMemory.class, 73)); add(GryoTypeReg.of(MapReduce.NullObject.class, 74)); add(GryoTypeReg.of(AtomicLong.class, 79)); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc9a87b3/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java index 1dc9b48..12e99b3 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java @@ -397,7 +397,7 @@ public class GryoMapperTest { * TinkerPop which then removes the requirement for providers to expose serializers on the client side for user * consumption. */ - public static class CustomClassResolver extends GryoClassResolver { + public static class CustomClassResolver extends GryoClassResolverV1d0 { private IoXIoRegistry.IoXToVertexSerializer ioXToVertexSerializer = new IoXIoRegistry.IoXToVertexSerializer(); private IoYIoRegistry.IoYToHashMapSerializer ioYToHashMapSerializer = new IoYIoRegistry.IoYToHashMapSerializer(); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc9a87b3/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoBaseMessageSerializerV1d0Test.java ---------------------------------------------------------------------- diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoBaseMessageSerializerV1d0Test.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoBaseMessageSerializerV1d0Test.java index 1929dbf..92627eb 100644 --- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoBaseMessageSerializerV1d0Test.java +++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoBaseMessageSerializerV1d0Test.java @@ -30,7 +30,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree; import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.io.AbstractIoRegistry; -import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoClassResolver; +import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoClassResolverV1d0; import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; @@ -560,7 +560,7 @@ public class GryoBaseMessageSerializerV1d0Test { } } - public static class ErrorOnlyClassResolver extends GryoClassResolver { + public static class ErrorOnlyClassResolver extends GryoClassResolverV1d0 { @Override public Registration getRegistration(Class clazz) { throw new RuntimeException("Registration is not allowed with this ClassResolver - it is not a good implementation"); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc9a87b3/gremlin-tools/gremlin-io-test/pom.xml ---------------------------------------------------------------------- diff --git a/gremlin-tools/gremlin-io-test/pom.xml b/gremlin-tools/gremlin-io-test/pom.xml index 60a56dc..afdc79b 100644 --- a/gremlin-tools/gremlin-io-test/pom.xml +++ b/gremlin-tools/gremlin-io-test/pom.xml @@ -168,7 +168,7 @@ writeSupportedV1Objects = { writer, mapper -> } mapper = GraphSONMapper.build(). - addRegistry(TinkerIoRegistry.instance()). + addRegistry(TinkerIoRegistryV1d0.instance()). addCustomModule(new AbstractGraphSONMessageSerializerV1d0.GremlinServerModule()). version(GraphSONVersion.V1_0).create().createMapper() http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc9a87b3/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_3_0/metrics-v3d0.kryo ---------------------------------------------------------------------- diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_3_0/metrics-v3d0.kryo b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_3_0/metrics-v3d0.kryo index c098e38..f65dd63 100644 Binary files a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_3_0/metrics-v3d0.kryo and b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_3_0/metrics-v3d0.kryo differ http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc9a87b3/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_3_0/traversalmetrics-v3d0.kryo ---------------------------------------------------------------------- diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_3_0/traversalmetrics-v3d0.kryo b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_3_0/traversalmetrics-v3d0.kryo index 1aee9e9..5ec44fd 100644 Binary files a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_3_0/traversalmetrics-v3d0.kryo and b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_3_0/traversalmetrics-v3d0.kryo differ http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc9a87b3/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java ---------------------------------------------------------------------- diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java index ca11e17..d90ff56 100644 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java +++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java @@ -37,7 +37,7 @@ import org.apache.tinkerpop.gremlin.structure.io.Mapper; import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader; import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter; import org.apache.tinkerpop.gremlin.structure.io.graphson.TypeInfo; -import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoClassResolver; +import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoClassResolverV1d0; import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper; import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter; import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; @@ -655,7 +655,7 @@ public class TinkerGraphTest { } } - public static class CustomClassResolver extends GryoClassResolver { + public static class CustomClassResolver extends GryoClassResolverV1d0 { private ColorToTinkerGraphSerializer colorToGraphSerializer = new ColorToTinkerGraphSerializer(); public Registration getRegistration(final Class clazz) {