chaoyli commented on a change in pull request #764: Convert next_row interface
to next_block
URL: https://github.com/apache/incubator-doris/pull/764#discussion_r268478355
##########
File path: be/src/olap/rowset/alpha_rowset_reader.cpp
##########
@@ -51,71 +46,67 @@ OLAPStatus AlphaRowsetReader::init(RowsetReaderContext*
read_context) {
if (_current_read_context->stats != nullptr) {
_stats = _current_read_context->stats;
}
- _dst_cursor = new(std::nothrow)RowCursor();
- _dst_cursor->init(*(_current_read_context->tablet_schema));
- OLAPStatus status = _init_column_datas(read_context);
- return status;
-}
-bool AlphaRowsetReader::has_next() {
- bool next_flag = false;
- for (int i = 0; i < _column_datas.size(); ++i) {
- auto& row_block = _row_blocks[i];
- if (row_block != nullptr) {
- if (row_block->has_remaining()) {
- next_flag = true;
+ Version version = _alpha_rowset_meta->version();
+ _is_singleton_rowset = (version.first == version.second);
+ bool merge = false;
+ /*
+ * For singleton rowset, there exists three situations.
+ * 1. DUP_KEYS tablet has no necessities to merge row in advance.
+ * 2. COMPACTION/CHECKSUM/ALTER_TABLET task has no necessities to
+ * merge row in advance.
+ * 3. QUERY task will set preaggregation. If preaggregation is
+ * set to be false, it is necessary to merge row in advance.
+ * For cumulative rowset, there is no necessities to merge row in advance.
+ */
+ if (_is_singleton_rowset) {
+ if (_current_read_context->tablet_schema->keys_type() == DUP_KEYS) {
+ // DUP_KEYS tablet
+ _next_block = &AlphaRowsetReader::_union_block;
+ } else {
+ if (_current_read_context->reader_type == READER_QUERY
+ && !_current_read_context->preaggregation) {
+ // QUERY task which set preaggregation to be true.
+ _next_block = &AlphaRowsetReader::_merge_block;
+ merge = true;
} else {
- OLAPStatus status = _get_next_block(i, &_row_blocks[i]);
- if (status == OLAP_ERR_DATA_EOF) {
- _row_blocks[i] = nullptr;
- continue;
- } else if (status != OLAP_SUCCESS) {
- LOG(WARNING) << "_get_next_block failed, status:" <<
status;
- return false;
- } else {
- if (_row_blocks[i] != nullptr &&
_row_blocks[i]->has_remaining()) {
- next_flag = true;
- }
- }
+ // COMPACTION/CHECKSUM/ALTER_TABLET task
+ _next_block = &AlphaRowsetReader::_union_block;
}
}
- }
- return next_flag;
-}
-
-OLAPStatus AlphaRowsetReader::next(RowCursor** row) {
- OLAPStatus status = OLAP_SUCCESS;
- if (_is_cumulative_rowset) {
- status = _get_next_row_for_cumulative_rowset(row);
} else {
- status = _get_next_row_for_singleton_rowset(row);
+ // query task to scan cumulative rowset
+ _next_block = &AlphaRowsetReader::_union_block;
}
- return status;
-}
-OLAPStatus AlphaRowsetReader::next_block(std::shared_ptr<RowBlock> block) {
- block->clear();
- size_t num_rows_in_block = 0;
- while (block->pos() < _num_rows_per_row_block) {
- RowCursor* row_cursor = nullptr;
- OLAPStatus status = next(&row_cursor);
- if (status == OLAP_ERR_DATA_EOF && block->pos() > 0) {
- break;
- } else if (status != OLAP_SUCCESS) {
- LOG(WARNING) << "next block failed.status:" << status;
- return status;
+ RETURN_NOT_OK(_init_column_datas(read_context));
+ if (_is_singleton_rowset && merge) {
Review comment:
OK
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]