问题描述
我尝试了Cassandra 3.0 alpha,看看物化视图是如何工作的,并按照所示的示例操作。
I was trying out the Cassandra 3.0 alpha to see how materialized views work and following the example shown here.
该示例在整个分区从基表中删除时工作,一个单独的聚簇行,它仍然出现在物化视图中。
The example works when a whole partition is deleted from the base table, but when I delete an individual clustered row, it continues to appear in the materialized view. Shouldn't a row deleted in the base table also disappear from the views?
例如:
CREATE TABLE base (part int, clus int , val int, PRIMARY KEY (part, clus));
CREATE MATERIALIZED VIEW view1 AS SELECT part FROM base WHERE part IS NOT NULL AND clus IS NOT NULL AND val IS NOT NULL PRIMARY KEY (val, part, clus);
INSERT INTO base (part, clus, val) VALUES ( 1, 2, 200 );
INSERT INTO base (part, clus, val) VALUES ( 1, 3, 300 );
SELECT * FROM view1;
val | part | clus
-----+------+------
200 | 1 | 2
300 | 1 | 3
然后我只删除一行:
DELETE FROM base WHERE part=1 and clus=3;
现在我期望val = 300从视图中消失, p>
Now I was expecting val=300 to disappear from the view, but it didn't:
SELECT * FROM view1;
val | part | clus
-----+------+------
200 | 1 | 2
300 | 1 | 3
接下来如果我删除整个分区,我之前删除的聚簇行留在视图中:
Next if I delete the whole partition, the clustering row I deleted earlier is left behind in the view:
DELETE FROM base WHERE part=1;
SELECT * from base;
clus | part | val
------+------+-----
SELECT * FROM view1;
val | part | clus
-----+------+------
300 | 1 | 3
我猜这是alpha版本中的一个错误,预期的行为。我应该能够删除单个聚簇行并看到物化视图中反映的行吗?
I'm guessing this is a bug in the alpha release, but wanted to make sure this isn't the expected behavior. Should I be able to delete individual clustered rows and see that reflected in the materialized views?
我使用此版本:
nodetool version
ReleaseVersion: 3.0.0-alpha1-SNAPSHOT
感谢。
推荐答案
删除和更新都应该根据 。
Both deletes and updates should be propagated to the view according to "Cassandra 3.0 materialised views in action".
这篇关于Cassandra物化视图显示陈旧的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!