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_r269855748
##########
File path: be/src/olap/rowset/alpha_rowset_reader.cpp
##########
@@ -129,100 +120,151 @@ VersionHash AlphaRowsetReader::version_hash() {
}
void AlphaRowsetReader::close() {
- _column_datas.clear();
+ _merge_ctxs.clear();
}
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) {
+ while (_ordinal < _merge_ctxs.size()) {
+ // union block only use one block to store
+ OLAPStatus status =
_next_block_for_column_data(&(_merge_ctxs[_ordinal]));
+ if (status == OLAP_ERR_DATA_EOF) {
+ _ordinal++;
+ continue;
+ } else if (status != OLAP_SUCCESS) {
+ return status;
+ } else {
+ (*block) = _merge_ctxs[_ordinal].row_block;
+ return OLAP_SUCCESS;
}
- if (_key_range_indices[pos] >= _key_range_size) {
- *row_block = nullptr;
- return OLAP_ERR_DATA_EOF;
+ }
+ if (_ordinal == _merge_ctxs.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) {
Review comment:
I change it to _pull_next_row_for_merge_rowset.
----------------------------------------------------------------
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]