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/16 15:03:53 UTC
incubator-tinkerpop git commit: Drop the old Graph.Io interface and
refactor tests to work with the new Graph.io() method
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/refactor-io 8a3b38ab6 -> b28252a1e
Drop the old Graph.Io interface and refactor tests to work with the new Graph.io() method
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/b28252a1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/b28252a1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/b28252a1
Branch: refs/heads/refactor-io
Commit: b28252a1ed82b88a5205dd7960ad2ef34386c593
Parents: 8a3b38a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Apr 16 09:03:19 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Apr 16 09:03:19 2015 -0400
----------------------------------------------------------------------
.../tinkerpop/gremlin/structure/Graph.java | 163 +--------------
.../gremlin/structure/io/DefaultIo.java | 82 --------
.../ser/AbstractJsonMessageSerializerV1d0.java | 3 +-
.../driver/ser/GryoMessageSerializerV1d0.java | 3 +-
.../gremlin/AbstractGraphProvider.java | 3 +-
.../structure/GraphWritePerformanceTest.java | 9 +-
.../tinkerpop/gremlin/structure/IoTest.java | 207 ++++++++++---------
.../gremlin/structure/SerializationTest.java | 51 +++--
.../tinkergraph/structure/TinkerGraphTest.java | 5 +-
9 files changed, 152 insertions(+), 374 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b28252a1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
index 529f6bb..8f2414b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
@@ -25,20 +25,10 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.engine.StandardTraversalEngine;
-import org.apache.tinkerpop.gremlin.structure.io.DefaultIo;
-import org.apache.tinkerpop.gremlin.structure.io.Mapper;
-import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader;
-import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLWriter;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
-import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper;
-import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
-import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
+import org.apache.tinkerpop.gremlin.structure.io.Io;
import org.apache.tinkerpop.gremlin.structure.util.FeatureDescriptor;
import org.javatuples.Pair;
-import java.io.IOException;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Repeatable;
@@ -246,14 +236,7 @@ public interface Graph extends AutoCloseable {
*/
public Transaction tx();
- /**
- * Provide input/output methods for serializing graph data.
- */
- public default Io io() {
- return new DefaultIo(this);
- }
-
- public default <I extends org.apache.tinkerpop.gremlin.structure.io.Io> I io(final org.apache.tinkerpop.gremlin.structure.io.Io.Builder<I> builder) {
+ public default <I extends Io> I io(final Io.Builder<I> builder) {
return (I) builder.graph(this).create();
}
@@ -275,148 +258,6 @@ public interface Graph extends AutoCloseable {
public Configuration configuration();
/**
- * Provides access to functions related to reading and writing graph data. Implementers can override these
- * methods to provider mapper configurations to the default {@link org.apache.tinkerpop.gremlin.structure.io.GraphReader}
- * and {@link org.apache.tinkerpop.gremlin.structure.io.GraphWriter} implementations (i.e. to register mapper
- * serialization classes).
- */
- public interface Io {
- /**
- * Creates a {@link org.apache.tinkerpop.gremlin.structure.io.GraphReader} builder for Gryo serializations. This
- * method calls the {@link Io#gryoMapper} method to supply to
- * {@link org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader.Builder#mapper} which means that implementers
- * should usually just override {@link Io#gryoMapper} to append in their mapper classes.
- */
- public default GryoReader.Builder gryoReader() {
- return GryoReader.build().mapper(gryoMapper().create());
- }
-
- /**
- * Creates a {@link org.apache.tinkerpop.gremlin.structure.io.GraphWriter} builder for Gryo serializations. This
- * method calls the {@link Io#gryoMapper} method to supply to
- * {@link org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter.Builder#mapper} which means that implementers
- * should usually just override {@link Io#gryoMapper} to append in their mapper classes.
- */
- public default GryoWriter.Builder gryoWriter() {
- return GryoWriter.build().mapper(gryoMapper().create());
- }
-
- /**
- * Write a gryo file using the default configuration of the {@link org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter}.
- */
- public void writeGryo(final String file) throws IOException;
-
- /**
- * Read a gryo file using the default configuration of the {@link org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader}.
- */
- public void readGryo(final String file) throws IOException;
-
- /**
- * By default, this method creates an instance of the most current version of {@link org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper} which is
- * used to serialize data to and from the graph. Implementers with mapper classes (e.g. a non-primitive
- * class returned from {@link Element#id}) should override this method with those classes automatically
- * registered to the returned {@link org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper}.
- * <br/>
- * Implementers should respect versions. Once a class is registered, the order of its registration should be
- * maintained. Note that registering such classes will reduce the portability of the graph data as data
- * written with {@link org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper} will not be readable without this serializer configuration. It is
- * considered good practice to make serialization classes generally available so that users may
- * register these classes themselves if necessary when building up a mapper {@link org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper}
- * instance.
- * <br/>
- * Note that this method is meant to return current versions for serialization operations. Users wishing
- * to use an "older" version should construct this instance as well as their readers and writers manually.
- */
- public default GryoMapper.Builder gryoMapper() {
- return GryoMapper.build();
- }
-
- /**
- * Creates a {@link org.apache.tinkerpop.gremlin.structure.io.GraphReader} builder for GraphML serializations. GraphML
- * is the most portable of all the formats, but comes at the price of the least flexibility.
- * {@code Graph} implementations that have mapper classes that need to be serialized will not be able
- * to properly use this format effectively.
- */
- public default GraphMLReader.Builder graphMLReader() {
- return GraphMLReader.build();
- }
-
- /**
- * Creates a {@link org.apache.tinkerpop.gremlin.structure.io.GraphWriter} builder for GraphML serializations. GraphML
- * is the most portable of all the formats, but comes at the price of the least flexibility.
- * {@code Graph} implementations that have mapper classes that need to be serialized will not be able
- * to properly use this format effectively.
- */
- public default GraphMLWriter.Builder graphMLWriter() {
- return GraphMLWriter.build();
- }
-
- /**
- * Write a GraphML file using the default configuration of the {@link GraphMLWriter}.
- */
- public void writeGraphML(final String file) throws IOException;
-
- /**
- * Read a GraphML file using the default configuration of the {@link GraphMLReader}.
- */
- public void readGraphML(final String file) throws IOException;
-
- /**
- * Creates a {@link org.apache.tinkerpop.gremlin.structure.io.GraphReader} builder for GraphSON serializations.
- * GraphSON is forgiving for implementers and will typically do a "reasonable" job in serializing most
- * mapper classes. This method by default uses the {@link org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper} created by
- * {@link #graphSONMapper}. That method enables implementers to register mapper serialization
- * modules for classes that do not serialize nicely by the default JSON serializers or completely
- * fail to do so.
- */
- public default GraphSONReader.Builder graphSONReader() {
- return GraphSONReader.build().mapper(graphSONMapper().create());
- }
-
- /**
- * Creates a {@link org.apache.tinkerpop.gremlin.structure.io.GraphWriter} builder for GraphML serializations.
- * GraphSON is forgiving for implementers and will typically do a "reasonable" job in serializing most
- * mapper classes. This method by default uses the {@link org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper} created by
- * {@link #graphSONMapper}. That method enables implementers to register mapper serialization
- * modules for classes that do not serialize nicely by the default JSON serializers or completely
- * fail to do so.
- */
- public default GraphSONWriter.Builder graphSONWriter() {
- return GraphSONWriter.build().mapper(graphSONMapper().create());
- }
-
- /**
- * Write a GraphSON file using the default configuration of the {@link GraphSONWriter}.
- */
- public void writeGraphSON(final String file) throws IOException;
-
- /**
- * Read a GraphSON file using the default configuration of the {@link GraphSONReader}.
- */
- public void readGraphSON(final String file) throws IOException;
-
- /**
- * By default, this method creates an instance of the most current version of
- * {@link org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper.Builder} which is can produce a
- * {@link org.apache.tinkerpop.gremlin.structure.io.Mapper} implementation for GraphSON to
- * serialize data to and from the graph. Implementers with custom classes (e.g. a
- * non-primitive class returned from {@link Element#id}) should override this method with serialization
- * modules added.
- * <br/>
- * It is considered good practice to make serialization classes generally available so that users may
- * register these classes themselves if necessary when building up a mapper {@link org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper}
- * instance.
- * <br/>
- * Note that this method is meant to return a {@link org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper.Builder} with default configuration
- * for the current {@link Graph}. Users can adjust and override such settings by altering the builder
- * settings.
- */
- public default GraphSONMapper.Builder graphSONMapper() {
- return GraphSONMapper.build();
- }
- }
-
- /**
* Graph variables are a set of key/value pairs associated with the graph.The keys are String and the values
* are Objects.
*/
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b28252a1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/DefaultIo.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/DefaultIo.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/DefaultIo.java
deleted file mode 100644
index 7ef6434..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/DefaultIo.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.structure.io;
-
-import org.apache.tinkerpop.gremlin.structure.Graph;
-
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * Default implementation of the {@link Graph.Io} interface which overrides none of the default methods.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class DefaultIo implements Graph.Io {
- private final Graph g;
-
- public DefaultIo(final Graph g) {
- this.g = g;
- }
-
- @Override
- public void writeGryo(final String file) throws IOException {
- try (final OutputStream out = new FileOutputStream(file)) {
- gryoWriter().create().writeGraph(out, g);
- }
- }
-
- @Override
- public void readGryo(final String file) throws IOException {
- try (final InputStream in = new FileInputStream(file)) {
- gryoReader().create().readGraph(in, g);
- }
- }
-
- @Override
- public void writeGraphML(final String file) throws IOException {
- try (final OutputStream out = new FileOutputStream(file)) {
- graphMLWriter().create().writeGraph(out, g);
- }
- }
-
- @Override
- public void readGraphML(final String file) throws IOException {
- try (final InputStream in = new FileInputStream(file)) {
- graphMLReader().create().readGraph(in, g);
- }
- }
-
- @Override
- public void writeGraphSON(final String file) throws IOException {
- try (final OutputStream out = new FileOutputStream(file)) {
- graphSONWriter().create().writeGraph(out, g);
- }
- }
-
- @Override
- public void readGraphSON(final String file) throws IOException {
- try (final InputStream in = new FileInputStream(file)) {
- graphSONReader().create().readGraph(in, g);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b28252a1/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractJsonMessageSerializerV1d0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractJsonMessageSerializerV1d0.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractJsonMessageSerializerV1d0.java
index 518f242..8c1980d 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractJsonMessageSerializerV1d0.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractJsonMessageSerializerV1d0.java
@@ -30,6 +30,7 @@ import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONIo;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
import groovy.json.JsonBuilder;
import io.netty.buffer.ByteBuf;
@@ -84,7 +85,7 @@ public abstract class AbstractJsonMessageSerializerV1d0 implements MessageSerial
// a graph was found so use the mapper it constructs. this allows graphson to be auto-configured with any
// custom classes that the implementation allows for
- initialBuilder = g.io().graphSONMapper();
+ initialBuilder = g.io(GraphSONIo.build()).mapper();
} else {
// no graph was supplied so just use the default - this will likely be the case when using a graph
// with no custom classes or a situation where the user needs complete control like when using two
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b28252a1/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0.java
index 40e23bd..479a740 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0.java
@@ -26,6 +26,7 @@ import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper;
import org.apache.tinkerpop.shaded.kryo.Kryo;
import org.apache.tinkerpop.shaded.kryo.Serializer;
@@ -109,7 +110,7 @@ public class GryoMessageSerializerV1d0 implements MessageSerializer {
// a graph was found so use the mapper it constructs. this allows gryo to be auto-configured with any
// custom classes that the implementation allows for
- initialBuilder = g.io().gryoMapper();
+ initialBuilder = g.io(GryoIo.build()).mapper();
} else {
// no graph was supplied so just use the default - this will likely be the case when using a graph
// with no custom classes or a situation where the user needs complete control like when using two
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b28252a1/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java
index e439d29..1b7a016 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java
@@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.configuration.Configuration;
@@ -123,7 +124,7 @@ public abstract class AbstractGraphProvider implements GraphProvider {
if (!workingDirectory.exists()) workingDirectory.mkdirs();
final GraphReader reader = GryoReader.build()
.workingDirectory(workingDirectory.getAbsolutePath())
- .mapper(g.io().gryoMapper().create())
+ .mapper(g.io(GryoIo.build()).mapper().create())
.create();
try (final InputStream stream = AbstractGremlinTest.class.getResourceAsStream(path)) {
reader.readGraph(stream, g);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b28252a1/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/GraphWritePerformanceTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/GraphWritePerformanceTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/GraphWritePerformanceTest.java
index 28171be..2d1f2df 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/GraphWritePerformanceTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/GraphWritePerformanceTest.java
@@ -27,8 +27,11 @@ import com.carrotsearch.junitbenchmarks.annotation.LabelType;
import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
import org.apache.tinkerpop.gremlin.LoadGraphWith;
import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
+import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLIo;
import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLWriter;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONIo;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
import org.junit.Rule;
import org.junit.Test;
@@ -95,7 +98,7 @@ public class GraphWritePerformanceTest {
@LoadGraphWith(LoadGraphWith.GraphData.GRATEFUL)
@BenchmarkOptions(benchmarkRounds = 10, warmupRounds = 0, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
public void writeGryo() throws Exception {
- final GraphWriter writer = graph.io().gryoWriter().create();
+ final GraphWriter writer = graph.io(GryoIo.build()).writer().create();
final OutputStream os = new ByteArrayOutputStream();
writer.writeGraph(os, graph);
}
@@ -104,7 +107,7 @@ public class GraphWritePerformanceTest {
@LoadGraphWith(LoadGraphWith.GraphData.GRATEFUL)
@BenchmarkOptions(benchmarkRounds = 10, warmupRounds = 0, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
public void writeGraphML() throws Exception {
- final GraphWriter writer = graph.io().graphMLWriter().create();
+ final GraphWriter writer = graph.io(GraphMLIo.build()).writer().create();
final OutputStream os = new ByteArrayOutputStream();
writer.writeGraph(os, graph);
}
@@ -113,7 +116,7 @@ public class GraphWritePerformanceTest {
@LoadGraphWith(LoadGraphWith.GraphData.GRATEFUL)
@BenchmarkOptions(benchmarkRounds = 10, warmupRounds = 0, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
public void writeGraphSON() throws Exception {
- final GraphWriter writer = graph.io().graphSONWriter().create();
+ final GraphWriter writer = graph.io(GraphSONIo.build()).writer().create();
final OutputStream os = new ByteArrayOutputStream();
writer.writeGraph(os, graph);
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b28252a1/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/IoTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/IoTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/IoTest.java
index 61dfcda..0b9765a 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/IoTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/IoTest.java
@@ -39,13 +39,16 @@ import org.apache.tinkerpop.gremlin.structure.Graph.Features.VertexPropertyFeatu
import org.apache.tinkerpop.gremlin.structure.io.GraphMigrator;
import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
+import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLIo;
import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader;
import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLWriter;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONIo;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
import org.apache.tinkerpop.gremlin.structure.io.graphson.LegacyGraphSONReader;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
@@ -158,11 +161,11 @@ public class IoTest extends AbstractGremlinTest {
public void shouldReadWriteClassicToGraphMLToFileWithHelpers() throws Exception {
final File f = TestHelper.generateTempFile(this.getClass(), name.getMethodName(), ".xml");
try {
- graph.io().writeGraphML(f.getAbsolutePath());
+ graph.io(GraphMLIo.build()).write(f.getAbsolutePath());
final Configuration configuration = graphProvider.newGraphConfiguration("readGraph", this.getClass(), name.getMethodName(), LoadGraphWith.GraphData.CLASSIC);
final Graph g1 = graphProvider.openTestGraph(configuration);
- g1.io().readGraphML(f.getAbsolutePath());
+ g1.io(GraphMLIo.build()).read(f.getAbsolutePath());
assertClassicGraph(graph, false, true);
@@ -210,8 +213,8 @@ public class IoTest extends AbstractGremlinTest {
@LoadGraphWith(LoadGraphWith.GraphData.CLASSIC)
public void shouldWriteNormalizedGraphSON() throws Exception {
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
- final GraphSONMapper mapper = graph.io().graphSONMapper().normalize(true).create();
- final GraphSONWriter w = graph.io().graphSONWriter().mapper(mapper).create();
+ final GraphSONMapper mapper = graph.io(GraphSONIo.build()).mapper().normalize(true).create();
+ final GraphSONWriter w = graph.io(GraphSONIo.build()).writer().mapper(mapper).create();
w.writeGraph(bos, graph);
final String expected = streamToString(IoTest.class.getResourceAsStream(GRAPHSON_RESOURCE_PATH_PREFIX + "tinkerpop-classic-normalized.json"));
@@ -274,8 +277,8 @@ public class IoTest extends AbstractGremlinTest {
final SimpleModule module = new SimpleModule();
module.addSerializer(CustomId.class, new CustomId.CustomIdJacksonSerializer());
- final GraphWriter writer = graph.io().graphSONWriter().mapper(
- graph.io().graphSONMapper().addCustomModule(module).embedTypes(true).create()).create();
+ final GraphWriter writer = graph.io(GraphSONIo.build()).writer().mapper(
+ graph.io(GraphSONIo.build()).mapper().addCustomModule(module).embedTypes(true).create()).create();
try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
writer.writeGraph(baos, graph);
@@ -294,8 +297,8 @@ public class IoTest extends AbstractGremlinTest {
final Graph g2 = graphProvider.openTestGraph(configuration);
try (final InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- final GraphReader reader = graph.io().graphSONReader()
- .mapper(graph.io().graphSONMapper().embedTypes(true).addCustomModule(module).create()).create();
+ final GraphReader reader = graph.io(GraphSONIo.build()).reader()
+ .mapper(graph.io(GraphSONIo.build()).mapper().embedTypes(true).addCustomModule(module).create()).create();
reader.readGraph(is, g2);
}
@@ -344,8 +347,8 @@ public class IoTest extends AbstractGremlinTest {
graphProvider.clear(configuration);
final Graph g1 = graphProvider.openTestGraph(configuration);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
GraphMigrator.migrateGraph(graph, g1, reader, writer);
@@ -364,8 +367,8 @@ public class IoTest extends AbstractGremlinTest {
graphProvider.clear(configuration);
final Graph g1 = graphProvider.openTestGraph(configuration);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
GraphMigrator.migrateGraph(graph, g1, reader, writer);
@@ -384,13 +387,13 @@ public class IoTest extends AbstractGremlinTest {
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
public void shouldReadWriteModernToGryo() throws Exception {
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeGraph(os, graph);
final Configuration configuration = graphProvider.newGraphConfiguration("readGraph", this.getClass(), name.getMethodName(), LoadGraphWith.GraphData.MODERN);
graphProvider.clear(configuration);
final Graph g1 = graphProvider.openTestGraph(configuration);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readGraph(bais, g1);
}
@@ -412,11 +415,11 @@ public class IoTest extends AbstractGremlinTest {
public void shouldReadWriteModernToGryoToFileWithHelpers() throws Exception {
final File f = TestHelper.generateTempFile(this.getClass(), name.getMethodName(), ".kryo");
try {
- graph.io().writeGryo(f.getAbsolutePath());
+ graph.io(GryoIo.build()).write(f.getAbsolutePath());
final Configuration configuration = graphProvider.newGraphConfiguration("readGraph", this.getClass(), name.getMethodName(), LoadGraphWith.GraphData.MODERN);
final Graph g1 = graphProvider.openTestGraph(configuration);
- g1.io().readGryo(f.getAbsolutePath());
+ g1.io(GryoIo.build()).read(f.getAbsolutePath());
// by making this lossy for float it will assert floats for doubles
assertModernGraph(g1, true, false);
@@ -438,14 +441,14 @@ public class IoTest extends AbstractGremlinTest {
public void shouldReadWriteCrewToGryo() throws Exception {
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeGraph(os, graph);
final Configuration configuration = graphProvider.newGraphConfiguration("readGraph", this.getClass(), name.getMethodName(), LoadGraphWith.GraphData.CREW);
graphProvider.clear(configuration);
final Graph g1 = graphProvider.openTestGraph(configuration);
final GryoReader reader = GryoReader.build()
- .mapper(graph.io().gryoMapper().create())
+ .mapper(graph.io(GryoIo.build()).mapper().create())
.workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readGraph(bais, g1);
@@ -468,13 +471,13 @@ public class IoTest extends AbstractGremlinTest {
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
public void shouldReadWriteClassicToGryo() throws Exception {
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeGraph(os, graph);
final Configuration configuration = graphProvider.newGraphConfiguration("readGraph", this.getClass(), name.getMethodName(), LoadGraphWith.GraphData.CLASSIC);
graphProvider.clear(configuration);
final Graph g1 = graphProvider.openTestGraph(configuration);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readGraph(bais, g1);
}
@@ -492,13 +495,13 @@ public class IoTest extends AbstractGremlinTest {
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
public void shouldReadWriteClassicToGraphSON() throws Exception {
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().create();
writer.writeGraph(os, graph);
final Configuration configuration = graphProvider.newGraphConfiguration("readGraph", this.getClass(), name.getMethodName(), LoadGraphWith.GraphData.CLASSIC);
graphProvider.clear(configuration);
final Graph g1 = graphProvider.openTestGraph(configuration);
- final GraphSONReader reader = graph.io().graphSONReader().create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readGraph(bais, g1);
}
@@ -516,13 +519,13 @@ public class IoTest extends AbstractGremlinTest {
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
public void shouldReadWriteModernToGraphSON() throws Exception {
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().create();
writer.writeGraph(os, graph);
final Configuration configuration = graphProvider.newGraphConfiguration("readGraph", this.getClass(), name.getMethodName(), LoadGraphWith.GraphData.MODERN);
graphProvider.clear(configuration);
final Graph g1 = graphProvider.openTestGraph(configuration);
- final GraphSONReader reader = graph.io().graphSONReader().create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readGraph(bais, g1);
}
@@ -541,12 +544,12 @@ public class IoTest extends AbstractGremlinTest {
public void shouldReadWriteModernToGraphSONWithHelpers() throws Exception {
final File f = TestHelper.generateTempFile(this.getClass(), name.getMethodName(), ".json");
try {
- graph.io().writeGraphSON(f.getAbsolutePath());
+ graph.io(GraphSONIo.build()).write(f.getAbsolutePath());
final Configuration configuration = graphProvider.newGraphConfiguration("readGraph", this.getClass(), name.getMethodName(), LoadGraphWith.GraphData.MODERN);
graphProvider.clear(configuration);
final Graph g1 = graphProvider.openTestGraph(configuration);
- g1.io().readGraphSON(f.getAbsolutePath());
+ g1.io(GraphSONIo.build()).read(f.getAbsolutePath());
assertModernGraph(g1, true, false);
@@ -566,13 +569,13 @@ public class IoTest extends AbstractGremlinTest {
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
public void shouldReadWriteCrewToGraphSON() throws Exception {
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().create();
writer.writeGraph(os, graph);
final Configuration configuration = graphProvider.newGraphConfiguration("readGraph", this.getClass(), name.getMethodName(), LoadGraphWith.GraphData.CREW);
graphProvider.clear(configuration);
final Graph g1 = graphProvider.openTestGraph(configuration);
- final GraphSONReader reader = graph.io().graphSONReader().create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readGraph(bais, g1);
}
@@ -594,11 +597,11 @@ public class IoTest extends AbstractGremlinTest {
final Edge e = v1.addEdge("friend", v2, "weight", 0.5f, "acl", "rw");
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeEdge(os, e);
final AtomicBoolean called = new AtomicBoolean(false);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readEdge(bais, detachedEdge -> {
assertEquals(e.id(), detachedEdge.id());
@@ -630,11 +633,11 @@ public class IoTest extends AbstractGremlinTest {
final Edge e = v1.addEdge("friend", v2, "weight", 0.5d, "acl", "rw");
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeEdge(os, e);
final AtomicBoolean called = new AtomicBoolean(false);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readEdge(bais, detachedEdge -> {
assertEquals(e.id(), detachedEdge.id());
@@ -664,11 +667,11 @@ public class IoTest extends AbstractGremlinTest {
final Edge e = DetachedFactory.detach(v1.addEdge("friend", v2, "weight", 0.5d, "acl", "rw"), false);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeEdge(os, e);
final AtomicBoolean called = new AtomicBoolean(false);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readEdge(bais, detachedEdge -> {
assertEquals(e.id(), detachedEdge.id());
@@ -698,11 +701,11 @@ public class IoTest extends AbstractGremlinTest {
final Edge e = DetachedFactory.detach(v1.addEdge("friend", v2, "weight", 0.5d, "acl", "rw"), true);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeEdge(os, e);
final AtomicBoolean called = new AtomicBoolean(false);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readEdge(bais, detachedEdge -> {
assertEquals(e.id(), detachedEdge.id());
@@ -733,11 +736,11 @@ public class IoTest extends AbstractGremlinTest {
final Edge e = v1.addEdge("friend", v2, "weight", 0.5f, "acl", "rw");
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().create();
writer.writeEdge(os, e);
final AtomicBoolean called = new AtomicBoolean(false);
- final GraphSONReader reader = graph.io().graphSONReader().create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readEdge(bais, detachedEdge -> {
assertEquals(e.id(), graph.edges(detachedEdge.id().toString()).next().id());
@@ -768,11 +771,11 @@ public class IoTest extends AbstractGremlinTest {
final Edge e = DetachedFactory.detach(v1.addEdge("friend", v2, "weight", 0.5f, "acl", "rw"), false);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().create();
writer.writeEdge(os, e);
final AtomicBoolean called = new AtomicBoolean(false);
- final GraphSONReader reader = graph.io().graphSONReader().create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readEdge(bais, detachedEdge -> {
assertEquals(e.id(), graph.edges(detachedEdge.id().toString()).next().id());
@@ -802,11 +805,11 @@ public class IoTest extends AbstractGremlinTest {
final Edge e = DetachedFactory.detach(v1.addEdge("friend", v2, "weight", 0.5f, "acl", "rw"), true);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().create();
writer.writeEdge(os, e);
final AtomicBoolean called = new AtomicBoolean(false);
- final GraphSONReader reader = graph.io().graphSONReader().create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readEdge(bais, detachedEdge -> {
assertEquals(e.id(), graph.edges(detachedEdge.id().toString()).next().id());
@@ -838,11 +841,11 @@ public class IoTest extends AbstractGremlinTest {
final Edge e = v1.addEdge("friend", v2, "weight", 0.5f, "acl", "rw");
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().mapper(graph.io().graphSONMapper().embedTypes(true).create()).create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().mapper(graph.io(GraphSONIo.build()).mapper().embedTypes(true).create()).create();
writer.writeEdge(os, e);
final AtomicBoolean called = new AtomicBoolean(false);
- final GraphSONReader reader = graph.io().graphSONReader().mapper(graph.io().graphSONMapper().embedTypes(true).create()).create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().mapper(graph.io(GraphSONIo.build()).mapper().embedTypes(true).create()).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readEdge(bais, detachedEdge -> {
assertEquals(e.id(), detachedEdge.id());
@@ -874,11 +877,11 @@ public class IoTest extends AbstractGremlinTest {
final Edge e = v1.addEdge("friend", v2, "uuid", id);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().mapper(graph.io().graphSONMapper().embedTypes(true).create()).create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().mapper(graph.io(GraphSONIo.build()).mapper().embedTypes(true).create()).create();
writer.writeEdge(os, e);
final AtomicBoolean called = new AtomicBoolean(false);
- final GraphSONReader reader = graph.io().graphSONReader().mapper(graph.io().graphSONMapper().embedTypes(true).create()).create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().mapper(graph.io(GraphSONIo.build()).mapper().embedTypes(true).create()).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readEdge(bais, detachedEdge -> {
// a quick reminder here that the purpose of these id assertions is to ensure that those with
@@ -914,11 +917,11 @@ public class IoTest extends AbstractGremlinTest {
final Edge e = v1.addEdge("friend", v2, "uuid", id);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeEdge(os, e);
final AtomicBoolean called = new AtomicBoolean(false);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readEdge(bais, detachedEdge -> {
assertEquals(e.id(), detachedEdge.id());
@@ -952,11 +955,11 @@ public class IoTest extends AbstractGremlinTest {
v1.addEdge("friends", v2, "weight", 0.5f);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeVertex(os, v1);
final AtomicBoolean called = new AtomicBoolean(false);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, detachedVertex -> {
assertEquals(v1.id(), detachedVertex.id());
@@ -983,11 +986,11 @@ public class IoTest extends AbstractGremlinTest {
v1.addEdge("friends", v2, "weight", 0.5d);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeVertex(os, v1);
final AtomicBoolean called = new AtomicBoolean(false);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, detachedVertex -> {
assertEquals(v1.id(), detachedVertex.id());
@@ -1014,12 +1017,12 @@ public class IoTest extends AbstractGremlinTest {
v1.addEdge("friends", v2, "weight", 0.5d);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
final DetachedVertex dv = DetachedFactory.detach(v1, true);
writer.writeVertex(os, dv);
final AtomicBoolean called = new AtomicBoolean(false);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, detachedVertex -> {
assertEquals(v1.id(), detachedVertex.id());
@@ -1046,12 +1049,12 @@ public class IoTest extends AbstractGremlinTest {
v1.addEdge("friends", v2, "weight", 0.5d);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
final DetachedVertex dv = DetachedFactory.detach(v1, false);
writer.writeVertex(os, dv);
final AtomicBoolean called = new AtomicBoolean(false);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, detachedVertex -> {
assertEquals(v1.id(), detachedVertex.id());
@@ -1079,11 +1082,11 @@ public class IoTest extends AbstractGremlinTest {
v1.addEdge("friends", v2, "weight", 0.5d);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeVertex(os, v1);
final AtomicBoolean called = new AtomicBoolean(false);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, detachedVertex -> {
assertEquals(v1.id(), detachedVertex.id());
@@ -1114,11 +1117,11 @@ public class IoTest extends AbstractGremlinTest {
v1.addEdge("friends", v2, "weight", 0.5f);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().create();
writer.writeVertex(os, v1);
final AtomicBoolean called = new AtomicBoolean(false);
- final GraphSONReader reader = graph.io().graphSONReader().create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, detachedVertex -> {
assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
@@ -1147,12 +1150,12 @@ public class IoTest extends AbstractGremlinTest {
v1.addEdge("friends", v2, "weight", 0.5f);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().create();
final DetachedVertex dv = DetachedFactory.detach(v1, true);
writer.writeVertex(os, dv);
final AtomicBoolean called = new AtomicBoolean(false);
- final GraphSONReader reader = graph.io().graphSONReader().create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, detachedVertex -> {
assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
@@ -1181,12 +1184,12 @@ public class IoTest extends AbstractGremlinTest {
v1.addEdge("friends", v2, "weight", 0.5f);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().create();
final DetachedVertex dv = DetachedFactory.detach(v1, false);
writer.writeVertex(os, dv);
final AtomicBoolean called = new AtomicBoolean(false);
- final GraphSONReader reader = graph.io().graphSONReader().create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, detachedVertex -> {
assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
@@ -1216,11 +1219,11 @@ public class IoTest extends AbstractGremlinTest {
v1.addEdge("friends", v2, "weight", 0.5d);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().create();
writer.writeVertex(os, v1);
final AtomicBoolean called = new AtomicBoolean(false);
- final GraphSONReader reader = graph.io().graphSONReader().create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, detachedVertex -> {
assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
@@ -1243,11 +1246,11 @@ public class IoTest extends AbstractGremlinTest {
@LoadGraphWith(LoadGraphWith.GraphData.CLASSIC)
public void shouldReadWriteVerticesNoEdgesToGryoManual() throws Exception {
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeVertices(os, g.V().has("age", Compare.gt, 30));
final AtomicInteger called = new AtomicInteger(0);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final VertexByteArrayInputStream vbais = new VertexByteArrayInputStream(new ByteArrayInputStream(os.toByteArray()))) {
reader.readVertex(new ByteArrayInputStream(vbais.readVertexBytes().toByteArray()),
@@ -1271,11 +1274,11 @@ public class IoTest extends AbstractGremlinTest {
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldReadWriteVerticesNoEdgesToGryo() throws Exception {
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeVertices(os, g.V().has("age", Compare.gt, 30));
final AtomicInteger called = new AtomicInteger(0);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
final Iterator<Vertex> itty = reader.readVertices(bais, null,
@@ -1297,11 +1300,11 @@ public class IoTest extends AbstractGremlinTest {
@LoadGraphWith(LoadGraphWith.GraphData.CLASSIC)
public void shouldReadWriteVerticesNoEdgesToGraphSONManual() throws Exception {
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().create();
writer.writeVertices(os, g.V().has("age", Compare.gt, 30));
final AtomicInteger called = new AtomicInteger(0);
- final GraphSONReader reader = graph.io().graphSONReader().create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().create();
final BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(os.toByteArray())));
String line = br.readLine();
reader.readVertex(new ByteArrayInputStream(line.getBytes()),
@@ -1334,12 +1337,12 @@ public class IoTest extends AbstractGremlinTest {
final Edge e = v1.addEdge("friends", v2, "weight", 0.5d);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeVertex(os, v1, Direction.OUT);
final AtomicBoolean calledVertex = new AtomicBoolean(false);
final AtomicBoolean calledEdge = new AtomicBoolean(false);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, Direction.OUT, detachedVertex -> {
@@ -1383,12 +1386,12 @@ public class IoTest extends AbstractGremlinTest {
final Edge e = v1.addEdge("friends", v2, "weight", 0.5f);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().create();
writer.writeVertex(os, v1, Direction.OUT);
final AtomicBoolean calledVertex = new AtomicBoolean(false);
final AtomicBoolean calledEdge = new AtomicBoolean(false);
- final GraphSONReader reader = graph.io().graphSONReader().create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, Direction.OUT, detachedVertex -> {
assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
@@ -1430,13 +1433,13 @@ public class IoTest extends AbstractGremlinTest {
final Edge e = v2.addEdge("friends", v1, "weight", 0.5d);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeVertex(os, v1, Direction.IN);
final AtomicBoolean calledVertex = new AtomicBoolean(false);
final AtomicBoolean calledEdge = new AtomicBoolean(false);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, Direction.IN, detachedVertex -> {
assertEquals(v1.id(), detachedVertex.id());
@@ -1479,13 +1482,13 @@ public class IoTest extends AbstractGremlinTest {
final Edge e = v2.addEdge("friends", v1, "weight", 0.5f);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().create();
writer.writeVertex(os, v1, Direction.IN);
os.close();
final AtomicBoolean calledVertex = new AtomicBoolean(false);
final AtomicBoolean calledEdge = new AtomicBoolean(false);
- final GraphSONReader reader = graph.io().graphSONReader().create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, Direction.IN, detachedVertex -> {
assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
@@ -1528,14 +1531,14 @@ public class IoTest extends AbstractGremlinTest {
final Edge e2 = v1.addEdge("friends", v2, "weight", 1.0d);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeVertex(os, v1, Direction.BOTH);
final AtomicBoolean calledVertex = new AtomicBoolean(false);
final AtomicBoolean calledEdge1 = new AtomicBoolean(false);
final AtomicBoolean calledEdge2 = new AtomicBoolean(false);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, Direction.BOTH, detachedVertex -> {
assertEquals(v1.id(), detachedVertex.id());
@@ -1592,14 +1595,14 @@ public class IoTest extends AbstractGremlinTest {
final Edge e2 = v1.addEdge("friends", v2, "weight", 1.0f);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().create();
writer.writeVertex(os, v1, Direction.BOTH);
final AtomicBoolean vertexCalled = new AtomicBoolean(false);
final AtomicBoolean edge1Called = new AtomicBoolean(false);
final AtomicBoolean edge2Called = new AtomicBoolean(false);
- final GraphSONReader reader = graph.io().graphSONReader().create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, Direction.BOTH, detachedVertex -> {
assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
@@ -1657,14 +1660,14 @@ public class IoTest extends AbstractGremlinTest {
final Edge e2 = v1.addEdge("friends", v2, "weight", 1.0f);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().mapper(graph.io().graphSONMapper().embedTypes(true).create()).create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().mapper(graph.io(GraphSONIo.build()).mapper().embedTypes(true).create()).create();
writer.writeVertex(os, v1, Direction.BOTH);
final AtomicBoolean vertexCalled = new AtomicBoolean(false);
final AtomicBoolean edge1Called = new AtomicBoolean(false);
final AtomicBoolean edge2Called = new AtomicBoolean(false);
- final GraphSONReader reader = graph.io().graphSONReader().mapper(graph.io().graphSONMapper().embedTypes(true).create()).create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().mapper(graph.io(GraphSONIo.build()).mapper().embedTypes(true).create()).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, Direction.BOTH, detachedVertex -> {
// a quick reminder here that the purpose of these id assertions is to ensure that those with
@@ -1725,13 +1728,13 @@ public class IoTest extends AbstractGremlinTest {
v1.addEdge("friends", v2, "weight", 1.0d);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeVertex(os, v1, Direction.BOTH);
final AtomicBoolean vertexCalled = new AtomicBoolean(false);
final AtomicBoolean edge1Called = new AtomicBoolean(false);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, Direction.IN, detachedVertex -> {
assertEquals(v1.id(), detachedVertex.id());
@@ -1778,13 +1781,13 @@ public class IoTest extends AbstractGremlinTest {
v1.addEdge("friends", v2, "weight", 1.0f);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().create();
writer.writeVertex(os, v1, Direction.BOTH);
final AtomicBoolean vertexCalled = new AtomicBoolean(false);
final AtomicBoolean edgeCalled = new AtomicBoolean(false);
- final GraphSONReader reader = graph.io().graphSONReader().create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, Direction.IN, detachedVertex -> {
assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
@@ -1831,13 +1834,13 @@ public class IoTest extends AbstractGremlinTest {
final Edge e2 = v1.addEdge("friends", v2, "weight", 1.0d);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeVertex(os, v1, Direction.BOTH);
final AtomicBoolean vertexCalled = new AtomicBoolean(false);
final AtomicBoolean edgeCalled = new AtomicBoolean(false);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, Direction.OUT, detachedVertex -> {
assertEquals(v1.id(), detachedVertex.id());
@@ -1885,13 +1888,13 @@ public class IoTest extends AbstractGremlinTest {
final Edge e2 = v1.addEdge("friends", v2, "weight", 1.0f);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GraphSONWriter writer = graph.io().graphSONWriter().create();
+ final GraphSONWriter writer = graph.io(GraphSONIo.build()).writer().create();
writer.writeVertex(os, v1, Direction.BOTH);
final AtomicBoolean vertexCalled = new AtomicBoolean(false);
final AtomicBoolean edgeCalled = new AtomicBoolean(false);
- final GraphSONReader reader = graph.io().graphSONReader().create();
+ final GraphSONReader reader = graph.io(GraphSONIo.build()).reader().create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais, Direction.OUT, detachedVertex -> {
assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
@@ -1935,10 +1938,10 @@ public class IoTest extends AbstractGremlinTest {
v1.addEdge("friends", v2, "weight", 0.5d);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeVertex(os, v1, Direction.OUT);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais,
Direction.BOTH,
@@ -1959,10 +1962,10 @@ public class IoTest extends AbstractGremlinTest {
v2.addEdge("friends", v1, "weight", 0.5d);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeVertex(os, v1, Direction.IN);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais,
Direction.BOTH,
@@ -1983,10 +1986,10 @@ public class IoTest extends AbstractGremlinTest {
v2.addEdge("friends", v1, "weight", 0.5d);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeVertex(os, v1, Direction.IN);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais,
Direction.OUT,
@@ -2007,10 +2010,10 @@ public class IoTest extends AbstractGremlinTest {
v1.addEdge("friends", v2, "weight", 0.5d);
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final GryoWriter writer = graph.io().gryoWriter().create();
+ final GryoWriter writer = graph.io(GryoIo.build()).writer().create();
writer.writeVertex(os, v1, Direction.IN);
- final GryoReader reader = graph.io().gryoReader().workingDirectory(tempPath).create();
+ final GryoReader reader = graph.io(GryoIo.build()).reader().workingDirectory(tempPath).create();
try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
reader.readVertex(bais,
Direction.OUT,
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b28252a1/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
index 6ad96d1..5b6b475 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
@@ -24,7 +24,9 @@ import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
import org.apache.tinkerpop.gremlin.LoadGraphWith;
import org.apache.tinkerpop.gremlin.process.traversal.Path;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONIo;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
import org.junit.Test;
@@ -53,8 +55,9 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertexAsDetached() throws Exception {
- final GryoWriter gryoWriter = graph.io().gryoWriter().create();
- final GryoReader gryoReader = graph.io().gryoReader().create();
+ final GryoIo gryoIo = graph.io(GryoIo.build());
+ final GryoWriter gryoWriter = gryoIo.writer().create();
+ final GryoReader gryoReader = gryoIo.reader().create();
final Vertex v = graph.vertices(convertToVertexId("marko")).next();
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
@@ -72,8 +75,9 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeEdgeAsDetached() throws Exception {
- final GryoWriter gryoWriter = graph.io().gryoWriter().create();
- final GryoReader gryoReader = graph.io().gryoReader().create();
+ final GryoIo gryoIo = graph.io(GryoIo.build());
+ final GryoWriter gryoWriter = gryoIo.writer().create();
+ final GryoReader gryoReader = gryoIo.reader().create();
final Edge e = g.E(convertToEdgeId("marko", "knows", "vadas")).next();
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
@@ -90,8 +94,9 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializePropertyAsDetached() throws Exception {
- final GryoWriter gryoWriter = graph.io().gryoWriter().create();
- final GryoReader gryoReader = graph.io().gryoReader().create();
+ final GryoIo gryoIo = graph.io(GryoIo.build());
+ final GryoWriter gryoWriter = gryoIo.writer().create();
+ final GryoReader gryoReader = gryoIo.reader().create();
final Property property = g.E(convertToEdgeId("marko", "knows", "vadas")).next().property("weight");
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
@@ -107,8 +112,9 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertexPropertyAsDetached() throws Exception {
- final GryoWriter gryoWriter = graph.io().gryoWriter().create();
- final GryoReader gryoReader = graph.io().gryoReader().create();
+ final GryoIo gryoIo = graph.io(GryoIo.build());
+ final GryoWriter gryoWriter = gryoIo.writer().create();
+ final GryoReader gryoReader = gryoIo.reader().create();
final VertexProperty vertexProperty = graph.vertices(convertToVertexId("marko")).next().property("name");
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
@@ -125,8 +131,9 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.CREW)
public void shouldSerializeVertexPropertyWithPropertiesAsDetached() throws Exception {
- final GryoWriter gryoWriter = graph.io().gryoWriter().create();
- final GryoReader gryoReader = graph.io().gryoReader().create();
+ final GryoIo gryoIo = graph.io(GryoIo.build());
+ final GryoWriter gryoWriter = gryoIo.writer().create();
+ final GryoReader gryoReader = gryoIo.reader().create();
final VertexProperty<?> vertexProperty = graph.vertices(convertToVertexId("marko")).next().properties("location").next();
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
@@ -148,8 +155,9 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializePathAsDetached() throws Exception {
- final GryoWriter gryoWriter = graph.io().gryoWriter().create();
- final GryoReader gryoReader = graph.io().gryoReader().create();
+ final GryoIo gryoIo = graph.io(GryoIo.build());
+ final GryoWriter gryoWriter = gryoIo.writer().create();
+ final GryoReader gryoReader = gryoIo.reader().create();
final Path p = g.V(convertToVertexId("marko")).as("a").outE().as("b").inV().as("c").path()
.filter(t -> ((Vertex) t.get().objects().get(2)).value("name").equals("lop")).next();
@@ -193,8 +201,9 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeTraversalMetrics() throws Exception {
- final GryoWriter gryoWriter = graph.io().gryoWriter().create();
- final GryoReader gryoReader = graph.io().gryoReader().create();
+ final GryoIo gryoIo = graph.io(GryoIo.build());
+ final GryoWriter gryoWriter = gryoIo.writer().create();
+ final GryoReader gryoReader = gryoIo.reader().create();
final TraversalMetrics before = (TraversalMetrics) g.V().both().profile().cap(TraversalMetrics.METRICS_KEY).next();
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
@@ -216,7 +225,7 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertex() throws Exception {
- final ObjectMapper mapper = graph.io().graphSONMapper().create().createMapper();
+ final ObjectMapper mapper = graph.io(GraphSONIo.build()).mapper().create().createMapper();
final Vertex v = graph.vertices(convertToVertexId("marko")).next();
final String json = mapper.writeValueAsString(v);
final Map<String, Object> m = mapper.readValue(json, mapTypeReference);
@@ -231,7 +240,7 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeEdge() throws Exception {
- final ObjectMapper mapper = graph.io().graphSONMapper().create().createMapper();
+ final ObjectMapper mapper = graph.io(GraphSONIo.build()).mapper().create().createMapper();
final Edge e = g.E(convertToEdgeId("marko", "knows", "vadas")).next();
final String json = mapper.writeValueAsString(e);
final Map<String, Object> m = mapper.readValue(json, mapTypeReference);
@@ -245,7 +254,7 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeProperty() throws Exception {
- final ObjectMapper mapper = graph.io().graphSONMapper().create().createMapper();
+ final ObjectMapper mapper = graph.io(GraphSONIo.build()).mapper().create().createMapper();
final Property p = g.E(convertToEdgeId("marko", "knows", "vadas")).next().property("weight");
final String json = mapper.writeValueAsString(p);
final Map<String, Object> m = mapper.readValue(json, mapTypeReference);
@@ -256,7 +265,7 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertexProperty() throws Exception {
- final ObjectMapper mapper = graph.io().graphSONMapper().create().createMapper();
+ final ObjectMapper mapper = graph.io(GraphSONIo.build()).mapper().create().createMapper();
final VertexProperty vp = graph.vertices(convertToVertexId("marko")).next().property("name");
final String json = mapper.writeValueAsString(vp);
final Map<String, Object> m = mapper.readValue(json, mapTypeReference);
@@ -269,7 +278,7 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.CREW)
public void shouldSerializeVertexPropertyWithProperties() throws Exception {
- final ObjectMapper mapper = graph.io().graphSONMapper().create().createMapper();
+ final ObjectMapper mapper = graph.io(GraphSONIo.build()).mapper().create().createMapper();
final VertexProperty vp = graph.vertices(convertToVertexId("marko")).next().properties("location").next();
final String json = mapper.writeValueAsString(vp);
final Map<String, Object> m = mapper.readValue(json, mapTypeReference);
@@ -284,7 +293,7 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializePath() throws Exception {
- final ObjectMapper mapper = graph.io().graphSONMapper().create().createMapper();
+ final ObjectMapper mapper = graph.io(GraphSONIo.build()).mapper().create().createMapper();
final Path p = g.V(convertToVertexId("marko")).as("a").outE().as("b").inV().as("c").path()
.filter(t -> ((Vertex) t.get().objects().get(2)).value("name").equals("lop")).next();
final String json = mapper.writeValueAsString(p);
@@ -311,7 +320,7 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeTraversalMetrics() throws Exception {
- final ObjectMapper mapper = graph.io().graphSONMapper().create().createMapper();
+ final ObjectMapper mapper = graph.io(GraphSONIo.build()).mapper().create().createMapper();
final TraversalMetrics tm = (TraversalMetrics) g.V().both().profile().cap(TraversalMetrics.METRICS_KEY).next();
final String json = mapper.writeValueAsString(tm);
final Map<String, Object> m = mapper.readValue(json, mapTypeReference);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b28252a1/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
index 291dddd..1cbc830 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
@@ -21,6 +21,7 @@ package org.apache.tinkerpop.gremlin.tinkergraph.structure;
import org.apache.commons.io.FileUtils;
import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
import org.apache.tinkerpop.gremlin.TestHelper;
+import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLIo;
import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
import org.apache.tinkerpop.gremlin.process.traversal.T;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
@@ -117,7 +118,7 @@ public class TinkerGraphTest {
public void benchmarkStandardTraversals() throws Exception {
Graph graph = TinkerGraph.open();
GraphTraversalSource g = graph.traversal();
- graph.io().readGraphML("data/grateful-dead.xml");
+ graph.io(GraphMLIo.build()).read("data/grateful-dead.xml");
final List<Supplier<Traversal>> traversals = Arrays.asList(
() -> g.V().outE().inV().outE().inV().outE().inV(),
() -> g.V().out().out().out(),
@@ -153,7 +154,7 @@ public class TinkerGraphTest {
@Ignore
public void testPlay4() throws Exception {
Graph graph = TinkerGraph.open();
- graph.io().readGraphML("/Users/marko/software/tinkerpop/tinkerpop3/data/grateful-dead.xml");
+ graph.io(GraphMLIo.build()).read("/Users/marko/software/tinkerpop/tinkerpop3/data/grateful-dead.xml");
GraphTraversalSource g = graph.traversal();
final List<Supplier<Traversal>> traversals = Arrays.asList(
() -> g.V().has(T.label, "song").out().groupCount().<Vertex>by(t ->