2017-04-20 89 views
2

我們正在使用Cassandra的卡桑德拉空細胞!=墓碑細胞計數

cqlsh 5.0.1 | Cassandra 2.1.14.1272 | DSE 4.8.7 | CQL spec 3.2.1 

我們有大約> 60萬行,其中我們已經插在大多數細胞的NULL此行。我們運行一個查詢,掃描8000行,日期爲昨天,今天,明天。 然而,當我啓用跟蹤我只發現:

Read 101 live and 997 tombstone cells [SharedPool-Worker-1] | 2017-04-20 11:05:02.901000 | 10.74.70.30 |   11297 

我知道,在卡桑德拉插入空值的那些細胞創建墓碑,但我爲什麼只能看到即使查詢將返回8K記錄,每個記錄保持這樣幾個墓碑多個NULL?什麼都可以解釋這個?這些記錄的TTL默認爲30天,因此這個8k的結果集由於TTL而不能有墓碑。

編輯1

我的模式是:

CREATE TABLE transportation_events.events_for_load_ops_exceptions (
    exception_phase text, 
    exception_date text, 
    event_id timeuuid, 
    actual_delivery_ts timestamp, 
    actual_pickup_ts timestamp, 
    carrier_due_ts timestamp, 
    carrier_id text, 
    carrier_mode text, 
    carrier_pickup_ts timestamp, 
    dest_loc_banner_code text, 
    dest_loc_class_code int, 
    dest_loc_id int, 
    dest_loc_name text, 
    dest_loc_type text, 
    dest_time_zone text, 
    destination_city text, 
    destination_postal_code text, 
    destination_state text, 
    destination_street_addr text, 
    exception_type text, 
    late_reason_code text, 
    load_id text, 
    load_type text, 
    loc_time_zone text, 
    orig_loc_id int, 
    orig_loc_name text, 
    orig_loc_type text, 
    orig_time_zone text, 
    origin_city text, 
    origin_postal_code text, 
    origin_state text, 
    origin_street_addr text, 
    reason_code_category text, 
    reason_code_desc text, 
    scheduled_delivery_ts timestamp, 
    scheduled_pickup_ts timestamp, 
    status_reason_code text, 
    stop_loc_id int, 
    stop_loc_name text, 
    stop_loc_type text, 
    stop_seq_num int, 
    stop_type text, 
    triggered_by text, 
    PRIMARY KEY ((exception_phase, exception_date), event_id) 
) WITH CLUSTERING ORDER BY (event_id DESC) 

而現在的儲蓄卡桑德拉由

import com.datastax.driver.mapping.Mapper; 

mapper.save(resultRecord); 

我可以通過CQL是已插入的NULL看到。

查詢我跟蹤

select * from transportation_events.events_for_load_ops_exceptions where exception_phase='PLANNING' AND exception_date IN ('2017-04-19','2017-04-20','2017-04-21'); 

也許壓實已刪除大部分的墓碑?還有其他解釋嗎? 編輯2 如果有一種方法可以總結和查看墓碑及其原因,一次查詢的共同點?像桌子上的墓碑轉儲一樣?

+0

你的表的模式是什麼? – DineMartine

+0

你究竟如何插入NULL值?據我所知,NULL在使用預處理語句時只會導致邏輯刪除,因爲Cassandra無法區分「未設置」參數和NULL參數。 C *版本<= 2.2.0允許您向insert語句提示提示C *將[NULL置爲未設置](https://issues.apache.org/jira/browse/CASSANDRA-7304)。 – Ralf

+0

使用dse API中的mapper.save自動插入NULL。當我使用CQLSH查詢行時,我可以看到NULL。 – Tanvi

回答

2

您可以插入NULL作爲值,因此它不會創建邏輯刪除。

根據您使用的驅動程序,查看將空值和空值插入值之間的差異。

另一種選擇是,對於每個值,您可以爲大廳行或甚至分區使用一個墓碑,而不是一個墓碑。

+0

你能否詳細說明你的最後一行?此外,如果它不是NULL,還有什麼可以解釋這些墓碑作爲TTL是30天,我查詢只有3天值得的數據?我沒有意識到插入NULL並插入NULL作爲值有不同之處? – Tanvi

+0

例如,在python驅動程序中,如果您在準備好的語句中插入null,它將作爲一個值被關心,並且不會像它應該創建邏輯刪除。查看真正發生的最簡單的方法是執行以下操作1)執行空插入。 2)沖洗。3)請參閱您的最新表sstable轉儲,並看到墓碑:) – nevsv

+0

我確定它正在創建NULLs.I使用DSE映射器,默認情況下添加NULL應該根據我導致墓碑。但我的問題是爲什麼墓碑數量有差異?如果在1行中有5個空行,我預計會有5個墓碑。但數字不匹配在這裏。 – Tanvi