Skip to content

Commit

Permalink
xx
Browse files Browse the repository at this point in the history
  • Loading branch information
eldenmoon committed Aug 6, 2024
1 parent 9bd6883 commit 5d2619b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 44 deletions.
40 changes: 1 addition & 39 deletions be/src/olap/rowset/segment_v2/hierarchical_data_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class HierarchicalDataReader : public ColumnIterator {
auto type = root_var.get_root_type();
container_variant.add_sub_column({}, std::move(column), type);
}
// parent -> subcolumns
// parent path -> subcolumns
std::map<PathInData, PathsWithColumnAndType> nested_subcolumns;
PathsWithColumnAndType non_nested_subcolumns;
RETURN_IF_ERROR(tranverse([&](SubstreamReaderTree::Node& node) {
Expand Down Expand Up @@ -182,44 +182,6 @@ class HierarchicalDataReader : public ColumnIterator {
container_variant.add_sub_column(entry.first, array->assume_mutable(),
ColumnObject::NESTED_TYPE);
}
// if (has_nested) {
// // rewrite nested nodes
// container_variant.finalize_if_not();
// MutableColumnPtr nested_object = ColumnObject::create(true, false);
// MutableColumnPtr offset =
// check_and_get_column<ColumnArray>(
// *remove_nullable(container_variant.get_subcolumns()
// .get_leaves()[0]
// ->data.get_finalized_column_ptr()))
// ->get_offsets_ptr()
// ->assume_mutable();
// auto* nested_object_ptr = assert_cast<ColumnObject*>(nested_object.get());
// // flatten nested arrays
// for (const auto& entry : container_variant.get_subcolumns()) {
// auto& column = entry->data.get_finalized_column_ptr();
// const auto& type = entry->data.get_least_common_type();
// if (!remove_nullable(column)->is_column_array()) {
// return Status::InvalidArgument(
// "Meet none array column when flatten nested array, path {}, type {}",
// entry->path.get_path(), entry->data.get_finalized_column().get_name());
// }
// MutableColumnPtr flattend_column =
// check_and_get_column<ColumnArray>(
// remove_nullable(entry->data.get_finalized_column_ptr()).get())
// ->get_data_ptr()
// ->assume_mutable();
// DataTypePtr flattend_type =
// check_and_get_data_type<DataTypeArray>(remove_nullable(type).get())
// ->get_nested_type();
// nested_object_ptr->add_sub_column(entry->path, std::move(flattend_column),
// std::move(flattend_type));
// }
// nested_object = make_nullable(nested_object->get_ptr())->assume_mutable();
// auto array =
// make_nullable(ColumnArray::create(std::move(nested_object), std::move(offset)));
// container_variant.clear();
// container_variant.create_root(ColumnObject::NESTED_TYPE, array->assume_mutable());
// }

// TODO select v:b -> v.b / v.b.c but v.d maybe in v
// copy container variant to dst variant, todo avoid copy
Expand Down
15 changes: 10 additions & 5 deletions be/src/olap/rowset/segment_v2/segment_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2422,17 +2422,22 @@ Status SegmentIterator::_fill_missing_columns(vectorized::Block* block) {
auto cid = _schema->column_id(i);
const auto* column_desc = _schema->column(cid);
int64_t current_size = block->get_by_position(i).column->size();
size_t max_rows = 0;
for (const auto& entry : *block) {
max_rows = std::max(max_rows, entry.column->size());
}
if (column_desc->path() != nullptr && column_desc->path()->has_nested_part() &&
current_size < block->rows()) {
current_size < max_rows) {
// Find leaf node of the same nested parent which column size is greate than current_size
const auto* leaf = offsets.get_leaf_of_the_same_nested(
*column_desc->path(), [](const auto& node) { return node.data->size(); },
current_size);
if (!leaf) {
VLOG_DEBUG << "Not found any subcolumns column_desc: "
<< column_desc->path()->get_path() << ", current_size: " << current_size
<< ", block_rows: " << block->rows();
<< ", block_rows: " << max_rows;
block->get_by_position(i).column->assume_mutable()->insert_many_defaults(
block->rows() - current_size);
max_rows - current_size);
continue;
}
LOG(INFO) << "fuck";
Expand All @@ -2444,8 +2449,8 @@ Status SegmentIterator::_fill_missing_columns(vectorized::Block* block) {
->get_nested_type()
->create_column_const_with_default_value(nested_padding_size);
auto nested_new_offset = vectorized::ColumnArray::ColumnOffsets::create();
nested_new_offset->reserve(block->rows() - current_size);
for (size_t i = current_size; i < block->rows(); ++i) {
nested_new_offset->reserve(max_rows - current_size);
for (size_t i = current_size; i < max_rows; ++i) {
nested_new_offset->get_data().push_back_without_reserve(
(*offset)[i] - (*offset)[current_size - 1]);
}
Expand Down

0 comments on commit 5d2619b

Please sign in to comment.