You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2018/04/24 15:21:15 UTC
[06/24] tinkerpop git commit: TINKERPOP-1936 Implemented bytecode
serialization performance enhancement for GraphSON 3.0
TINKERPOP-1936 Implemented bytecode serialization performance enhancement for GraphSON 3.0
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7e6e9854
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7e6e9854
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7e6e9854
Branch: refs/heads/TINKERPOP-1628
Commit: 7e6e98548625c83ad419737166fe6c679d204468
Parents: b8b46b0
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Apr 20 19:26:05 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Apr 20 19:26:05 2018 -0400
----------------------------------------------------------------------
.../io/graphson/TraversalSerializersV3d0.java | 33 ++++++++++++++------
1 file changed, 23 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7e6e9854/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV3d0.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV3d0.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV3d0.java
index fd11f25..eaa7b0f 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV3d0.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV3d0.java
@@ -252,17 +252,30 @@ final class TraversalSerializersV3d0 {
final Bytecode bytecode = new Bytecode();
while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
- if (jsonParser.getCurrentName().equals(GraphSONTokens.SOURCE)) {
+ final String current = jsonParser.getCurrentName();
+ if (current.equals(GraphSONTokens.SOURCE) || current.equals(GraphSONTokens.STEP)) {
jsonParser.nextToken();
- final List<List<Object>> instructions = deserializationContext.readValue(jsonParser, listListJavaType);
- for (final List<Object> instruction : instructions) {
- bytecode.addSource((String) instruction.get(0), Arrays.copyOfRange(instruction.toArray(), 1, instruction.size()));
- }
- } else if (jsonParser.getCurrentName().equals(GraphSONTokens.STEP)) {
- jsonParser.nextToken();
- final List<List<Object>> instructions = deserializationContext.readValue(jsonParser, listListJavaType);
- for (final List<Object> instruction : instructions) {
- bytecode.addStep((String) instruction.get(0), Arrays.copyOfRange(instruction.toArray(), 1, instruction.size()));
+
+ while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
+
+ // there should be a list now and the first item in the list is always string and is the step name
+ // skip the start array
+ jsonParser.nextToken();
+
+ final String stepName = jsonParser.getText();
+
+ // iterate through the rest of the list for arguments until it gets to the end
+ final List<Object> arguments = new ArrayList<>();
+ while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
+ // we don't know the types here, so let the deserializer figure that business out
+ arguments.add(deserializationContext.readValue(jsonParser, Object.class));
+ }
+
+ // if it's not a "source" then it must be a "step"
+ if (current.equals(GraphSONTokens.SOURCE))
+ bytecode.addSource(stepName, arguments.toArray());
+ else
+ bytecode.addStep(stepName, arguments.toArray());
}
}
}