liutang123 commented on a change in pull request #3025: Restructure storage 
type to support complex types expending
URL: https://github.com/apache/incubator-doris/pull/3025#discussion_r392648264
 
 

 ##########
 File path: be/src/olap/rowset/segment_v2/column_reader.cpp
 ##########
 @@ -290,6 +316,109 @@ Status ColumnReader::seek_at_or_before(ordinal_t 
ordinal, OrdinalPageIndexIterat
     return Status::OK();
 }
 
+////////////////////////////////////////////////////////////////////////////////
+
+ListColumnReader::~ListColumnReader() = default;
+
+Status ListColumnReader::new_iterator(ColumnIterator** iterator) {
+    ColumnIterator* item_iterator;
+    _item_reader->new_iterator(&item_iterator);
+    *iterator = new ListFileColumnIterator(this, item_iterator);
+    return Status::OK();
+}
+
+TypeInfo* ListColumnReader::get_type_info_for_read() {
+    return get_scalar_type_info(FieldType::OLAP_FIELD_TYPE_BIGINT);
+}
+
+ListFileColumnIterator::ListFileColumnIterator(ColumnReader* offset_reader, 
ColumnIterator* item_reader)
+: FileColumnIterator(offset_reader) {
+    _item_iterator.reset(item_reader);
+}
+
+ListFileColumnIterator::~ListFileColumnIterator() = default;
+
+Status ListFileColumnIterator::init(const ColumnIteratorOptions& opts) {
+    RETURN_IF_ERROR(FileColumnIterator::init(opts));
+    TypeInfo* bigint_type_info = 
get_scalar_type_info(FieldType::OLAP_FIELD_TYPE_BIGINT);
+    RETURN_IF_ERROR(ColumnVectorBatch::create(1024, true, bigint_type_info, 
&_offset_batch));
+    RETURN_IF_ERROR(_item_iterator->init(opts));
+    return Status::OK();
+}
+
+// every invoke this method, _offset_batch will be cover, so this method is 
not thread safe.
+Status ListFileColumnIterator::next_batch(size_t* n, ColumnBlockView* dst) {
+    // 1. read offsets into  _offset_batch;
+    _offset_batch->resize(*n + 1);
+    ColumnBlock ordinal_block(_offset_batch.get(), nullptr);
+    ColumnBlockView ordinal_view(&ordinal_block);
+    RETURN_IF_ERROR(FileColumnIterator::next_batch(n, &ordinal_view));
+
+    if (*n == 0) {
+        return Status::OK();
+    }
+
+    // 2. 读取最后一个ordinal
+    if (_page->data_decoder->has_remaining()) { // not _page->has_remaining()
+        size_t i = 1;
 
 Review comment:
   Because in  step 1, we read n rows and we should read n + 1 rows.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to