From 99c5e80fbe814c77ce536bbf0e0c17ef02222cbc Mon Sep 17 00:00:00 2001 From: lihongjian Date: Wed, 12 Apr 2023 00:34:41 +0800 Subject: [PATCH] fix(tianmu):Remove excess log printing and add some code comments(#1545) --- storage/tianmu/executor/combined_iterator.cpp | 7 ++----- storage/tianmu/handler/ha_tianmu.cpp | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/storage/tianmu/executor/combined_iterator.cpp b/storage/tianmu/executor/combined_iterator.cpp index 309de24b8..e5227f4b7 100644 --- a/storage/tianmu/executor/combined_iterator.cpp +++ b/storage/tianmu/executor/combined_iterator.cpp @@ -51,9 +51,6 @@ void CombinedIterator::Next() { } } else { base_iter_->Next(); - if (base_iter_->Valid()) { - TIANMU_LOG(LogCtl_Level::ERROR, "base pos: %d", base_iter_->Position()); - } } } @@ -85,8 +82,8 @@ bool CombinedIterator::Valid() const { return Position() != -1; } bool CombinedIterator::IsBase() const { return is_base_; } bool CombinedIterator::BaseCurrentRowIsInvalid() const { - if (base_iter_->CurrentRowIsDeleted() || InDeltaDeletedRow.find(base_iter_->Position()) != InDeltaDeletedRow.end() || - InDeltaUpdateRow.find(base_iter_->Position()) != InDeltaUpdateRow.end()) { + if (InDeltaDeletedRow.find(base_iter_->Position()) != InDeltaDeletedRow.end() || + InDeltaUpdateRow.find(base_iter_->Position()) != InDeltaUpdateRow.end() || base_iter_->CurrentRowIsDeleted()) { return true; } return false; diff --git a/storage/tianmu/handler/ha_tianmu.cpp b/storage/tianmu/handler/ha_tianmu.cpp index 0bc83465d..342071d89 100644 --- a/storage/tianmu/handler/ha_tianmu.cpp +++ b/storage/tianmu/handler/ha_tianmu.cpp @@ -1259,8 +1259,10 @@ int ha_tianmu::fill_row(uchar *buf) { std::memcpy(buffer.get(), table->record[0], table->s->reclength); } if (iterator_->IsBase()) { - // judge whether this line has been deleted. - // if this line has been deleted, data will not be copied. + /* + Determine whether the current row is invalid in the base layer, + If it is invalid, directly return to the SQL layer that the current row has been deleted + */ if (iterator_->BaseCurrentRowIsInvalid()) { current_position_ = iterator_->Position(); iterator_->Next(); @@ -1275,6 +1277,7 @@ int ha_tianmu::fill_row(uchar *buf) { if (!delta_record.empty()) { switch (core::DeltaRecordHead::GetRecordType(delta_record.data())) { case core::RecordType::kInsert: + // If the function change fails, it will be considered that the row change has been deleted. if (!core::Engine::DecodeInsertRecordToField(delta_record.data(), table->field)) { current_position_ = iterator_->Position(); iterator_->Next(); @@ -1283,6 +1286,11 @@ int ha_tianmu::fill_row(uchar *buf) { } break; case core::RecordType::kUpdate: + /* + Merge data from the base layer and delta layer. + At the same time, record the status of switching to the delta layer + When iterating the base layer data, it is judged as invalid for changing rows + */ current_txn_->GetTableByPath(table_name_)->FillRowByRowid(table, iterator_->Position()); core::Engine::DecodeUpdateRecordToField(delta_record.data(), table->field); iterator_->InDeltaUpdateRow.insert( @@ -1290,6 +1298,11 @@ int ha_tianmu::fill_row(uchar *buf) { break; case core::RecordType::kDelete: current_position_ = iterator_->Position(); + /* + If there is deleted data with a new row in the delta layer, + Just record it down, + When iterating the base layer data, it is judged as invalid for changing rows + */ iterator_->InDeltaDeletedRow.insert(std::unordered_map::value_type(current_position_, true)); iterator_->Next(); dbug_tmp_restore_column_map(table->write_set, org_bitmap);