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/24 14:59:11 UTC
incubator-tinkerpop git commit: Reworked StarGraphTest that evaluates
size against detached.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/refactor-io cab778d78 -> 1132d8ab6
Reworked StarGraphTest that evaluates size against detached.
writeVertex no longer uses detached, so the detached serialization had to be done manually.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/1132d8ab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/1132d8ab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/1132d8ab
Branch: refs/heads/refactor-io
Commit: 1132d8ab6c9317a9731472b9e36f189b44291859
Parents: cab778d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Apr 24 08:58:26 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Apr 24 08:58:26 2015 -0400
----------------------------------------------------------------------
.../structure/util/star/StarGraphTest.java | 28 ++++++++++++--------
1 file changed, 17 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1132d8ab/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
index d6ebfcc..cf34667 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
@@ -34,6 +34,7 @@ import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
import org.apache.tinkerpop.gremlin.structure.util.Attachable;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
import org.javatuples.Pair;
import org.junit.Test;
@@ -52,16 +53,6 @@ import static org.junit.Assert.*;
*/
public class StarGraphTest extends AbstractGremlinTest {
- private static Pair<StarGraph, Integer> serializeDeserialize(final StarGraph starGraph) {
- final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- GryoWriter.build().create().writeObject(outputStream, starGraph);
- try {
- return Pair.with(GryoReader.build().create().readObject(new ByteArrayInputStream(outputStream.toByteArray()), StarGraph.class), outputStream.size());
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
- }
- }
-
@Test
@LoadGraphWith(LoadGraphWith.GraphData.CREW)
public void shouldHashAndEqualsCorrectly() {
@@ -141,8 +132,13 @@ public class StarGraphTest extends AbstractGremlinTest {
starGraphSize = pair.getValue1();
TestHelper.validateEquality(vertex, pair.getValue0().getStarVertex());
///
+ // this is a rough approximation of "detached" serialization of all vertices and edges.
+ // now that writeVertex in gryo writes StarGraph that approach can't be used anymore to test
+ // serialization size of detached.
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- GryoWriter.build().create().writeVertex(outputStream, vertex, Direction.BOTH);
+ final GryoWriter writer = GryoWriter.build().create();
+ writer.writeObject(outputStream, DetachedFactory.detach(vertex, true));
+ vertex.edges(Direction.BOTH).forEachRemaining(e -> writer.writeObject(outputStream, DetachedFactory.detach(e, true)));
final int detachedVertexSize = outputStream.size();
assertTrue(starGraphSize < detachedVertexSize);
@@ -151,6 +147,16 @@ public class StarGraphTest extends AbstractGremlinTest {
System.out.println("Size reduction: " + (float) detachedVertexSize / (float) starGraphSize);
}
+ private static Pair<StarGraph, Integer> serializeDeserialize(final StarGraph starGraph) {
+ final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ GryoWriter.build().create().writeObject(outputStream, starGraph);
+ try {
+ return Pair.with(GryoReader.build().create().readObject(new ByteArrayInputStream(outputStream.toByteArray()), StarGraph.class), outputStream.size());
+ } catch (IOException ioe) {
+ throw new RuntimeException(ioe);
+ }
+ }
+
}