| 231 | } |
| 232 | |
| 233 | void IndexForNativeFormat::read(ReadBuffer & istr, const NameSet & required_columns) |
| 234 | { |
| 235 | while (!istr.eof()) |
| 236 | { |
| 237 | blocks.emplace_back(); |
| 238 | IndexOfBlockForNativeFormat & block = blocks.back(); |
| 239 | |
| 240 | readVarUInt(block.num_columns, istr); |
| 241 | readVarUInt(block.num_rows, istr); |
| 242 | |
| 243 | if (block.num_columns < required_columns.size()) |
| 244 | throw Exception("Index contain less than required columns", ErrorCodes::INCORRECT_INDEX); |
| 245 | |
| 246 | for (size_t i = 0; i < block.num_columns; ++i) |
| 247 | { |
| 248 | IndexOfOneColumnForNativeFormat column_index; |
| 249 | |
| 250 | readBinary(column_index.name, istr); |
| 251 | readBinary(column_index.type, istr); |
| 252 | readBinary(column_index.location.offset_in_compressed_file, istr); |
| 253 | readBinary(column_index.location.offset_in_decompressed_block, istr); |
| 254 | |
| 255 | if (required_columns.count(column_index.name)) |
| 256 | block.columns.push_back(std::move(column_index)); |
| 257 | } |
| 258 | |
| 259 | if (block.columns.size() < required_columns.size()) |
| 260 | throw Exception("Index contain less than required columns", ErrorCodes::INCORRECT_INDEX); |
| 261 | if (block.columns.size() > required_columns.size()) |
| 262 | throw Exception("Index contain duplicate columns", ErrorCodes::INCORRECT_INDEX); |
| 263 | |
| 264 | block.num_columns = block.columns.size(); |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | } |
no test coverage detected