本文整理汇总了Java中org.janusgraph.core.JanusGraph类的典型用法代码示例。如果您正苦于以下问题:Java JanusGraph类的具体用法?Java JanusGraph怎么用?Java JanusGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JanusGraph类属于org.janusgraph.core包,在下文中一共展示了JanusGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EdgeLoaderWorker
import org.janusgraph.core.JanusGraph; //导入依赖的package包/类
public EdgeLoaderWorker(final Iterator<Map<String, String>> records, final Map<String, Object> propertiesMap,
final JanusGraph graph) {
super(records, propertiesMap, graph);
this.currentRecord = 0;
this.defaultEdgeLabel = (String) propertiesMap.get(Constants.EDGE_LABEL_MAPPING);
this.edgeLabelFieldName = null;
COMMIT_COUNT = Config.getConfig().getEdgeRecordCommitCount();
if (propertiesMap.values().contains(Constants.EDGE_LABEL_MAPPING)) {
for (String propName : propertiesMap.keySet()) {
if (Constants.EDGE_LABEL_MAPPING.equals(propertiesMap.get(propName))) {
this.edgeLabelFieldName = propName;
break;
}
}
}
}
示例2: EdgeLoaderWorker
import org.janusgraph.core.JanusGraph; //导入依赖的package包/类
public EdgeLoaderWorker(final Iterator<Map<String, String>> records, final Map<String, Object> propertiesMap,
final JanusGraph graph) {
super(records, propertiesMap, graph);
this.currentRecord = 0;
this.defaultEdgeLabel = (String) propertiesMap.get(Constants.EDGE_LABEL_MAPPING);
this.edgeLabelFieldName = null;
COMMIT_COUNT = Config.getConfig().getEdgeRecordCommitCount();
if (propertiesMap.values().contains(Constants.EDGE_LABEL_MAPPING)) {
for (String propName : propertiesMap.keySet()) {
if (Constants.EDGE_LABEL_MAPPING.equals(propertiesMap.get(propName))) {
this.edgeLabelFieldName = propName;
break;
}
}
}
}
示例3: VertexLoaderWorker
import org.janusgraph.core.JanusGraph; //导入依赖的package包/类
public VertexLoaderWorker(final Iterator<Map<String, String>> records, final Map<String, Object> propertiesMap,
final JanusGraph graph) {
super(records, propertiesMap, graph);
this.currentRecord = 0;
this.defaultVertexLabel = (String) propertiesMap.get(Constants.VERTEX_LABEL_MAPPING);
this.vertexLabelFieldName = null;
COMMIT_COUNT = Config.getConfig().getVertexRecordCommitCount();
if (propertiesMap.values().contains(Constants.VERTEX_LABEL_MAPPING)) {
// find the vertex
for (String propName : propertiesMap.keySet()) {
if (Constants.VERTEX_LABEL_MAPPING.equals(propertiesMap.get(propName))) {
this.vertexLabelFieldName = propName;
break;
}
}
}
}
示例4: main
import org.janusgraph.core.JanusGraph; //导入依赖的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();
}
}
示例5: main
import org.janusgraph.core.JanusGraph; //导入依赖的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();
}
示例6: startWorkers
import org.janusgraph.core.JanusGraph; //导入依赖的package包/类
private void startWorkers(Iterator<CSVRecord> iter, long targetRecordCount, WorkerPool workers)
throws Exception {
while (iter.hasNext()) {
long currentRecord = 0;
List<Map<String,String>> sub = new ArrayList<Map<String,String>>();
while (iter.hasNext() && currentRecord < targetRecordCount) {
sub.add(iter.next().toMap());
currentRecord++;
}
Constructor<Worker> constructor = workerClass.getConstructor(Iterator.class, Map.class, JanusGraph.class);
Worker worker = constructor.newInstance(sub.iterator(), propertiesMap, graph);
workers.submit(worker);
}
}
示例7: VertexLoaderWorker
import org.janusgraph.core.JanusGraph; //导入依赖的package包/类
public VertexLoaderWorker(final Iterator<Map<String,String>> records, final Map<String, Object> propertiesMap,
final JanusGraph graph) {
super(records, propertiesMap, graph);
this.currentRecord = 0;
this.defaultVertexLabel = (String) propertiesMap.get(Constants.VERTEX_LABEL_MAPPING);
this.vertexLabelFieldName = null;
COMMIT_COUNT = Config.getConfig().getVertexRecordCommitCount();
if (propertiesMap.values().contains(Constants.VERTEX_LABEL_MAPPING)) {
// find the vertex
for (String propName : propertiesMap.keySet()) {
if (Constants.VERTEX_LABEL_MAPPING.equals(propertiesMap.get(propName))) {
this.vertexLabelFieldName = propName;
break;
}
}
}
}
示例8: SchemaLoader
import org.janusgraph.core.JanusGraph; //导入依赖的package包/类
/**
* Constructor of JansugraphGSONSchema object with the {@code graph}
*
* @param graph
* a JanusGraph and write GraphSON schema into it
*/
public SchemaLoader(JanusGraph graph) {
if (graph == null) {
// throw new Exception("JanusGraph is null");
}
this.graph = graph;
}
示例9: main
import org.janusgraph.core.JanusGraph; //导入依赖的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();
}
示例10: main
import org.janusgraph.core.JanusGraph; //导入依赖的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();
}
示例11: main
import org.janusgraph.core.JanusGraph; //导入依赖的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();
}
示例12: getGraphWithNewTransaction
import org.janusgraph.core.JanusGraph; //导入依赖的package包/类
@Override
public JanusGraph getGraphWithNewTransaction(JanusGraph graph, boolean batchloading){
if(graph.isClosed()) graph = buildTinkerPopGraph(batchloading);
if(!graph.tx().isOpen()){
graph.tx().open();
}
return graph;
}
示例13: configureGraph
import org.janusgraph.core.JanusGraph; //导入依赖的package包/类
private JanusGraph configureGraph(boolean batchLoading){
JanusGraphFactory.Builder builder = JanusGraphFactory.build().
set("storage.hostname", session().uri()).
set("storage.cassandra.keyspace", session().keyspace().getValue()).
set("storage.batch-loading", batchLoading);
String storageBackend = "storage.backend";
//Load Defaults
DEFAULT_PROPERTIES.forEach((key, value) -> builder.set(key.toString(), value));
//Load Passed in properties
session().config().properties().forEach((key, value) -> {
//Overwrite storage
if(key.equals(storageBackend)){
value = storageBackendMapper.get(value);
}
//Inject properties into other default properties
if(overrideMap.containsKey(key)){
builder.set(overrideMap.get(key), value);
}
builder.set(key.toString(), value);
});
LOG.debug("Opening graph on {}", session().uri());
return builder.open();
}
示例14: buildJanusIndexes
import org.janusgraph.core.JanusGraph; //导入依赖的package包/类
private static void buildJanusIndexes(JanusGraph graph) {
JanusGraphManagement management = graph.openManagement();
makeVertexLabels(management);
makeEdgeLabels(management);
makePropertyKeys(management);
makeIndicesVertexCentric(management);
makeIndicesComposite(management);
management.commit();
}
示例15: testSingleton
import org.janusgraph.core.JanusGraph; //导入依赖的package包/类
@Test
public void testSingleton(){
when(session.keyspace()).thenReturn(Keyspace.of("anothertest"));
TxFactoryJanus factory = new TxFactoryJanus(session);
GraknTxJanus mg1 = factory.open(GraknTxType.BATCH);
JanusGraph tinkerGraphMg1 = mg1.getTinkerPopGraph();
mg1.close();
GraknTxJanus mg2 = factory.open(GraknTxType.WRITE);
JanusGraph tinkerGraphMg2 = mg2.getTinkerPopGraph();
mg2.close();
GraknTxJanus mg3 = factory.open(GraknTxType.BATCH);
assertEquals(mg1, mg3);
assertEquals(tinkerGraphMg1, mg3.getTinkerPopGraph());
assertTrue(mg1.isBatchTx());
assertFalse(mg2.isBatchTx());
assertNotEquals(mg1, mg2);
assertNotEquals(tinkerGraphMg1, tinkerGraphMg2);
StandardJanusGraph standardJanusGraph1 = (StandardJanusGraph) tinkerGraphMg1;
StandardJanusGraph standardJanusGraph2 = (StandardJanusGraph) tinkerGraphMg2;
assertTrue(standardJanusGraph1.getConfiguration().isBatchLoading());
assertFalse(standardJanusGraph2.getConfiguration().isBatchLoading());
}