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 2019/09/04 13:22:37 UTC
[tinkerpop] 27/40: Fixed lambda serialization in python graphbinary
This is an automated email from the ASF dual-hosted git repository.
spmallette pushed a commit to branch TINKERPOP-2279
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 7a59fb8c2630d329d367eb6465c38d4ce7babcd8
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Tue Aug 13 15:56:09 2019 -0400
Fixed lambda serialization in python graphbinary
---
.../src/main/jython/gremlin_python/structure/io/graphbinaryV1.py | 6 +++---
.../src/main/jython/tests/driver/test_driver_remote_connection.py | 4 ++++
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py
index a8eb853..d9844e9 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py
@@ -735,12 +735,12 @@ class LambdaIO(_GraphBinaryTypeIO):
@classmethod
def dictify(cls, obj, writer, as_value=False, nullable=True):
- ba = bytearray() if as_value else bytearray([cls.graphbinary_type.value])
+ ba = bytearray()
lambda_result = obj()
script = lambda_result if isinstance(lambda_result, str) else lambda_result[0]
language = statics.default_lambda_language if isinstance(lambda_result, str) else lambda_result[1]
- ba.extend(cls.string_as_bytes(language))
+ ba.extend(StringIO.dictify(language, writer, True, False))
script_cleaned = script
script_args = -1
@@ -750,7 +750,7 @@ class LambdaIO(_GraphBinaryTypeIO):
script_cleaned = "lambda " + script
script_args = six.get_function_code(eval(script_cleaned)).co_argcount
- ba.extend(cls.string_as_bytes(script_cleaned))
+ ba.extend(StringIO.dictify(script_cleaned, writer, True, False))
ba.extend(struct.pack(">i", script_args))
return cls.as_bytes(cls.write_as_value(cls.graphbinary_type, as_value), None, nullable, ba)
diff --git a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
index 1c689d9..9073ad6 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
@@ -82,6 +82,10 @@ class TestDriverRemoteConnection(object):
assert 'marko' in results
assert 'vadas' in results
# #
+ results = g.V().has('person', 'name', 'marko').map(lambda: ("it.get().value('name')", "gremlin-groovy")).toList()
+ assert 1 == len(results)
+ assert 'marko' in results
+ # #
# this test just validates that the underscored versions of steps conflicting with Gremlin work
# properly and can be removed when the old steps are removed - TINKERPOP-2272
results = g.V().filter_(__.values('age').sum_().and_(