TINKERPOP-1595 Changed vertex program serialization to base64 encoded This approach shows to be faster than writing the bytes as an array of string values and deserializing with regex based parsing.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/628d5df1 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/628d5df1 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/628d5df1 Branch: refs/heads/TINKERPOP-1968 Commit: 628d5df128e428dcb33638309dd78bc95cd69707 Parents: a5d9ecd Author: Stephen Mallette <sp...@genoprime.com> Authored: Tue Apr 24 08:06:56 2018 -0400 Committer: Stephen Mallette <sp...@genoprime.com> Committed: Mon May 21 12:32:57 2018 -0400 ---------------------------------------------------------------------- .../process/computer/util/VertexProgramHelper.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/628d5df1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/VertexProgramHelper.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/VertexProgramHelper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/VertexProgramHelper.java index bc67866..a1c299d 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/VertexProgramHelper.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/VertexProgramHelper.java @@ -28,7 +28,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep; import org.apache.tinkerpop.gremlin.util.Serializer; import java.io.IOException; -import java.util.Arrays; +import java.util.Base64; import java.util.HashSet; import java.util.Set; @@ -64,8 +64,7 @@ public final class VertexProgramHelper { if (configuration instanceof AbstractConfiguration) ((AbstractConfiguration) configuration).setDelimiterParsingDisabled(true); try { - final String byteString = Arrays.toString(Serializer.serializeObject(object)); - configuration.setProperty(key, byteString.substring(1, byteString.length() - 1)); + configuration.setProperty(key, Base64.getEncoder().encodeToString(Serializer.serializeObject(object))); } catch (final IOException e) { throw new IllegalArgumentException(e.getMessage(), e); } @@ -73,12 +72,8 @@ public final class VertexProgramHelper { public static <T> T deserialize(final Configuration configuration, final String key) { try { - final String[] stringBytes = configuration.getString(key).split(","); - byte[] bytes = new byte[stringBytes.length]; - for (int i = 0; i < stringBytes.length; i++) { - bytes[i] = Byte.valueOf(stringBytes[i].trim()); - } - return (T) Serializer.deserializeObject(bytes); + + return (T) Serializer.deserializeObject(Base64.getDecoder().decode(configuration.getString(key).getBytes())); } catch (final IOException | ClassNotFoundException e) { throw new IllegalArgumentException(e.getMessage(), e); }