TitanFactory.open()配置 [英] TitanFactory.open() configration

查看:176
本文介绍了TitanFactory.open()配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我上一个问题是关于TitanFactory类的语法。现在我不知道如何使用它?



例如,我可以像下面这样构造RexsterGraph对象,它的工作原理就像一个魅力。

  Graph graph = new RexsterGraph(http://190.188.20.11:8183/graphs/graph); 

现在我想导入csv文件到Titan中,所以我需要TitanGraph对象,我找到了下面的帖子。



如何导入CSV文件



>

无法找到实现类:
com.thinkaurelius.titan.diskstorage.cassandra.thrift.CassandraThriftStoreManager




  TitanGraph titanGraph = null; 
try {
titanGraph = TitanFactory
.open(D:\\TEMP\\ );
} catch(Exception e){
System.err.println(e.getMessage());

System.out.println(\\\
);

System.err.println(e.getStackTrace());
}

我需要的唯一的东西是我想要一些代码像RexsterGraph示例TitanGraph对象的实例。我该怎么办?我运行的代码在我的本地,但图是工作远程Linux机器

解决方案


test.csv行



id:1,name:xxx,age:20,........



id:2,name:yyy,age:21,........


t知道你的csv文件大小是什么,但它很小,可以这样导入

  String path =c:\ \test.csv; 
Charset encoding = Charset.forName(ISO-8859-1);
try {
List< String> lines = Files.readAllLines(Paths.get(path),encoding);
Graph graph = new RexsterGraph(http://190.188.20.11:8183/graphs/graph);

for(String line:lines){
Vertex currentNode = graph.addVertex(null);
String [] values = line.split(,);
for(String value:values){
String [] property = value.split(:);
currentNode.setProperty(property [0] .toString(),property [1] .toString());
}
}

}


My previous question was about the syntax of the TitanFactory class. Now i wonder how to use it?

For example i can construct RexsterGraph object like the following and it works like a charm.

Graph graph = new RexsterGraph(http://190.188.20.11:8183/graphs/graph");

Now i want to import csv file into the titan. So i need TitanGraph object. I found the following post to do that.

How to import a CSV file into Titan graph database?

And i worte the following code and it gives me error.

Could not find implementation class: com.thinkaurelius.titan.diskstorage.cassandra.thrift.CassandraThriftStoreManager

    TitanGraph titanGraph = null;
    try {
        titanGraph = TitanFactory
                .open("D:\\TEMP\\titan-cassandra.properties");
    } catch (Exception e) {
        System.err.println(e.getMessage());

        System.out.println("\n");

        System.err.println(e.getStackTrace());
    }

The only thing i need is that i want some code like RexsterGraph example for getting instance of TitanGraph object. What should i do? by the way i run the code on my local but graph is working remote linux machine

解决方案

sample test.csv lines

id:1,name:xxx,age:20,........

id:2,name:yyy,age:21,........

I don't know what is your csv file size but it is small, you can import like this

            String path = "c:\\test.csv";
            Charset encoding = Charset.forName("ISO-8859-1");
            try {
                List<String> lines = Files.readAllLines(Paths.get(path), encoding);
                Graph graph = new RexsterGraph("http://190.188.20.11:8183/graphs/graph");

                for (String line : lines) {
                    Vertex currentNode = graph.addVertex(null);
                    String[] values = line.split(",");
                    for (String value : values) {
                        String[] property = value.split(":");
                        currentNode.setProperty(property[0].toString(), property[1].toString());
                    }
                }

            }

这篇关于TitanFactory.open()配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆