本文整理汇总了Java中org.janusgraph.core.JanusGraphFactory.open方法的典型用法代码示例。如果您正苦于以下问题:Java JanusGraphFactory.open方法的具体用法?Java JanusGraphFactory.open怎么用?Java JanusGraphFactory.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.janusgraph.core.JanusGraphFactory
的用法示例。
在下文中一共展示了JanusGraphFactory.open方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.janusgraph.core.JanusGraphFactory; //导入方法依赖的package包/类
public static void main(String[] args) {
if (null == args || args.length < 2) {
System.err.println("Usage: SchemaLoader <janusgraph-config-file> <schema-file>");
System.exit(1);
}
String configFile = args[0];
String schemaFile = args[1];
// use custom or default config file to get JanusGraph
JanusGraph g = JanusGraphFactory.open(configFile);
try {
new SchemaLoader().loadSchema(g, schemaFile);
} catch (Exception e) {
System.out.println("Failed to import schema due to " + e.getMessage());
} finally {
g.close();
}
}
示例2: main
import org.janusgraph.core.JanusGraphFactory; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
if (null == args || args.length < 4) {
System.err.println(
"Usage: BatchImport <janusgraph-config-file> <data-files-directory> <schema.json> <data-mapping.json> [skipSchema]");
System.exit(1);
}
JanusGraph graph = JanusGraphFactory.open(args[0]);
if (!(args.length > 4 && args[4].equals("skipSchema")))
new SchemaLoader().loadSchema(graph, args[2]);
new DataLoader(graph).loadVertex(args[1], args[3]);
new DataLoader(graph).loadEdges(args[1], args[3]);
graph.close();
}
示例3: main
import org.janusgraph.core.JanusGraphFactory; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
if (null == args || args.length < 4) {
System.err.println("Usage: BatchImport <janusgraph-config-file> <data-files-directory> <schema.json> <data-mapping.json>");
System.exit(1);
}
JanusGraph graph = JanusGraphFactory.open(args[0]);
new SchemaLoader(graph).loadFile(args[2]);
new DataLoader(graph).loadVertex(args[1], args[3]);
new DataLoader(graph).loadEdges(args[1], args[3]);
graph.close();
}
示例4: workerIterationStart
import org.janusgraph.core.JanusGraphFactory; //导入方法依赖的package包/类
@Override
public void workerIterationStart(final Memory memory) {
LOGGER.info("workerIterationStart");
// TODO: add method in GraphEtl that allows us to simply copy from config to properties.
graph = JanusGraphFactory.open(configuration);
g = graph.traversal();
sevenDaysAgo = (new Date()).getTime() - (1000 * 60 * 60 * 24 * 7);
count = 0;
min = -10;
max = 0;
}
示例5: CreateWeightIndex
import org.janusgraph.core.JanusGraphFactory; //导入方法依赖的package包/类
/**
* Initialize the graph and the graph management interface.
*
* @param configFile
*/
public CreateWeightIndex(String configFile) {
LOGGER.info("Connecting graph");
graph = JanusGraphFactory.open(configFile);
LOGGER.info("Getting management");
mgt = graph.openManagement();
}
示例6: main
import org.janusgraph.core.JanusGraphFactory; //导入方法依赖的package包/类
public static void main(String argv[]) throws Exception {
JanusGraph graph = JanusGraphFactory.open(Schema.CONFIG_FILE);
HadoopQueryRunner q = new HadoopQueryRunner(graph.traversal(), "testUser1");
int runs = 10;
for(int i =0; i < runs; i++) {
LOGGER.info("New timeline (run {} of {})", i+1, runs);
q.printTimeline(q.getTimeline3(10));
}
q.close();
graph.close();
}
示例7: main
import org.janusgraph.core.JanusGraphFactory; //导入方法依赖的package包/类
public static void main(String argv[]) throws Exception {
JanusGraph graph = JanusGraphFactory.open(Schema.CONFIG_FILE);
HadoopQueryRunner q = new HadoopQueryRunner(graph.traversal(), "testUser1");
int runs = 10;
for(int i =0; i < runs; i++) {
LOGGER.info("Previous timeline (run {} of {})", i+1, runs);
q.printTimeline(q.getTimeline2(10));
}
q.close();
graph.close();
}
示例8: CreateSupernodes
import org.janusgraph.core.JanusGraphFactory; //导入方法依赖的package包/类
/**
* Initialize the graph connection.
*
* @param configFile
*/
public CreateSupernodes(String configFile) throws Exception {
graph = JanusGraphFactory.open(configFile);
faker = new Faker();
queryRunner = new QueryRunner(graph.traversal(), "test");
Calendar cal = Calendar.getInstance();
cal.add(Calendar.YEAR, -1);
oneYearAgo = cal.getTime();
}
示例9: LoadData
import org.janusgraph.core.JanusGraphFactory; //导入方法依赖的package包/类
/**
* Initialize the graph connection.
*
* @param configFile
*/
public LoadData(String configFile) {
graph = JanusGraphFactory.open(configFile);
faker = new Faker();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, -1);
oneMonthAgo = cal.getTime();
}
示例10: performanceTest
import org.janusgraph.core.JanusGraphFactory; //导入方法依赖的package包/类
/**
* This test is to demonstrate performance in response to a report of elevated latency for committing 30 vertices.
* http://stackoverflow.com/questions/42899388/titan-dynamodb-local-incredibly-slow-8s-commit-for-30-vertices
* @throws BackendException in case cleanUpTables fails
*/
@Test
public void performanceTest() throws BackendException {
final Graph graph = JanusGraphFactory.open(TestGraphUtil.instance.createTestGraphConfig(BackendDataModel.MULTI));
IntStream.of(30).forEach(i -> graph.addVertex(LABEL));
final Stopwatch watch = Stopwatch.createStarted();
graph.tx().commit();
System.out.println("Committing took " + watch.stop().elapsed(TimeUnit.MILLISECONDS) + " ms");
TestGraphUtil.instance.cleanUpTables();
}
示例11: tripleIngestBase
import org.janusgraph.core.JanusGraphFactory; //导入方法依赖的package包/类
private void tripleIngestBase(final BiConsumer<StandardJanusGraph, List<Triple>> writer) throws BackendException {
final Stopwatch watch = Stopwatch.createStarted();
final StandardJanusGraph graph = (StandardJanusGraph) JanusGraphFactory.open(TestGraphUtil.instance.createTestGraphConfig(BackendDataModel.MULTI));
log.info("Created graph in " + watch.elapsed(TimeUnit.MILLISECONDS) + " ms");
watch.reset();
watch.start();
createHotelSchema(graph);
log.info("Created schema in " + watch.elapsed(TimeUnit.MILLISECONDS) + " ms");
watch.reset();
watch.start();
final URL url = ScenarioTests.class.getClassLoader().getResource("META-INF/HotelTriples.txt");
Preconditions.checkNotNull(url);
final List<Triple> lines;
try (CSVReader reader = new CSVReader(new InputStreamReader(url.openStream()))) {
lines = reader.readAll().stream()
.map(Triple::new)
.collect(Collectors.toList());
} catch (IOException e) {
throw new IllegalStateException("Error processing triple file", e);
}
log.info("Read file into Triple objects in " + watch.elapsed(TimeUnit.MILLISECONDS) + " ms");
watch.reset();
watch.start();
writer.accept(graph, lines);
log.info("Added objects in " + watch.elapsed(TimeUnit.MILLISECONDS) + " ms");
TestGraphUtil.instance.cleanUpTables();
}
示例12: main
import org.janusgraph.core.JanusGraphFactory; //导入方法依赖的package包/类
public static void main(String[] args) {
JanusGraph graph = JanusGraphFactory.open("conf/janusgraph-berkeleyje-lucene.properties");
GraphTraversalSource g = graph.traversal();
if (g.V().count().next() == 0) {
// load the schema and graph data
GraphOfTheGodsFactory.load(graph);
}
Map<String, ?> saturnProps = g.V().has("name", "saturn").valueMap(true).next();
LOGGER.info(saturnProps.toString());
List<Edge> places = g.E().has("place", Geo.geoWithin(Geoshape.circle(37.97, 23.72, 50))).toList();
LOGGER.info(places.toString());
System.exit(0);
}
示例13: main
import org.janusgraph.core.JanusGraphFactory; //导入方法依赖的package包/类
/**
* Run every example query, outputting results via @LOGGER
*
* @param argv
* @throws Exception
*/
public static void main(String[] argv) throws Exception {
JanusGraph graph = JanusGraphFactory.open(Schema.CONFIG_FILE);
GraphTraversalSource graphTraversalSource = graph.traversal();
QueryRunner queryRunner = new QueryRunner(graphTraversalSource, "testUser0");
LOGGER.info("Initialized the builtin query executor");
queryRunner.runQueries();
queryRunner.close();
graph.close();
System.exit(0);
}
示例14: initializeJanusGraph
import org.janusgraph.core.JanusGraphFactory; //导入方法依赖的package包/类
private JanusGraph initializeJanusGraph(boolean createMode)
{
LOG.fine("Initializing graph.");
Path lucene = graphDir.resolve("graphsearch");
Path berkeley = graphDir.resolve("titangraph");
// TODO: Externalize this.
conf = new BaseConfiguration();
// Sets a unique id in order to fix WINDUP-697. This causes Titan to not attempt to generate and ID,
// as the Titan id generation code fails on machines with broken network configurations.
conf.setProperty("graph.unique-instance-id", "windup_" + System.nanoTime() + "_" + RandomStringUtils.randomAlphabetic(6));
conf.setProperty("storage.directory", berkeley.toAbsolutePath().toString());
conf.setProperty("storage.backend", "berkeleyje");
// Sets the berkeley cache to a relatively small value to reduce the memory footprint.
// This is actually more important than performance on some of the smaller machines out there, and
// the performance decrease seems to be minimal.
conf.setProperty("storage.berkeleydb.cache-percentage", 1);
// Set READ UNCOMMITTED to improve performance
conf.setProperty("storage.berkeleydb.lock-mode", LockMode.READ_UNCOMMITTED);
conf.setProperty("storage.berkeleydb.isolation-level", BerkeleyJEStoreManager.IsolationLevel.READ_UNCOMMITTED);
// Increase storage write buffer since we basically do a large bulk load during the first phases.
// See http://s3.thinkaurelius.com/docs/titan/current/bulk-loading.html
conf.setProperty("storage.buffer-size", "4096");
// Turn off transactions to improve performance
conf.setProperty("storage.transactions", false);
conf.setProperty("ids.block-size", 25000);
// conf.setProperty("ids.flush", true);
// conf.setProperty("", false);
//
// turn on a db-cache that persists across txn boundaries, but make it relatively small
conf.setProperty("cache.db-cache", true);
conf.setProperty("cache.db-cache-clean-wait", 0);
conf.setProperty("cache.db-cache-size", .09);
conf.setProperty("cache.db-cache-time", 0);
conf.setProperty("index.search.backend", "lucene");
conf.setProperty("index.search.directory", lucene.toAbsolutePath().toString());
writeToPropertiesFile(conf, graphDir.resolve("TitanConfiguration.properties").toFile());
JanusGraph janusGraph = JanusGraphFactory.open(conf);
/*
* We only need to setup the eventing system when initializing a graph, not when loading it later for
* reporting.
*/
if (createMode)
{
TraversalStrategies graphStrategies = TraversalStrategies.GlobalCache
.getStrategies(StandardJanusGraph.class)
.clone();
// Remove any old listeners
if (graphStrategies.getStrategy(EventStrategy.class) != null)
graphStrategies.removeStrategies(EventStrategy.class);
graphStrategies.addStrategies(EventStrategy.build().addListener(mutationListener).create());
TraversalStrategies.GlobalCache.registerStrategies(StandardJanusGraph.class, graphStrategies);
mutationListener.setGraph(this);
}
return janusGraph;
}