imay 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_r268471749
##########
File path: be/src/olap/rowset/alpha_rowset_reader.cpp
##########
@@ -136,57 +127,70 @@ int64_t AlphaRowsetReader::filtered_rows() {
return _stats->rows_del_filtered;
}
-OLAPStatus AlphaRowsetReader::_get_next_block(size_t pos, RowBlock**
row_block) {
- // get next block
- OLAPStatus status = _column_datas[pos]->get_next_block(row_block);
- if (status == OLAP_ERR_DATA_EOF && _key_range_size > 0) {
- // reach the end of one predicate
- // currently, SegmentReader can only support filter one key range a
time
- // refresh the predicate and continue read
- _key_range_indices[pos]++;
- OLAPStatus status = OLAP_SUCCESS;
- while (_key_range_indices[pos] < _key_range_size) {
- status = _column_datas[pos]->prepare_block_read(
-
_current_read_context->lower_bound_keys->at(_key_range_indices[pos]),
-
_current_read_context->is_lower_keys_included->at(_key_range_indices[pos]),
-
_current_read_context->upper_bound_keys->at(_key_range_indices[pos]),
-
_current_read_context->is_upper_keys_included->at(_key_range_indices[pos]),
- row_block);
- if (status == OLAP_ERR_DATA_EOF) {
- _key_range_indices[pos]++;
- continue;
- } else if (status != OLAP_SUCCESS) {
- LOG(WARNING) << "prepare block read failed";
- return status;
- } else {
- break;
- }
+OLAPStatus AlphaRowsetReader::_union_block(RowBlock** block) {
+ size_t pos = 0;
+ for (; pos < _column_datas.size(); ++pos) {
+ // union block only use one block to store
+ OLAPStatus status = _next_block_for_column_data(pos,
&_row_blocks[pos]);
+ if (status == OLAP_ERR_DATA_EOF) {
+ continue;
+ } else if (status != OLAP_SUCCESS) {
+ return status;
+ } else {
+ (*block) = _row_blocks[pos];
+ return OLAP_SUCCESS;
}
- if (_key_range_indices[pos] >= _key_range_size) {
- *row_block = nullptr;
- return OLAP_ERR_DATA_EOF;
+ }
+ if (pos == _row_blocks.size()) {
+ *block = nullptr;
+ return OLAP_ERR_DATA_EOF;
+ }
+
+ return OLAP_SUCCESS;
+}
+
+OLAPStatus AlphaRowsetReader::_merge_block(RowBlock** block) {
+ // Row among different segment groups may overlap with each other.
+ // Iterate all row_blocks to fetch min row each round.
+ OLAPStatus status = OLAP_SUCCESS;
+ _read_block->clear();
+ size_t num_rows_in_block = 0;
+ while (_read_block->pos() < _num_rows_per_row_block) {
+ RowCursor* row_cursor = nullptr;
+ status = _next_row_for_singleton_rowset(&row_cursor);
+ if (status == OLAP_ERR_DATA_EOF && _read_block->pos() > 0) {
+ status = OLAP_SUCCESS;
+ break;
+ } else if (status != OLAP_SUCCESS) {
+ return status;
}
- return OLAP_SUCCESS;
+ _read_block->get_row(_read_block->pos(), _dst_cursor);
+ _dst_cursor->copy(*row_cursor, _read_block->mem_pool());
+ _read_block->pos_inc();
+ num_rows_in_block++;
}
+ _read_block->set_pos(0);
+ _read_block->set_limit(num_rows_in_block);
+ _read_block->finalize(num_rows_in_block);
+ *block = _read_block.get();
return status;
}
-OLAPStatus AlphaRowsetReader::_get_next_row_for_singleton_rowset(RowCursor**
row) {
+OLAPStatus AlphaRowsetReader::_next_row_for_singleton_rowset(RowCursor** row) {
RowCursor* min_row = nullptr;
int min_index = -1;
for (int i = 0; i < _row_blocks.size(); i++) {
- if (_row_blocks[i] == nullptr) {
- continue;
- }
- RowCursor* current_row = _row_cursors[i];
- if (!_row_blocks[i]->has_remaining()) {
- OLAPStatus status = _get_next_block(i, &_row_blocks[i]);
- if (status != OLAP_SUCCESS) {
- LOG(WARNING) << "_get_next_block failed, status:" << status;
+ if (_row_blocks[i] == nullptr || !_row_blocks[i]->has_remaining()) {
+ OLAPStatus status = _next_block_for_column_data(i,
&_row_blocks[i]);
+ if (status == OLAP_ERR_DATA_EOF) {
+ continue;
+ } else if (status != OLAP_SUCCESS) {
+ LOG(INFO) << "read next row of singleton rowset failed:" <<
status;
return status;
}
}
size_t pos = _row_blocks[i]->pos();
+ RowCursor* current_row = _row_cursors[i];
_row_blocks[i]->get_row(pos, current_row);
if (min_row == nullptr || min_row->cmp(*current_row) < 0) {
Review comment:
```suggestion
if (min_row == nullptr || min_row->cmp(*current_row) > 0) {
```
I think this should be large than
----------------------------------------------------------------
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]