How can a CSV file with counter columns be loaded to a Cassandra CQL3 table

ⅰ亾dé卋堺 提交于 2019-12-11 04:27:41

问题


I have a CSV file in the following format

key1,key2,key3,counter1,counter2,counter3,counter4
1,2,1,0,0,0,1
1,2,2,0,1,0,4

The CQL3 table has all value columns of type 'counter'. When I try to use the COPY command to load the CSV I get the usual error which asks for an UPDATE instead of an INSERT.

The question is : how can I tell CQL to use an UPDATE ?

Is there any other way to do this ?


回答1:


using sstables solved this issue. Although a little slower than what i expected , it does the job




回答2:


To update a counter column you have to delete it (with Consistency set to ALL) and then insert a new value (same consistency).

So my advice is to use an HashMap in you program and determine which value you want to write to the counter column (oldest, highest, lowest, ...).



来源:https://stackoverflow.com/questions/21112166/how-can-a-csv-file-with-counter-columns-be-loaded-to-a-cassandra-cql3-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!