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

Conversation

GuoKaku
Copy link
Contributor

@GuoKaku GuoKaku commented May 7, 2024

bug 1: join tuple cannot be visited by cell_at() at position 0
bug 2: row tuple's schema will be double or triple initialized when trying to reopen table scanner

@@ -40,6 +40,7 @@ class RowTuple : public Tuple
{
table_ = table;
table_alias_ = table_alias;
species_.clear();
Copy link
Member

Choose a reason for hiding this comment

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

添加一些注释来解释这个代码的含义吧 什么时候需要

@@ -40,6 +40,7 @@ class RowTuple : public Tuple
{
table_ = table;
table_alias_ = table_alias;
species_.clear();
Copy link
Contributor

Choose a reason for hiding this comment

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

这里直接 clear 是不是会造成内存泄漏,其实可以考虑把 species_ 换成 vector<unique_ptr<FieldExpr>>,用 RAII 管理内存?

Copy link
Member

Choose a reason for hiding this comment

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

这里直接 clear 是不是会造成内存泄漏,其实可以考虑把 species_ 换成 vector<unique_ptr<FieldExpr>>,用 RAII 管理内存?

确实会,但你这个是小众场景,引入一个智能指针是不是没必要?
你可以手动维护一下指针的释放,然后判断一下如果species_不为空,再做对应的操作

@ycycse ycycse changed the title 【need a second review】try to fix JoinedTuple::cell_at() & RowTuple::set_schema() fix: wrong index in cell_at() of JoinTuple and redundant species when calling open() repeatedly May 7, 2024
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时,需要做对应的清理

@ycycse ycycse merged commit a4537c0 into THSS-DB:master May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants