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/e2eebf4c Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/e2eebf4c Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/e2eebf4c Branch: refs/heads/TINKERPOP-1595 Commit: e2eebf4c5590fd20c8184bd0162c717614575034 Parents: 1d149c6 Author: Stephen Mallette <[email protected]> Authored: Tue Apr 24 08:06:56 2018 -0400 Committer: Stephen Mallette <[email protected]> Committed: Fri Apr 27 10:32:44 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/e2eebf4c/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); }
