| 197 | } |
| 198 | |
| 199 | static TDeque<TChunkRef> GatherAndSortChunks(const TQuantizedPool& pool) { |
| 200 | TDeque<TChunkRef> chunks; |
| 201 | for (const auto [columnIdx, localIdx] : pool.ColumnIndexToLocalIndex) { |
| 202 | for (const auto& description : pool.Chunks[localIdx]) { |
| 203 | chunks.push_back({&description, static_cast<ui32>(columnIdx), static_cast<ui32>(localIdx)}); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | const ui32 fakeIndices[] = { |
| 208 | pool.StringDocIdLocalIndex, |
| 209 | pool.StringGroupIdLocalIndex, |
| 210 | pool.StringSubgroupIdLocalIndex |
| 211 | }; |
| 212 | for (const auto fakeIdx : fakeIndices) { |
| 213 | if (fakeIdx == static_cast<ui32>(-1)) { |
| 214 | continue; |
| 215 | } |
| 216 | |
| 217 | for (const auto& description : pool.Chunks[fakeIdx]) { |
| 218 | chunks.push_back({&description, 0, fakeIdx}); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | // Sort chunks in ascending order based on the address of the chunks. We'll use it later to |
| 223 | // process chunks in the same order as if we were reading them from file one by one |
| 224 | // sequentially. |
| 225 | Sort( |
| 226 | chunks, |
| 227 | [](const auto lhs, const auto rhs) { |
| 228 | return lhs.Description->Chunk->Quants()->data() < rhs.Description->Chunk->Quants()->data(); |
| 229 | }); |
| 230 | |
| 231 | return chunks; |
| 232 | } |
| 233 | |
| 234 | template <typename T, typename U> |
| 235 | static void AssignUnaligned(const TConstArrayRef<ui8> unaligned, TVector<U>* dst) { |