from nebula.ngMeta.MetaClient import MetaClient
from nebula.ngStorage.StorageClient import StorageClient
from nebula.ngStorage.ngProcessor.ScanEdgeProcessor import ScanEdgeProcessor
meta_client = MetaClient([('10.176.18.53', 9559)])
meta_client.connect()
storage_client = StorageClient(meta_client)
scan_edge_processor = ScanEdgeProcessor(meta_client)
def scan_nebula_edge():
space_name = 'pay_risk_identify' # 要读取的图空间名称
return_cols = {} # 要返回的边(或点)及其属性列
return_cols['transfer_account_user'] = ['msg_cd']
return_cols['transfer_account_bank'] = ['cap_crd_nm']
allCols = True # 是否返回所有属性列,当该值为 False 时,仅返回在 returnCols 里指定的属性列,当为 True 时,返回所有属性列
limit = 100 # 最多返回的数据条数
start_time = 0
end_time = 20000
scan_edge_response_iterator = storage_client.scan_edge(space_name, return_cols, allCols, limit, start_time,end_time)
while scan_edge_response_iterator.has_next():
scan_edge_response = scan_edge_response_iterator.next()
if scan_edge_response is None:
print("Error occurs while scaning edge")
break
process_edge(space_name, scan_edge_response)
def process_edge(space, scan_edge_response):
result = scan_edge_processor.process(space, scan_edge_response)
# Get the corresponding rows by edge_name
for edge_name, edge_rows in result.rows.items():
for row in edge_rows:
srcId = row.default_properties[0].get_value()
dstId = row.default_properties[2].get_value()
print(srcId)
print(dstId)
props = {}
for prop in row.properties:
prop_name = prop.get_name()
prop_value = prop.get_value()
props[prop_name] = prop_value
if __name__ == '__main__':
scan_nebula_edge()
代码运行一直报错,堆栈信息如下
ERROR:root:unsupported operand type(s) for &: 'NoneType' and 'int'
Traceback (most recent call last):
File "C:\soft\Anaconda\lib\site-packages\nebula\ngMeta\MetaClient.py", line 98, in do_connect
self.update_schemas()
File "C:\soft\Anaconda\lib\site-packages\nebula\ngMeta\MetaClient.py", line 109, in update_schemas
self._space_part_location[space_name] = self.get_parts_alloc(space_name)
File "C:\soft\Anaconda\lib\site-packages\nebula\ngMeta\MetaClient.py", line 233, in get_parts_alloc
host = socket.inet_ntoa(struct.pack('I',socket.htonl(host_addr.ip & 0xffffffff)))
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'
ERROR:root:unsupported operand type(s) for &: 'NoneType' and 'int'
Traceback (most recent call last):
File "C:\soft\Anaconda\lib\site-packages\nebula\ngMeta\MetaClient.py", line 98, in do_connect
self.update_schemas()
File "C:\soft\Anaconda\lib\site-packages\nebula\ngMeta\MetaClient.py", line 109, in update_schemas
self._space_part_location[space_name] = self.get_parts_alloc(space_name)
File "C:\soft\Anaconda\lib\site-packages\nebula\ngMeta\MetaClient.py", line 233, in get_parts_alloc
host = socket.inet_ntoa(struct.pack('I',socket.htonl(host_addr.ip & 0xffffffff)))
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'
ERROR:root:unsupported operand type(s) for &: 'NoneType' and 'int'
Traceback (most recent call last):
File "C:\soft\Anaconda\lib\site-packages\nebula\ngMeta\MetaClient.py", line 98, in do_connect
self.update_schemas()
File "C:\soft\Anaconda\lib\site-packages\nebula\ngMeta\MetaClient.py", line 109, in update_schemas
self._space_part_location[space_name] = self.get_parts_alloc(space_name)
File "C:\soft\Anaconda\lib\site-packages\nebula\ngMeta\MetaClient.py", line 233, in get_parts_alloc
host = socket.inet_ntoa(struct.pack('I',socket.htonl(host_addr.ip & 0xffffffff)))
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'
Traceback (most recent call last):
File "C:\project\2-code\pycharm\data_analyse\data_process\nebula\louvin.py", line 75, in <module>
scan_nebula_edge()
File "C:\project\2-code\pycharm\data_analyse\data_process\nebula\louvin.py", line 40, in scan_nebula_edge
scan_edge_response_iterator = storage_client.scan_edge(space_name, return_cols, allCols, limit, start_time,end_time)
File "C:\soft\Anaconda\lib\site-packages\nebula\ngStorage\StorageClient.py", line 251, in scan_edge
part_ids = self._meta_client.get_parts_alloc_from_cache()[space].keys()
KeyError: 'pay_risk_identify'
Process finished with exit code 1
有谁能帮忙看下吗