实际上,我对有关 cassandra 的一些概念感到困惑。
- 更新 Cassandra 行的实际含义是什么?这是否意味着添加更多列或更新列的值。或者两者兼而有之。?
- 当我们向一行添加更多列时。 sstable 中的前一行是否无效,并且新行条目与新添加的行一起插入到 SSTABLE 中。?
- 由于 SSTable 是不可变的,因此列数据中的每次新更新或添加列或删除列数据都会导致前一行无效并插入包含所有前一列+新列的新行?
<
请帮忙..
最佳答案
What do we Actually mean by updating Cassandra row? is it mean adding more column or updates in the value of the column. or it is both.?
在cassandra中,更新一行和插入一行是相同的操作,机器人会导致将数据添加到memtable(内存中的sstable),后者随后刷新到磁盘并成为sstable(日志行也被写入如果启用了持久写入,则为提交日志)。如果您插入已经存在的列(顺便说一句,在 cassandra 术语中,列与单元格相同,行称为分区,如果您进一步阅读,您可能会发现这很有用),例如:
INSERT INTO db.tbl (id, value) VALUES ('text_id1', 'some text as a value');
INSERT INTO db.tbl (id, value) VALUES ('text_id1', 'some text as a value');
您最终将得到 1 个分区,因为第一个分区被第二个插入覆盖。这意味着插入具有重复键的分区会导致前一个被覆盖(并且覆盖基于插入时的时间戳,最后写入获胜)。
When we are adding more column(cell) to a row(partition). is the previous row in the sstable got invalidate and new row entry is inserted in the SSTABLE with the newly added rows.?
对于 cql,前面的列将仅包含 null
值。不会发生失效,您可以根据需要更改模式。如果删除列,则其数据将在下次压缩期间删除,目的是回收磁盘空间。
Since SSTable is immutable so each new update in Column data OR addition of Column OR Deletion of Column data will result in invalidating the previous row and inserting a new Row with all the previous column+new Column?
在某种程度上,sstables 在必要时会合并成更大的 sstables,具体如何完成取决于所使用的压缩策略。有两种风格,尺寸分层和水平压实。涵盖它们如何工作是一个完全独立的问题,比我聪明的人已经回答了have a read here .
关于cassandra - Cassandra 如何管理列和列数据的插入、更新和删除。内部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25138064/