Java Code Examples for org.apache.tinkerpop.gremlin.LoadGraphWith#GraphData
The following examples show how to use
org.apache.tinkerpop.gremlin.LoadGraphWith#GraphData .
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: TinkerGraphProvider.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName, final LoadGraphWith.GraphData loadGraphWith) { final TinkerGraph.DefaultIdManager idManager = selectIdMakerFromGraphData(loadGraphWith); final String idMaker = (idManager.equals(TinkerGraph.DefaultIdManager.ANY) ? selectIdMakerFromTest(test, testMethodName) : idManager).name(); return new HashMap<String, Object>() {{ put(Graph.GRAPH, TinkerGraph.class.getName()); put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, idMaker); put(TinkerGraph.GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, idMaker); put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, idMaker); if (requiresListCardinalityAsDefault(loadGraphWith, test, testMethodName)) put(TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.name()); if (requiresPersistence(test, testMethodName)) { put(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "gryo"); put(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, TestHelper.makeTestDataFile(test, "temp", testMethodName + ".kryo")); } }}; }
Example 2
Source File: TinkerGraphProvider.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName, final LoadGraphWith.GraphData loadGraphWith) { final TinkerGraph.DefaultIdManager idManager = selectIdMakerFromGraphData(loadGraphWith); final String idMaker = (idManager.equals(TinkerGraph.DefaultIdManager.ANY) ? selectIdMakerFromTest(test, testMethodName) : idManager).name(); return new HashMap<String, Object>() {{ put(Graph.GRAPH, TinkerGraph.class.getName()); put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, idMaker); put(TinkerGraph.GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, idMaker); put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, idMaker); if (requiresListCardinalityAsDefault(loadGraphWith, test, testMethodName)) put(TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.name()); if (requiresPersistence(test, testMethodName)) { put(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "gryo"); put(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION,TestHelper.makeTestDataFile(test, "temp", testMethodName + ".kryo")); } }}; }
Example 3
Source File: TinkerGraphProvider.java From tinkergraph-gremlin with Apache License 2.0 | 6 votes |
@Override public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName, final LoadGraphWith.GraphData loadGraphWith) { final TinkerGraph.DefaultIdManager idManager = selectIdMakerFromGraphData(loadGraphWith); final String idMaker = (idManager.equals(TinkerGraph.DefaultIdManager.ANY) ? selectIdMakerFromTest(test, testMethodName) : idManager).name(); return new HashMap<String, Object>() {{ put(Graph.GRAPH, TinkerGraph.class.getName()); put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, idMaker); put(TinkerGraph.GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, idMaker); put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, idMaker); if (requiresListCardinalityAsDefault(loadGraphWith, test, testMethodName)) put(TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.name()); if (requiresPersistence(test, testMethodName)) { put(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "gryo"); final File tempDir = TestHelper.makeTestDataPath(test, "temp"); put(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, tempDir.getAbsolutePath() + File.separator + testMethodName + ".kryo"); } }}; }
Example 4
Source File: TinkerGraphUUIDProvider.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName, final LoadGraphWith.GraphData loadGraphWith) { final TinkerGraph.DefaultIdManager idManager = TinkerGraph.DefaultIdManager.UUID; final String idMaker = idManager.name(); return new HashMap<String, Object>() {{ put(Graph.GRAPH, TinkerGraph.class.getName()); put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, idMaker); put(TinkerGraph.GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, idMaker); put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, idMaker); if (requiresListCardinalityAsDefault(loadGraphWith, test, testMethodName)) put(TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.name()); if (requiresPersistence(test, testMethodName)) { put(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "gryo"); put(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, TestHelper.makeTestDataFile(test, "temp", testMethodName + ".kryo")); } }}; }
Example 5
Source File: TinkerGraphProvider.java From tinkergraph-gremlin with Apache License 2.0 | 6 votes |
/** * Test that load with specific graph data can be configured with a specific id manager as the data type to * be used in the test for that graph is known. */ protected TinkerGraph.DefaultIdManager selectIdMakerFromGraphData(final LoadGraphWith.GraphData loadGraphWith) { if (null == loadGraphWith) return TinkerGraph.DefaultIdManager.ANY; if (loadGraphWith.equals(LoadGraphWith.GraphData.CLASSIC)) return TinkerGraph.DefaultIdManager.INTEGER; else if (loadGraphWith.equals(LoadGraphWith.GraphData.MODERN)) return TinkerGraph.DefaultIdManager.INTEGER; else if (loadGraphWith.equals(LoadGraphWith.GraphData.CREW)) return TinkerGraph.DefaultIdManager.INTEGER; else if (loadGraphWith.equals(LoadGraphWith.GraphData.GRATEFUL)) return TinkerGraph.DefaultIdManager.INTEGER; else if (loadGraphWith.equals(LoadGraphWith.GraphData.SINK)) return TinkerGraph.DefaultIdManager.INTEGER; else throw new IllegalStateException(String.format("Need to define a new %s for %s", TinkerGraph.IdManager.class.getName(), loadGraphWith.name())); }
Example 6
Source File: Neo4jGraphProvider.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName, final LoadGraphWith.GraphData graphData) { final String directory = makeTestDirectory(graphName, test, testMethodName); return new HashMap<String, Object>() {{ put(Graph.GRAPH, Neo4jGraph.class.getName()); put(Neo4jGraph.CONFIG_DIRECTORY, directory); put(Neo4jGraph.CONFIG_CONF + ".dbms.memory.pagecache.size", "1m"); }}; }
Example 7
Source File: SparkHadoopGraphGryoSerializerProvider.java From tinkerpop with Apache License 2.0 | 5 votes |
public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName, final LoadGraphWith.GraphData loadGraphWith) { if (!SparkHadoopGraphGryoSerializerProvider.class.getCanonicalName().equals(System.getProperty(PREVIOUS_SPARK_PROVIDER, null))) { Spark.close(); KryoShimServiceLoader.close(); System.setProperty(PREVIOUS_SPARK_PROVIDER, SparkHadoopGraphGryoSerializerProvider.class.getCanonicalName()); } final Map<String, Object> config = super.getBaseConfiguration(graphName, test, testMethodName, loadGraphWith); config.put(Constants.SPARK_SERIALIZER, GryoSerializer.class.getCanonicalName()); config.remove(Constants.SPARK_KRYO_REGISTRATOR); return config; }
Example 8
Source File: TinkerGraphProvider.java From tinkerpop with Apache License 2.0 | 5 votes |
/** * Determines if a test requires a different cardinality as the default or not. */ protected static boolean requiresListCardinalityAsDefault(final LoadGraphWith.GraphData loadGraphWith, final Class<?> test, final String testMethodName) { return loadGraphWith == LoadGraphWith.GraphData.CREW || (test == StarGraphTest.class && testMethodName.equals("shouldAttachWithCreateMethod")) || (test == DetachedGraphTest.class && testMethodName.equals("testAttachableCreateMethod")); }
Example 9
Source File: AbstractRemoteGraphProvider.java From tinkerpop with Apache License 2.0 | 5 votes |
private static String getServerGraphName(final LoadGraphWith.GraphData loadGraphWith) { final String serverGraphName; if (null == loadGraphWith) return "graph"; switch (loadGraphWith) { case CLASSIC: serverGraphName = "classic"; break; case MODERN: serverGraphName = "modern"; break; case GRATEFUL: serverGraphName = "grateful"; break; case CREW: serverGraphName = "crew"; break; case SINK: serverGraphName = "sink"; break; default: serverGraphName = "graph"; break; } return serverGraphName; }
Example 10
Source File: AbstractRemoteGraphProvider.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public Map<String, Object> getBaseConfiguration(final String graphName, Class<?> test, final String testMethodName, final LoadGraphWith.GraphData loadGraphWith) { final String serverGraphName = getServerGraphName(loadGraphWith); final Supplier<Graph> graphGetter = () -> server.getServerGremlinExecutor().getGraphManager().getGraph(serverGraphName); return new HashMap<String, Object>() {{ put(Graph.GRAPH, RemoteGraph.class.getName()); put(RemoteConnection.GREMLIN_REMOTE_CONNECTION_CLASS, DriverRemoteConnection.class.getName()); put(DriverRemoteConnection.GREMLIN_REMOTE_DRIVER_SOURCENAME, "g" + serverGraphName); put("clusterConfiguration.port", TestClientFactory.PORT); put("clusterConfiguration.hosts", "localhost"); put(GREMLIN_REMOTE + "attachment", graphGetter); }}; }
Example 11
Source File: HadoopGraphProvider.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName, final LoadGraphWith.GraphData loadGraphWith) { this.graphSONInput = RANDOM.nextBoolean(); return new HashMap<String, Object>() {{ put(Graph.GRAPH, HadoopGraph.class.getName()); put(Constants.GREMLIN_HADOOP_GRAPH_READER, graphSONInput ? GraphSONInputFormat.class.getCanonicalName() : GryoInputFormat.class.getCanonicalName()); put(Constants.GREMLIN_HADOOP_GRAPH_WRITER, GryoOutputFormat.class.getCanonicalName()); put(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, getWorkingDirectory()); put(Constants.GREMLIN_HADOOP_JARS_IN_DISTRIBUTED_CACHE, false); }}; }
Example 12
Source File: AbstractTitanGraphProvider.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Override public Map<String, Object> getBaseConfiguration(String graphName, Class<?> test, String testMethodName, final LoadGraphWith.GraphData loadGraphWith) { ModifiableConfiguration conf = getTitanConfiguration(graphName, test, testMethodName); conf.set(GraphDatabaseConfiguration.COMPUTER_RESULT_MODE, "persist"); conf.set(GraphDatabaseConfiguration.AUTO_TYPE, "tp3"); Map<String, Object> result = new HashMap<>(); conf.getAll().entrySet().stream().forEach(e -> result.put(ConfigElement.getPath(e.getKey().element, e.getKey().umbrellaElements), e.getValue())); result.put(Graph.GRAPH, TitanFactory.class.getName()); return result; }
Example 13
Source File: TestGraphProvider.java From hugegraph with Apache License 2.0 | 5 votes |
@Override public Map<String, Object> getBaseConfiguration( String graphName, Class<?> testClass, String testMethod, LoadGraphWith.GraphData graphData) { // Check if test in blackList String testFullName = testClass.getCanonicalName() + "." + testMethod; int index = testFullName.indexOf('@') == -1 ? testFullName.length() : testFullName.indexOf('@'); testFullName = testFullName.substring(0, index); Assume.assumeFalse( String.format("Test %s will be ignored with reason: %s", testFullName, this.blackMethods.get(testFullName)), this.blackMethods.containsKey(testFullName)); LOG.debug("Full name of test is: {}", testFullName); LOG.debug("Prefix of test is: {}", testFullName.substring(0, index)); HashMap<String, Object> confMap = new HashMap<>(); PropertiesConfiguration config = Utils.getConf(); Iterator<String> keys = config.getKeys(); while (keys.hasNext()) { String key = keys.next(); confMap.put(key, config.getProperty(key)); } String storePrefix = config.getString(CoreOptions.STORE.name()); confMap.put(CoreOptions.STORE.name(), storePrefix + "_" + this.suite + "_" + graphName); confMap.put(GREMLIN_GRAPH_KEY, GREMLIN_GRAPH_VALUE); confMap.put(TEST_CLASS, testClass); confMap.put(TEST_METHOD, testMethod); confMap.put(LOAD_GRAPH, graphData); confMap.put(EXPECT_CUSTOMIZED_ID, customizedId(testClass, testMethod)); return confMap; }
Example 14
Source File: AbstractGraphBenchmark.java From tinkerpop with Apache License 2.0 | 5 votes |
/** * Opens a new {@link TinkerGraph} instance and optionally preloads it with one of the test data sets enumerated * in {@link LoadGraphWith}. * * @throws IOException on failure to load graph */ @Setup public void prepare() throws IOException { graph = TinkerGraph.open(); g = graph.traversal(); final LoadGraphWith[] loadGraphWiths = this.getClass().getAnnotationsByType(LoadGraphWith.class); final LoadGraphWith loadGraphWith = loadGraphWiths.length == 0 ? null : loadGraphWiths[0]; final LoadGraphWith.GraphData loadGraphWithData = null == loadGraphWith ? null : loadGraphWith.value(); String graphFile; if(loadGraphWithData != null) { if (loadGraphWithData.equals(LoadGraphWith.GraphData.GRATEFUL)) { graphFile = "grateful-dead-v3d0.kryo"; } else if (loadGraphWithData.equals(LoadGraphWith.GraphData.MODERN)) { graphFile = "tinkerpop-modern-v3d0.kryo"; } else if (loadGraphWithData.equals(LoadGraphWith.GraphData.CLASSIC)) { graphFile = "tinkerpop-classic-v3d0.kryo"; } else if (loadGraphWithData.equals(LoadGraphWith.GraphData.CREW)) { graphFile = "tinkerpop-crew-v3d0.kryo"; } else { throw new RuntimeException("Could not load graph with " + loadGraphWithData); } final GraphReader reader = GryoReader.build().create(); try (final InputStream stream = AbstractGraphBenchmark.class. getResourceAsStream(PATH + graphFile)) { reader.readGraph(stream, graph); } } }
Example 15
Source File: TinkerGraphProvider.java From tinkergraph-gremlin with Apache License 2.0 | 5 votes |
/** * Determines if a test requires a different cardinality as the default or not. */ protected static boolean requiresListCardinalityAsDefault(final LoadGraphWith.GraphData loadGraphWith, final Class<?> test, final String testMethodName) { return loadGraphWith == LoadGraphWith.GraphData.CREW || (test == StarGraphTest.class && testMethodName.equals("shouldAttachWithCreateMethod")) || (test == DetachedGraphTest.class && testMethodName.equals("testAttachableCreateMethod")); }
Example 16
Source File: AbstractTinkerGraphGraphSONTranslatorProvider.java From tinkergraph-gremlin with Apache License 2.0 | 5 votes |
@Override public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName, final LoadGraphWith.GraphData loadGraphWith) { final Map<String, Object> config = super.getBaseConfiguration(graphName, test, testMethodName, loadGraphWith); config.put("skipTest", SKIP_TESTS.contains(testMethodName) || SKIP_TESTS.contains(test.getCanonicalName())); return config; }
Example 17
Source File: TinkerGraphGryoTranslatorProvider.java From tinkergraph-gremlin with Apache License 2.0 | 5 votes |
@Override public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName, final LoadGraphWith.GraphData loadGraphWith) { final Map<String, Object> config = super.getBaseConfiguration(graphName, test, testMethodName, loadGraphWith); config.put("skipTest", SKIP_TESTS.contains(testMethodName) || SKIP_TESTS.contains(test.getCanonicalName())); return config; }
Example 18
Source File: AbstractNeo4jGraphProvider.java From tinkerpop with Apache License 2.0 | 4 votes |
private void createIndices(final Neo4jGraph graph, final LoadGraphWith.GraphData graphData) { final Random random = TestHelper.RANDOM; final boolean pick = random.nextBoolean(); if (graphData.equals(LoadGraphWith.GraphData.GRATEFUL)) { if (pick) { graph.tx().readWrite(); if (random.nextBoolean()) graph.cypher("CREATE INDEX ON :artist(name)").iterate(); if (random.nextBoolean()) graph.cypher("CREATE INDEX ON :song(name)").iterate(); if (random.nextBoolean()) graph.cypher("CREATE INDEX ON :song(songType)").iterate(); if (random.nextBoolean()) graph.cypher("CREATE INDEX ON :song(performances)").iterate(); graph.tx().commit(); } // else no indices } else if (graphData.equals(LoadGraphWith.GraphData.MODERN)) { if (pick) { graph.tx().readWrite(); if (random.nextBoolean()) graph.cypher("CREATE INDEX ON :person(name)").iterate(); if (random.nextBoolean()) graph.cypher("CREATE INDEX ON :person(age)").iterate(); if (random.nextBoolean()) graph.cypher("CREATE INDEX ON :software(name)").iterate(); if (random.nextBoolean()) { graph.cypher("CREATE INDEX ON :software(lang)").iterate(); } graph.tx().commit(); } // else no indices } else if (graphData.equals(LoadGraphWith.GraphData.CLASSIC)) { if (pick) { graph.tx().readWrite(); if (random.nextBoolean()) graph.cypher("CREATE INDEX ON :vertex(name)").iterate(); if (random.nextBoolean()) graph.cypher("CREATE INDEX ON :vertex(age)").iterate(); if (random.nextBoolean()) graph.cypher("CREATE INDEX ON :vertex(lang)").iterate(); graph.tx().commit(); } // else no indices } }
Example 19
Source File: SparkHadoopGraphProvider.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName, final LoadGraphWith.GraphData loadGraphWith) { this.graphSONInput = RANDOM.nextBoolean(); if (this.getClass().equals(SparkHadoopGraphProvider.class) && !SparkHadoopGraphProvider.class.getCanonicalName().equals(System.getProperty(PREVIOUS_SPARK_PROVIDER, null))) { Spark.close(); HadoopPools.close(); KryoShimServiceLoader.close(); System.setProperty(PREVIOUS_SPARK_PROVIDER, SparkHadoopGraphProvider.class.getCanonicalName()); } final Map<String,Object> config = new HashMap<String, Object>() {{ put(Graph.GRAPH, HadoopGraph.class.getName()); put(Constants.GREMLIN_HADOOP_GRAPH_READER, graphSONInput ? GraphSONInputFormat.class.getCanonicalName() : GryoInputFormat.class.getCanonicalName()); put(Constants.GREMLIN_HADOOP_GRAPH_WRITER, GryoOutputFormat.class.getCanonicalName()); put(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, getWorkingDirectory()); put(Constants.GREMLIN_HADOOP_JARS_IN_DISTRIBUTED_CACHE, false); put(Constants.GREMLIN_SPARK_PERSIST_CONTEXT, true); // this makes the test suite go really fast }}; // toy graph inputRDD does not have corresponding outputRDD so where jobs chain, it fails (failing makes sense) if (null != loadGraphWith && !test.equals(ProgramTest.Traversals.class) && !test.equals(PageRankTest.Traversals.class) && !test.equals(ConnectedComponentTest.Traversals.class) && !test.equals(ShortestPathTest.Traversals.class) && !test.equals(PeerPressureTest.Traversals.class) && !test.equals(FileSystemStorageCheck.class) && !testMethodName.equals("shouldSupportJobChaining") && // GraphComputerTest.shouldSupportJobChaining RANDOM.nextBoolean()) { config.put(Constants.GREMLIN_HADOOP_GRAPH_READER, ToyGraphInputRDD.class.getCanonicalName()); } // tests persisted RDDs if (test.equals(SparkContextStorageCheck.class)) { config.put(Constants.GREMLIN_HADOOP_GRAPH_READER, ToyGraphInputRDD.class.getCanonicalName()); config.put(Constants.GREMLIN_HADOOP_GRAPH_WRITER, PersistedOutputRDD.class.getCanonicalName()); } config.put(Constants.GREMLIN_HADOOP_DEFAULT_GRAPH_COMPUTER, SparkGraphComputer.class.getCanonicalName()); config.put(SparkLauncher.SPARK_MASTER, "local[" + AVAILABLE_PROCESSORS + "]"); config.put(Constants.SPARK_SERIALIZER, KryoSerializer.class.getCanonicalName()); config.put(Constants.SPARK_KRYO_REGISTRATOR, GryoRegistrator.class.getCanonicalName()); config.put(Constants.SPARK_KRYO_REGISTRATION_REQUIRED, true); return config; }
Example 20
Source File: TestGraphProvider.java From hugegraph with Apache License 2.0 | 4 votes |
@Watched public void loadGraphData(final Graph graph, final LoadGraphWith.GraphData loadGraphWith) { TestGraph testGraph = (TestGraph) graph; // Clear basic schema initiated in openTestGraph testGraph.clearAll(""); if (testGraph.loadedGraph() == null) { testGraph.loadedGraph(REGULAR_LOAD); } boolean standard = testGraph.hugegraph().name().endsWith(STANDARD); IdStrategy idStrategy = standard && !testGraph.ioTest() ? IdStrategy.AUTOMATIC : IdStrategy.CUSTOMIZE_STRING; switch (loadGraphWith) { case GRATEFUL: testGraph.initGratefulSchema(idStrategy); break; case MODERN: testGraph.initModernSchema(idStrategy); break; case CLASSIC: testGraph.initClassicSchema(idStrategy); break; case CREW: break; case SINK: testGraph.initSinkSchema(); break; default: throw new AssertionError(String.format( "Only support GRATEFUL, MODERN and CLASSIC " + "for @LoadGraphWith(), but '%s' is used ", loadGraphWith)); } LOG.debug("Load graph with {} schema", loadGraphWith); testGraph.tx().commit(); }