| 292 | } |
| 293 | |
| 294 | IGNORE_DEPRECATED |
| 295 | [[deprecated]] |
| 296 | int ErasureCodeShec::_decode(const set<int> &want_to_read, |
| 297 | const map<int, bufferlist> &chunks, |
| 298 | map<int, bufferlist> *decoded) |
| 299 | { |
| 300 | vector<int> have; |
| 301 | |
| 302 | if (!decoded || !decoded->empty()){ |
| 303 | return -EINVAL; |
| 304 | } |
| 305 | if (!want_to_read.empty() && chunks.empty()) { |
| 306 | // i need to get the blocksize from the first element of chunks |
| 307 | return -1; |
| 308 | } |
| 309 | |
| 310 | have.reserve(chunks.size()); |
| 311 | for (map<int, bufferlist>::const_iterator i = chunks.begin(); |
| 312 | i != chunks.end(); |
| 313 | ++i) { |
| 314 | have.push_back(i->first); |
| 315 | } |
| 316 | if (includes( |
| 317 | have.begin(), have.end(), want_to_read.begin(), want_to_read.end())) { |
| 318 | for (set<int>::iterator i = want_to_read.begin(); |
| 319 | i != want_to_read.end(); |
| 320 | ++i) { |
| 321 | (*decoded)[*i] = chunks.find(*i)->second; |
| 322 | } |
| 323 | return 0; |
| 324 | } |
| 325 | unsigned int k = get_data_chunk_count(); |
| 326 | unsigned int m = get_chunk_count() - k; |
| 327 | unsigned blocksize = (*chunks.begin()).second.length(); |
| 328 | for (unsigned int i = 0; i < k + m; i++) { |
| 329 | if (chunks.find(i) == chunks.end()) { |
| 330 | bufferlist tmp; |
| 331 | bufferptr ptr(buffer::create_aligned(blocksize, SIMD_ALIGN)); |
| 332 | tmp.push_back(ptr); |
| 333 | tmp.claim_append((*decoded)[i]); |
| 334 | (*decoded)[i].swap(tmp); |
| 335 | } else { |
| 336 | (*decoded)[i] = chunks.find(i)->second; |
| 337 | (*decoded)[i].rebuild_aligned(SIMD_ALIGN); |
| 338 | } |
| 339 | } |
| 340 | return decode_chunks(want_to_read, chunks, decoded); |
| 341 | } |
| 342 | |
| 343 | [[deprecated]] |
| 344 | int ErasureCodeShec::decode_chunks(const set<int> &want_to_read, |