首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gremlin_python中的大容量插入失败,"TypeError:'GraphTraversal‘对象不可调用“

gremlin_python中的大容量插入失败,"TypeError:'GraphTraversal‘对象不可调用“
EN

Stack Overflow用户
提问于 2022-03-09 08:13:33
回答 2查看 452关注 0票数 2

我是Gremlin的新手,尝试用gremlin_python在海王星db中执行大容量插入。

我在谷歌集团中找到了这个解决方案

代码语言:javascript
复制
l = [
  [name:'josh',age:29,country:'usa'],
  [name:'bar',age:24,country:'usa']];
 
g.inject(l).
 unfold().as('properties').
 select('name').as('pName').
 coalesce(V().has('name', where(eq('pName'))),
     addV('person')).as('vertex').
 sideEffect(select('properties').
              unfold().as('kv').
              select('vertex').
              property(select('kv').by(Column.keys), select('kv').by(Column.values)))

并试图像这样对gremlin_python进行调整:

代码语言:javascript
复制
l = [
  {'name':'josh','age':29,'country':'usa'},
  {'name':'bar','age':24,'country':'usa'}];
 
g.inject(l).\
 unfold().as_('properties').\
 select('name').as_('pName').\
 coalesce(__.V().has('name', __.where(__.eq('pName'))),
     addV('person')).as_('vertex').\
 sideEffect(select('properties').\
              unfold().as_('kv').\
              select('vertex').\
              property(select('kv').by(Column.keys), select('kv').by(Column.values)))

有以下错误:

代码语言:javascript
复制
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-162-c262a63ad82e> in <module>
      8  unfold().as_('properties').\
      9  select('name').as_('pName').\
---> 10  coalesce(__.V().has('name', __.where(__.eq('pName'))),
     11      addV('person')).as_('vertex').\
     12  sideEffect(select('properties').\

TypeError: 'GraphTraversal' object is not callable

我认为代码修改可能是错误的。有人能告诉我这是怎么回事吗?

EN

回答 2

Stack Overflow用户

发布于 2022-03-09 16:05:07

__.eq('pName')部分应该是statics.eq(PName)。

之后

代码语言:javascript
复制
from gremlin_python import statics
statics.load_statics(globals())

__.eq('pName')部分可以是eq('pName')。

请参阅:https://tinkerpop.apache.org/docs/current/reference/#gremlin-python-imports

票数 2
EN

Stack Overflow用户

发布于 2022-10-17 02:18:29

由于我使用了AWS Neptune DB,我最终应用了Neptune Python工具来进行批量插入:它比我们讨论的解决方案要快,但是在使用它时要小心数据类型和映射。(我对BigInts有意见)

以下是库和文档:https://github.com/awslabs/amazon-neptune-tools/tree/master/neptune-python-utils

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71406191

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档