我正在使用 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() 函數。但我想知道是否有一種更優雅的方法來做到這一點,而不是必須循環遍歷集合中的所有值。謝謝。
1 回答

慕標琳琳
TA貢獻1830條經驗 獲得超9個贊
恐怕您需要property(SET, 'key', ...)
多次致電。如果您發現您在代碼中做得足夠多,您可能會考慮編寫Gremlin DSL來擴展語言,以允許您指定Set
隨后將轉換為預期語法的語言。
添加回答
舉報
0/150
提交
取消