gremlin python检索id和标签(valueMap(True))

时间:2022-06-29 04:49:15

python g.V('test_red1').valueMap().toList()

works fine but when I pass true to request ids and labels I get this error. Anything I am missing?

工作正常,但当我传递给请求ID和标签时,我收到此错误。我错过了什么?

g.V('test_red1').valueMap(True).toList()

  Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ec2-user/environment/merchantGraph/gremlin_python/process/traversal.py", line 52, in toList
    return list(iter(self))
  File "/home/ec2-user/environment/merchantGraph/gremlin_python/process/traversal.py", line 43, in __next__
 ...

Am I missing something. I am using AWS Neptune ...

我错过了什么。我正在使用AWS Neptune ......

I am adding extra import statements

我正在添加额外的import语句

and traceback

import time
import requests
import json
from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection


import boto3
from os import environ

graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection(environ['gremlinNeptuneConnection'],'g'))


# this works
g.V('test_red1').valueMap().toList()

# this fails
g.V('test_red1').valueMap(True).toList()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ec2-user/environment/merchantGraph/gremlin_python/process/traversal.py", line 52, in toList
    return list(iter(self))
  ....
  File "/home/ec2-user/environment/merchantGraph/gremlin_python/structure/io/graphsonV3d0.py", line 455, in objectify
    new_dict[reader.toObject(l[x])] = reader.toObject(l[x + 1])

TypeError: unhashable type: 'dict'

1 个解决方案

#1


3  

My guess is that you are running into trouble with this recently reported bug with valueMap(true):

我的猜测是你最近报告的valueMap错误(真)你遇到了麻烦:

https://issues.apache.org/jira/browse/TINKERPOP-1860

it is patched and will be fixed with release of 3.3.2. Until then you will have to work around the issue as there really is no fix short of reverting to GraphSON 2.0 (which comes with it's own set of downsides). One workaround would be to project() your results:

它已修补,将在3.3.2版本中修复。在此之前,你将不得不解决这个问题,因为没有修复程序没有恢复到GraphSON 2.0(它带有它自己的一组缺点)。一个解决方法是project()您的结果:

gremlin> g.V().project('props','id','label').
......1>         by(valueMap()).
......2>         by(id).
......3>         by(label)
==>[props:[name:[marko],age:[29]],id:1,label:person]
==>[props:[name:[vadas],age:[27]],id:2,label:person]
==>[props:[name:[lop],lang:[java]],id:3,label:software]
==>[props:[name:[josh],age:[32]],id:4,label:person]
==>[props:[name:[ripple],lang:[java]],id:5,label:software]
==>[props:[name:[peter],age:[35]],id:6,label:person]

#1


3  

My guess is that you are running into trouble with this recently reported bug with valueMap(true):

我的猜测是你最近报告的valueMap错误(真)你遇到了麻烦:

https://issues.apache.org/jira/browse/TINKERPOP-1860

it is patched and will be fixed with release of 3.3.2. Until then you will have to work around the issue as there really is no fix short of reverting to GraphSON 2.0 (which comes with it's own set of downsides). One workaround would be to project() your results:

它已修补,将在3.3.2版本中修复。在此之前,你将不得不解决这个问题,因为没有修复程序没有恢复到GraphSON 2.0(它带有它自己的一组缺点)。一个解决方法是project()您的结果:

gremlin> g.V().project('props','id','label').
......1>         by(valueMap()).
......2>         by(id).
......3>         by(label)
==>[props:[name:[marko],age:[29]],id:1,label:person]
==>[props:[name:[vadas],age:[27]],id:2,label:person]
==>[props:[name:[lop],lang:[java]],id:3,label:software]
==>[props:[name:[josh],age:[32]],id:4,label:person]
==>[props:[name:[ripple],lang:[java]],id:5,label:software]
==>[props:[name:[peter],age:[35]],id:6,label:person]