cambyzju commented on code in PR #12293:
URL: https://github.com/apache/doris/pull/12293#discussion_r966700110


##########
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 < offsets_data.size() - 1; ++i) {

Review Comment:
   ```suggestion
       for (ssize_t i = start; i + 1 < offsets_data.size(); ++i) {
   ```
   
   in pod_array.h, size function return type is size_t(uint64). 
   There will be problem while size==0. You could test this simple case:
   ```
       uint64_t size = 0;
       for (int64_t i = 0; i < size -1; ++i) {
           std::cout << i << std::endl;
       }
   ```



-- 
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

Reply via email to