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 15:58:23 UTC
[tinkerpop] branch TINKERPOP-2279 updated (34d26b0 -> 66d770b)
This is an automated email from the ASF dual-hosted git repository.
spmallette pushed a change to branch TINKERPOP-2279
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git.
from 34d26b0 Refactored python graphbinary to stop using special means of string conversion
new 6c54900 Factor away non-standard method of reading non-null strings for graphbinary in python
new 66d770b Rename python function to use underscore
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../gremlin_python/structure/io/graphbinaryV1.py | 35 +++++++++-------------
1 file changed, 14 insertions(+), 21 deletions(-)
[tinkerpop] 01/02: Factor away non-standard method of reading
non-null strings for graphbinary in python
Posted by sp...@apache.org.
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 6c54900bf53755e534399b6b39f10c5d5fd2fe9e
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Mon Aug 19 11:46:43 2019 -0400
Factor away non-standard method of reading non-null strings for graphbinary in python
---
.../gremlin_python/structure/io/graphbinaryV1.py | 31 +++++++++-------------
1 file changed, 12 insertions(+), 19 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 5fd2fe5..5803f30 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
@@ -195,16 +195,8 @@ class _GraphBinaryTypeIO(object):
return struct.unpack(">i", buff.read(4))[0]
@classmethod
- def read_string(cls, buff):
- return buff.read(cls.read_int(buff)).decode("utf-8")
-
- @classmethod
def unmangleKeyword(cls, symbol):
return cls.symbolMap.get(symbol, symbol)
-
- @classmethod
- def write_as_value(cls, graphbin_type, as_value):
- return None if as_value else graphbin_type
@classmethod
def is_null(cls, buff, reader, else_opt, nullable=True):
@@ -463,9 +455,9 @@ class EdgeIO(_GraphBinaryTypeIO):
@classmethod
def _read_edge(cls, b, r):
edgeid = r.readObject(b)
- edgelbl = cls.read_string(b)
- edge = Edge(edgeid, Vertex(r.readObject(b), cls.read_string(b)),
- edgelbl, Vertex(r.readObject(b), cls.read_string(b)))
+ edgelbl = r.toObject(b, DataType.string, False)
+ edge = Edge(edgeid, Vertex(r.readObject(b), r.toObject(b, DataType.string, False)),
+ edgelbl, Vertex(r.readObject(b), r.toObject(b, DataType.string, False)))
b.read(4)
return edge
@@ -506,7 +498,7 @@ class PropertyIO(_GraphBinaryTypeIO):
@classmethod
def _read_property(cls, b, r):
- p = Property(cls.read_string(b), r.readObject(b), None)
+ p = Property(r.toObject(b, DataType.string, False), r.readObject(b), None)
b.read(2)
return p
@@ -544,7 +536,7 @@ class VertexIO(_GraphBinaryTypeIO):
@classmethod
def _read_vertex(cls, b, r):
- vertex = Vertex(r.readObject(b), cls.read_string(b))
+ vertex = Vertex(r.readObject(b), r.toObject(b, DataType.string, False))
b.read(2)
return vertex
@@ -570,7 +562,7 @@ class VertexPropertyIO(_GraphBinaryTypeIO):
@classmethod
def _read_vertexproperty(cls, b, r):
- vp = VertexProperty(r.readObject(b), cls.read_string(b), r.readObject(b), None)
+ vp = VertexProperty(r.readObject(b), r.toObject(b, DataType.string, False), r.readObject(b), None)
b.read(4)
return vp
@@ -647,7 +639,8 @@ class BindingIO(_GraphBinaryTypeIO):
@classmethod
def objectify(cls, buff, reader, nullable=True):
- return cls.is_null(buff, reader, lambda b, r: Binding(cls.read_string(b), reader.readObject(b)), nullable)
+ return cls.is_null(buff, reader, lambda b, r: Binding(r.toObject(b, DataType.string, False),
+ reader.readObject(b)), nullable)
class BytecodeIO(_GraphBinaryTypeIO):
@@ -690,7 +683,7 @@ class BytecodeIO(_GraphBinaryTypeIO):
step_count = cls.read_int(b)
ix = 0
while ix < step_count:
- inst = [cls.read_string(b)]
+ inst = [r.toObject(b, DataType.string, False)]
inst_ct = cls.read_int(b)
iy = 0
while iy < inst_ct:
@@ -702,7 +695,7 @@ class BytecodeIO(_GraphBinaryTypeIO):
source_count = cls.read_int(b)
ix = 0
while ix < source_count:
- inst = [cls.read_string(b)]
+ inst = [r.toObject(b, DataType.string, False)]
inst_ct = cls.read_int(b)
iy = 0
while iy < inst_ct:
@@ -913,8 +906,8 @@ class MetricsDeserializer(_GraphBinaryTypeIO):
@classmethod
def _read_metrics(cls, b, r):
- metricid = cls.read_string(b)
- name = cls.read_string(b)
+ metricid = r.toObject(b, DataType.string, False)
+ name = r.toObject(b, DataType.string, False)
duration = r.toObject(b, DataType.long, nullable=False)
counts = r.toObject(b, DataType.map, nullable=False)
annotations = r.toObject(b, DataType.map, nullable=False)
[tinkerpop] 02/02: Rename python function to use underscore
Posted by sp...@apache.org.
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 66d770b1c36507791ac2ca5c5c0c598b80d5e26d
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Mon Aug 19 11:57:39 2019 -0400
Rename python function to use underscore
---
.../src/main/jython/gremlin_python/structure/io/graphbinaryV1.py | 4 ++--
1 file changed, 2 insertions(+), 2 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 5803f30..e37ad8e3 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
@@ -195,7 +195,7 @@ class _GraphBinaryTypeIO(object):
return struct.unpack(">i", buff.read(4))[0]
@classmethod
- def unmangleKeyword(cls, symbol):
+ def unmangle_keyword(cls, symbol):
return cls.symbolMap.get(symbol, symbol)
@classmethod
@@ -572,7 +572,7 @@ class _EnumIO(_GraphBinaryTypeIO):
@classmethod
def dictify(cls, obj, writer, as_value=False, nullable=True):
ba = bytearray()
- ba.extend(StringIO.dictify(cls.unmangleKeyword(str(obj.name)), writer))
+ ba.extend(StringIO.dictify(cls.unmangle_keyword(str(obj.name)), writer))
return cls.as_bytes(cls.graphbinary_type, as_value, nullable, ba)
@classmethod