kangpinghuang 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_r267604121
##########
File path: be/src/olap/rowset/alpha_rowset_reader.cpp
##########
@@ -54,66 +48,57 @@ OLAPStatus AlphaRowsetReader::init(RowsetReaderContext*
read_context) {
_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::_next_block_for_singleton_without_merge;
+ } else {
+ if (_current_read_context->reader_type == READER_QUERY
+ && !_current_read_context->preaggregation) {
+ // QUERY task which set preaggregation to be true.
+ _next_block =
&AlphaRowsetReader::_next_block_for_singleton_with_merge;
+ 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::_next_block_for_singleton_without_merge;
}
}
+ } else {
+ // query task to scan cumulative rowset
+ _next_block = &AlphaRowsetReader::_next_block_for_cumulative_rowset;
}
- 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);
+ if (_is_singleton_rowset && merge) {
+ _read_block.reset(new RowBlock(_current_read_context->tablet_schema));
Review comment:
```suggestion
_read_block.reset(new
(std::nothrow)RowBlock(_current_read_context->tablet_schema));
```
----------------------------------------------------------------
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]