xiaokang commented on code in PR #26689: URL: https://github.com/apache/doris/pull/26689#discussion_r1390106600
########## be/src/olap/rowset/segment_v2/segment_iterator.cpp: ########## @@ -189,9 +193,38 @@ class SegmentIterator::BackwardBitmapRangeIterator : public SegmentIterator::Bit return true; } + uint32_t read_batch_rowids(rowid_t* buf, uint32_t batch_size) override { + if (!_riter.has_value || _rowid_left == 0) { + return 0; + } + + if (_rowid_count <= batch_size) { Review Comment: Is it OK if _rowid_left <= batch_size? ########## be/src/olap/rowset/segment_v2/segment_iterator.cpp: ########## @@ -189,9 +193,38 @@ class SegmentIterator::BackwardBitmapRangeIterator : public SegmentIterator::Bit return true; } + uint32_t read_batch_rowids(rowid_t* buf, uint32_t batch_size) override { + if (!_riter.has_value || _rowid_left == 0) { + return 0; + } + + if (_rowid_count <= batch_size) { + roaring_bitmap_to_uint32_array(_riter.parent, + buf); // Fill 'buf' with '_rowid_count' elements. + uint32_t num_read = _rowid_left; // Save the number of row IDs read. + _rowid_left = 0; // No row IDs left after this operation. + return num_read; // Return the number of row IDs read. + } + + uint32_t read_size = std::min(batch_size, _rowid_left); + uint32_t num_read = 0; // Counter for the number of row IDs read. + + // Read row IDs into the buffer in reverse order. + while (num_read < read_size && _riter.has_value) { + buf[read_size - num_read - 1] = _riter.current_value; + num_read++; + _rowid_left--; // Decrement the count of remaining row IDs. + roaring_previous_uint32_iterator(&_riter); Review Comment: Is this op time consuming in perf? May be there is more effecient function to get batch. -- 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. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org