org.apache.tinkerpop.gremlin.structure.io.IoCore Java Examples

The following examples show how to use org.apache.tinkerpop.gremlin.structure.io.IoCore. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestableTinkerPopGraphManager.java    From timbuctoo with GNU General Public License v3.0 6 votes vote down vote up
public String writeGraph() {
  java.io.OutputStream output = new java.io.OutputStream() {
    private StringBuilder stringBuilder = new StringBuilder();
    @Override
    public void write(int chr) throws java.io.IOException {
      stringBuilder.append((char) chr );
    }

    @Override
    public String toString() {
      return stringBuilder.toString();
    }
  };
  try {
    graph.io(IoCore.graphson()).writer().create().writeGraph(output, graph);
  } catch (java.io.IOException e) {
    e.printStackTrace();
  }

  String wellformedJson = "[" + String.join(",\n", (CharSequence[]) output.toString().split("\n")) + "]";
  com.google.gson.Gson gson = new GsonBuilder().setPrettyPrinting().create();
  com.google.gson.JsonParser jp = new JsonParser();
  com.google.gson.JsonElement je = jp.parse(wellformedJson);
  return gson.toJson(je);
}
 
Example #2
Source File: TinkerGraph.java    From tinkergraph-gremlin with Apache License 2.0 6 votes vote down vote up
private void loadGraph() {
    final File f = new File(graphLocation);
    if (f.exists() && f.isFile()) {
        try {
            if (graphFormat.equals("graphml")) {
                io(IoCore.graphml()).readGraph(graphLocation);
            } else if (graphFormat.equals("graphson")) {
                io(IoCore.graphson()).readGraph(graphLocation);
            } else if (graphFormat.equals("gryo")) {
                io(IoCore.gryo()).readGraph(graphLocation);
            } else {
                io(IoCore.createIoBuilder(graphFormat)).readGraph(graphLocation);
            }
        } catch (Exception ex) {
            throw new RuntimeException(String.format("Could not load graph at %s with %s", graphLocation, graphFormat), ex);
        }
    }
}
 
Example #3
Source File: TinkerGraph.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
private void loadGraph() {
    final File f = new File(graphLocation);
    if (f.exists() && f.isFile()) {
        try {
            if (graphFormat.equals("graphml")) {
                io(IoCore.graphml()).readGraph(graphLocation);
            } else if (graphFormat.equals("graphson")) {
                io(IoCore.graphson()).readGraph(graphLocation);
            } else if (graphFormat.equals("gryo")) {
                io(IoCore.gryo()).readGraph(graphLocation);
            } else {
                io(IoCore.createIoBuilder(graphFormat)).readGraph(graphLocation);
            }
        } catch (Exception ex) {
            throw new RuntimeException(String.format("Could not load graph at %s with %s", graphLocation, graphFormat), ex);
        }
    }
}
 
Example #4
Source File: AbstractEntityGraphFormatConsumer.java    From baleen with Apache License 2.0 6 votes vote down vote up
@Override
protected void processGraph(String documentSourceName, Graph graph) {
  WriterBuilder<? extends GraphWriter> writer;
  switch (format) {
    case GRYO:
      writer = graph.io(IoCore.gryo()).writer();
      break;
    case GRAPHSON:
      writer = graph.io(IoCore.graphson()).writer();
      break;
    case GRAPHML:
      // FALL THROUGH
    default:
      writer = graph.io(IoCore.graphml()).writer().normalize(true);
      break;
  }

  try (final OutputStream os = createOutputStream(documentSourceName)) {
    writer.create().writeGraph(os, graph);
  } catch (IOException e) {
    getMonitor().error("Error writing graph", e);
  }
}
 
Example #5
Source File: TinkerGraphSerializer.java    From trainbenchmark with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void persistModel() throws IOException, XMLStreamException, ClassNotFoundException, IllegalAccessException,
		InstantiationException {
	final TinkerGraphFormat format = gc.getGraphFormat();
	Builder<?> builder = null;
	switch (format) {
	case GRAPHML:
		builder = IoCore.graphml();
		break;
	case GRAPHSON:
		builder = IoCore.graphson();
		break;
	case GRYO:
		builder = IoCore.gryo();
		break;
	default:
		throw new UnsupportedOperationException("Format " + format + " is not supported.");
	}

	final String postfix = "-tinkerpop." + format.toString().toLowerCase();
	final String fileName = gc.getConfigBase().getModelPathWithoutExtension() + postfix;
	graph.io(builder).writeGraph(fileName);
	graph.close();
}
 
Example #6
Source File: AbstractDocumentGraphFormatConsumer.java    From baleen with Apache License 2.0 6 votes vote down vote up
@Override
protected void processGraph(String documentSourceName, Graph graph) {
  WriterBuilder<? extends GraphWriter> writer;
  switch (format) {
    case GRYO:
      writer = graph.io(IoCore.gryo()).writer();
      break;
    case GRAPHSON:
      writer = graph.io(IoCore.graphson()).writer();
      break;
    case GRAPHML:
      // FALL THROUGH
    default:
      writer = graph.io(IoCore.graphml()).writer().normalize(true);
      break;
  }

  try (final OutputStream os = createOutputStream(documentSourceName)) {
    writer.create().writeGraph(os, graph);
  } catch (IOException e) {
    getMonitor().error("Error writing graph", e);
  }
}
 
Example #7
Source File: AtlasJanusGraph.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public void exportToGson(OutputStream os) throws IOException {
    GraphSONMapper         mapper  = getGraph().io(IoCore.graphson()).mapper().create();
    GraphSONWriter.Builder builder = GraphSONWriter.build();

    builder.mapper(mapper);

    GraphSONWriter writer = builder.create();

    writer.writeGraph(os, getGraph());
}
 
Example #8
Source File: TinkerGraphTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSerializeTinkerGraphToGraphSONWithTypes() throws Exception {
    final TinkerGraph graph = TinkerFactory.createModern();
    final Mapper<ObjectMapper> mapper = graph.io(IoCore.graphson()).mapper().typeInfo(TypeInfo.PARTIAL_TYPES).create();
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        final GraphWriter writer = GraphSONWriter.build().mapper(mapper).create();
        writer.writeObject(out, graph);
        try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray())) {
            final GraphReader reader = GraphSONReader.build().mapper(mapper).create();
            final TinkerGraph target = reader.readObject(inputStream, TinkerGraph.class);
            IoTest.assertModernGraph(target, true, false);
        }
    }
}
 
Example #9
Source File: TinkerGraphTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSerializeTinkerGraphWithMultiPropertiesToGraphSON() throws Exception {
    final TinkerGraph graph = TinkerFactory.createTheCrew();
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        graph.io(IoCore.graphson()).writer().create().writeObject(out, graph);
        try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray())) {
            final TinkerGraph target = graph.io(IoCore.graphson()).reader().create().readObject(inputStream, TinkerGraph.class);
            IoTest.assertCrewGraph(target, false);
        }
    }
}
 
Example #10
Source File: TinkerGraphTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSerializeTinkerGraphToGraphSON() throws Exception {
    final TinkerGraph graph = TinkerFactory.createModern();
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        graph.io(IoCore.graphson()).writer().create().writeObject(out, graph);
        try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray())) {
            final TinkerGraph target = graph.io(IoCore.graphson()).reader().create().readObject(inputStream, TinkerGraph.class);
            IoTest.assertModernGraph(target, true, false);
        }
    }
}
 
Example #11
Source File: TinkerGraphTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSerializeTinkerGraphWithMultiPropertiesToGryo() throws Exception {
    final TinkerGraph graph = TinkerFactory.createTheCrew();
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        graph.io(IoCore.gryo()).writer().create().writeObject(out, graph);
        final byte[] b = out.toByteArray();
        try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(b)) {
            final TinkerGraph target = graph.io(IoCore.gryo()).reader().create().readObject(inputStream, TinkerGraph.class);
            IoTest.assertCrewGraph(target, false);
        }
    }
}
 
Example #12
Source File: TinkerGraphTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSerializeTinkerGraphToGryo() throws Exception {
    final TinkerGraph graph = TinkerFactory.createModern();
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        graph.io(IoCore.gryo()).writer().create().writeObject(out, graph);
        final byte[] b = out.toByteArray();
        try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(b)) {
            final TinkerGraph target = graph.io(IoCore.gryo()).reader().create().readObject(inputStream, TinkerGraph.class);
            IoTest.assertModernGraph(target, true, false);
        }
    }
}
 
Example #13
Source File: TinkerGraph.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private void saveGraph() {
    final File f = new File(graphLocation);
    if (f.exists()) {
        f.delete();
    } else {
        final File parent = f.getParentFile();

        // the parent would be null in the case of an relative path if the graphLocation was simply: "f.gryo"
        if (parent != null && !parent.exists()) {
            parent.mkdirs();
        }
    }

    try {
        if (graphFormat.equals("graphml")) {
            io(IoCore.graphml()).writeGraph(graphLocation);
        } else if (graphFormat.equals("graphson")) {
            io(IoCore.graphson()).writeGraph(graphLocation);
        } else if (graphFormat.equals("gryo")) {
            io(IoCore.gryo()).writeGraph(graphLocation);
        } else {
            io(IoCore.createIoBuilder(graphFormat)).writeGraph(graphLocation);
        }
    } catch (Exception ex) {
        throw new RuntimeException(String.format("Could not save graph at %s with %s", graphLocation, graphFormat), ex);
    }
}
 
Example #14
Source File: StarGraphTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private Pair<StarGraph, Integer> serializeDeserialize(final StarGraph starGraph) {
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    try {
        graph.io(IoCore.gryo()).writer().create().writeObject(outputStream, starGraph);
        return Pair.with(graph.io(IoCore.gryo()).reader().create().readObject(new ByteArrayInputStream(outputStream.toByteArray()), StarGraph.class), outputStream.size());
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
}
 
Example #15
Source File: ImportGremlinPluginTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldImportSingleArgMethod() throws Exception {
    final Method singleArg = IoCore.class.getMethod("createIoBuilder", String.class);
    final ImportGremlinPlugin module = ImportGremlinPlugin.build()
            .methodImports(Collections.singletonList(toMethodDescriptor(singleArg))).create();

    final DefaultImportCustomizer customizer = (DefaultImportCustomizer) module.getCustomizers().get()[0];
    assertEquals(1, module.getCustomizers().get().length);
    assertThat(customizer.getMethodImports(), hasItems(singleArg));
    assertEquals(1, customizer.getMethodImports().size());
}
 
Example #16
Source File: Titan1Graph.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Override
public void exportToGson(OutputStream os) throws IOException {

    GraphSONMapper mapper = getGraph().io(IoCore.graphson()).mapper().create();
    GraphSONWriter.Builder builder = GraphSONWriter.build();
    builder.mapper(mapper);
    GraphSONWriter writer = builder.create();
    writer.writeGraph(os, getGraph());
}
 
Example #17
Source File: JanusGraphDriver.java    From trainbenchmark with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void read(final String modelPath) throws XMLStreamException, IOException, ConfigurationException {
	//final PropertiesConfiguration conf = new PropertiesConfiguration("conf/jgex-berkeleyje.properties");
	final PropertiesConfiguration conf = new PropertiesConfiguration("conf/jgex-inmemory.properties");
	graph = GraphFactory.open(conf);
	graph.io(IoCore.graphml()).readGraph(modelPath);
}
 
Example #18
Source File: TinkerGraphTest.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSerializeTinkerGraphToGraphSONWithTypes() throws Exception {
    final TinkerGraph graph = TinkerFactory.createModern();
    final Mapper<ObjectMapper> mapper = graph.io(IoCore.graphson()).mapper().typeInfo(TypeInfo.PARTIAL_TYPES).create();
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        final GraphWriter writer = GraphSONWriter.build().mapper(mapper).create();
        writer.writeObject(out, graph);
        try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray())) {
            final GraphReader reader = GraphSONReader.build().mapper(mapper).create();
            final TinkerGraph target = reader.readObject(inputStream, TinkerGraph.class);
            IoTest.assertModernGraph(target, true, false);
        }
    }
}
 
Example #19
Source File: TinkerGraphTest.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSerializeTinkerGraphWithMultiPropertiesToGraphSON() throws Exception {
    final TinkerGraph graph = TinkerFactory.createTheCrew();
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        graph.io(IoCore.graphson()).writer().create().writeObject(out, graph);
        try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray())) {
            final TinkerGraph target = graph.io(IoCore.graphson()).reader().create().readObject(inputStream, TinkerGraph.class);
            IoTest.assertCrewGraph(target, false);
        }
    }
}
 
Example #20
Source File: TinkerGraphTest.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSerializeTinkerGraphToGraphSON() throws Exception {
    final TinkerGraph graph = TinkerFactory.createModern();
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        graph.io(IoCore.graphson()).writer().create().writeObject(out, graph);
        try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray())) {
            final TinkerGraph target = graph.io(IoCore.graphson()).reader().create().readObject(inputStream, TinkerGraph.class);
            IoTest.assertModernGraph(target, true, false);
        }
    }
}
 
Example #21
Source File: TinkerGraphTest.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSerializeTinkerGraphWithMultiPropertiesToGryo() throws Exception {
    final TinkerGraph graph = TinkerFactory.createTheCrew();
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        graph.io(IoCore.gryo()).writer().create().writeObject(out, graph);
        final byte[] b = out.toByteArray();
        try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(b)) {
            final TinkerGraph target = graph.io(IoCore.gryo()).reader().create().readObject(inputStream, TinkerGraph.class);
            IoTest.assertCrewGraph(target, false);
        }
    }
}
 
Example #22
Source File: TinkerGraphTest.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSerializeTinkerGraphToGryo() throws Exception {
    final TinkerGraph graph = TinkerFactory.createModern();
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        graph.io(IoCore.gryo()).writer().create().writeObject(out, graph);
        final byte[] b = out.toByteArray();
        try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(b)) {
            final TinkerGraph target = graph.io(IoCore.gryo()).reader().create().readObject(inputStream, TinkerGraph.class);
            IoTest.assertModernGraph(target, true, false);
        }
    }
}
 
Example #23
Source File: TinkerGraph.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
private void saveGraph() {
    final File f = new File(graphLocation);
    if (f.exists()) {
        f.delete();
    } else {
        final File parent = f.getParentFile();

        // the parent would be null in the case of an relative path if the graphLocation was simply: "f.gryo"
        if (parent != null && !parent.exists()) {
            parent.mkdirs();
        }
    }

    try {
        if (graphFormat.equals("graphml")) {
            io(IoCore.graphml()).writeGraph(graphLocation);
        } else if (graphFormat.equals("graphson")) {
            io(IoCore.graphson()).writeGraph(graphLocation);
        } else if (graphFormat.equals("gryo")) {
            io(IoCore.gryo()).writeGraph(graphLocation);
        } else {
            io(IoCore.createIoBuilder(graphFormat)).writeGraph(graphLocation);
        }
    } catch (Exception ex) {
        throw new RuntimeException(String.format("Could not save graph at %s with %s", graphLocation, graphFormat), ex);
    }
}
 
Example #24
Source File: MainGraphConnector.java    From egeria with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
//TODO Remove before pentest or production
public void dumpMainGraph() {
    try {
        mainGraph.io(IoCore.graphml()).writeGraph("mainGraph.graphml");
    } catch (IOException e) {
        log.error(e.getMessage());
    }
}
 
Example #25
Source File: GraphDriver.java    From trainbenchmark with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void read(String modelPath) throws Exception {
	graph.io(IoCore.graphml()).readGraph(modelPath);
}
 
Example #26
Source File: ConsoleCompiler.java    From sparql-gremlin with Apache License 2.0 4 votes vote down vote up
public static void main(final String[] args) throws IOException {

        final Options options = new Options();
        options.addOption("f", "file", true, "a file that contains a SPARQL query");
        options.addOption("g", "graph", true, "the graph that's used to execute the query [classic|modern|crew|kryo file]");
        // TODO: add an OLAP option (perhaps: "--olap spark"?)

        final CommandLineParser parser = new DefaultParser();
        final CommandLine commandLine;

        try {
            commandLine = parser.parse(options, args);
        } catch (ParseException e) {
            System.out.println(e.getMessage());
            printHelp(1);
            return;
        }

        final InputStream inputStream = commandLine.hasOption("file")
                ? new FileInputStream(commandLine.getOptionValue("file"))
                : System.in;
        final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        final StringBuilder queryBuilder = new StringBuilder();

        if (!reader.ready()) {
            printHelp(1);
        }

        String line;
        while (null != (line = reader.readLine())) {
            queryBuilder.append(System.lineSeparator()).append(line);
        }

        final String queryString = queryBuilder.toString();
        final Graph graph;

        if (commandLine.hasOption("graph")) {
            switch (commandLine.getOptionValue("graph").toLowerCase()) {
                case "classic":
                    graph = TinkerFactory.createClassic();
                    break;
                case "modern":
                    graph = TinkerFactory.createModern();
                    break;
                case "crew":
                    graph = TinkerFactory.createTheCrew();
                    break;
                default:
                    graph = TinkerGraph.open();
                    graph.io(IoCore.gryo()).readGraph(commandLine.getOptionValue("graph"));
                    break;
            }
        } else {
            graph = TinkerFactory.createModern();
        }

        final Traversal<Vertex, ?> traversal = SparqlToGremlinCompiler.convertToGremlinTraversal(graph, queryString);

        printWithHeadline("SPARQL Query", queryString);
        printWithHeadline("Traversal (prior execution)", traversal);
        printWithHeadline("Result", String.join(System.lineSeparator(),
                traversal.toStream().map(Object::toString).collect(Collectors.toList())));
        printWithHeadline("Traversal (after execution)", traversal);
    }
 
Example #27
Source File: GraphSaveRestoreTest.java    From tinkergraph-gremlin with Apache License 2.0 4 votes vote down vote up
private void loadGraphMl(TinkerGraph graph) throws IOException {
  graph.io(IoCore.graphml()).readGraph("src/test/resources/grateful-dead.xml");
}
 
Example #28
Source File: SpecializedElementsTest.java    From tinkergraph-gremlin with Apache License 2.0 4 votes vote down vote up
private void loadGraphMl(TinkerGraph graph) throws IOException {
    graph.io(IoCore.graphml()).readGraph("src/test/resources/grateful-dead.xml");
}
 
Example #29
Source File: SpecializedElementsWithOndiskTest.java    From tinkergraph-gremlin with Apache License 2.0 4 votes vote down vote up
private void loadGraphMl(TinkerGraph graph) throws IOException {
    graph.io(IoCore.graphml()).readGraph("src/test/resources/grateful-dead.xml");
}
 
Example #30
Source File: GryoSerializerIntegrateTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldHaveAllRegisteredGryoSerializerClasses() throws Exception {
    // this is a stress test that ensures that when data is spilling to disk, persisted to an RDD, etc. the correct classes are registered with GryoSerializer.
    final TinkerGraph randomGraph = TinkerGraph.open();
    int totalVertices = 200000;
    TestHelper.createRandomGraph(randomGraph, totalVertices, 100);
    final String inputLocation = TestHelper.makeTestDataFile(GryoSerializerIntegrateTest.class,
                                                             UUID.randomUUID().toString(),
                                                             "random-graph.kryo");
    randomGraph.io(IoCore.gryo()).writeGraph(inputLocation);
    randomGraph.clear();
    randomGraph.close();

    final String outputLocation = TestHelper.makeTestDataDirectory(GryoSerializerIntegrateTest.class, UUID.randomUUID().toString());
    Configuration configuration = getBaseConfiguration();
    configuration.clearProperty(Constants.SPARK_SERIALIZER); // ensure proper default to GryoSerializer
    configuration.setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, inputLocation);
    configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, GryoInputFormat.class.getCanonicalName());
    configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, GryoOutputFormat.class.getCanonicalName());
    configuration.setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, outputLocation);
    configuration.setProperty(Constants.GREMLIN_SPARK_PERSIST_CONTEXT, false);
    Graph graph = GraphFactory.open(configuration);
    final GraphTraversal.Admin<Vertex, Map<Vertex, Collection<Vertex>>> traversal = graph.traversal().withComputer(SparkGraphComputer.class).V().group("m").<Map<Vertex, Collection<Vertex>>>cap("m").asAdmin();
    assertTrue(traversal.hasNext());
    assertEquals(traversal.next(), traversal.getSideEffects().get("m"));
    assertFalse(traversal.hasNext());
    assertTrue(traversal.getSideEffects().exists("m"));
    assertTrue(traversal.getSideEffects().get("m") instanceof Map);
    assertEquals(totalVertices, traversal.getSideEffects().<Map>get("m").size());

    configuration = getBaseConfiguration();
    configuration.clearProperty(Constants.SPARK_SERIALIZER); // ensure proper default to GryoSerializer
    configuration.setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, inputLocation);
    configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, GryoInputFormat.class.getCanonicalName());
    configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, PersistedOutputRDD.class.getCanonicalName());
    configuration.setProperty(Constants.GREMLIN_SPARK_PERSIST_STORAGE_LEVEL, "DISK_ONLY");
    configuration.setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, "persisted-rdd");
    configuration.setProperty(Constants.GREMLIN_SPARK_PERSIST_CONTEXT, true);
    graph = GraphFactory.open(configuration);
    assertEquals(totalVertices, graph.compute(SparkGraphComputer.class).program(PageRankVertexProgram.build().iterations(2).create(graph)).submit().get().graph().traversal().V().count().next().longValue());

    configuration = getBaseConfiguration();
    configuration.clearProperty(Constants.SPARK_SERIALIZER); // ensure proper default to GryoSerializer
    configuration.setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, "persisted-rdd");
    configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, PersistedInputRDD.class.getCanonicalName());
    configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, GryoOutputFormat.class.getCanonicalName());
    configuration.setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, outputLocation);
    configuration.setProperty(Constants.GREMLIN_SPARK_PERSIST_CONTEXT, true);
    graph = GraphFactory.open(configuration);
    assertEquals(totalVertices, graph.traversal().withComputer(SparkGraphComputer.class).V().count().next().longValue());

    configuration = getBaseConfiguration();
    configuration.setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, "persisted-rdd");
    configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, PersistedInputRDD.class.getCanonicalName());
    configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, PersistedOutputRDD.class.getCanonicalName());
    configuration.setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, outputLocation);
    configuration.setProperty(Constants.GREMLIN_SPARK_GRAPH_STORAGE_LEVEL, "MEMORY_ONLY"); // this should be ignored as you can't change the persistence level once created
    configuration.setProperty(Constants.GREMLIN_SPARK_PERSIST_STORAGE_LEVEL, "MEMORY_AND_DISK");
    configuration.setProperty(Constants.GREMLIN_SPARK_PERSIST_CONTEXT, true);
    graph = GraphFactory.open(configuration);
    assertEquals(totalVertices, graph.traversal().withComputer(SparkGraphComputer.class).V().count().next().longValue());
}