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 2015/04/28 15:55:47 UTC
incubator-tinkerpop git commit: Renamed GraphSerializer to
GryoSerializers.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master 9fdfdb309 -> 1a3a346d1
Renamed GraphSerializer to GryoSerializers.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/1a3a346d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/1a3a346d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/1a3a346d
Branch: refs/heads/master
Commit: 1a3a346d17a61593b08618e7e72cafe4322a793e
Parents: 9fdfdb3
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Apr 28 09:55:23 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Apr 28 09:55:23 2015 -0400
----------------------------------------------------------------------
.../structure/io/gryo/GraphSerializer.java | 164 -------------------
.../gremlin/structure/io/gryo/GryoMapper.java | 10 +-
.../structure/io/gryo/GryoSerializers.java | 144 ++++++++++++++++
.../gremlin/structure/util/ElementHelper.java | 2 +-
4 files changed, 150 insertions(+), 170 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1a3a346d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GraphSerializer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GraphSerializer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GraphSerializer.java
deleted file mode 100644
index 4a849b0..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GraphSerializer.java
+++ /dev/null
@@ -1,164 +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.Path;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-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.DetachedFactory;
-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.shaded.kryo.Kryo;
-import org.apache.tinkerpop.shaded.kryo.Serializer;
-import org.apache.tinkerpop.shaded.kryo.io.Input;
-import org.apache.tinkerpop.shaded.kryo.io.Output;
-
-/**
- * Class used to serialize graph-based objects such as vertices, edges, properties, and paths.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-class GraphSerializer {
- /**
- * Serializes any {@link Edge} implementation encountered to a {@link DetachedEdge}.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
- static class EdgeSerializer extends Serializer<Edge> {
- @Override
- public void write(final Kryo kryo, final Output output, final Edge edge) {
- kryo.writeClassAndObject(output, DetachedFactory.detach(edge, true));
- }
-
- @Override
- public Edge read(final Kryo kryo, final Input input, final Class<Edge> edgeClass) {
- final Object o = kryo.readClassAndObject(input);
- return (Edge) o;
- }
- }
-
- /**
- * Serializes any {@link Vertex} implementation encountered to an {@link DetachedVertex}.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
- static class VertexSerializer extends Serializer<Vertex> {
- public VertexSerializer() {
- }
-
- @Override
- public void write(final Kryo kryo, final Output output, final Vertex vertex) {
- kryo.writeClassAndObject(output, DetachedFactory.detach(vertex, true));
- }
-
- @Override
- public Vertex read(final Kryo kryo, final Input input, final Class<Vertex> vertexClass) {
- return (Vertex) kryo.readClassAndObject(input);
- }
- }
-
- /**
- * Serializes any {@link Property} implementation encountered to an {@link DetachedProperty}.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
- static class PropertySerializer extends Serializer<Property> {
- public PropertySerializer() {
- }
-
- @Override
- public void write(final Kryo kryo, final Output output, final Property property) {
- kryo.writeClassAndObject(output, DetachedFactory.detach(property));
- }
-
- @Override
- public Property read(final Kryo kryo, final Input input, final Class<Property> propertyClass) {
- return (Property) kryo.readClassAndObject(input);
- }
- }
-
- /**
- * Serializes any {@link VertexProperty} implementation encountered to an {@link DetachedVertexProperty}.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
- static class VertexPropertySerializer extends Serializer<VertexProperty> {
- public VertexPropertySerializer() {
- }
-
- @Override
- public void write(final Kryo kryo, final Output output, final VertexProperty vertexProperty) {
- kryo.writeClassAndObject(output, DetachedFactory.detach(vertexProperty, true));
- }
-
- @Override
- public VertexProperty read(final Kryo kryo, final Input input, final Class<VertexProperty> vertexPropertyClass) {
- return (VertexProperty) kryo.readClassAndObject(input);
- }
- }
-
- /**
- * Serializes any {@link Path} implementation encountered to an {@link DetachedPath}.
- *
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
- static class PathSerializer extends Serializer<Path> {
- public PathSerializer() {
- }
-
- @Override
- public void write(final Kryo kryo, final Output output, final Path path) {
- kryo.writeClassAndObject(output, DetachedFactory.detach(path, false));
- }
-
- @Override
- public Path read(final Kryo kryo, final Input input, final Class<Path> pathClass) {
- return (Path) kryo.readClassAndObject(input);
- }
-
- }
-
- /**
- * Serializes any {@link Traverser} implementation encountered via pre-processing with {@link Traverser.Admin#detach()}.
- *
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
- /*static class TraverserSerializer extends Serializer<Traverser.Admin> {
- public TraverserSerializer() {
- }
-
- @Override
- public void write(final Kryo kryo, final Output output, final Traverser.Admin traverser) {
- gryo.writeClassAndObject(output, traverser.asAdmin().detach());
- }
-
- @Override
- public Traverser.Admin read(final Kryo kryo, final Input input, final Class<Traverser.Admin> traverser) {
- return (Traverser.Admin) gryo.readClassAndObject(input);
- }
-
- }*/
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1a3a346d/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 9297f50..b7f722d 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
@@ -200,11 +200,11 @@ public final class GryoMapper implements Mapper<Kryo> {
add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(StarGraph.class, kryo -> StarGraphSerializer.with(Direction.BOTH), 86)); // ***LAST ID**
- add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Edge.class, kryo -> new GraphSerializer.EdgeSerializer(), 65));
- add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Vertex.class, kryo -> new GraphSerializer.VertexSerializer(), 66));
- add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Property.class, kryo -> new GraphSerializer.PropertySerializer(), 67));
- add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(VertexProperty.class, kryo -> new GraphSerializer.VertexPropertySerializer(), 68));
- add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Path.class, kryo -> new GraphSerializer.PathSerializer(), 59));
+ add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Edge.class, kryo -> new GryoSerializers.EdgeSerializer(), 65));
+ add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Vertex.class, kryo -> new GryoSerializers.VertexSerializer(), 66));
+ add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Property.class, kryo -> new GryoSerializers.PropertySerializer(), 67));
+ add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(VertexProperty.class, kryo -> new GryoSerializers.VertexPropertySerializer(), 68));
+ add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Path.class, kryo -> new GryoSerializers.PathSerializer(), 59));
// skip 55
add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(B_O_Traverser.class, null, 75));
add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(O_Traverser.class, null, 76));
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1a3a346d/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
new file mode 100644
index 0000000..a862efe
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializers.java
@@ -0,0 +1,144 @@
+/*
+ * 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.Path;
+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.DetachedFactory;
+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.shaded.kryo.Kryo;
+import org.apache.tinkerpop.shaded.kryo.Serializer;
+import org.apache.tinkerpop.shaded.kryo.io.Input;
+import org.apache.tinkerpop.shaded.kryo.io.Output;
+
+/**
+ * Class used to serialize graph-based objects such as vertices, edges, properties, and paths. These objects are
+ * "detached" using {@link DetachedFactory} before serialization. These serialize present a generalized way to
+ * serialize the implementations of core interfaces.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+class GryoSerializers {
+ /**
+ * Serializes any {@link Edge} implementation encountered to a {@link DetachedEdge}.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+ static class EdgeSerializer extends Serializer<Edge> {
+ @Override
+ public void write(final Kryo kryo, final Output output, final Edge edge) {
+ kryo.writeClassAndObject(output, DetachedFactory.detach(edge, true));
+ }
+
+ @Override
+ public Edge read(final Kryo kryo, final Input input, final Class<Edge> edgeClass) {
+ final Object o = kryo.readClassAndObject(input);
+ return (Edge) o;
+ }
+ }
+
+ /**
+ * Serializes any {@link Vertex} implementation encountered to an {@link DetachedVertex}.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+ static class VertexSerializer extends Serializer<Vertex> {
+ public VertexSerializer() {
+ }
+
+ @Override
+ public void write(final Kryo kryo, final Output output, final Vertex vertex) {
+ kryo.writeClassAndObject(output, DetachedFactory.detach(vertex, true));
+ }
+
+ @Override
+ public Vertex read(final Kryo kryo, final Input input, final Class<Vertex> vertexClass) {
+ return (Vertex) kryo.readClassAndObject(input);
+ }
+ }
+
+ /**
+ * Serializes any {@link Property} implementation encountered to an {@link DetachedProperty}.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+ static class PropertySerializer extends Serializer<Property> {
+ public PropertySerializer() {
+ }
+
+ @Override
+ public void write(final Kryo kryo, final Output output, final Property property) {
+ kryo.writeClassAndObject(output, DetachedFactory.detach(property));
+ }
+
+ @Override
+ public Property read(final Kryo kryo, final Input input, final Class<Property> propertyClass) {
+ return (Property) kryo.readClassAndObject(input);
+ }
+ }
+
+ /**
+ * Serializes any {@link VertexProperty} implementation encountered to an {@link DetachedVertexProperty}.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+ static class VertexPropertySerializer extends Serializer<VertexProperty> {
+ public VertexPropertySerializer() {
+ }
+
+ @Override
+ public void write(final Kryo kryo, final Output output, final VertexProperty vertexProperty) {
+ kryo.writeClassAndObject(output, DetachedFactory.detach(vertexProperty, true));
+ }
+
+ @Override
+ public VertexProperty read(final Kryo kryo, final Input input, final Class<VertexProperty> vertexPropertyClass) {
+ return (VertexProperty) kryo.readClassAndObject(input);
+ }
+ }
+
+ /**
+ * Serializes any {@link Path} implementation encountered to an {@link DetachedPath}.
+ *
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+ static class PathSerializer extends Serializer<Path> {
+ public PathSerializer() {
+ }
+
+ @Override
+ public void write(final Kryo kryo, final Output output, final Path path) {
+ kryo.writeClassAndObject(output, DetachedFactory.detach(path, false));
+ }
+
+ @Override
+ public Path read(final Kryo kryo, final Input input, final Class<Path> pathClass) {
+ return (Path) kryo.readClassAndObject(input);
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1a3a346d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelper.java
index 9f51761..931f1ae 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelper.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelper.java
@@ -156,7 +156,7 @@ public final class ElementHelper {
.filter(i -> i % 2 == 0)
.filter(i -> !keyToRemove.equals(list.get(i)))
.flatMap(i -> IntStream.of(i, i + 1))
- .mapToObj(list::get)
+ .mapToObj(i -> list.get(i))
.collect(Collectors.toList());
return revised.size() > 0 ? Optional.of(revised.toArray()) : Optional.empty();
}