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 2015/04/17 18:02:01 UTC
[10/17] incubator-tinkerpop git commit: Remove the requirement for a
Kryo object to write the header.
Remove the requirement for a Kryo object to write the header.
Seems unlikely that we would need to have a Kryo object to just write a header on a file. This was forcing creation of a Kryo object up front which is expensive as a throwaway.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/4fd88702
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/4fd88702
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/4fd88702
Branch: refs/heads/variables
Commit: 4fd88702992051ed1beb3cca50294245bc3088d4
Parents: 271cdde
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Apr 17 09:13:22 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Apr 17 09:13:22 2015 -0400
----------------------------------------------------------------------
.../tinkerpop/gremlin/structure/io/gryo/GryoMapper.java | 10 +++++-----
.../tinkerpop/gremlin/structure/io/gryo/GryoReader.java | 6 +++---
.../tinkerpop/gremlin/structure/io/gryo/GryoWriter.java | 8 ++++----
3 files changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4fd88702/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
index 5ab18e6..045d40d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
@@ -111,7 +111,7 @@ public final class GryoMapper implements Mapper<Kryo> {
final Output out = new Output(32);
try {
- this.headerWriter.write(createMapper(), out);
+ this.headerWriter.write(out);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
@@ -155,12 +155,12 @@ public final class GryoMapper implements Mapper<Kryo> {
@FunctionalInterface
public interface HeaderReader {
- public void read(final Kryo kryo, final Input input) throws IOException;
+ public void read(final Input input) throws IOException;
}
@FunctionalInterface
public interface HeaderWriter {
- public void write(final Kryo kryo, final Output output) throws IOException;
+ public void write(final Output output) throws IOException;
}
/**
@@ -399,7 +399,7 @@ public final class GryoMapper implements Mapper<Kryo> {
return new GryoMapper(serializationList, this::writeHeader, this::readHeader);
}
- private void writeHeader(final Kryo kryo, final Output output) throws IOException {
+ private void writeHeader(final Output output) throws IOException {
// 32 byte header total
output.writeBytes(GIO);
@@ -413,7 +413,7 @@ public final class GryoMapper implements Mapper<Kryo> {
output.writeByte(extendedVersion);
}
- private void readHeader(final Kryo kryo, final Input input) throws IOException {
+ private void readHeader(final Input input) throws IOException {
if (!Arrays.equals(GIO, input.readBytes(3)))
throw new IOException("Invalid format - first three bytes of header do not match expected value");
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4fd88702/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
index 08ca97a..af64872 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
@@ -107,7 +107,7 @@ public class GryoReader implements GraphReader {
@Override
public Edge readEdge(final InputStream inputStream, final Function<DetachedEdge, Edge> edgeMaker) throws IOException {
final Input input = new Input(inputStream);
- this.headerReader.read(kryo, input);
+ this.headerReader.read(input);
final Object o = kryo.readClassAndObject(input);
return edgeMaker.apply((DetachedEdge) o);
}
@@ -126,7 +126,7 @@ public class GryoReader implements GraphReader {
@Override
public void readGraph(final InputStream inputStream, final Graph graphToWriteTo) throws IOException {
final Input input = new Input(inputStream);
- this.headerReader.read(kryo, input);
+ this.headerReader.read(input);
final BatchGraph graph;
try {
@@ -217,7 +217,7 @@ public class GryoReader implements GraphReader {
if (null != directionRequested && null == edgeMaker)
throw new IllegalArgumentException("If a directionRequested is specified then an edgeAdder function should also be specified");
- this.headerReader.read(kryo, input);
+ this.headerReader.read(input);
final Vertex vertex = vertexMaker.apply((DetachedVertex) kryo.readClassAndObject(input));
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4fd88702/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoWriter.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoWriter.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoWriter.java
index 242b1d5..042911b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoWriter.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoWriter.java
@@ -52,7 +52,7 @@ public class GryoWriter implements GraphWriter {
@Override
public void writeGraph(final OutputStream outputStream, final Graph g) throws IOException {
final Output output = new Output(outputStream);
- this.headerWriter.write(kryo, output);
+ this.headerWriter.write(output);
final boolean supportsGraphVariables = g.features().graph().variables().supportsVariables();
output.writeBoolean(supportsGraphVariables);
@@ -73,7 +73,7 @@ public class GryoWriter implements GraphWriter {
@Override
public void writeVertex(final OutputStream outputStream, final Vertex v, final Direction direction) throws IOException {
final Output output = new Output(outputStream);
- this.headerWriter.write(kryo, output);
+ this.headerWriter.write(output);
writeVertexToOutput(output, v, direction);
output.flush();
}
@@ -81,7 +81,7 @@ public class GryoWriter implements GraphWriter {
@Override
public void writeVertex(final OutputStream outputStream, final Vertex v) throws IOException {
final Output output = new Output(outputStream);
- this.headerWriter.write(kryo, output);
+ this.headerWriter.write(output);
writeVertexWithNoEdgesToOutput(output, v);
output.flush();
}
@@ -89,7 +89,7 @@ public class GryoWriter implements GraphWriter {
@Override
public void writeEdge(final OutputStream outputStream, final Edge e) throws IOException {
final Output output = new Output(outputStream);
- this.headerWriter.write(kryo, output);
+ this.headerWriter.write(output);
kryo.writeClassAndObject(output, DetachedFactory.detach(e, true));
output.flush();
}