簡體   English   中英

在 CassandraCSharpDriver.Graph 中使用 SimpleGraphStatement 的樹查詢拋出“無法轉換為 org.apache.tinkerpop.gremlin.structure.Element”

[英]Tree query using SimpleGraphStatement in CassandraCSharpDriver.Graph throws “cannot cast to org.apache.tinkerpop.gremlin.structure.Element”

我可以在 Datastax Studio 控制台中運行這個查詢並返回一個樹結果(盡管它是格式錯誤的 json,所有數據都在鍵而不是值中返回)。

g.V().has("mything","key", "mykey")
.emit()
.repeat(outE("contains").inV())
.dedup()

.tree()
.by(
    group()
    .by(label)
    .by(
            valueMap()
            .unfold()
            .group()
            .by(select(keys))
            .by(select(values).unfold())
        )
    .unfold()
    .unfold()
)

控制台結果如下所示(注意奇怪的 json 格式,數據在 json 鍵中?):

{
  "mystuff={dynamicproperties={stuff}, key=mykey}": {
    "contains={}": {
      "astuff={dynamicproperties=stuff, key=mykey}": {},
      "bstuff={dynamicproperties={stuff}, key=mykey}": {},
      "container={key=mykey}": {
        "contains={}": {
          "thing={key=mykey}": {
            "contains={}": {
              "cstuff={dynamicproperties={stuff}, key=mykey}": {}
            }
          }
        }
      }
    }
  }
}

但是,當我使用 CassandraCSharpGraph 在 Gremlin.NET 中將其作為 SimpleGraphStatement 運行時,它會引發此異常: "java.util.HashMap$Node cannot be cast to org.apache.tinkerpop.gremlin.structure.Element"

這是我運行查詢的 C# 代碼:

var graphResultSet = cassandraGraphProvider.Session.ExecuteGraph(new SimpleGraphStatement(query));

我能夠將語句一直運行到 .dedup() 行並在 graphResultSet 中獲取頂點,但是在它開始拋出錯誤時添加下面的樹代碼。

我正在使用 CassandraCSharpDriver.Graph 2.1、CassandraCSharpDriver 3.14、Gremlin.Net 3.2.9。 服務器正在運行 dse cassandra 5.1.14 和 gremlin 3.2.11。

在 CassandraCSharpDriver 中運行樹查詢的技巧是什么? 關於下一步我可以嘗試什么的任何想法?

The real issue with Tree right now is denoted here in TINKERPOP-2063 - Gremlin Language Variants like C# do not currently support the deserialization of that object so you get that ugly "java.util.HashMap$Node cannot be cast to org.apache. tinkerpop.gremlin.structure.Element”。 在這一點上,您唯一的解決方法是提交帶有驅動程序的腳本(Studio 的方式),但隨后您需要處理看起來很粗糙的 JSON。 該表示與 JSON 不支持非字符串鍵的問題有關(即不能像 Java 那樣使用object )。 所以,我相信所有的數據都在那里,但遺憾的是,使用它並不容易。 正如 JIRA 問題還指出的那樣, subgraph()步驟也存在類似的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM