| 62 | |
| 63 | protected: |
| 64 | Chunk generate() override |
| 65 | { |
| 66 | if (part_index >= data_parts.size()) |
| 67 | return {}; |
| 68 | |
| 69 | auto component_guard = Coordination::setCurrentComponent("MergeTreeIndexSource::generate"); |
| 70 | |
| 71 | const auto & part = data_parts[part_index]; |
| 72 | const auto & index_granularity = part->index_granularity; |
| 73 | |
| 74 | std::shared_ptr<MergeTreeMarksLoader> marks_loader; |
| 75 | if (with_marks && isCompactPart(part)) |
| 76 | { |
| 77 | marks_loader = createMarksLoader( |
| 78 | part, |
| 79 | MergeTreeDataPartCompact::DATA_FILE_NAME, |
| 80 | part->index_granularity_info.mark_type.with_substreams ? part->getColumnsSubstreams().getTotalSubstreams() |
| 81 | : part->getColumns().size()); |
| 82 | } |
| 83 | |
| 84 | size_t num_columns = header->columns(); |
| 85 | size_t num_rows = index_granularity->getMarksCount(); |
| 86 | |
| 87 | const auto & part_name_column = StorageMergeTreeIndex::part_name_column; |
| 88 | const auto & mark_number_column = StorageMergeTreeIndex::mark_number_column; |
| 89 | const auto & rows_in_granule_column = StorageMergeTreeIndex::rows_in_granule_column; |
| 90 | IMergeTreeDataPart::IndexPtr index_ptr; |
| 91 | |
| 92 | Columns result_columns(num_columns); |
| 93 | for (size_t pos = 0; pos < num_columns; ++pos) |
| 94 | { |
| 95 | const auto & column_name = header->getByPosition(pos).name; |
| 96 | const auto & column_type = header->getByPosition(pos).type; |
| 97 | |
| 98 | if (index_header->has(column_name)) |
| 99 | { |
| 100 | if (!index_ptr) |
| 101 | index_ptr = part->getIndex(); |
| 102 | |
| 103 | size_t index_position = index_header->getPositionByName(column_name); |
| 104 | |
| 105 | /// Some of the columns from suffix of primary index may be not loaded |
| 106 | /// according to setting 'primary_key_ratio_of_unique_prefix_values_to_skip_suffix_columns'. |
| 107 | if (index_position < index_ptr->size()) |
| 108 | { |
| 109 | result_columns[pos] = index_ptr->at(index_position); |
| 110 | } |
| 111 | else |
| 112 | { |
| 113 | auto index_column = column_type->createColumnConstWithDefaultValue(num_rows); |
| 114 | result_columns[pos] = index_column->convertToFullColumnIfConst(); |
| 115 | } |
| 116 | } |
| 117 | else if (minmax_header && minmax_header->has(column_name)) |
| 118 | { |
| 119 | FieldRef min_value(Null{}); |
| 120 | FieldRef max_value(Null{}); |
| 121 |
nothing calls this directly
no test coverage detected