tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ok...@apache.org
Subject tinkerpop git commit: stuck in a total GraphSON hole. I can't register Operator enum without everything breaking. This commit is up to Operator serialization not working -- everyhing else is fine.
Date Tue, 23 Aug 2016 16:50:56 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1278 e6f4cfdf9 -> e4c750d2a


stuck in a total GraphSON hole. I can't register Operator enum without everything breaking.
This commit is up to Operator serialization not working -- everyhing else is fine.


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

Branch: refs/heads/TINKERPOP-1278
Commit: e4c750d2a7f18e70f155e70e68832be8b7c622a2
Parents: e6f4cfd
Author: Marko A. Rodriguez <okrammarko@gmail.com>
Authored: Tue Aug 23 10:50:50 2016 -0600
Committer: Marko A. Rodriguez <okrammarko@gmail.com>
Committed: Tue Aug 23 10:50:50 2016 -0600

----------------------------------------------------------------------
 .../structure/io/graphson/GraphSONModule.java   |  59 +++--
 .../structure/io/graphson/GraphSONTokens.java   |  12 +-
 .../GraphSONTraversalSerializersV2d0.java       | 245 +++++++------------
 .../process/traversal/step/filter/IsTest.java   |   4 +-
 .../io/graphson/GraphSONTranslator.java         |   6 +-
 5 files changed, 143 insertions(+), 183 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e4c750d2/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONModule.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONModule.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONModule.java
index 21a48f3..c40af5c 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONModule.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONModule.java
@@ -29,7 +29,9 @@ import org.apache.tinkerpop.gremlin.process.traversal.Scope;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
+import org.apache.tinkerpop.gremlin.process.traversal.util.AndP;
 import org.apache.tinkerpop.gremlin.process.traversal.util.Metrics;
+import org.apache.tinkerpop.gremlin.process.traversal.util.OrP;
 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;
@@ -60,6 +62,7 @@ import java.time.ZoneOffset;
 import java.time.ZonedDateTime;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.stream.Stream;
 
 /**
  * The set of serializers that handle the core graph interfaces.  These serializers support
normalization which
@@ -117,6 +120,21 @@ abstract class GraphSONModule extends TinkerPopJacksonModule {
             put(TraversalMetrics.class, "traversalmetrics");
             put(Traverser.class, "traverser");
             put(Tree.class, "tree");
+            put(Bytecode.class, "bytecode");
+            put(Bytecode.Binding.class, "binding");
+            put(AndP.class, "P");
+            put(OrP.class, "P");
+            put(P.class, "P");
+            Stream.of(
+                    VertexProperty.Cardinality.values(),
+                    Column.values(),
+                    Direction.values(),
+                    // Operator.values(),
+                    Order.values(),
+                    Pop.values(),
+                    SackFunctions.Barrier.values(),
+                    Scope.values(),
+                    T.values()).flatMap(Stream::of).forEach(e -> put(e.getClass(), e.getDeclaringClass().getSimpleName()));
         }};
 
         /**
@@ -165,15 +183,15 @@ abstract class GraphSONModule extends TinkerPopJacksonModule {
             // TODO: review (added for integration with new GraphSON model for GLV bytecode)
             addSerializer(Traversal.class, new GraphSONTraversalSerializersV2d0.TraversalJacksonSerializer());
             addSerializer(Bytecode.class, new GraphSONTraversalSerializersV2d0.BytecodeJacksonSerializer());
-            addSerializer(VertexProperty.Cardinality.class, new GraphSONTraversalSerializersV2d0.EnumJacksonSerializer());
-            addSerializer(Column.class, new GraphSONTraversalSerializersV2d0.EnumJacksonSerializer());
-            addSerializer(Direction.class, new GraphSONTraversalSerializersV2d0.EnumJacksonSerializer());
-            addSerializer(SackFunctions.Barrier.class, new GraphSONTraversalSerializersV2d0.EnumJacksonSerializer());
-            addSerializer(Operator.class, new GraphSONTraversalSerializersV2d0.EnumJacksonSerializer());
-            addSerializer(Order.class, new GraphSONTraversalSerializersV2d0.EnumJacksonSerializer());
-            addSerializer(Pop.class, new GraphSONTraversalSerializersV2d0.EnumJacksonSerializer());
-            addSerializer(Scope.class, new GraphSONTraversalSerializersV2d0.EnumJacksonSerializer());
-            addSerializer(T.class, new GraphSONTraversalSerializersV2d0.EnumJacksonSerializer());
+            Stream.of(VertexProperty.Cardinality.values(),
+                    Column.values(),
+                    //Operator.values(),
+                    Direction.values(),
+                    Order.values(),
+                    Pop.values(),
+                    SackFunctions.Barrier.values(),
+                    Scope.values(),
+                    T.values()).flatMap(Stream::of).forEach(e -> addSerializer(e.getClass(),
new GraphSONTraversalSerializersV2d0.EnumJacksonSerializer()));
             addSerializer(P.class, new GraphSONTraversalSerializersV2d0.PJacksonSerializer());
             addSerializer(Lambda.class, new GraphSONTraversalSerializersV2d0.LambdaJacksonSerializer());
             addSerializer(Bytecode.Binding.class, new GraphSONTraversalSerializersV2d0.BindingJacksonSerializer());
@@ -208,10 +226,18 @@ abstract class GraphSONModule extends TinkerPopJacksonModule {
 
             // traversal
             addDeserializer(Bytecode.class, new GraphSONTraversalSerializersV2d0.BytecodeJacksonDeserializer());
-            addDeserializer(Enum.class, new GraphSONTraversalSerializersV2d0.EnumJacksonDeserializer());
+            addDeserializer(Bytecode.Binding.class, new GraphSONTraversalSerializersV2d0.BindingJacksonDeserializer());
+            Stream.of(VertexProperty.Cardinality.values(),
+                    Column.values(),
+                    Direction.values(),
+                    //Operator.values(),
+                    Order.values(),
+                    Pop.values(),
+                    SackFunctions.Barrier.values(),
+                    Scope.values(),
+                    T.values()).flatMap(Stream::of).forEach(e -> addDeserializer(e.getClass(),
new GraphSONTraversalSerializersV2d0.EnumJacksonDeserializer(e)));
             addDeserializer(P.class, new GraphSONTraversalSerializersV2d0.PJacksonDeserializer());
             addDeserializer(Lambda.class, new GraphSONTraversalSerializersV2d0.LambdaJacksonDeserializer());
-            addDeserializer(Bytecode.Binding.class, new GraphSONTraversalSerializersV2d0.BindingJacksonDeserializer());
             addDeserializer(Traverser.class, new GraphSONTraversalSerializersV2d0.TraverserJacksonDeserializer());
         }
 
@@ -231,7 +257,8 @@ abstract class GraphSONModule extends TinkerPopJacksonModule {
 
         static final class Builder implements GraphSONModuleBuilder {
 
-            private Builder() {}
+            private Builder() {
+            }
 
             @Override
             public GraphSONModule create(final boolean normalize) {
@@ -261,7 +288,7 @@ abstract class GraphSONModule extends TinkerPopJacksonModule {
             addSerializer(Path.class, new GraphSONSerializersV1d0.PathJacksonSerializer());
             addSerializer(DirectionalStarGraph.class, new StarGraphGraphSONSerializerV1d0(normalize));
             addSerializer(Tree.class, new GraphSONSerializersV1d0.TreeJacksonSerializer());
-           
+
             // java.util
             addSerializer(Map.Entry.class, new JavaUtilSerializersV1d0.MapEntryJacksonSerializer());
 
@@ -296,7 +323,7 @@ abstract class GraphSONModule extends TinkerPopJacksonModule {
 
             // traversal
             // TODO: review (added for integration with new GraphSON model for GLV bytecode)
-            addSerializer(Traversal.class, new GraphSONTraversalSerializersV2d0.TraversalJacksonSerializer());
+            /*addSerializer(Traversal.class, new GraphSONTraversalSerializersV2d0.TraversalJacksonSerializer());
             addSerializer(Bytecode.class, new GraphSONTraversalSerializersV2d0.BytecodeJacksonSerializer());
             addSerializer(VertexProperty.Cardinality.class, new GraphSONTraversalSerializersV2d0.EnumJacksonSerializer());
             addSerializer(Column.class, new GraphSONTraversalSerializersV2d0.EnumJacksonSerializer());
@@ -310,10 +337,10 @@ abstract class GraphSONModule extends TinkerPopJacksonModule {
             addSerializer(P.class, new GraphSONTraversalSerializersV2d0.PJacksonSerializer());
             addSerializer(Lambda.class, new GraphSONTraversalSerializersV2d0.LambdaJacksonSerializer());
             addSerializer(Bytecode.Binding.class, new GraphSONTraversalSerializersV2d0.BindingJacksonSerializer());
-            addSerializer(Traverser.class, new GraphSONTraversalSerializersV2d0.TraverserSerializer());
+            addSerializer(Traverser.class, new GraphSONTraversalSerializersV2d0.TraverserSerializer());*/
             // -- deserializers for traversal
             addDeserializer(Bytecode.class, new GraphSONTraversalSerializersV2d0.BytecodeJacksonDeserializer());
-            addDeserializer(Enum.class, new GraphSONTraversalSerializersV2d0.EnumJacksonDeserializer());
+            //addDeserializer(Enum.class, new GraphSONTraversalSerializersV2d0.EnumJacksonDeserializer());
             addDeserializer(P.class, new GraphSONTraversalSerializersV2d0.PJacksonDeserializer());
             addDeserializer(Lambda.class, new GraphSONTraversalSerializersV2d0.LambdaJacksonDeserializer());
             addDeserializer(Bytecode.Binding.class, new GraphSONTraversalSerializersV2d0.BindingJacksonDeserializer());

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e4c750d2/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTokens.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTokens.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTokens.java
index 6833d11..7a50b63 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTokens.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTokens.java
@@ -23,7 +23,8 @@ package org.apache.tinkerpop.gremlin.structure.io.graphson;
  */
 public final class GraphSONTokens {
 
-    private GraphSONTokens() {}
+    private GraphSONTokens() {
+    }
 
     public static final String CLASS = "@class";
     public static final String VALUETYPE = "@type";
@@ -64,4 +65,13 @@ public final class GraphSONTokens {
     public static final String ANNOTATIONS = "annotations";
 
     public static final String BULK = "bulk";
+
+    public static final String SCRIPT = "script";
+    public static final String LANGUAGE = "language";
+    public static final String ARGUMENTS = "arguments";
+    public static final String PREDICATE = "predicate";
+    public static final String AND = "and";
+    public static final String OR = "or";
+    public static final String SOURCE = "source";
+    public static final String STEP = "step";
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e4c750d2/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTraversalSerializersV2d0.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTraversalSerializersV2d0.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTraversalSerializersV2d0.java
index d768d8e..0741b05 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTraversalSerializersV2d0.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTraversalSerializersV2d0.java
@@ -21,37 +21,24 @@ package org.apache.tinkerpop.gremlin.structure.io.graphson;
 
 import org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser;
 import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
-import org.apache.tinkerpop.gremlin.process.traversal.Operator;
-import org.apache.tinkerpop.gremlin.process.traversal.Order;
 import org.apache.tinkerpop.gremlin.process.traversal.P;
-import org.apache.tinkerpop.gremlin.process.traversal.Pop;
-import org.apache.tinkerpop.gremlin.process.traversal.SackFunctions;
-import org.apache.tinkerpop.gremlin.process.traversal.Scope;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 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.OrP;
-import org.apache.tinkerpop.gremlin.structure.Column;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
 import org.apache.tinkerpop.gremlin.util.function.Lambda;
 import org.apache.tinkerpop.shaded.jackson.core.JsonGenerator;
 import org.apache.tinkerpop.shaded.jackson.core.JsonParser;
 import org.apache.tinkerpop.shaded.jackson.core.JsonProcessingException;
-import org.apache.tinkerpop.shaded.jackson.core.ObjectCodec;
 import org.apache.tinkerpop.shaded.jackson.databind.DeserializationContext;
-import org.apache.tinkerpop.shaded.jackson.databind.JsonNode;
 import org.apache.tinkerpop.shaded.jackson.databind.SerializerProvider;
 import org.apache.tinkerpop.shaded.jackson.databind.deser.std.StdDeserializer;
-import org.apache.tinkerpop.shaded.jackson.databind.jsontype.TypeSerializer;
-import org.apache.tinkerpop.shaded.jackson.databind.node.JsonNodeType;
 import org.apache.tinkerpop.shaded.jackson.databind.ser.std.StdScalarSerializer;
 import org.apache.tinkerpop.shaded.jackson.databind.ser.std.StdSerializer;
 
 import java.io.IOException;
-import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
@@ -82,7 +69,7 @@ final class GraphSONTraversalSerializersV2d0 {
 
     }
 
-    final static class BytecodeJacksonSerializer extends StdSerializer<Bytecode> {
+    final static class BytecodeJacksonSerializer extends StdScalarSerializer<Bytecode>
{
 
         public BytecodeJacksonSerializer() {
             super(Bytecode.class);
@@ -92,9 +79,8 @@ final class GraphSONTraversalSerializersV2d0 {
         public void serialize(final Bytecode bytecode, final JsonGenerator jsonGenerator,
final SerializerProvider serializerProvider)
                 throws IOException {
             jsonGenerator.writeStartObject();
-            jsonGenerator.writeStringField(GraphSONTokens.VALUETYPE, "Bytecode");
             if (bytecode.getSourceInstructions().iterator().hasNext()) {
-                jsonGenerator.writeArrayFieldStart("source");
+                jsonGenerator.writeArrayFieldStart(GraphSONTokens.SOURCE);
                 for (final Bytecode.Instruction instruction : bytecode.getSourceInstructions())
{
                     jsonGenerator.writeStartArray();
                     jsonGenerator.writeString(instruction.getOperator());
@@ -106,7 +92,7 @@ final class GraphSONTraversalSerializersV2d0 {
                 jsonGenerator.writeEndArray();
             }
             if (bytecode.getStepInstructions().iterator().hasNext()) {
-                jsonGenerator.writeArrayFieldStart("step");
+                jsonGenerator.writeArrayFieldStart(GraphSONTokens.STEP);
                 for (final Bytecode.Instruction instruction : bytecode.getStepInstructions())
{
                     jsonGenerator.writeStartArray();
                     jsonGenerator.writeString(instruction.getOperator());
@@ -122,7 +108,7 @@ final class GraphSONTraversalSerializersV2d0 {
         }
     }
 
-    final static class EnumJacksonSerializer extends StdSerializer<Enum> {
+    static class EnumJacksonSerializer extends StdScalarSerializer<Enum> {
 
         public EnumJacksonSerializer() {
             super(Enum.class);
@@ -131,15 +117,12 @@ final class GraphSONTraversalSerializersV2d0 {
         @Override
         public void serialize(final Enum enumInstance, final JsonGenerator jsonGenerator,
final SerializerProvider serializerProvider)
                 throws IOException {
-            jsonGenerator.writeStartObject();
-            jsonGenerator.writeObjectField(GraphSONTokens.VALUETYPE, enumInstance.getDeclaringClass().getSimpleName());
-            jsonGenerator.writeObjectField(GraphSONTokens.VALUE, enumInstance.name());
-            jsonGenerator.writeEndObject();
+            jsonGenerator.writeString(enumInstance.name());
         }
 
     }
 
-    final static class PJacksonSerializer extends StdSerializer<P> {
+    final static class PJacksonSerializer extends StdScalarSerializer<P> {
 
         public PJacksonSerializer() {
             super(P.class);
@@ -149,15 +132,34 @@ final class GraphSONTraversalSerializersV2d0 {
         public void serialize(final P p, final JsonGenerator jsonGenerator, final SerializerProvider
serializerProvider)
                 throws IOException {
             jsonGenerator.writeStartObject();
-            jsonGenerator.writeStringField(GraphSONTokens.VALUETYPE, "P");
-            jsonGenerator.writeStringField("predicate", p instanceof ConnectiveP ? p instanceof
AndP ? "and" : "or" : p.getBiPredicate().toString());
-            jsonGenerator.writeObjectField(GraphSONTokens.VALUE, p instanceof ConnectiveP
? ((ConnectiveP) p).getPredicates() : p.getValue());
+            jsonGenerator.writeStringField(GraphSONTokens.PREDICATE,
+                    p instanceof ConnectiveP ?
+                            p instanceof AndP ?
+                                    GraphSONTokens.AND :
+                                    GraphSONTokens.OR :
+                            p.getBiPredicate().toString());
+            if (p instanceof ConnectiveP) {
+                jsonGenerator.writeArrayFieldStart(GraphSONTokens.VALUE);
+                for (final P<?> predicate : ((ConnectiveP<?>) p).getPredicates())
{
+                    jsonGenerator.writeObject(predicate);
+                }
+                jsonGenerator.writeEndArray();
+            } else {
+                if (p.getValue() instanceof Collection) {
+                    jsonGenerator.writeArrayFieldStart(GraphSONTokens.VALUE);
+                    for (final Object object : (Collection) p.getValue()) {
+                        jsonGenerator.writeObject(object);
+                    }
+                    jsonGenerator.writeEndArray();
+                } else
+                    jsonGenerator.writeObjectField(GraphSONTokens.VALUE, p.getValue());
+            }
             jsonGenerator.writeEndObject();
         }
 
     }
 
-    final static class LambdaJacksonSerializer extends StdSerializer<Lambda> {
+    final static class LambdaJacksonSerializer extends StdScalarSerializer<Lambda>
{
 
         public LambdaJacksonSerializer() {
             super(Lambda.class);
@@ -167,16 +169,15 @@ final class GraphSONTraversalSerializersV2d0 {
         public void serialize(final Lambda lambda, final JsonGenerator jsonGenerator, final
SerializerProvider serializerProvider)
                 throws IOException {
             jsonGenerator.writeStartObject();
-            jsonGenerator.writeStringField(GraphSONTokens.VALUETYPE, "Lambda");
-            jsonGenerator.writeStringField(GraphSONTokens.VALUE, lambda.getLambdaScript());
-            jsonGenerator.writeStringField("language", lambda.getLambdaLanguage());
-            jsonGenerator.writeNumberField("arguments", lambda.getLambdaArguments());
+            jsonGenerator.writeStringField(GraphSONTokens.SCRIPT, lambda.getLambdaScript());
+            jsonGenerator.writeStringField(GraphSONTokens.LANGUAGE, lambda.getLambdaLanguage());
+            jsonGenerator.writeNumberField(GraphSONTokens.ARGUMENTS, lambda.getLambdaArguments());
             jsonGenerator.writeEndObject();
         }
 
     }
 
-    final static class BindingJacksonSerializer extends StdSerializer<Bytecode.Binding>
{
+    final static class BindingJacksonSerializer extends StdScalarSerializer<Bytecode.Binding>
{
 
         public BindingJacksonSerializer() {
             super(Bytecode.Binding.class);
@@ -186,8 +187,7 @@ final class GraphSONTraversalSerializersV2d0 {
         public void serialize(final Bytecode.Binding binding, final JsonGenerator jsonGenerator,
final SerializerProvider serializerProvider)
                 throws IOException {
             jsonGenerator.writeStartObject();
-            jsonGenerator.writeStringField(GraphSONTokens.VALUETYPE, "Binding");
-            jsonGenerator.writeStringField("variable", binding.variable());
+            jsonGenerator.writeStringField(GraphSONTokens.KEY, binding.variable());
             jsonGenerator.writeObjectField(GraphSONTokens.VALUE, binding.value());
             jsonGenerator.writeEndObject();
         }
@@ -214,185 +214,106 @@ final class GraphSONTraversalSerializersV2d0 {
     // DESERIALIZERS //
     //////////////////
 
-    final static class BytecodeJacksonDeserializer extends StdDeserializer<Bytecode>
{
+    final static class BytecodeJacksonDeserializer extends AbstractObjectDeserializer<Bytecode>
{
 
         public BytecodeJacksonDeserializer() {
             super(Bytecode.class);
         }
 
-        private static void processInstruction(final JsonNode instruction, final ObjectCodec
oc, final Bytecode bytecode, final boolean source) throws IOException {
-            final String operator = instruction.get(0).textValue();
-            final List<Object> arguments = new ArrayList<>();
-            for (int j = 1; j < instruction.size(); j++) {
-                final JsonNode argument = instruction.get(j);
-                if (argument.getNodeType().equals(JsonNodeType.OBJECT)) {
-                    if (argument.has(GraphSONTokens.VALUETYPE)) {
-                        final String type = argument.get(GraphSONTokens.VALUETYPE).textValue();
-                        if (type.equals("Bytecode"))
-                            arguments.add(oc.readValue(argument.traverse(oc), Bytecode.class));
-                        else if (type.equals("Binding"))
-                            arguments.add(oc.readValue(argument.traverse(oc), Bytecode.Binding.class));
-                        else if (type.equals("P"))
-                            arguments.add(oc.readValue(argument.traverse(oc), P.class));
-                        else if (type.equals("Lambda"))
-                            arguments.add(oc.readValue(argument.traverse(oc), Lambda.class));
-                        else
-                            arguments.add(oc.readValue(argument.traverse(oc), Enum.class));
-                    } else {
-                        arguments.add(oc.readValue(argument.traverse(oc), Object.class));
// TODO: vertices/edges/etc. don't get processed correctly
-                    }
-                } else if (argument.getNodeType().equals(JsonNodeType.NUMBER)) {
-                    arguments.add(argument.asInt()); // TODO
-                } else if (argument.getNodeType().equals(JsonNodeType.STRING)) {
-                    arguments.add(argument.textValue());
-                } else if (argument.getNodeType().equals(JsonNodeType.BOOLEAN)) {
-                    arguments.add(argument.booleanValue());
-                } else if (argument.getNodeType().equals(JsonNodeType.ARRAY)) {
-                    final List<Object> list = new ArrayList<>();
-                    for (int k = 0; k < argument.size(); k++) {
-                        list.add(oc.readValue(argument.get(k).traverse(oc), Object.class));
-                        //list.add(argument.get(k).textValue());
-                    }
-                    arguments.add(list);
-                } else {
-                    throw new IOException("Unknown argument: " + argument);
-                }
-            }
-            if (source)
-                bytecode.addSource(operator, arguments.toArray());
-            else
-                bytecode.addStep(operator, arguments.toArray());
-        }
-
         @Override
-        public Bytecode deserialize(final JsonParser jsonParser, final DeserializationContext
deserializationContext) throws IOException, JsonProcessingException {
+        Bytecode createObject(final Map<String, Object> data) {
             final Bytecode bytecode = new Bytecode();
-            final ObjectCodec oc = jsonParser.getCodec();
-            final JsonNode node = oc.readTree(jsonParser);
-            assert node.get(GraphSONTokens.VALUETYPE).textValue().equals("Bytecode");
-            if (node.has("source")) {
-                final JsonNode source = node.get("source");
-                for (int i = 0; i < source.size(); i++) {
-                    processInstruction(source.get(i), oc, bytecode, true);
+            if (data.containsKey(GraphSONTokens.SOURCE)) {
+                final List<List<Object>> instructions = (List) data.get(GraphSONTokens.SOURCE);
+                for (final List<Object> instruction : instructions) {
+                    bytecode.addSource((String) instruction.get(0), Arrays.copyOfRange(instruction.toArray(),
1, instruction.size()));
                 }
             }
-            if (node.has("step")) {
-                final JsonNode step = node.get("step");
-                for (int i = 0; i < step.size(); i++) {
-                    processInstruction(step.get(i), oc, bytecode, false);
-
+            if (data.containsKey(GraphSONTokens.STEP)) {
+                final List<List<Object>> instructions = (List) data.get(GraphSONTokens.STEP);
+                for (final List<Object> instruction : instructions) {
+                    bytecode.addStep((String) instruction.get(0), Arrays.copyOfRange(instruction.toArray(),
1, instruction.size()));
                 }
             }
             return bytecode;
         }
     }
 
-    final static class EnumJacksonDeserializer extends StdDeserializer<Enum> {
+    final static class EnumJacksonDeserializer<A extends Enum> extends StdDeserializer<A>
{
 
-        public EnumJacksonDeserializer() {
-            super(Enum.class);
+
+        public EnumJacksonDeserializer(final A enumInstance) {
+            super(enumInstance.getDeclaringClass());
         }
 
         @Override
-        public Enum deserialize(final JsonParser jsonParser, final DeserializationContext
deserializationContext) throws IOException, JsonProcessingException {
-
-            final ObjectCodec oc = jsonParser.getCodec();
-            final JsonNode node = oc.readTree(jsonParser);
-            final String type = node.get(GraphSONTokens.VALUETYPE).textValue();
-            if (type.equals("Cardinality"))
-                return VertexProperty.Cardinality.valueOf(node.get(GraphSONTokens.VALUE).textValue());
-            else if (type.equals("Column"))
-                return Column.valueOf(node.get(GraphSONTokens.VALUE).textValue());
-            else if (type.equals("Direction"))
-                return Direction.valueOf(node.get(GraphSONTokens.VALUE).textValue());
-            else if (type.equals("Barrier"))
-                return SackFunctions.Barrier.valueOf(node.get(GraphSONTokens.VALUE).textValue());
-            else if (type.equals("Operator"))
-                return Operator.valueOf(node.get(GraphSONTokens.VALUE).textValue());
-            else if (type.equals("Order"))
-                return Order.valueOf(node.get(GraphSONTokens.VALUE).textValue());
-            else if (type.equals("Pop"))
-                return Pop.valueOf(node.get(GraphSONTokens.VALUE).textValue());
-            else if (type.equals("Scope"))
-                return Scope.valueOf(node.get(GraphSONTokens.VALUE).textValue());
-            else if (type.equals("T"))
-                return T.valueOf(node.get(GraphSONTokens.VALUE).textValue());
-            else
-                throw new IOException("Unknown enum type: " + type);
-
+        public A deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
+            final Class<A> enumClass = (Class<A>) this._valueClass;
+            final String enumName = jsonParser.getText();
+            for (final Enum a : enumClass.getEnumConstants()) {
+                if (a.name().equals(enumName))
+                    return (A) a;
+            }
+            throw new IOException("Unknown enum type: " + enumClass);
         }
+
+
     }
 
-    final static class PJacksonDeserializer extends StdDeserializer<P> {
+    final static class PJacksonDeserializer extends AbstractObjectDeserializer<P> {
 
         public PJacksonDeserializer() {
             super(P.class);
         }
 
         @Override
-        public P deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
-
-            final ObjectCodec oc = jsonParser.getCodec();
-            final JsonNode node = oc.readTree(jsonParser);
-            assert node.get(GraphSONTokens.VALUETYPE).textValue().equals("P");
-            final JsonNode predicate = node.get("predicate");
-            if (predicate.textValue().equals("and") || predicate.textValue().equals("or"))
{
-                final List<P<?>> arguments = new ArrayList<>();
-                for (int i = 0; i < node.get(GraphSONTokens.VALUE).size(); i++) {
-                    arguments.add(oc.readValue(node.get(GraphSONTokens.VALUE).get(i).traverse(oc),
P.class));
-                }
-                return predicate.textValue().equals("and") ? new AndP(arguments) : new OrP(arguments);
+        P createObject(final Map<String, Object> data) {
+            final String predicate = (String) data.get(GraphSONTokens.PREDICATE);
+            final Object value = data.get(GraphSONTokens.VALUE);
+            if (predicate.equals(GraphSONTokens.AND) || predicate.equals(GraphSONTokens.OR))
{
+                return predicate.equals(GraphSONTokens.AND) ? new AndP((List<P>) value)
: new OrP((List<P>) value);
             } else {
                 try {
-                    final Object argument = oc.readValue(node.get(GraphSONTokens.VALUE).traverse(oc),
Object.class);
-                    return (P) P.class.getMethod(predicate.textValue(), argument instanceof
Collection ? Collection.class : Object.class).invoke(null, argument); // TODO: number stuff,
eh?
+                    return (P) P.class.getMethod(predicate, value instanceof Collection ?
Collection.class : Object.class).invoke(null, value); // TODO: number stuff, eh?
                 } catch (final Exception e) {
-                    throw new IOException(e.getMessage(), e);
+                    throw new IllegalStateException(e.getMessage(), e);
                 }
             }
         }
     }
 
-    final static class LambdaJacksonDeserializer extends StdDeserializer<Lambda> {
+    final static class LambdaJacksonDeserializer extends AbstractObjectDeserializer<Lambda>
{
 
         public LambdaJacksonDeserializer() {
             super(Lambda.class);
         }
 
         @Override
-        public Lambda deserialize(final JsonParser jsonParser, final DeserializationContext
deserializationContext) throws IOException, JsonProcessingException {
-
-            final ObjectCodec oc = jsonParser.getCodec();
-            final JsonNode node = oc.readTree(jsonParser);
-            assert node.get(GraphSONTokens.VALUETYPE).textValue().equals("Lambda");
-            final String lambdaScript = node.get(GraphSONTokens.VALUE).textValue();
-            final String lambdaLanguage = node.get("language").textValue();
-            final int lambdaArguments = node.get("arguments").intValue();
-            if (-1 == lambdaArguments || lambdaArguments > 2)
-                return new Lambda.UnknownArgLambda(lambdaScript, lambdaLanguage, lambdaArguments);
-            else if (0 == lambdaArguments)
-                return new Lambda.ZeroArgLambda<>(lambdaScript, lambdaLanguage);
-            else if (1 == lambdaArguments)
-                return new Lambda.OneArgLambda<>(lambdaScript, lambdaLanguage);
+        Lambda createObject(final Map<String, Object> data) {
+            final String script = (String) data.get(GraphSONTokens.SCRIPT);
+            final String language = (String) data.get(GraphSONTokens.LANGUAGE);
+            final int arguments = ((Number) data.getOrDefault(GraphSONTokens.ARGUMENTS, -1)).intValue();
+            //
+            if (-1 == arguments || arguments > 2)
+                return new Lambda.UnknownArgLambda(script, language, arguments);
+            else if (0 == arguments)
+                return new Lambda.ZeroArgLambda<>(script, language);
+            else if (1 == arguments)
+                return new Lambda.OneArgLambda<>(script, language);
             else
-                return new Lambda.TwoArgLambda<>(lambdaScript, lambdaLanguage);
+                return new Lambda.TwoArgLambda<>(script, language);
         }
     }
 
-    final static class BindingJacksonDeserializer extends StdDeserializer<Bytecode.Binding>
{
+    final static class BindingJacksonDeserializer extends AbstractObjectDeserializer<Bytecode.Binding>
{
 
         public BindingJacksonDeserializer() {
             super(Bytecode.Binding.class);
         }
 
         @Override
-        public Bytecode.Binding deserialize(final JsonParser jsonParser, final DeserializationContext
deserializationContext) throws IOException, JsonProcessingException {
-            final ObjectCodec oc = jsonParser.getCodec();
-            final JsonNode node = oc.readTree(jsonParser);
-            assert node.get(GraphSONTokens.VALUETYPE).textValue().equals("Binding");
-            final String variable = node.get("variable").textValue();
-            final Object value = oc.readValue(node.get(GraphSONTokens.VALUE).traverse(oc),
Object.class);
-            return new Bytecode.Binding<>(variable, value);
+        Bytecode.Binding createObject(final Map<String, Object> data) {
+            return new Bytecode.Binding<>((String) data.get(GraphSONTokens.KEY), data.get(GraphSONTokens.VALUE));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e4c750d2/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/IsTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/IsTest.java
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/IsTest.java
index 931a1a2..56bdcfa 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/IsTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/IsTest.java
@@ -77,7 +77,7 @@ public abstract class IsTest extends AbstractGremlinProcessTest {
 
     @Test
     @LoadGraphWith(MODERN)
-    public void g_V_hasXinXcreatedX_count_isX1XX_valuesXnameX() {
+    public void g_V_whereXinXcreatedX_count_isX1XX_valuesXnameX() {
         final Traversal<Vertex, String> traversal = get_g_V_whereXinXcreatedX_count_isX1XX_valuesXnameX();
         printTraversalForm(traversal);
         assertTrue(traversal.hasNext());
@@ -87,7 +87,7 @@ public abstract class IsTest extends AbstractGremlinProcessTest {
 
     @Test
     @LoadGraphWith(MODERN)
-    public void g_V_hasXinXcreatedX_count_isXgte_2XX_valuesXnameX() {
+    public void g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX() {
         final Traversal<Vertex, String> traversal = get_g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX();
         printTraversalForm(traversal);
         assertTrue(traversal.hasNext());

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e4c750d2/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/GraphSONTranslator.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/GraphSONTranslator.java
b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/GraphSONTranslator.java
index 5b63082..d113475 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/GraphSONTranslator.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/GraphSONTranslator.java
@@ -25,7 +25,9 @@ import org.apache.tinkerpop.gremlin.process.traversal.Translator;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.util.BytecodeHelper;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
 
 import java.io.ByteArrayInputStream;
@@ -37,8 +39,8 @@ import java.io.ByteArrayOutputStream;
 final class GraphSONTranslator<S extends TraversalSource, T extends Traversal.Admin<?,
?>> implements Translator.StepTranslator<S, T> {
 
     private final JavaTranslator<S, T> wrappedTranslator;
-    private final GraphSONWriter writer = GraphSONWriter.build().create();
-    private final GraphSONReader reader = GraphSONReader.build().create();
+    private final GraphSONWriter writer = GraphSONWriter.build().mapper(GraphSONMapper.build().version(GraphSONVersion.V2_0).create()).create();
+    private final GraphSONReader reader = GraphSONReader.build().mapper(GraphSONMapper.build().version(GraphSONVersion.V2_0).create()).create();
 
     public GraphSONTranslator(final JavaTranslator<S, T> wrappedTranslator) {
         this.wrappedTranslator = wrappedTranslator;


Mime
View raw message