adonis0147 commented on code in PR #12293: URL: https://github.com/apache/doris/pull/12293#discussion_r969389961
########## be/src/olap/rowset/segment_v2/column_reader.cpp: ########## @@ -466,6 +486,42 @@ Status ArrayFileColumnIterator::next_batch(size_t* n, ColumnBlockView* dst, bool return Status::OK(); } +Status ArrayFileColumnIterator::_seek_by_offsets(ordinal_t ord) { + // using offsets info + ordinal_t offset = 0; + RETURN_IF_ERROR(_peek_one_offset(&offset)); + RETURN_IF_ERROR(_item_iterator->seek_to_ordinal(offset)); + return Status::OK(); +} + +Status ArrayFileColumnIterator::seek_to_ordinal(ordinal_t ord) { + RETURN_IF_ERROR(_offset_iterator->seek_to_ordinal(ord)); + if (_array_reader->is_nullable()) { + RETURN_IF_ERROR(_null_iterator->seek_to_ordinal(ord)); + } + return _seek_by_offsets(ord); +} + +Status ArrayFileColumnIterator::_caculate_offsets(ssize_t start, + vectorized::MutableColumnPtr& offsets, + size_t* num_items) { + auto& column_offsets = static_cast<vectorized::ColumnArray::ColumnOffsets&>(*offsets); + ordinal_t last_offset = 0; + RETURN_IF_ERROR(_peek_one_offset(&last_offset)); + + auto& offsets_data = column_offsets.get_data(); + *num_items = last_offset - offsets_data[start]; + // caculate real offsets + ordinal_t first_offset = offsets_data[start - 1]; // -1 is valid + ordinal_t first_ord = offsets_data[start]; + for (ssize_t i = start; i + 1 < offsets_data.size(); ++i) { + offsets_data[i] = first_offset + (offsets_data[i + 1] - first_ord); + } Review Comment: Maybe there is a potential optimization point if we don't read by rowids. It seems that the item_writer doesn't reset the next_rowid in the same segment. So I don't think these answer are yes. -- 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