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/08/19 13:37:23 UTC

[tinkerpop] 19/33: Added BulkSet support to 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 8cda34ca0ec61444b9ce3767090173c9ee09674d
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Fri Aug 2 07:34:58 2019 -0400

    Added BulkSet support to python graphbinary
---
 docs/src/dev/io/graphbinary.asciidoc               |  4 ++--
 .../gremlin_python/structure/io/graphbinaryV1.py   | 28 ++++++++++++++++++----
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/docs/src/dev/io/graphbinary.asciidoc b/docs/src/dev/io/graphbinary.asciidoc
index 5fa4afe..0262387 100644
--- a/docs/src/dev/io/graphbinary.asciidoc
+++ b/docs/src/dev/io/graphbinary.asciidoc
@@ -532,8 +532,8 @@ Where:
 `{type_code}{type_info}{value_flag}{value}` followed by the "bulk" which is a `Long` value.
 
 If the implementing language does not have a `BulkSet` object to deserialize into, this format can be coerced to a
-`List` and still be considered compliant with Gremlin. Simply create "expand the bulk" by adding the item to the `List`
-the number of times specified by the bulk.
+`List` and still be considered compliant with Gremlin. Simply "expand the bulk" by adding the item to the `List` the
+number of times specified by the bulk.
 
 ==== Tree
 
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 2f64ba2..e282dda 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
@@ -58,7 +58,7 @@ class DataType(Enum):
     string = 0x03
     date = 0x04
     timestamp = 0x05
-    clazz = 0x06
+    clazz = 0x06                  #todo
     double = 0x07
     float = 0x08
     list = 0x09
@@ -86,14 +86,14 @@ class DataType(Enum):
     scope = 0x1f
     t = 0x20
     traverser = 0x21
-    bigdecimal = 0x22    #todo
-    biginteger = 0x23    #todo
+    bigdecimal = 0x22             #todo
+    biginteger = 0x23             #todo
     byte = 0x24
     bytebuffer = 0x25
-    short = 0x26         #todo?
+    short = 0x26                  #todo?
     boolean = 0x27
     textp = 0x28
-    traversalstrategy = 0x29
+    traversalstrategy = 0x29      #todo
     bulkset = 0x2a
     tree = 0x2b
     metrics = 0x2c
@@ -791,3 +791,21 @@ class TextPIO(_GraphBinaryTypeIO):
             ba.extend(a)
 
         return ba
+
+
+class BulkSetIO(_GraphBinaryTypeIO):
+
+    graphbinary_type = DataType.bulkset
+
+    @classmethod
+    def objectify(cls, buff, reader):
+        size = cls.read_int(buff)
+        the_list = []
+        while size > 0:
+            itm = reader.readObject(buff)
+            bulk = cls.read_int(buff)
+            for y in range(bulk):
+                the_list.append(itm)            
+            size = size - 1
+
+        return the_list