在Cassandra中创建了一个基于两个列(groupname,type)的主键表。当我尝试插入多行且groupname和type相同时,它不会存储超过一行,后续的写入也是如此。在groupname和type相同的情况下,最新的写入会替换之前的相似写入。为什么Cassandra会以这种方式替换而不是写入我插入的每一行呢?
cqlsh:resto> insert into restmaster (rest_id,type,rname,groupname,address,city,country)values(blobAsUuid(timeuuidAsBlob(now())),'SportsBar','SportsDen','VK Group','Majestic','Bangalore','India');
写作 2
insert into restmaster (rest_id,type,rname,groupname,address,city,country)values(blobAsUuid(timeuuidAsBlob(now())),'SportsBar','Sports Spot','VK Group','Bandra','Mumbai','India');
写作 3
cqlsh:resto> insert into restmaster (rest_id,type,rname,groupname,address,city,country)values(blobAsUuid(timeuuidAsBlob(now())),'SportsBar','Cricket Heaven ','VK Group','Connaught Place','New Delhi','India');
我期望的结果(查看第4、5、6行)
groupname | type | rname
----------------+------------+-----------------
none | Udipi | Gayatri Bhavan
none | dinein | Blue Diamond
VK Group | FoodCourt | FoodLion
VK Group | SportsBar | Sports Den
VK Group | SportsBar | Sports Spot
VK Group | SportsBar | Cricket Heaven
Viceroy Group | Vegetarian | Palace Heights
Mainland Group | Chinese | MainLand China
JSP Group | FoodCourt | Nautanki
Ohris | FoodCourt | Ohris
但这是实际的结果(写入3已替换之前插入的2行[第4、5行])
cqlsh:resto> select groupname,type,rname From restmaster;
groupname | type | rname
----------------+------------+-----------------
none | Udipi | Gayatri Bhavan
none | dinein | Blue Diamond
VK Group | FoodCourt | FoodLion
VK Group | SportsBar | Cricket Heaven
Viceroy Group | Vegetarian | Palace Heights
Mainland Group | Chinese | MainLand China
JSP Group | FoodCourt | Nautanki
Ohris | FoodCourt | Ohris
cqlsh:resto> describe table restmaster;
CREATE TABLE restmaster (
groupname text,
type text,
address text,
city text,
country text,
rest_id uuid,
rname text,
PRIMARY KEY ((groupname), type)
) WITH
bloom_filter_fp_chance=0.010000 AND
caching='KEYS_ONLY' AND
comment='' AND
dclocal_read_repair_chance=0.100000 AND
gc_grace_seconds=864000 AND
index_interval=128 AND
read_repair_chance=0.000000 AND
replicate_on_write='true' AND
populate_io_cache_on_flush='false' AND
default_time_to_live=0 AND
speculative_retry='99.0PERCENTILE' AND
memtable_flush_period_in_ms=0 AND
compaction={'class': 'SizeTieredCompactionStrategy'} AND
compression={'sstable_compression': 'LZ4Compressor'};