本文整理汇总了Java中org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph类的典型用法代码示例。如果您正苦于以下问题:Java Neo4jGraph类的具体用法?Java Neo4jGraph怎么用?Java Neo4jGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Neo4jGraph类属于org.apache.tinkerpop.gremlin.neo4j.structure包,在下文中一共展示了Neo4jGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBaseConfiguration
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; //导入依赖的package包/类
@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_META_PROPERTIES, true);
put(Neo4jGraph.CONFIG_MULTI_PROPERTIES, true);
}};
}
示例2: clear
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; //导入依赖的package包/类
@Override
public void clear(final Graph graph, final Configuration configuration) throws Exception {
if (null != graph) {
if (graph.tx().isOpen()) graph.tx().rollback();
graph.close();
}
if (configuration.containsKey(Neo4jGraph.CONFIG_DIRECTORY)) {
// this is a non-in-sideEffects configuration so blow away the directory
final File graphDirectory = new File(configuration.getString(Neo4jGraph.CONFIG_DIRECTORY));
deleteDirectory(graphDirectory);
}
}
示例3: dropIndices
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; //导入依赖的package包/类
public static void dropIndices(final Neo4jGraph graph, final LoadGraphWith.GraphData graphData) {
if (graphData.equals(LoadGraphWith.GraphData.GRATEFUL)) {
graph.tx().readWrite();
graph.cypher("DROP INDEX ON :artist(name)").iterate();
graph.cypher("DROP INDEX ON :song(name)").iterate();
graph.cypher("DROP INDEX ON :song(songType)").iterate();
graph.cypher("DROP INDEX ON :song(performances)").iterate();
graph.tx().commit();
} else if (graphData.equals(LoadGraphWith.GraphData.MODERN)) {
graph.tx().readWrite();
graph.cypher("DROP INDEX ON :person(name)").iterate();
graph.cypher("DROP INDEX ON :person(age)").iterate();
graph.cypher("DROP INDEX ON :software(name)").iterate();
graph.cypher("DROP INDEX ON :software(lang)").iterate();
graph.tx().commit();
} else if (graphData.equals(LoadGraphWith.GraphData.CLASSIC)) {
graph.tx().readWrite();
graph.cypher("DROP INDEX ON :vertex(name)").iterate();
graph.cypher("DROP INDEX ON :vertex(age)").iterate();
graph.cypher("DROP INDEX ON :vertex(lang)").iterate();
graph.tx().commit();
} else {
// TODO: add CREW work here.
// TODO: add meta_property indices when meta_property graph is provided
//throw new RuntimeException("Could not load graph with " + graphData);
}
}
示例4: getBaseConfiguration
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; //导入依赖的package包/类
@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_META_PROPERTIES, false);
put(Neo4jGraph.CONFIG_MULTI_PROPERTIES, false);
}};
}
示例5: getStorage
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; //导入依赖的package包/类
private static Storage getStorage(AntiochConfiguration config) {
String dataDir = config.getStorageDirectory() + "/neo4jdb";
createWhenAbsent(dataDir);
try {
graph = Neo4jGraph.open(dataDir);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("There was an error starting up the Neo4J graph; If this was caused by an interrupted indexing job, restarting the server might help.");
}
setIndexes();
return new Storage(graph);
}
示例6: setGraphProvider
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; //导入依赖的package包/类
@BeforeClass
public static void setGraphProvider() throws IOException {
GraphTest.graphProvider = new GraphProvider() {
public Graph getGraph() throws IOException {
return Neo4jGraph.open(folder.newFolder().getAbsolutePath());
}
};
}
示例7: getBaseConfiguration
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; //导入依赖的package包/类
@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_META_PROPERTIES, true);
put(Neo4jGraph.CONFIG_MULTI_PROPERTIES, true);
put(Neo4jGraph.CONFIG_CONF + ".dbms.memory.pagecache.size", "1m");
}};
}
示例8: getBaseConfiguration
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; //导入依赖的package包/类
@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_META_PROPERTIES, false);
put(Neo4jGraph.CONFIG_MULTI_PROPERTIES, false);
put(Neo4jGraph.CONFIG_CONF + ".dbms.memory.pagecache.size", "1m");
}};
}
示例9: generateTestParameters
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; //导入依赖的package包/类
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> generateTestParameters() {
final int LAZY_SIZE = 2500;
return Arrays.asList(new Object[][]{
{__.V().out(), g_V().out(), Collections.emptyList()},
{__.V().has("name", "marko").out(), g_V("name", eq("marko")).out(), Collections.emptyList()},
{__.V().has("name", "marko").has("age", gt(31).and(lt(10))).out(),
g_V("name", eq("marko"), "age", gt(31), "age", lt(10)).out(), Collections.emptyList()},
{__.V().has("name", "marko").or(has("age"), has("age", gt(32))).has("lang", "java"),
g_V("name", eq("marko"), "lang", eq("java")).or(has("age"), has("age", gt(32))), Collections.singletonList(FilterRankingStrategy.instance())},
{__.V().has("name", "marko").as("a").or(has("age"), has("age", gt(32))).has("lang", "java"),
g_V("name", eq("marko")).as("a").or(has("age"), has("age", gt(32))).has("lang", "java"), Collections.emptyList()},
{__.V().has("name", "marko").as("a").or(has("age"), has("age", gt(32))).has("lang", "java"),
g_V("name", eq("marko"), "lang", eq("java")).or(has("age"), has("age", gt(32))).as("a"), Collections.singletonList(FilterRankingStrategy.instance())},
{__.V().dedup().has("name", "marko").or(has("age"), has("age", gt(32))).has("lang", "java"),
g_V("name", eq("marko"), "lang", eq("java")).or(has("age"), has("age", gt(32))).dedup(), Collections.singletonList(FilterRankingStrategy.instance())},
{__.V().as("a").dedup().has("name", "marko").or(has("age"), has("age", gt(32))).has("lang", "java"),
g_V("name", eq("marko"), "lang", eq("java")).or(has("age"), has("age", gt(32))).dedup().as("a"), Collections.singletonList(FilterRankingStrategy.instance())},
{__.V().as("a").has("name", "marko").as("b").or(has("age"), has("age", gt(32))).has("lang", "java"),
g_V("name", eq("marko"), "lang", eq("java")).or(has("age"), has("age", gt(32))).as("b", "a"), Collections.singletonList(FilterRankingStrategy.instance())},
{__.V().as("a").dedup().has("name", "marko").or(has("age"), has("age", gt(32))).filter(has("name", "bob")).has("lang", "java"),
g_V("name", eq("marko"), "lang", eq("java"), "name", eq("bob")).or(has("age"), has("age", gt(32))).dedup().as("a"), Arrays.asList(InlineFilterStrategy.instance(), FilterRankingStrategy.instance())},
{__.V().as("a").dedup().has("name", "marko").or(has("age", 10), has("age", gt(32))).filter(has("name", "bob")).has("lang", "java"),
g_V("name", eq("marko"), "lang", eq("java"), "name", eq("bob"), "age", eq(10).or(gt(32))).dedup().as("a"), TraversalStrategies.GlobalCache.getStrategies(Neo4jGraph.class).toList()},
{__.V().has("name", "marko").or(not(has("age")), has("age", gt(32))).has("name", "bob").has("lang", "java"),
g_V("name", eq("marko"), "name", eq("bob"), "lang", eq("java")).or(not(filter(properties("age"))), has("age", gt(32))), TraversalStrategies.GlobalCache.getStrategies(Neo4jGraph.class).toList()},
{__.V().has("name", P.eq("marko").or(P.eq("bob").and(P.eq("stephen")))).out("knows"),
g_V("name", eq("marko").or(P.eq("bob").and(P.eq("stephen")))).out("knows"), Collections.emptyList()},
{__.V().has("name", P.eq("marko").and(P.eq("bob").and(P.eq("stephen")))).out("knows"),
g_V("name", eq("marko"), "name", eq("bob"), "name", eq("stephen")).out("knows"), Collections.emptyList()},
{__.V().has("name", P.eq("marko").and(P.eq("bob").or(P.eq("stephen")))).out("knows"),
g_V("name", eq("marko"), "name", P.eq("bob").or(eq("stephen"))).out("knows"), Collections.emptyList()},
///////
{__.V().out().out().V().has("name", "marko").out(), g_V().out().barrier(LAZY_SIZE).out().barrier(LAZY_SIZE).asAdmin().addStep(V("name", eq("marko"))).barrier(LAZY_SIZE).out(), Arrays.asList(InlineFilterStrategy.instance(), FilterRankingStrategy.instance(), LazyBarrierStrategy.instance())},
{__.V().out().out().V().has("name", "marko").as("a").out(), g_V().out().barrier(LAZY_SIZE).out().barrier(LAZY_SIZE).asAdmin().addStep(V("name", eq("marko"))).barrier(LAZY_SIZE).as("a").out(), Arrays.asList(InlineFilterStrategy.instance(), FilterRankingStrategy.instance(), LazyBarrierStrategy.instance())},
{__.V().out().V().has("age", gt(32)).barrier(10).has("name", "marko").as("a"), g_V().out().barrier(LAZY_SIZE).asAdmin().addStep(V("age", gt(32), "name", eq("marko"))).barrier(LAZY_SIZE).barrier(10).as("a"), Arrays.asList(InlineFilterStrategy.instance(), FilterRankingStrategy.instance(), LazyBarrierStrategy.instance())},
{__.V().out().V().has("age", gt(32)).barrier(10).has("name", "marko").as("a"), g_V().out().barrier(LAZY_SIZE).asAdmin().addStep(V("age", gt(32), "name", eq("marko"))).barrier(LAZY_SIZE).barrier(10).as("a"), TraversalStrategies.GlobalCache.getStrategies(Neo4jGraph.class).toList()},
});
}
示例10: getOrCreateGraph
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; //导入依赖的package包/类
private static Neo4jGraph getOrCreateGraph(final GraphDatabaseService database) {
if (neo4jGraph == null) {
synchronized (LOCK) {
if (neo4jGraph == null) {
final Neo4jGraphAPI neo4jGraphAPI = new Neo4jGraphAPIImpl(database);
neo4jGraph = Neo4jGraph.open(neo4jGraphAPI);
}
}
}
return neo4jGraph;
}
示例11: start
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; //导入依赖的package包/类
@Override
public void start() throws Exception {
synchronized (graphWaitList) {
initGraphDatabaseService();
this.graph = Neo4jGraph.open(new Neo4jGraphAPIImpl(graphDatabase));
new DatabaseMigrator(this, migrations).execute();
callWaiters();
}
}
示例12: build
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; //导入依赖的package包/类
public Neo4jGraph build() {
//When creating a new database you have to close the previous one, because
//each database will create a new thread. This fills up the available
//threads when running thousands of tests.
//
//Closing the database is very slow however (testruns go from less then a
//second to 3 minutes on a machine with an SSD) so instead we now re-use
//the same neo4j database that we clear when the function to create a new
//one is called.
if (neo4jDb == reusableNeo4jDb) {
if (trans != null) {
trans.close();
}
cleanDb(neo4jDb);
}
Neo4jGraphAPIImpl neo4jGraphApi = new Neo4jGraphAPIImpl(neo4jDb);
Neo4jGraph neo4jGraph = Neo4jGraph.open(neo4jGraphApi);
try (org.apache.tinkerpop.gremlin.structure.Transaction tx = neo4jGraph.tx()) {
final List<RelationData> requestedRelations = new LinkedList<>();
final Map<String, Vertex> identifiableVertices = new HashMap<>();
//Create all identifiable vertices
graphFragmentBuilders.forEach(
builder -> {
Tuple<Vertex, String> result = builder.build(neo4jGraph, requestedRelations::add);
identifiableVertices.put(result.getRight(), result.getLeft());
}
);
//then we can create the relations between them
requestedRelations.forEach(
relationData -> relationData.makeRelation(identifiableVertices)
);
tx.commit();
}
if (neo4jDb == reusableNeo4jDb) { //we're re-using the database
trans = neo4jDb.beginTx(); //make sure we own the toplevel transaction so are guaranteed to close it
}
return neo4jGraph;
}
示例13: vertices
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; //导入依赖的package包/类
private Iterator<? extends Vertex> vertices() {
final Neo4jGraph graph = (Neo4jGraph) this.getTraversal().getGraph().get();
return graph.getTrait().lookupVertices(graph, this.hasContainers, this.ids);
}
示例14: Neo4jCypherIterator
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; //导入依赖的package包/类
public Neo4jCypherIterator(final Iterator<Map<String, T>> iterator, final Neo4jGraph graph) {
this.iterator = iterator;
this.graph = graph;
}
示例15: loadGraphData
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; //导入依赖的package包/类
@Override
public void loadGraphData(final Graph graph, final LoadGraphWith loadGraphWith, final Class testClass, final String testName) {
if (loadGraphWith != null) this.createIndices((Neo4jGraph) graph, loadGraphWith.value());
super.loadGraphData(graph, loadGraphWith, testClass, testName);
}