【问题标题】:Have Gremlin-console show all the methods available for a specific object?Gremlin-console 是否显示了可用于特定对象的所有方法?
【发布时间】:2018-03-07 22:28:21
【问题描述】:

在 gremlin-console 中,有没有办法显示可用于特定对象的所有方法?

例如,在 gremlin-console 中,如果我键入 g.V().hasLabel("person") 并且我想查看我可以为 g.V().hasLabel("person") 返回的对象链接/调用哪些方法。你是怎么做到的?

【问题讨论】:

    标签: gremlin datastax-enterprise-graph


    【解决方案1】:

    答案是使用<Tab> 键。

    gremlin> "test".c
    capitalize()           center(                charAt(                chars()                codePointAt(           codePointBefore(       codePointCount(        codePoints()           collectReplacements(   compareTo(             
    compareToIgnoreCase(   concat(                contains(              contentEquals(         count(
    

    但是,我发现它不适用于像 g.V().o 这样的东西,我希望它会显示 out()。显然,groovy shell(这是 Gremlin 控制台所基于的)似乎不想在流畅的 API 上进行自动完成。它似乎只适用于您调用该方法的第一个对象:

    gremlin> g.
    E(                        V(                        addV(                     addV()                    close()                   inject(                   tx()                      withBindings(             withBulk(                 
    withComputer(             withComputer()            withPath()                withRemote(               withSack(                 withSideEffect(           withStrategies(           withoutStrategies(        anonymousTraversalClass   
    bytecode                  graph                     strategies                
    gremlin> x = g.V();[]
    gremlin> x.o
    option(     optional(   or(         order(      order()     otherV()    out(        outE(       outV()      
    gremlin> x.o
    

    这太臭了……这并不是真正的 TinkerPop 问题——我们依靠 groovysh 来实现该功能。我不认为我们可以在那里做很多事情......

    当然,您使用的是 DSE Graph,这意味着您可以访问 DataStax Studio,它不仅具有您正在寻找的自动完成功能,而且还支持架构(等等!)。我建议你切换到那个。

    【讨论】:

    • 奇怪的是,使用dse gremlin-console 对我不起作用。但它适用于apache-tinkerpop-gremlin-console。这是预期的吗?
    • 是的 - 既然你这么说,这是意料之中的。 Gremlin 控制台进入“远程”模式以与 DSE Graph 对话。在该模式下,您在控制台中键入的内容最终会成为发送到服务器进行评估并返回结果的字符串。因此,当您执行<tab> 时,它实际上最终没有任何效果,因为它没有在本地评估代码 - 就像 groovy shell 更少参与确定在这种情况下要做什么。如果您需要这种功能,我肯定会切换到 DataStax Studio。
    • 我一定会尝试 DataStax 工作室。那么是否可以使用 apache 的 Gremlin 控制台与远程 DSE Graph 对话,以便我可以拥有“自动完成”功能。当我尝试它时,我在执行g.V() 时遇到以下错误:io.netty.handler.codec.DecoderException: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: java.lang.IndexOutOfBoundsException: Index: 121, Size : 0 在 io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:98)
    • 不——那也行不通。控制台必须处于“远程”模式才能使用 DSE Graph。因此,即使您使用 tinkerpop 控制台,您也需要将其置于“远程”模式才能与 DSE Graph 对话。
    猜你喜欢
    • 2010-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-25
    • 2018-10-08
    • 2013-04-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多