Repository: ClickHouse/ClickHouse
File: src/Storages/StorageMergeTreeTextIndex.cpp (C++)

Code before:
                    continue;

                auto sparse_file_name = *actual_sparse_index_name + extension;
                auto idx_file = storage.readFile(sparse_file_name, read_settings, storage.getFileSize(sparse_file_name));

                CompressedReadBufferFromFile idx_buf(std::move(idx_file));
                sparse_index = TextIndexSerialization::deserializeSparseIndex(idx_buf);

                if (sparse_index.empty())
                    continue;

                computeMatchingBlocks();
                if (matching_blocks.empty())
                    continue;
            }

            auto [stream_name, extension] = index_streams.at(MergeTreeIndexSubstream::Type::TextIndexDictionary);

            /// Skip part if index is not materialized in the part.
            /// Check for both original and hashed filenames (hashed if the index name is too long).
            auto actual_dict_name = IMergeTreeDataPart::getStreamNameOrHash(stream_name, extension, part->checksums);
            if (!actual_dict_name)
                continue;

            auto dict_file_name = *actual_dict_name + extension;
            auto dict_file = storage.readFile(dict_file_name, read_settings, storage.getFileSize(dict_file_name));

            dictionary_buf = std::make_unique<CompressedReadBufferFromFile>(std::move(dict_file));
            current_part_name = part->name;
            return true;
        }
    }

    /// Use the KeyCondition against the sparse index to find which dictionary blocks match.
    void computeMatchingBlocks()
    {
        size_t num_blocks = sparse_index.size();
        auto string_type = std::make_shared<DataTypeString>();
        DataTypes key_types = {string_type};

        /// FieldRef can reference a column cell by pointer, avoiding string copies.
        ColumnsWithTypeAndName ref_columns = {{sparse_index.tokens, string_type, "token"}};

        for (size_t i = 0; i < num_blocks; ++i)
        {
            FieldRef left_ref(&ref_columns, i, 0);

            Range token_range = (i + 1 < num_blocks)
                ? Range(left_ref, true, FieldRef(&ref_columns, i + 1, 0), false)
                : Range::createLeftBounded(left_ref, true);


Review comment (suggestion):
```suggestion
            auto dict_file = storage.readFile(dict_file_name, read_settings, part->checksums.files.at(dict_file_name).file_size);
```

Code after:
                    continue;

                auto sparse_file_name = *actual_sparse_index_name + extension;
                auto idx_file = storage.readFile(sparse_file_name, read_settings, part->checksums.files.at(sparse_file_name).file_size);

                CompressedReadBufferFromFile idx_buf(std::move(idx_file));
                sparse_index = TextIndexSerialization::deserializeSparseIndex(idx_buf);

                if (sparse_index.empty())
                    continue;

                computeMatchingBlocks();
                if (matching_blocks.empty())
                    continue;
            }

            auto [stream_name, extension] = index_streams.at(MergeTreeIndexSubstream::Type::TextIndexDictionary);

            /// Skip part if index is not materialized in the part.
            /// Check for both original and hashed filenames (hashed if the index name is too long).
            auto actual_dict_name = IMergeTreeDataPart::getStreamNameOrHash(stream_name, extension, part->checksums);
            if (!actual_dict_name)
                continue;

            auto dict_file_name = *actual_dict_name + extension;
            auto dict_file = storage.readFile(dict_file_name, read_settings, part->checksums.files.at(dict_file_name).file_size);

            dictionary_buf = std::make_unique<CompressedReadBufferFromFile>(std::move(dict_file));
            current_part_name = part->name;
            return true;
        }
    }

    /// Use the KeyCondition against the sparse index to find which dictionary blocks match.
    void computeMatchingBlocks()
    {
        size_t num_blocks = sparse_index.size();
        auto string_type = std::make_shared<DataTypeString>();
        DataTypes key_types = {string_type};

        /// FieldRef can reference a column cell by pointer, avoiding string copies.
        ColumnsWithTypeAndName ref_columns = {{sparse_index.tokens, string_type, "token"}};

        for (size_t i = 0; i < num_blocks; ++i)
        {
            FieldRef left_ref(&ref_columns, i, 0);

            Range token_range = (i + 1 < num_blocks)
                ? Range(left_ref, true, FieldRef(&ref_columns, i + 1, 0), false)
                : Range::createLeftBounded(left_ref, true);