-
Notifications
You must be signed in to change notification settings - Fork 16
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
Conversation
@@ -40,6 +40,7 @@ class RowTuple : public Tuple | |||
{ | |||
table_ = table; | |||
table_alias_ = table_alias; | |||
species_.clear(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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 管理内存?
There was a problem hiding this comment.
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_不为空,再做对应的操作
for(auto& field_expr : species_){ | ||
delete field_expr; //clear()前先释放目前的fields | ||
} | ||
species_.clear();/// 在TableScanPhysicalOperator::open()会调用set_schema。 |
There was a problem hiding this comment.
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时,需要做对应的清理
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