[tinkerpop] branch TINKERPOP-2154 created (now c66c497)

2019-02-08 Thread jorgebg
This is an automated email from the ASF dual-hosted git repository.

jorgebg pushed a change to branch TINKERPOP-2154
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git.


  at c66c497  TINKERPOP-2154 GraphBinary: Release working buffers on failure

This branch includes the following new commits:

 new c66c497  TINKERPOP-2154 GraphBinary: Release working buffers on failure

The 1 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.




[tinkerpop] 01/01: TINKERPOP-2154 GraphBinary: Release working buffers on failure

2019-02-08 Thread jorgebg
This is an automated email from the ASF dual-hosted git repository.

jorgebg pushed a commit to branch TINKERPOP-2154
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit c66c497880c0dae6df5e5450bee6a2376f10a149
Author: Jorge Bay Gondra 
AuthorDate: Fri Feb 8 12:31:53 2019 +0100

TINKERPOP-2154 GraphBinary: Release working buffers on failure
---
 .../driver/ser/binary/GraphBinaryWriter.java   | 21 +++--
 .../driver/ser/binary/types/BindingSerializer.java |  9 +-
 .../driver/ser/binary/types/BulkSetSerializer.java | 12 ++-
 .../ser/binary/types/ByteCodeSerializer.java   | 25 --
 .../ser/binary/types/CollectionSerializer.java | 10 ++-
 .../ser/binary/types/CustomTypeSerializer.java |  3 -
 .../driver/ser/binary/types/EdgeSerializer.java| 33 +---
 .../driver/ser/binary/types/GraphSerializer.java   | 79 --
 .../driver/ser/binary/types/LambdaSerializer.java  | 14 +++-
 .../driver/ser/binary/types/MapSerializer.java | 14 ++--
 .../driver/ser/binary/types/MetricsSerializer.java | 27 --
 .../driver/ser/binary/types/PathSerializer.java| 11 ++-
 .../binary/types/TraversalMetricsSerializer.java   | 16 +++-
 .../binary/types/TraversalStrategySerializer.java  | 11 ++-
 .../ser/binary/types/TraverserSerializer.java  | 11 ++-
 .../driver/ser/binary/types/TreeSerializer.java| 16 ++--
 .../ser/binary/types/VertexPropertySerializer.java | 23 +++--
 .../driver/ser/binary/types/VertexSerializer.java  | 19 +++--
 .../ser/binary/TypeSerializerFailureTests.java | 97 ++
 19 files changed, 341 insertions(+), 110 deletions(-)

diff --git 
a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/binary/GraphBinaryWriter.java
 
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/binary/GraphBinaryWriter.java
index b3c2c0f..1703658 100644
--- 
a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/binary/GraphBinaryWriter.java
+++ 
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/binary/GraphBinaryWriter.java
@@ -71,14 +71,16 @@ public class GraphBinaryWriter {
 final TypeSerializer serializer = (TypeSerializer) 
registry.getSerializer(objectClass);
 
 if (serializer instanceof CustomTypeSerializer) {
+// It's a custom type
 CustomTypeSerializer customTypeSerializer = (CustomTypeSerializer) 
serializer;
-// Is a custom type
-// Write type code, custom type name and let the serializer write
-// the rest of {custom_type_info} followed by {value_flag} and 
{value}
-return allocator.compositeBuffer(3).addComponents(true,
-Unpooled.wrappedBuffer(customTypeCodeBytes),
-writeValue(customTypeSerializer.getTypeName(), allocator, 
false),
-customTypeSerializer.write(value, allocator, this));
+
+// Try to serialize the custom value before allocating a composite 
buffer
+ByteBuf customTypeValueBuffer = customTypeSerializer.write(value, 
allocator, this);
+
+return allocator.compositeBuffer(3)
+.addComponent(true, 
Unpooled.wrappedBuffer(customTypeCodeBytes))
+.addComponent(true, 
writeValue(customTypeSerializer.getTypeName(), allocator, false))
+.addComponent(true, customTypeValueBuffer);
 }
 
 if (serializer instanceof TransformSerializer) {
@@ -88,11 +90,14 @@ public class GraphBinaryWriter {
 return write(transformSerializer.transform(value), allocator);
 }
 
+// Try to serialize the value before creating a new composite buffer
+ByteBuf typeInfoAndValueBuffer = serializer.write(value, allocator, 
this);
+
 return allocator.compositeBuffer(2).addComponents(true,
 // {type_code}
 
Unpooled.wrappedBuffer(serializer.getDataType().getDataTypeBuffer()),
 // {type_info}{value_flag}{value}
-serializer.write(value, allocator, this));
+typeInfoAndValueBuffer);
 }
 
 /**
diff --git 
a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/binary/types/BindingSerializer.java
 
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/binary/types/BindingSerializer.java
index de73fb2..3d9f61a 100644
--- 
a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/binary/types/BindingSerializer.java
+++ 
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/binary/types/BindingSerializer.java
@@ -45,8 +45,13 @@ public class BindingSerializer extends 
SimpleTypeSerializer {
 @Override
 protected ByteBuf writeValue(final Bytecode.Binding value, final 
ByteBufAllocator allocator, final GraphBinaryWriter context) throws 
SerializationException {
 final CompositeByteBuf result = allocator.compositeBuffer(2);
-result.addCo

[GitHub] jorgebay opened a new pull request #1058: TINKERPOP-2154 GraphBinary: Release working buffers on failure

2019-02-08 Thread GitBox
jorgebay opened a new pull request #1058: TINKERPOP-2154 GraphBinary: Release 
working buffers on failure
URL: https://github.com/apache/tinkerpop/pull/1058
 
 
   https://issues.apache.org/jira/browse/TINKERPOP-2154
   
   Ensures that reference counts of allocated buffers are set to 0 when there 
is a failure during serialization.
   
   Includes a test for memory allocation when introducing failures.
   
   VOTE +1


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[tinkerpop] branch TINKERPOP-2154 updated: TINKERPOP-2154 fix add missing license to file

2019-02-08 Thread jorgebg
This is an automated email from the ASF dual-hosted git repository.

jorgebg pushed a commit to branch TINKERPOP-2154
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/TINKERPOP-2154 by this push:
 new c2a0d4b  TINKERPOP-2154 fix add missing license to file
c2a0d4b is described below

commit c2a0d4bb9d8566694e855e5628f36e892f930f5b
Author: Jorge Bay Gondra 
AuthorDate: Fri Feb 8 12:37:51 2019 +0100

TINKERPOP-2154 fix add missing license to file
---
 .../driver/ser/binary/TypeSerializerFailureTests.java | 19 +++
 1 file changed, 19 insertions(+)

diff --git 
a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/binary/TypeSerializerFailureTests.java
 
b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/binary/TypeSerializerFailureTests.java
index c8f935e..2118497 100644
--- 
a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/binary/TypeSerializerFailureTests.java
+++ 
b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/binary/TypeSerializerFailureTests.java
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 package org.apache.tinkerpop.gremlin.driver.ser.binary;
 
 import io.netty.buffer.UnpooledByteBufAllocator;



[tinkerpop] branch TINKERPOP-1435 updated: TINKERPOP-1435 Add ByteBuffer support in GraphSON for python

2019-02-08 Thread spmallette
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch TINKERPOP-1435
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/TINKERPOP-1435 by this push:
 new 1f17eaf  TINKERPOP-1435 Add ByteBuffer support in GraphSON for python
1f17eaf is described below

commit 1f17eaf89ae3fbb55f37cdf02130832e2fad9336
Author: Stephen Mallette 
AuthorDate: Fri Feb 8 10:41:49 2019 -0500

TINKERPOP-1435 Add ByteBuffer support in GraphSON for python
---
 .../src/main/jython/gremlin_python/statics.py   |  2 ++
 .../jython/gremlin_python/structure/io/graphsonV2d0.py  | 17 -
 .../jython/gremlin_python/structure/io/graphsonV3d0.py  | 17 -
 .../main/jython/tests/structure/io/test_graphsonV2d0.py | 12 
 .../main/jython/tests/structure/io/test_graphsonV3d0.py | 12 
 5 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/gremlin-python/src/main/jython/gremlin_python/statics.py 
b/gremlin-python/src/main/jython/gremlin_python/statics.py
index 61b8f3e..9ab7286 100644
--- a/gremlin-python/src/main/jython/gremlin_python/statics.py
+++ b/gremlin-python/src/main/jython/gremlin_python/statics.py
@@ -32,9 +32,11 @@ if six.PY3:
 ListType = list
 DictType = dict
 SetType = set
+ByteBufferType = bytes
 else:
 long = long
 SetType = set
+ByteBufferType = bytearray
 from types import FloatType
 from types import IntType
 from types import LongType
diff --git 
a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV2d0.py 
b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV2d0.py
index d72cd8f..45bab4c 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV2d0.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV2d0.py
@@ -21,6 +21,7 @@ import json
 import time
 import uuid
 import math
+import base64
 from collections import OrderedDict
 from decimal import *
 
@@ -28,7 +29,7 @@ import six
 from aenum import Enum
 
 from gremlin_python import statics
-from gremlin_python.statics import FloatType, FunctionType, IntType, LongType, 
TypeType, SingleByte
+from gremlin_python.statics import FloatType, FunctionType, IntType, LongType, 
TypeType, SingleByte, ByteBufferType
 from gremlin_python.process.traversal import Binding, Bytecode, P, Traversal, 
Traverser, TraversalStrategy
 from gremlin_python.structure.graph import Edge, Property, Vertex, 
VertexProperty, Path
 
@@ -501,6 +502,20 @@ class ByteIO(_NumberIO):
 return int.__new__(SingleByte, v)
 
 
+class ByteBufferIO(_GraphSONTypeIO):
+python_type = ByteBufferType
+graphson_type = "gx:ByteBuffer"
+graphson_base_type = "ByteBuffer"
+
+@classmethod
+def dictify(cls, n, writer):
+return GraphSONUtil.typedValue(cls.graphson_base_type, "".join(chr(x) 
for x in n), "gx")
+
+@classmethod
+def objectify(cls, v, _):
+return cls.python_type(v, "ascii")
+
+
 class VertexDeserializer(_GraphSONTypeIO):
 graphson_type = "g:Vertex"
 
diff --git 
a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV3d0.py 
b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV3d0.py
index 1a0298b..454074e 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV3d0.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV3d0.py
@@ -21,6 +21,7 @@ import json
 import time
 import uuid
 import math
+import base64
 from collections import OrderedDict
 from decimal import *
 import logging
@@ -29,7 +30,7 @@ import six
 from aenum import Enum
 
 from gremlin_python import statics
-from gremlin_python.statics import FloatType, FunctionType, IntType, LongType, 
TypeType, DictType, ListType, SetType, SingleByte
+from gremlin_python.statics import FloatType, FunctionType, IntType, LongType, 
TypeType, DictType, ListType, SetType, SingleByte, ByteBufferType
 from gremlin_python.process.traversal import Binding, Bytecode, P, Traversal, 
Traverser, TraversalStrategy, T
 from gremlin_python.structure.graph import Edge, Property, Vertex, 
VertexProperty, Path
 
@@ -582,6 +583,20 @@ class ByteIO(_NumberIO):
 return int.__new__(SingleByte, v)
 
 
+class ByteBufferIO(_GraphSONTypeIO):
+python_type = ByteBufferType
+graphson_type = "gx:ByteBuffer"
+graphson_base_type = "ByteBuffer"
+
+@classmethod
+def dictify(cls, n, writer):
+return GraphSONUtil.typedValue(cls.graphson_base_type, "".join(chr(x) 
for x in n), "gx")
+
+@classmethod
+def objectify(cls, v, _):
+return cls.python_type(v, "ascii")
+
+
 class VertexDeserializer(_GraphSONTypeIO):
 graphson_type = "g:Vertex"
 
diff --git 
a/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV2d0.py 
b/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV2d0.py
index 68fe015..8d3c68c 1006

[tinkerpop] branch TINKERPOP-1435 updated: TINKERPOP-1435 Added Char support to graphson and python

2019-02-08 Thread spmallette
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch TINKERPOP-1435
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/TINKERPOP-1435 by this push:
 new 3c8fe40  TINKERPOP-1435 Added Char support to graphson and python
3c8fe40 is described below

commit 3c8fe40502eb47bed433d12e4997839e23f28539
Author: Stephen Mallette 
AuthorDate: Fri Feb 8 11:26:48 2019 -0500

TINKERPOP-1435 Added Char support to graphson and python
---
 .../src/main/jython/gremlin_python/statics.py  | 12 
 .../jython/gremlin_python/structure/io/graphsonV2d0.py | 18 --
 .../jython/gremlin_python/structure/io/graphsonV3d0.py |  2 +-
 .../jython/tests/structure/io/test_graphsonV2d0.py | 15 +--
 .../jython/tests/structure/io/test_graphsonV3d0.py |  4 ++--
 5 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/gremlin-python/src/main/jython/gremlin_python/statics.py 
b/gremlin-python/src/main/jython/gremlin_python/statics.py
index 9ab7286..2f06b97 100644
--- a/gremlin-python/src/main/jython/gremlin_python/statics.py
+++ b/gremlin-python/src/main/jython/gremlin_python/statics.py
@@ -52,6 +52,7 @@ class timestamp(float):
 """
 pass
 
+
 class SingleByte(int):
 """
 Provides a way to pass a single byte via GraphSON.
@@ -63,6 +64,17 @@ class SingleByte(int):
 raise ValueError("value must be between -128 and 127 inclusive")
 
 
+class SingleChar(str):
+"""
+Provides a way to pass a single character via GraphSON.
+"""
+def __new__(cls, c):
+if len(b) == 1:
+str.__new__(cls, c)
+else:
+raise ValueError("string must contain a single character")
+
+
 staticMethods = {}
 staticEnums = {}
 default_lambda_language = "gremlin-python"
diff --git 
a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV2d0.py 
b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV2d0.py
index 45bab4c..7136ad5 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV2d0.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV2d0.py
@@ -29,7 +29,7 @@ import six
 from aenum import Enum
 
 from gremlin_python import statics
-from gremlin_python.statics import FloatType, FunctionType, IntType, LongType, 
TypeType, SingleByte, ByteBufferType
+from gremlin_python.statics import FloatType, FunctionType, IntType, LongType, 
TypeType, SingleByte, ByteBufferType, SingleChar
 from gremlin_python.process.traversal import Binding, Bytecode, P, Traversal, 
Traverser, TraversalStrategy
 from gremlin_python.structure.graph import Edge, Property, Vertex, 
VertexProperty, Path
 
@@ -513,7 +513,21 @@ class ByteBufferIO(_GraphSONTypeIO):
 
 @classmethod
 def objectify(cls, v, _):
-return cls.python_type(v, "ascii")
+return cls.python_type(v, "utf8")
+
+
+class CharIO(_GraphSONTypeIO):
+python_type = SingleChar
+graphson_type = "gx:Char"
+graphson_base_type = "Char"
+
+@classmethod
+def dictify(cls, n, writer):
+return GraphSONUtil.typedValue(cls.graphson_base_type, n, "gx")
+
+@classmethod
+def objectify(cls, v, _):
+return str.__new__(SingleChar, v)
 
 
 class VertexDeserializer(_GraphSONTypeIO):
diff --git 
a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV3d0.py 
b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV3d0.py
index 454074e..8b3c759 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV3d0.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV3d0.py
@@ -594,7 +594,7 @@ class ByteBufferIO(_GraphSONTypeIO):
 
 @classmethod
 def objectify(cls, v, _):
-return cls.python_type(v, "ascii")
+return cls.python_type(v, "utf8")
 
 
 class VertexDeserializer(_GraphSONTypeIO):
diff --git 
a/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV2d0.py 
b/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV2d0.py
index 8d3c68c..b8a70b5 100644
--- a/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV2d0.py
+++ b/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV2d0.py
@@ -281,7 +281,12 @@ class TestGraphSONReader(object):
 bb = self.graphson_reader.readObject(
 json.dumps({"@type": "gx:ByteBuffer", "@value": 
"c29tZSBieXRlcyBmb3IgeW91"}))
 assert isinstance(bb, ByteBufferType)
-assert ByteBufferType("c29tZSBieXRlcyBmb3IgeW91", "ascii") == bb
+assert ByteBufferType("c29tZSBieXRlcyBmb3IgeW91", "utf8") == bb
+
+def test_char(self):
+c = self.graphson_reader.readObject(json.dumps({"@type": "gx:Char", 
"@value": "L"}))
+assert isinstance(c, SingleChar)
+assert chr(76) == c
 
 
 class TestGraphSONWriter(object):
@@ -443,10 +448,16 @@ class TestGraphSONWriter(objec