标签: titan

在两个顶点之间找到边的正确方法是什么?

使用tinkerpop blueprints API,找到两个顶点之间是否存在边缘的最佳方法是什么?我想避免vertex.getEdges()和迭代,直到找到正确的.

例如:检查是否v1是朋友v2

Vertex v1 = g.addVertex(null);
Vertex v2 = g.addVertex(null);
Edge edge = g.addEdge(null, v1, v2, "friends");
Edge edge = g.addEdge(null, v1, v2, "follows");

// Node with lots of edges - Supernode - problem?
List<Edge> edges = new ArrayList<Edge>();
for(Edge edge : g.getVertex(v1.getId()).getEdges(Direction.OUT, "friends")){
   if(edge.getVertex(Direction.IN).getId().equals(v2.getId()){
      edges.add(edge);
  }
}
Run Code Online (Sandbox Code Playgroud)

我应该使用顶点查询吗?


通过gremlin我能做到:

g.v(v1.getID()).outE("friends").inV.filter{it.id == v2.getID}
Run Code Online (Sandbox Code Playgroud)

Neo4j方式:

IndexHits<Relationship> relationships = relationshipIndex().get("type", edgeType, node1, node2);
Run Code Online (Sandbox Code Playgroud)

谢谢您的帮助!我还是新手.

graph neo4j graph-databases titan tinkerpop

6
推荐指数
1
解决办法
5144
查看次数

在Titan(Cassandra)中已存在的顶点属性上创建索引?

我正在使用Titan Server(Cassandra)v 0.3.1.我想在我已经开始使用的顶点键/属性上创建索引.然而,在他们的文档中,Titan解释说:

要按键索引顶点,必须在首次在顶点属性中使用键之前创建相应的键索引.

如果我尝试在已存在的字段上创建索引,我会看到预期的错误:

gremlin> g.createKeyIndex("my_key",Vertex.class)
Cannot add an index to an already existing property key: my_key
Run Code Online (Sandbox Code Playgroud)

但是,即使我尝试通过删除所有顶点和边缘来清除图形,我也会看到同样的错误:

gremlin> g.E.remove()
==>null
gremlin> g.V.remove()
==>null
gremlin> g.createKeyIndex("my_key",Vertex.class)
Cannot add an index to an already existing property key: my_key
Run Code Online (Sandbox Code Playgroud)

因此,my_key即使在删除所有图形元素之后,似乎仍然存在于底层数据存储中.这与文档一致(即使元素已被删除,属性已经"首次使用"),但似乎值得一试.

我的下一步将是重新创建一个新的Cassandra数据存储,但我想知道是否有更好的选择.

在已经在Titan中使用的字段上创建索引的最简单方法是什么?

gremlin titan

6
推荐指数
1
解决办法
3653
查看次数

Titan在索引键上的查找速度非常慢?

使用Titan w/Cassandra v 0.3.1,我创建了一个顶点键索引,createKeyIndexTitan文档中所述.

gremlin> g.createKeyIndex("my_key", Vertex.class)
==>null
Run Code Online (Sandbox Code Playgroud)

我现在在图中有appx 50k节点和186k边缘,我发现使用的查找之间存在显着的性能差异my_key.此查询大约需要5秒钟才能运行:

gremlin> g.V.has("my_key", "abc")
==>v[12345]
Run Code Online (Sandbox Code Playgroud)

而使用索引ID的时间不到1秒:

gremlin> g.v(12345)
==>v[12345]
Run Code Online (Sandbox Code Playgroud)

my_key没有一个独特的约束(我不想),但我想知道是什么导致这种性能差异.如何提高非唯一索引顶点键的查找性能?

gremlin titan

6
推荐指数
1
解决办法
954
查看次数

你如何让Titan图数据库与Python一起工作?

我是新手,我正试图让Titan使用Python.我已经在这一天打了一个半天,无法到达任何地方.我尝试过灯泡和rexpro-python,但似乎没什么用.

rexpro-python中有以下代码:

from rexpro import RexProConnection
conn = RexProConnection('localhost', 8184, 'graph')
Run Code Online (Sandbox Code Playgroud)

将挂起并且服务器产生以下消息(对于titan版本0.3.2,0.3.1和0.2.1)

13/09/18 16:59:27 WARN filter.RexProMessageFilter: unsupported rexpro version: 1
Run Code Online (Sandbox Code Playgroud)

灯泡:

from bulbs.config import Config, DEBUG
from bulbs.rexster import Graph

config = Config('http://localhost:8182/graphs/graph')
g = Graph(config)
Run Code Online (Sandbox Code Playgroud)

产生以下错误:

SystemError: ({'status': '500', 'transfer-encoding': 'chunked', 'server': 'grizzly/2.2.16', 'connection': 'close', 'date': 'Wed, 18 Sep 2013 21:06:27 GMT', 'access-control-allow-origin': '*', 'content-type': 'application/json'}, '{"message":"","error":"javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: groovy.lang.MissingMethodException.idx() is applicable for argument types: () values: []\\nPossible solutions: is(java.lang.Object), any(), find(), …
Run Code Online (Sandbox Code Playgroud)

python titan rexster

6
推荐指数
1
解决办法
2966
查看次数

关于卡桑德拉的泰坦地理数据

我正在寻找使用Titan来创建可扩展的地理空间数据存储(我在想R树).在文档中,有一个GeoShape查询,文档说titan可以使用Lucene或ElasticSearch执行地理数据.但是,看起来这会非常慢,因为在cassandra中遍历节点本质上是在cassandra中进行连接查询,这是一个非常糟糕的主意.我想我可能会误解数据表示.

我阅读了Titan数据模型文档,但我仍然不太了解它.如果所有边都存储在Cassandra行中,那么Titan仍然必须在顶点表上"连接".解决此问题的一种方法是使列值等于边属性数据,然后您可以将顶点数据和边数据整齐地打包到行中.但是,当您想要执行超过1个节点的查询时,这会中断,我们又会再次回到加入问题.

所以.Titan是否在Cassandra中模拟连接查询? - 和 - 在这些条件下地理查找的性能如何?

graph cassandra titan

6
推荐指数
1
解决办法
1315
查看次数

为什么Rexster Server(和Titan)停止响应?

建立

我正在使用Titan Rexster(titan-server-0.4.4.zip)和Elasticsearch后端在Ubuntu 12.4服务器上运行推荐系统.为了连接到Rexster Server,我使用Bulbflow库进行python.

Beta似乎运行良好3周,但随着负载"增加"(只有几个用户~10),Rexster服务器停止响应.我不知道我的rexster配置是错误的还是我没有正确使用Bulbflow库.

Rexster/Titan配置

这是我的rexster-cassandra-es.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <rexster>
        <http>
            <server-port>8182</server-port>
            <server-host>0.0.0.0</server-host>
            <base-uri>http://MY_IP</base-uri>
            <web-root>public</web-root>
            <character-set>UTF-8</character-set>
            <enable-jmx>false</enable-jmx>
            <enable-doghouse>true</enable-doghouse>
            <max-post-size>2097152</max-post-size>
            <max-header-size>8192</max-header-size>
            <upload-timeout-millis>30000</upload-timeout-millis>
            <thread-pool>
                <worker>
                    <core-size>20</core-size>
                    <max-size>40</max-size>
                </worker>
                <kernal>
                    <core-size>10</core-size>
                    <max-size>20</max-size>
                </kernal>
            </thread-pool>
            <io-strategy>leader-follower</io-strategy>
        </http>
        <rexpro>
            <server-port>8184</server-port>
            <server-host>0.0.0.0</server-host>
            <session-max-idle>1790000</session-max-idle>
            <session-check-interval>3000000</session-check-interval>
            <connection-max-idle>180000</connection-max-idle>
            <connection-check-interval>3000000</connection-check-interval>
            <enable-jmx>false</enable-jmx>
            <thread-pool>
                <worker>
                    <core-size>8</core-size>
                    <max-size>8</max-size>
                </worker>
                <kernal>
                    <core-size>4</core-size>
                    <max-size>4</max-size>
                </kernal>
            </thread-pool>
            <io-strategy>leader-follower</io-strategy>
        </rexpro>
        <shutdown-port>8183</shutdown-port>
        <shutdown-host>127.0.0.1</shutdown-host>
        <script-engines>
            <script-engine>
                <name>gremlin-groovy</name>
                <reset-threshold>-1</reset-threshold>
                <imports>com.tinkerpop.gremlin.*,com.tinkerpop.gremlin.java.*,com.tinkerpop.gremlin.pipes.filter.*,com.tinkerpop.gremlin.pipes.sideeffect.*,com.tinkerpop.gremlin.pipes.transform.*,com.tinkerpop.blueprints.*,com.tinkerpop.blueprints.impls.*,com.tinkerpop.blueprints.impls.tg.*,com.tinkerpop.blueprints.impls.neo4j.*,com.tinkerpop.blueprints.impls.neo4j.batch.*,com.tinkerpop.blueprints.impls.orient.*,com.tinkerpop.blueprints.impls.orient.batch.*,com.tinkerpop.blueprints.impls.dex.*,com.tinkerpop.blueprints.impls.rexster.*,com.tinkerpop.blueprints.impls.sail.*,com.tinkerpop.blueprints.impls.sail.impls.*,com.tinkerpop.blueprints.util.*,com.tinkerpop.blueprints.util.io.*,com.tinkerpop.blueprints.util.io.gml.*,com.tinkerpop.blueprints.util.io.graphml.*,com.tinkerpop.blueprints.util.io.graphson.*,com.tinkerpop.blueprints.util.wrappers.*,com.tinkerpop.blueprints.util.wrappers.batch.*,com.tinkerpop.blueprints.util.wrappers.batch.cache.*,com.tinkerpop.blueprints.util.wrappers.event.*,com.tinkerpop.blueprints.util.wrappers.event.listener.*,com.tinkerpop.blueprints.util.wrappers.id.*,com.tinkerpop.blueprints.util.wrappers.partition.*,com.tinkerpop.blueprints.util.wrappers.readonly.*,com.tinkerpop.blueprints.oupls.sail.*,com.tinkerpop.blueprints.oupls.sail.pg.*,com.tinkerpop.blueprints.oupls.jung.*,com.tinkerpop.pipes.*,com.tinkerpop.pipes.branch.*,com.tinkerpop.pipes.filter.*,com.tinkerpop.pipes.sideeffect.*,com.tinkerpop.pipes.transform.*,com.tinkerpop.pipes.util.*,com.tinkerpop.pipes.util.iterators.*,com.tinkerpop.pipes.util.structures.*,org.apache.commons.configuration.*,com.thinkaurelius.titan.core.*,com.thinkaurelius.titan.core.attribute.*,com.thinkaurelius.titan.core.util.*,com.thinkaurelius.titan.example.*,org.apache.commons.configuration.*,com.tinkerpop.gremlin.Tokens.T,com.tinkerpop.gremlin.groovy.*</imports>
            <static-imports>com.tinkerpop.blueprints.Direction.*,com.tinkerpop.blueprints.TransactionalGraph$Conclusion.*,com.tinkerpop.blueprints.Compare.*,com.thinkaurelius.titan.core.attribute.Geo.*,com.thinkaurelius.titan.core.attribute.Text.*,com.thinkaurelius.titan.core.TypeMaker$UniquenessConsistency.*,com.tinkerpop.blueprints.Query$Compare.*</static-imports>
            </script-engine>
        </script-engines>
        <security>
            <authentication>
                <type>none</type>
                <configuration>
                    <users>
                        <user>
                            <username>rexster</username>
                            <password>rexster</password>
                        </user>
                    </users>
                </configuration>
            </authentication>
        </security>
        <metrics>
            <reporter> …
Run Code Online (Sandbox Code Playgroud)

python titan bulbs rexster

6
推荐指数
1
解决办法
399
查看次数

下一个()在TinkerPop中意味着什么

我正在阅读TinkerPop3 文档

我很困惑的是我找不到任何解释next().

例如,w/next()或w/o next()返回相同的椎骨

gremlin> g.V().has('name', 'marko')
==>v[1]
gremlin> g.V().has('name', 'marko').next()
==>v[1]
Run Code Online (Sandbox Code Playgroud)

但是,班级名称彼此不同.

gremlin> g.V().has('name', 'marko').getClass()
==>class org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal
gremlin> g.V().has('name', 'marko').next().getClass()
==>class org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex
Run Code Online (Sandbox Code Playgroud)

没有'next()',指定的变量没有值.

gremlin> marko = g.V().has('name', 'marko')
==>v[1]
gremlin> marko
Run Code Online (Sandbox Code Playgroud)

甚至,与clockWithResult()输出完全不同.

gremlin> clockWithResult(1){g.V().both().barrier().both().barrier().both().barrier().count().next()}
==>1.079524
==>72
gremlin> clockWithResult(1){g.V().both().barrier().both().barrier().both().barrier().count()}
==>0.11863599999999999
==>[GraphStep([],vertex), VertexStep(BOTH,vertex), NoOpBarrierStep(2147483647), VertexStep(BOTH,vertex), NoOpBarrierStep(2147483647), VertexStep(BOTH,vertex), NoOpBarrierStep(2147483647), CountGlobalStep]
Run Code Online (Sandbox Code Playgroud)

或者这个例子:

gremlin> g.V(1).out('knows').values('name').fold()
==>[vadas, josh]
gremlin> g.V(1).out('knows').values('name').fold().next()
==>vadas
==>josh
Run Code Online (Sandbox Code Playgroud)

在手册中,还有许多其他例子让我感到困惑.

我希望马尔科和他的朋友能帮助我.

titan tinkerpop3

6
推荐指数
1
解决办法
2045
查看次数

计算土卫六上的超级节点

在我的系统中,我要求节点上的边数必须存储为顶点的内部属性以及特定传出边上的顶点中心索引.这自然要求我在所有数据加载完毕后计算节点上的边数.我这样做如下:

long edgeCount = graph.getGraph().traversal().V(vertexId).bothE().count().next();
Run Code Online (Sandbox Code Playgroud)

但是,当我将测试扩展到某些节点是"超级"节点时,我在上面的行中得到以下异常:

Caused by: com.netflix.astyanax.connectionpool.exceptions.TransportException: TransportException: [host=127.0.0.1(127.0.0.1):9160, latency=4792(4792), attempts=1]org.apache.thrift.transport.TTransportException: Frame size (70936735) larger than max length (62914560)!
    at com.netflix.astyanax.thrift.ThriftConverter.ToConnectionPoolException(ThriftConverter.java:197) ~[astyanax-thrift-3.8.0.jar!/:3.8.0]
    at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:65) ~[astyanax-thrift-3.8.0.jar!/:3.8.0]
    at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:28) ~[astyanax-thrift-3.8.0.jar!/:3.8.0]
    at com.netflix.astyanax.thrift.ThriftSyncConnectionFactoryImpl$ThriftConnection.execute(ThriftSyncConnectionFactoryImpl.java:153) ~[astyanax-thrift-3.8.0.jar!/:3.8.0]
    at com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl.tryOperation(AbstractExecuteWithFailoverImpl.java:119) ~[astyanax-core-3.8.0.jar!/:3.8.0]
    at com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:352) ~[astyanax-core-3.8.0.jar!/:3.8.0]
    at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$4.execute(ThriftColumnFamilyQueryImpl.java:538) ~[astyanax-thrift-3.8.0.jar!/:3.8.0]
    at com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxKeyColumnValueStore.getNamesSlice(AstyanaxKeyColumnValueStore.java:112) ~[titan-cassandra-1.0.0.jar!/:na]
Run Code Online (Sandbox Code Playgroud)

解决这个问题的最佳方法是什么?我应该简单地增加帧大小还是有更好的方法来计算节点上的边数?

titan tinkerpop

6
推荐指数
1
解决办法
144
查看次数

Titan和Neo4j图形数据库有什么区别?

我曾在关系数据库工作; 但现在想了解图数据库.我才知道这两个是图数据库.这两个数据库有什么区别.我们应该在他们中间选择什么?

database non-relational-database neo4j graph-databases titan

6
推荐指数
3
解决办法
5011
查看次数

Gremlin - 如果它不存在,只添加一个顶点

我有一组用户名(例如['abc','def','ghi'])要添加到图表中的"用户"标签下.

现在我首先要检查用户名是否已经存在(g.V().hasLabel('user').has('username','def')),然后仅添加"用户"标签下用户名属性不匹配的用户名.

此外,这可以在单个gremlin查询或groovy脚本中完成吗?

我正在使用titan graph数据库,tinkerpop3和gremlin REST服务器.

groovy graph-databases gremlin titan tinkerpop3

6
推荐指数
1
解决办法
4061
查看次数