我正在使用Cassandra's insert JSON feature向表中插入数据。在我创建的JSON中,我没有包含null值。也就是说,忽略其中包含null值的字段。
如果我第一次插入记录,Cassandra会在这种情况下创建墓碑吗?
我假设对于相同key的后续upsert将创建tombstone。是那么回事吗?
发布于 2020-05-13 15:33:57
仍应为您尝试插入的json中未包含的值创建Cell tombstone。
考虑一个名为cyclist的表,该表具有id、名字和姓氏。我们将使用只包含姓氏的json字符串插入一行。
CREATE KEYSPACE IF NOT EXISTS cycling WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'datacenter1' : 3 };
CREATE TABLE cycling.cyclist ( id UUID PRIMARY KEY, first_name text, last_name text );
CREATE TABLE cycling.cyclist ( id UUID PRIMARY KEY, first_name text, last_name text );
INSERT INTO cycling.cyclist JSON '{"id" : "829aa84a-4bba-411f-a4fb-38167a987cda", "last_name" : "MYLASTNAME" }';现在,如果我们看看sstable中的数据结构,它看起来如下所示。
[
{
"partition" : {
"key" : [ "829aa84a-4bba-411f-a4fb-38167a987cda" ],
"position" : 0
},
"rows" : [
{
"type" : "row",
"position" : 30,
"liveness_info" : { "tstamp" : "2020-05-13T07:10:59.298374Z" },
"cells" : [
{ "name" : "first_name", "deletion_info" : { "local_delete_time" : "2020-05-13T07:10:59Z" }
},
{ "name" : "last_name", "value" : "MYLASTNAME" }
]
}
]
}
]观察为first_name创建的cell tombstone。
这与我们使用选择字段插入数据时的sstable结构不同。
INSERT INTO cycling.cyclist(id, first_name) VALUES ( 'c49d1614-e841-4bd4-993b-02d49ae7414c', 'MYFIRSTNAME');现在看一下sstable结构。
[
{
"partition" : {
"key" : [ "829aa84a-4bba-411f-a4fb-38167a987cda" ],
"position" : 0
},
"rows" : [
{
"type" : "row",
"position" : 30,
"liveness_info" : { "tstamp" : "2020-05-13T07:10:59.298374Z" },
"cells" : [
{ "name" : "first_name", "deletion_info" : { "local_delete_time" : "2020-05-13T07:10:59Z" }
},
{ "name" : "last_name", "value" : "MYLASTNAME" }
]
}
]
},
{
"partition" : {
"key" : [ "c49d1614-e841-4bd4-993b-02d49ae7414c" ],
"position" : 47
},
"rows" : [
{
"type" : "row",
"position" : 77,
"liveness_info" : { "tstamp" : "2020-05-13T07:23:42.964609Z" },
"cells" : [
{ "name" : "first_name", "value" : "MYFIRSTNAME" }
]
}
]
}
]https://stackoverflow.com/questions/61768228
复制相似问题