Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.9k
[BUG] fix bug for vectorized compaction#9610
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -26,6 +26,14 @@ namespace vectorized { | ||
| VCollectIterator::~VCollectIterator() {} | ||
| #define RETURN_IF_NOT_EOF_AND_OK(stmt) \ | ||
| do { \ | ||
| const Status& _status_ = (stmt); \ | ||
| if (UNLIKELY(!_status_.ok() && _status_.precise_code() != OLAP_ERR_DATA_EOF)) { \ | ||
| return _status_; \ | ||
| } \ | ||
| } while (false) | ||
| void VCollectIterator::init(TabletReader* reader) { | ||
| _reader = reader; | ||
| // when aggregate is enabled or key_type is DUP_KEYS, we don't merge | ||
| @@ -45,20 +53,24 @@ Status VCollectIterator::add_child(RowsetReaderSharedPtr rs_reader) { | ||
| // Build a merge heap. If _merge is true, a rowset with the max rownum | ||
| // status will be used as the base rowset, and the other rowsets will be merged first and | ||
| // then merged with the base rowset. | ||
| void VCollectIterator::build_heap(std::vector<RowsetReaderSharedPtr>& rs_readers) { | ||
| Status VCollectIterator::build_heap(std::vector<RowsetReaderSharedPtr>& rs_readers) { | ||
| DCHECK(rs_readers.size() == _children.size()); | ||
| _skip_same = _reader->_tablet->tablet_schema().keys_type() == KeysType::UNIQUE_KEYS; | ||
| if (_children.empty()) { | ||
| _inner_iter.reset(nullptr); | ||
| return; | ||
| return Status::OK(); | ||
| } else if (_merge) { | ||
| DCHECK(!rs_readers.empty()); | ||
| for (auto [c_iter, r_iter] = std::pair {_children.begin(), rs_readers.begin()}; | ||
| c_iter != _children.end();) { | ||
| if ((*c_iter)->init() != Status::OK()) { | ||
| auto s = (*c_iter)->init(); | ||
| if (!s.ok()) { | ||
| delete (*c_iter); | ||
| c_iter = _children.erase(c_iter); | ||
| r_iter = rs_readers.erase(r_iter); | ||
| if (s.precise_code() != OLAP_ERR_DATA_EOF) { | ||
| return s; | ||
| } | ||
| } else { | ||
| ++c_iter; | ||
| ++r_iter; | ||
| @@ -91,7 +103,7 @@ void VCollectIterator::build_heap(std::vector<RowsetReaderSharedPtr>& rs_readers | ||
| } | ||
| Level1Iterator* cumu_iter = new Level1Iterator(cumu_children, _reader, | ||
| cumu_children.size() > 1, _skip_same); | ||
| cumu_iter->init(); | ||
| RETURN_IF_NOT_EOF_AND_OK(cumu_iter->init()); | ||
| std::list<LevelIterator*> children; | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cumu_iter->init(); called twice? ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forgot to remove this line and I did this just now | ||
| children.push_back(*base_reader_child); | ||
| children.push_back(cumu_iter); | ||
| @@ -103,9 +115,10 @@ void VCollectIterator::build_heap(std::vector<RowsetReaderSharedPtr>& rs_readers | ||
| } else { | ||
| _inner_iter.reset(new Level1Iterator(_children, _reader, _merge, _skip_same)); | ||
| } | ||
| _inner_iter->init(); | ||
| RETURN_IF_NOT_EOF_AND_OK(_inner_iter->init()); | ||
| // Clear _children earlier to release any related references | ||
| _children.clear(); | ||
| return Status::OK(); | ||
| } | ||
| bool VCollectIterator::LevelIteratorComparator::operator()(LevelIterator* lhs, LevelIterator* rhs) { | ||
| @@ -197,9 +210,13 @@ Status VCollectIterator::Level0Iterator::_refresh_current_row() { | ||
| _ref.row_pos = 0; | ||
| _block->clear_column_data(); | ||
| auto res = _rs_reader->next_block(_block.get()); | ||
| if (!res.ok()) { | ||
| if (!res.ok() && res.precise_code() != OLAP_ERR_DATA_EOF) { | ||
| return res; | ||
| } | ||
| if (res.precise_code() == OLAP_ERR_DATA_EOF && _block->rows() == 0) { | ||
| _ref.row_pos = -1; | ||
| return Status::OLAPInternalError(OLAP_ERR_DATA_EOF); | ||
| } | ||
| } | ||
| } while (_block->rows() != 0); | ||
| _ref.row_pos = -1; | ||
| @@ -209,7 +226,6 @@ Status VCollectIterator::Level0Iterator::_refresh_current_row() { | ||
| Status VCollectIterator::Level0Iterator::next(IteratorRowRef* ref) { | ||
| _ref.row_pos++; | ||
| RETURN_NOT_OK(_refresh_current_row()); | ||
| *ref = _ref; | ||
| return Status::OK(); | ||
| } | ||
| @@ -220,7 +236,14 @@ Status VCollectIterator::Level0Iterator::next(Block* block) { | ||
| _ref.row_pos = -1; | ||
| return Status::OK(); | ||
| } else { | ||
| return _rs_reader->next_block(block); | ||
| auto res = _rs_reader->next_block(block); | ||
| if (!res.ok() && res.precise_code() != OLAP_ERR_DATA_EOF) { | ||
| return res; | ||
| } | ||
| if (res.precise_code() == OLAP_ERR_DATA_EOF && _block->rows() == 0) { | ||
| return Status::OLAPInternalError(OLAP_ERR_DATA_EOF); | ||
| } | ||
| return Status::OK(); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.