这是我的表:
CREATE KEYSPACE CqlDemo WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1};
CREATE TABLE CqlDemo.MyBooks (id UUID PRIMARY KEY,title TEXT, impcol set<int>);
现在我通过执行follwiing CQL查询来插入数据:
update CqlDemo.mybooks set impcol=impcol+{0} where id=44a2054c-f98b-43a7-833d-0e1358fdaa82;
update CqlDemo.mybooks set impcol=impcol+{1} where id=44a2054c-f98b-43a7-833d-0e1358fdaa82;
update CqlDemo.mybooks set impcol=impcol+{2} where id=44a2054c-f98b-43a7-833d-0e1358fdaa82;
update CqlDemo.mybooks set impcol=impcol+{3} where id=44a2054c-f98b-43a7-833d-0e1358fdaa82;
update CqlDemo.mybooks set impcol=impcol+{4} where id=44a2054c-f98b-43a7-833d-0e1358fdaa82;
update CqlDemo.mybooks set impcol=impcol+{5} where id=44a2054c-f98b-43a7-833d-0e1358fdaa82;
update CqlDemo.mybooks set impcol=impcol+{6} where id=44a2054c-f98b-43a7-833d-0e1358fdaa82;
update CqlDemo.mybooks set impcol=impcol+{7} where id=44a2054c-f98b-43a7-833d-0e1358fdaa82;
update CqlDemo.mybooks set impcol=impcol+{8} where id=44a2054c-f98b-43a7-833d-0e1358fdaa82;
update CqlDemo.mybooks set impcol=impcol+{9} where id=44a2054c-f98b-43a7-833d-0e1358fdaa82;
update CqlDemo.mybooks set impcol=impcol+{10} where id=44a2054c-f98b-43a7-833d-0e1358fdaa82;
update CqlDemo.mybooks set impcol=impcol+{11} where id=44a2054c-f98b-43a7-833d-0e1358fdaa82;
update CqlDemo.mybooks set impcol=impcol+{12} where id=44a2054c-f98b-43a7-833d-0e1358fdaa82;
update CqlDemo.mybooks set impcol=impcol+{13} where id=44a2054c-f98b-43a7-833d-0e1358fdaa82;
update CqlDemo.mybooks set impcol=impcol+{14} where id=44a2054c-f98b-43a7-833d-0e1358fdaa82;
使用datastax驱动程序从java执行这些queres。当我执行它们之后,每个人都很好。 但是当我并行执行它们时,一些插入就会消失......
我在我的代码中假设线程错误,但由于我无法找到它,我想知道集合上的并行更新是否有限制?
这是我的代码: https://github.com/maciejmiklas/cyclop/blob/master/cyclop-webapp/src/main/java/org/cyclop/service/importer/impl/ParallelQueryImporter.java https://github.com/maciejmiklas/cyclop/blob/master/cyclop-webapp/src/main/java/org/cyclop/service/importer/impl/ImportWorker.java
答案 0 :(得分:1)
Cassandra集合被提取并整体存储。而卡桑德拉确实写了胜利。您的一些更新基本上会被后续更新覆盖。