Skip to content

Commit

Permalink
fix(tianmu):Remove excess log printing and add some code comments(sto…
Browse files Browse the repository at this point in the history
  • Loading branch information
konghaiya authored and mergify[bot] committed Apr 17, 2023
1 parent 09f0e40 commit 99c5e80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
7 changes: 2 additions & 5 deletions storage/tianmu/executor/combined_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

Expand Down Expand Up @@ -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;
Expand Down
17 changes: 15 additions & 2 deletions storage/tianmu/handler/ha_tianmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -1283,13 +1286,23 @@ 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(
std::unordered_map<int64_t, bool>::value_type(iterator_->Position(), true));
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<int64_t, bool>::value_type(current_position_, true));
iterator_->Next();
dbug_tmp_restore_column_map(table->write_set, org_bitmap);
Expand Down

0 comments on commit 99c5e80

Please sign in to comment.