You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2016/08/23 18:14:54 UTC

tinkerpop git commit: python graphson.py now uses gremlin:int32 and gremlin:int64 for number typing and I was able to expose more tests. very cool.

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1278 e5801281f -> 1c0e2629a


python graphson.py now uses gremlin:int32 and gremlin:int64 for number typing and I was able to expose more tests. very cool.


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

Branch: refs/heads/TINKERPOP-1278
Commit: 1c0e2629ab7247ebb135a56f96d0ff9d3952c02a
Parents: e580128
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue Aug 23 12:14:37 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue Aug 23 12:14:47 2016 -0600

----------------------------------------------------------------------
 .../main/jython/gremlin_python/process/graphson.py | 17 ++++++++++++++++-
 .../gremlin/python/jsr223/PythonProvider.java      |  2 --
 .../TinkerGraphGraphSONTranslatorProvider.java     |  2 --
 3 files changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1c0e2629/gremlin-python/src/main/jython/gremlin_python/process/graphson.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/graphson.py b/gremlin-python/src/main/jython/gremlin_python/process/graphson.py
index 7949ca9..5ebbb00 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/graphson.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/graphson.py
@@ -21,6 +21,8 @@ import json
 from abc import abstractmethod
 from aenum import Enum
 from types import FunctionType
+from types import LongType
+from types import IntType
 
 from .traversal import Binding
 from .traversal import Bytecode
@@ -28,6 +30,7 @@ from .traversal import P
 from .traversal import Traversal
 from .. import statics
 
+
 class GraphSONWriter(object):
     @staticmethod
     def _dictify(object):
@@ -121,6 +124,16 @@ class LambdaSerializer(GraphSONSerializer):
         return {_SymbolHelper._TYPE: _SymbolHelper.prefix("lambda"), _SymbolHelper._VALUE: dict}
 
 
+class NumberSerializer(GraphSONSerializer):
+    def _dictify(self, number):
+        if isinstance(number, long):
+            return {_SymbolHelper._TYPE: _SymbolHelper.prefix("int64"), _SymbolHelper._VALUE: number}
+        elif isinstance(number, int):
+            return {_SymbolHelper._TYPE: _SymbolHelper.prefix("int32"), _SymbolHelper._VALUE: number}
+        else:
+            return number
+
+
 class TraversalSerializer(BytecodeSerializer):
     def _dictify(self, traversal):
         return BytecodeSerializer._dictify(self, traversal.bytecode)
@@ -148,5 +161,7 @@ serializers = {
     P: PSerializer(),
     Enum: EnumSerializer(),
     FunctionType: LambdaSerializer(),
-    Traversal: TraversalSerializer()
+    Traversal: TraversalSerializer(),
+    LongType: NumberSerializer(),
+    IntType: NumberSerializer()
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1c0e2629/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
index 2c26084..e98a044 100644
--- a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
@@ -73,8 +73,6 @@ public class PythonProvider extends AbstractGraphProvider {
             "g_VXlistXv1_v2_v3XX_name",
             "g_V_hasLabelXpersonX_asXpX_VXsoftwareX_addInEXuses_pX",
             "g_VXv1X_hasXage_gt_30X",
-            "g_V_chooseXout_countX_optionX2L__nameX_optionX3L__valueMapX",
-            "g_V_branchXlabelX_optionXperson__ageX_optionXsoftware__langX_optionXsoftware__nameX",
             //
             PageRankTest.Traversals.class.getCanonicalName(),
             ProgramTest.Traversals.class.getCanonicalName(),

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1c0e2629/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/TinkerGraphGraphSONTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/TinkerGraphGraphSONTranslatorProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/TinkerGraphGraphSONTranslatorProvider.java
index 4b5878f..3967d96 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/TinkerGraphGraphSONTranslatorProvider.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/TinkerGraphGraphSONTranslatorProvider.java
@@ -53,8 +53,6 @@ public class TinkerGraphGraphSONTranslatorProvider extends TinkerGraphProvider {
             "g_VXlistXv1_v2_v3XX_name",
             "g_V_hasLabelXpersonX_asXpX_VXsoftwareX_addInEXuses_pX",
             "g_VXv1X_hasXage_gt_30X",
-            "g_V_chooseXout_countX_optionX2L__nameX_optionX3L__valueMapX",
-            "g_V_branchXlabelX_optionXperson__ageX_optionXsoftware__langX_optionXsoftware__nameX",
             //
             PageRankTest.Traversals.class.getCanonicalName(),
             ProgramTest.Traversals.class.getCanonicalName(),