Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在cassandra数据库中使用JavaAPI创建和检索图形数据库_Cassandra_Gremlin_Titan_Rexster - Fatal编程技术网

如何在cassandra数据库中使用JavaAPI创建和检索图形数据库

如何在cassandra数据库中使用JavaAPI创建和检索图形数据库,cassandra,gremlin,titan,rexster,Cassandra,Gremlin,Titan,Rexster,我正在尝试使用Titan graph api在Cassandra数据库中创建一个具有节点和边的图,这些节点和边具有一些权重。那么,如何检索这个图表,以便我可以可视化它 rexster或gremlin是解决方案??如果是这样。。请告诉我流程。首先注意,TitanGraph使用API,因此Titan API就是Blueprints API。当您使用蓝图时,您可以使用或其任何部分来处理图形 如何在Titan中可视化图形取决于您选择的图形可视化工具。如果我假设您正在使用或类似的工具来使用GraphML,

我正在尝试使用Titan graph api在Cassandra数据库中创建一个具有节点和边的图,这些节点和边具有一些权重。那么,如何检索这个图表,以便我可以可视化它


rexster或gremlin是解决方案??如果是这样。。请告诉我流程。

首先注意,
TitanGraph
使用API,因此Titan API就是Blueprints API。当您使用蓝图时,您可以使用或其任何部分来处理图形

如何在Titan中可视化图形取决于您选择的图形可视化工具。如果我假设您正在使用或类似的工具来使用GraphML,那么从Titan获取数据的最简单方法是打开一个Gremlin REPL,获取对该图形的引用,然后执行以下操作:

g = TitanFactory.open(...)
g.saveGraphML('/tmp/my-graph.xml')

从那里,您可以将
my graph.xml
导入Gephi并可视化它

首先请注意,
TitanGraph
使用API,因此Titan API就是Blueprints API。当您使用蓝图时,您可以使用或其任何部分来处理图形

如何在Titan中可视化图形取决于您选择的图形可视化工具。如果我假设您正在使用或类似的工具来使用GraphML,那么从Titan获取数据的最简单方法是打开一个Gremlin REPL,获取对该图形的引用,然后执行以下操作:

g = TitanFactory.open(...)
g.saveGraphML('/tmp/my-graph.xml')

从那里,您可以将
my graph.xml
导入Gephi并可视化它

我有一个4集群cassandra设置。我在上面运行titan。我制作了这个程序,它创建两个节点,然后在它们之间创建一条边,最后查询并打印它

    public static void main(String args[])
    {
        BaseConfiguration baseConfiguration = new BaseConfiguration();
        baseConfiguration.setProperty("storage.backend", "cassandra");
        baseConfiguration.setProperty("storage.hostname", "192.168.1.10");

        TitanGraph titanGraph = TitanFactory.open(baseConfiguration);

        Vertex rash = titanGraph.addVertex(null);
        rash.setProperty("userId", 1);
        rash.setProperty("username", "rash");
        rash.setProperty("firstName", "Rahul");
        rash.setProperty("lastName", "Chaudhary");
        rash.setProperty("birthday", 101);

        Vertex honey = titanGraph.addVertex(null);
        honey.setProperty("userId", 2);
        honey.setProperty("username", "honey");
        honey.setProperty("firstName", "Honey");
        honey.setProperty("lastName", "Anant");
        honey.setProperty("birthday", 201);

        Edge frnd = titanGraph.addEdge(null, rash, honey, "FRIEND");
        frnd.setProperty("since", 2011);

        titanGraph.commit();

        Iterable<Vertex> results = rash.query().labels("FRIEND").has("since", 2011).vertices();

        for(Vertex result : results)
        {
            System.out.println("Id: " + result.getProperty("userId"));
            System.out.println("Username: " + result.getProperty("username"));
            System.out.println("Name: " + result.getProperty("firstName") + " " + result.getProperty("lastName"));
        }
    }
publicstaticvoidmain(字符串参数[])
{
BaseConfiguration BaseConfiguration=新的BaseConfiguration();
setProperty(“storage.backend”、“cassandra”);
baseConfiguration.setProperty(“storage.hostname”、“192.168.1.10”);
TitanGraph TitanGraph=TitanFactory.open(基本配置);
顶点rash=titanGraph.addVertex(null);
setProperty(“userId”,1);
rash.setProperty(“用户名”、“rash”);
rash.setProperty(“名字”、“Rahul”);
rash.setProperty(“姓氏”、“Chaudhary”);
rash.setProperty(“生日”,101);
顶点=titanGraph.addVertex(null);
蜂蜜.setProperty(“userId”,2);
设置属性(“用户名”、“蜂蜜”);
蜂蜜。setProperty(“名字”、“蜂蜜”);
honey.setProperty(“姓氏”、“Anant”);
亲爱的,setProperty(“生日”,201);
Edge frnd=titanGraph.addEdge(空、冒失、亲爱的、朋友);
自2011年起(自);
提交();
Iterable results=rash.query().labels(“FRIEND”).has(“自”,2011年)。顶点();
用于(顶点结果:结果)
{
System.out.println(“Id:+result.getProperty(“userId”);
System.out.println(“用户名:”+result.getProperty(“用户名”);
System.out.println(“Name:”+result.getProperty(“firstName”)+“+result.getProperty(“lastName”);
}
}
在我的pom.xml中,我只有以下依赖项:

<dependency>
    <groupId>com.thinkaurelius.titan</groupId>
    <artifactId>titan-cassandra</artifactId>
    <version>0.5.4</version>
</dependency>

com.thinkaurelius.titan

我有一个4集群cassandra设置。我在上面运行titan。我制作了这个程序,它创建两个节点,然后在它们之间创建一条边,最后查询并打印它

    public static void main(String args[])
    {
        BaseConfiguration baseConfiguration = new BaseConfiguration();
        baseConfiguration.setProperty("storage.backend", "cassandra");
        baseConfiguration.setProperty("storage.hostname", "192.168.1.10");

        TitanGraph titanGraph = TitanFactory.open(baseConfiguration);

        Vertex rash = titanGraph.addVertex(null);
        rash.setProperty("userId", 1);
        rash.setProperty("username", "rash");
        rash.setProperty("firstName", "Rahul");
        rash.setProperty("lastName", "Chaudhary");
        rash.setProperty("birthday", 101);

        Vertex honey = titanGraph.addVertex(null);
        honey.setProperty("userId", 2);
        honey.setProperty("username", "honey");
        honey.setProperty("firstName", "Honey");
        honey.setProperty("lastName", "Anant");
        honey.setProperty("birthday", 201);

        Edge frnd = titanGraph.addEdge(null, rash, honey, "FRIEND");
        frnd.setProperty("since", 2011);

        titanGraph.commit();

        Iterable<Vertex> results = rash.query().labels("FRIEND").has("since", 2011).vertices();

        for(Vertex result : results)
        {
            System.out.println("Id: " + result.getProperty("userId"));
            System.out.println("Username: " + result.getProperty("username"));
            System.out.println("Name: " + result.getProperty("firstName") + " " + result.getProperty("lastName"));
        }
    }
publicstaticvoidmain(字符串参数[])
{
BaseConfiguration BaseConfiguration=新的BaseConfiguration();
setProperty(“storage.backend”、“cassandra”);
baseConfiguration.setProperty(“storage.hostname”、“192.168.1.10”);
TitanGraph TitanGraph=TitanFactory.open(基本配置);
顶点rash=titanGraph.addVertex(null);
setProperty(“userId”,1);
rash.setProperty(“用户名”、“rash”);
rash.setProperty(“名字”、“Rahul”);
rash.setProperty(“姓氏”、“Chaudhary”);
rash.setProperty(“生日”,101);
顶点=titanGraph.addVertex(null);
蜂蜜.setProperty(“userId”,2);
设置属性(“用户名”、“蜂蜜”);
蜂蜜。setProperty(“名字”、“蜂蜜”);
honey.setProperty(“姓氏”、“Anant”);
亲爱的,setProperty(“生日”,201);
Edge frnd=titanGraph.addEdge(空、冒失、亲爱的、朋友);
自2011年起(自);
提交();
Iterable results=rash.query().labels(“FRIEND”).has(“自”,2011年)。顶点();
用于(顶点结果:结果)
{
System.out.println(“Id:+result.getProperty(“userId”);
System.out.println(“用户名:”+result.getProperty(“用户名”);
System.out.println(“Name:”+result.getProperty(“firstName”)+“+result.getProperty(“lastName”);
}
}
在我的pom.xml中,我只有以下依赖项:

<dependency>
    <groupId>com.thinkaurelius.titan</groupId>
    <artifactId>titan-cassandra</artifactId>
    <version>0.5.4</version>
</dependency>

com.thinkaurelius.titan

非常感谢,这是一个比@BenKirby上的例子更完整的例子,非常感谢您的支持。非常感谢,这是一个比@BenKirby上的例子更完整的例子,非常感谢您的支持。