2015-11-05 51 views
0

我正在使用gocql,但它應該沒有什麼不同。
你知道如何解決以下?:批處理條件不能跨越多個分區

A2B := gocql.NewBatch(gocql.LoggedBatch) 
stmtA2B := "INSERT INTO tableName (idA, idB) VALUES (?,?) IF NOT EXISTS" 

for index, id := range listOfids { 
    A2B.Query(stmtAB, "test_id_A", "test_id_B") // This works 
    A2B.Query(stmtAB, "test_id_B", "test_id_A") // When I add this I get err 
} 

err := session.ExecuteBatch(A2B) 

的錯誤信息是:

批與條件不能跨越多個分區 2015年11月5日19時30分04秒的http:恐慌服務xxxx:44647:批處理條件不能跨越多個分區

+0

你能後,你看到的錯誤訊息? – Aaron

回答

1

由於錯誤狀態,批處理語句不能跨多個分區運行。

我假設idA是您的表的分區鍵。在這種情況下,您只能執行正在更新idA的值相同的行的語句。 例如下面的查詢在同一個批處理語句中可以正常工作。

A2B.Query(stmtAB, "test_id_A", "val1") 
A2B.Query(stmtAB, "test_id_A", "val2") 
A2B.Query(stmtAB, "test_id_A", "val3") 

但並不是以下,因爲test_id_B行是在不同的分區test_id_A

A2B.Query(stmtAB, "test_id_A", "val1") 
A2B.Query(stmtAB, "test_id_A", "val2") 
A2B.Query(stmtAB, "test_id_B", "val3")