@@ -49,8 +49,9 @@ Status HierarchicalDataIterator::create(ColumnIteratorUPtr* reader, int32_t col_
4949 ColumnReaderCache* column_reader_cache,
5050 OlapReaderStatistics* stats, ReadType read_type) {
5151 // None leave node need merge with root
52- std::unique_ptr<HierarchicalDataIterator> stream_iter (new HierarchicalDataIterator (path));
53- if (node != nullptr && read_type != ReadType::MERGE_ROOT_DOC) {
52+ std::unique_ptr<HierarchicalDataIterator> stream_iter (
53+ new HierarchicalDataIterator (path, read_type));
54+ if (node != nullptr && read_type == ReadType::SUBCOLUMNS_AND_SPARSE) {
5455 std::vector<const SubcolumnColumnMetaInfo::Node*> leaves;
5556 vectorized::PathsInData leaves_paths;
5657 SubcolumnColumnMetaInfo::get_leaves_of_node (node, leaves, leaves_paths);
@@ -68,7 +69,6 @@ Status HierarchicalDataIterator::create(ColumnIteratorUPtr* reader, int32_t col_
6869 // need read from sparse column if not null
6970 stream_iter->_binary_column_reader = std::move (binary_column_reader);
7071 stream_iter->_stats = stats;
71- stream_iter->_read_type = read_type;
7272 *reader = std::move (stream_iter);
7373
7474 return Status::OK ();
@@ -84,7 +84,7 @@ Status HierarchicalDataIterator::init(const ColumnIteratorOptions& opts) {
8484 RETURN_IF_ERROR (_root_reader->iterator ->init (opts));
8585 _root_reader->inited = true ;
8686 }
87- if (_binary_column_reader && !_binary_column_reader->inited ) {
87+ if (!_binary_column_reader->inited ) {
8888 RETURN_IF_ERROR (_binary_column_reader->iterator ->init (opts));
8989 _binary_column_reader->inited = true ;
9090 }
@@ -100,10 +100,8 @@ Status HierarchicalDataIterator::seek_to_ordinal(ordinal_t ord) {
100100 DCHECK (_root_reader->inited );
101101 RETURN_IF_ERROR (_root_reader->iterator ->seek_to_ordinal (ord));
102102 }
103- if (_binary_column_reader) {
104- DCHECK (_binary_column_reader->inited );
105- RETURN_IF_ERROR (_binary_column_reader->iterator ->seek_to_ordinal (ord));
106- }
103+ DCHECK (_binary_column_reader->inited );
104+ RETURN_IF_ERROR (_binary_column_reader->iterator ->seek_to_ordinal (ord));
107105 return Status::OK ();
108106}
109107
@@ -319,18 +317,12 @@ Status HierarchicalDataIterator::_process_sparse_column(
319317 vectorized::ColumnVariant& container_variant, size_t nrows) {
320318 using namespace vectorized ;
321319 container_variant.clear_sparse_column ();
322- if (!_binary_column_reader) {
323- container_variant.get_sparse_column ()->assume_mutable ()->resize (nrows);
324- container_variant.get_doc_value_column ()->assume_mutable ()->resize (nrows);
325- ENABLE_CHECK_CONSISTENCY (&container_variant);
326- return Status::OK ();
327- }
328320 // process sparse column
329321 if (_path.get_parts ().empty ()) {
330- if (_read_type == ReadType::MERGE_ROOT_SPARSE ) {
322+ if (_read_type == ReadType::SUBCOLUMNS_AND_SPARSE ) {
331323 container_variant.set_sparse_column (_binary_column_reader->column ->get_ptr ());
332324 container_variant.get_doc_value_column ()->assume_mutable ()->resize (nrows);
333- } else if (_read_type == ReadType::MERGE_ROOT_DOC ) {
325+ } else if (_read_type == ReadType::DOC_VALUE_COLUMN ) {
334326 container_variant.set_doc_value_column (_binary_column_reader->column ->get_ptr ());
335327 container_variant.get_sparse_column ()->assume_mutable ()->resize (nrows);
336328 } else {
@@ -402,7 +394,8 @@ Status HierarchicalDataIterator::_process_sparse_column(
402394 lower_bound_index);
403395 }
404396 // Case 2: subcolumn not created yet and we still have quota → create it and insert.
405- else if (subcolumns_from_sparse_column.size () < count) {
397+ else if (subcolumns_from_sparse_column.size () < count ||
398+ container_variant.max_subcolumns_count () == 0 ) {
406399 // Initialize subcolumn with current logical row index i to align sizes.
407400 ColumnVariant::Subcolumn subcolumn (/* size*/ i, /* is_nullable*/ true ,
408401 false );
@@ -477,9 +470,7 @@ Status HierarchicalDataIterator::_init_null_map_and_clear_columns(
477470 return Status::OK ();
478471 }));
479472 container->clear ();
480- if (_binary_column_reader) {
481- _binary_column_reader->column ->clear ();
482- }
473+ _binary_column_reader->column ->clear ();
483474 if (_root_reader) {
484475 if (_root_reader->column ->is_nullable ()) {
485476 // fill nullmap
0 commit comments