Enforce that REINSERTs are not supported in DeltaMemStores We never really supported REINSERTs in the delta memstore but had code that seemed like we eventually would. This adds a CHECK to make sure we never see REINSERTs in the DeltaMemStore and also simplifies some of the code accordingly.
Change-Id: I04d0ea70969dcf60b3690d21122f3a9d497c29e3 Reviewed-on: http://gerrit.cloudera.org:8080/4991 Tested-by: Kudu Jenkins Reviewed-by: Jean-Daniel Cryans <jdcry...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/9544ea08 Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/9544ea08 Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/9544ea08 Branch: refs/heads/master Commit: 9544ea0881f5c6379146068ddc33784bbd407bfe Parents: 2fcbe18 Author: David Alves <dral...@apache.org> Authored: Mon Nov 7 21:28:44 2016 -0800 Committer: David Ribeiro Alves <dral...@apache.org> Committed: Tue Nov 8 23:36:54 2016 +0000 ---------------------------------------------------------------------- src/kudu/tablet/deltamemstore.cc | 20 ++++++++------------ src/kudu/tablet/deltamemstore.h | 6 +----- 2 files changed, 9 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/9544ea08/src/kudu/tablet/deltamemstore.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tablet/deltamemstore.cc b/src/kudu/tablet/deltamemstore.cc index de58c11..204efba 100644 --- a/src/kudu/tablet/deltamemstore.cc +++ b/src/kudu/tablet/deltamemstore.cc @@ -236,7 +236,7 @@ Status DMSIterator::PrepareBatch(size_t nrows, PrepareFlag flag) { for (UpdatesForColumn& ufc : updates_by_col_) { ufc.clear(); } - deletes_and_reinserts_.clear(); + deleted_.clear(); prepared_deltas_.clear(); while (iter_->IsValid()) { @@ -257,11 +257,9 @@ Status DMSIterator::PrepareBatch(size_t nrows, PrepareFlag flag) { if (flag == PREPARE_FOR_APPLY) { RowChangeListDecoder decoder((RowChangeList(val))); decoder.InitNoSafetyChecks(); - if (decoder.is_delete() || decoder.is_reinsert()) { - DeleteOrReinsert dor; - dor.row_id = key.row_idx(); - dor.exists = decoder.is_reinsert(); - deletes_and_reinserts_.push_back(dor); + DCHECK(!decoder.is_reinsert()) << "Reinserts are not supported in the DeltaMemStore."; + if (decoder.is_delete()) { + deleted_.push_back(key.row_idx()); } else { DCHECK(decoder.is_update()); while (decoder.HasNext()) { @@ -332,11 +330,9 @@ Status DMSIterator::ApplyDeletes(SelectionVector *sel_vec) { DCHECK_EQ(prepared_for_, PREPARED_FOR_APPLY); DCHECK_EQ(prepared_count_, sel_vec->nrows()); - for (const DeleteOrReinsert& dor : deletes_and_reinserts_) { - uint32_t idx_in_block = dor.row_id - prepared_idx_; - if (!dor.exists) { - sel_vec->SetRowUnselected(idx_in_block); - } + for (auto& row_id : deleted_) { + uint32_t idx_in_block = row_id - prepared_idx_; + sel_vec->SetRowUnselected(idx_in_block); } return Status::OK(); @@ -371,7 +367,7 @@ bool DMSIterator::HasNext() { } bool DMSIterator::MayHaveDeltas() { - if (!deletes_and_reinserts_.empty()) { + if (!deleted_.empty()) { return true; } for (auto& col: updates_by_col_) { http://git-wip-us.apache.org/repos/asf/kudu/blob/9544ea08/src/kudu/tablet/deltamemstore.h ---------------------------------------------------------------------- diff --git a/src/kudu/tablet/deltamemstore.h b/src/kudu/tablet/deltamemstore.h index 3ded59a..f9526e1 100644 --- a/src/kudu/tablet/deltamemstore.h +++ b/src/kudu/tablet/deltamemstore.h @@ -257,11 +257,7 @@ class DMSIterator : public DeltaIterator { }; typedef std::deque<ColumnUpdate> UpdatesForColumn; std::vector<UpdatesForColumn> updates_by_col_; - struct DeleteOrReinsert { - rowid_t row_id; - bool exists; - }; - std::deque<DeleteOrReinsert> deletes_and_reinserts_; + std::deque<rowid_t> deleted_; // State when prepared_for_ == PREPARED_FOR_COLLECT // ------------------------------------------------------------