Cassandra插入JSON是否会创建墓碑? [英] Does Cassandra Insert JSON creates Tombstones?

查看:130
本文介绍了Cassandra插入JSON是否会创建墓碑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Cassandra的插入JSON功能将数据插入表中.在创建的JSON中,不包含null值.意思是,忽略其中具有null值的字段.

I am using Cassandra's insert JSON feature to insert data into the table. In the JSON that I create, I do not include the null values. Meaning, ignore the fields that have null values in it.

如果我要插入记录,Cassandra是否会在这种情况下首次创建墓碑?

Does Cassandra create tombstones in such cases, if I am inserting the record say, for the first time?

我认为对于同一key的后续更新,将创建逻辑删除.是吗?

I assume for subsequent upsert for the same key will create tombstone. Is that right?

推荐答案

仍应为您要插入的json中未包含的值创建单元格逻辑删除.

Cell tombstone should still get created for the values which are not included in the json you are trying to insert.

考虑一个名为cyclist的表,该表具有ID,名字和姓氏.我们将使用仅包含姓氏的json字符串插入一行.

Consider a table called cyclist having id, first name and last name. We will insert a row using a json string which contains only last name.

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中的数据结构,则如下所示.

Now if we look at the data structure within sstable, it looks like below.

[
  {
    "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创建的单元格逻辑删除.

Observe the cell tombstone created for first_name.

这与我们使用选择性字段插入数据时的sstable结构不同.

This is different than the sstable structure when we insert the data using selective fields.

INSERT INTO cycling.cyclist(id, first_name) VALUES ( 'c49d1614-e841-4bd4-993b-02d49ae7414c', 'MYFIRSTNAME');

现在看看sstable结构

Now look at the sstable structure

[
  {
    "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" }
        ]
      }
    ]
  }
]

这篇关于Cassandra插入JSON是否会创建墓碑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆