Gremlin Java - 设置属性值列表

我正在使用 gremlin-java 访问 AWS Neptune。我想使用值列表设置顶点属性的值。我尝试执行以下操作:


g.V(<id of vertex>).property(Cardinality.set, "countries", new HashSet<>()).next();

当我执行它时,出现以下异常:


Caused by: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: {"requestId":"39207d15-75df-4e04-9c25-574070c94687","code":"UnsupportedOperationException","detailedMessage":"Unsupported property value type: java.util.LinkedHashSet"}

at org.apache.tinkerpop.gremlin.driver.Handler$GremlinResponseHandler.channelRead0(Handler.java:259)

at org.apache.tinkerpop.gremlin.driver.Handler$GremlinResponseHandler.channelRead0(Handler.java:198)

at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)

at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)

at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)

at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)

我在网上发现,要使用值列表设置属性的值,我可以使用相同的属性键多次调用 property() 函数。但我想知道是否有一种更优雅的方法来做到这一点,而不是必须循环遍历集合中的所有值。


谢谢。


呼如林
浏览 92回答 1
1回答

慕标琳琳

恐怕您需要property(SET, 'key', ...)多次致电。如果您发现您在代码中做得足够多,您可能会考虑编写Gremlin DSL来扩展语言,以允许您指定Set随后将转换为预期语法的语言。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java