Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrong index in cell_at() of JoinTuple and redundant species when calling open() repeatedly #16

Merged
merged 5 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/server/include/query_engine/structor/tuple/join_tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class JoinedTuple : public Tuple
RC cell_at(int index, Value &value) const override
{
const int left_cell_num = left_->cell_num();
if (index > 0 && index < left_cell_num) {
if (index >= 0 && index < left_cell_num) {
return left_->cell_at(index, value);
}

Expand All @@ -68,4 +68,4 @@ class JoinedTuple : public Tuple
private:
Tuple *left_ = nullptr;
Tuple *right_ = nullptr;
};
};
8 changes: 8 additions & 0 deletions src/server/include/query_engine/structor/tuple/row_tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,19 @@ class RowTuple : public Tuple
this->bitmap_.init(record->data() + null_filed_meta->offset(), null_filed_meta->len());
}


void set_schema(const Table *table, const std::string &table_alias, const std::vector<FieldMeta> *fields)
{
table_ = table;
table_alias_ = table_alias;
this->species_.reserve(fields->size());
if(!species_.empty()){
for(auto& field_expr : species_){
delete field_expr; //clear()前先释放目前的fields
}
species_.clear();/// 在TableScanPhysicalOperator::open()会调用set_schema。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不光是table_scan_operator,index_scan_operator也会调用这个方法,只是当open()被调用多次调用set_schema时,需要做对应的清理

//如果不加clear(),当同一个operator多次open()时,sepcies_就会积累多套重复的fields。
}
for (const FieldMeta &field : *fields) {
species_.push_back(new FieldExpr(table, &field));
species_[species_.size() - 1]->set_field_table_alias(table_alias);
Expand Down