Cassandra 获取<;关键、价值>;来自Titan图节点的对
我正在使用Titan GraphDB+Cassandra。我正在启动Titan,如下所示Cassandra 获取<;关键、价值>;来自Titan图节点的对,cassandra,titan,bulbs,Cassandra,Titan,Bulbs,我正在使用Titan GraphDB+Cassandra。我正在启动Titan,如下所示 cd titan-cassandra-0.3.1 bin/titan.sh config/titan-server-rexster.xml config/titan-server-cassandra.properties 我有一个雷克斯特外壳,可以用来和上面的泰坦+卡桑德拉通信 cd rexster-console-2.3.0 bin/rexster-console.sh 我想从我的python程序中编
cd titan-cassandra-0.3.1
bin/titan.sh config/titan-server-rexster.xml config/titan-server-cassandra.properties
我有一个雷克斯特外壳,可以用来和上面的泰坦+卡桑德拉通信
cd rexster-console-2.3.0
bin/rexster-console.sh
我想从我的python程序中编程Titan Graph DB。我正在为此使用Bulls包
我使用下面给出的灯泡从python创建了3种类型的顶点。
这3种类型的顶点是
- switch
- port
- device
from bulbs.titan import Graph
vswitch = self.g.vertices.get_or_create('dpid',dpid_str,{'state':'active','dpid':dpid_str,'type':'switch'})
vport = self.g.vertices.get_or_create('port_id',port_id,{'desc':desc,'port_id':port_id,'state':state,'port_state':port_state,'number':number,'type':'port'})
如果我尝试打印变量vswitch、vport和vdevice,我会得到以下结果
vswitch <Vertex: http://localhost:8182/graphs/graph/vertices/4>
vport <Vertex: http://localhost:8182/graphs/graph/vertices/28>
vswitch
vport
但是,如果我尝试使用如下键检索上述顶点
vswitch = self.g.vertices.index.lookup(dpid=dpid_str)
vport = self.g.vertices.index.lookup(port_id=port_id_str)
for s in vswitch
print s
Here 's' prints the the node `<Vertex: http://localhost:8182/graphs/graph/vertices/4>`
which is expected.How do I extract the key-value pairs from this node?
'dpid' : dpid_str,
'state' :'active',
'type' :'switch'
vswitch=self.g.vertices.index.lookup(dpid=dpid\u str)
vport=self.g.vertices.index.lookup(port\u id=port\u id\u str)
对于vswitch中的s
印刷品
这里的“s”打印节点的``
这是预期的。如何从该节点提取键值对?
“dpid”:dpid_str,
“状态”:“活动”,
“类型”:“开关”
…或者如果顶点是唯一的(仅返回一个值),则使用index.get_unique()而不是index.lookup()
有关更多信息,请参阅文档和快速启动:
>>> switches = self.g.vertices.index.lookup(dpid=dpid_str)
>>> ports = self.g.vertices.index.lookup(port_id=port_id_str)
for s in switches
print s.dpid, s.state, s.type
print s.data()
>>> switch = self.g.vertices.index.get_unique(dpid=dpid_str)
>>> print switch.dpid, switch.state, switch.type
>>> print switch.data()