-----
| 358 | |
| 359 | //----- |
| 360 | cVector * cDataReader::getFrame(long vIdx, int special, int privateVec, int *result) |
| 361 | { |
| 362 | // XXX : get multiple frames, concat them |
| 363 | // PROBLEM::: only return success, if all frames were read successfully |
| 364 | // if not all frames were read successfully, UNDO changes to write/read counters!! |
| 365 | // THUS::=> use a checkRead() function to see if data is available!! |
| 366 | long i; |
| 367 | int r = 1; |
| 368 | cVector *VV = NULL; |
| 369 | if (!privateVec) |
| 370 | VV = V_; |
| 371 | if (result != NULL) |
| 372 | *result = 0; |
| 373 | |
| 374 | if (nLevels > 1) { |
| 375 | for (i = 0; i < nLevels; i++) { |
| 376 | int myResult = 0; |
| 377 | r &= dm->checkRead(level[i],vIdx,special,rdId[i], 1, &myResult); |
| 378 | if (result != NULL) |
| 379 | *result |= myResult; |
| 380 | } |
| 381 | if (r) { |
| 382 | if (VV == NULL) { |
| 383 | VV = new cVector(myLcfg->N); |
| 384 | } |
| 385 | int fmetaUpdate = 0; |
| 386 | if (myfmeta == NULL) { |
| 387 | fmetaUpdate = 1; |
| 388 | myfmeta = new FrameMetaInfo(); |
| 389 | if (myfmeta == NULL) OUT_OF_MEMORY; |
| 390 | myfmeta->N = myLcfg->Nf; // assign number of fields (total) |
| 391 | myfmeta->field = (FieldMetaInfo *)calloc(1,sizeof(FieldMetaInfo)*(myLcfg->Nf)); |
| 392 | myLcfg->fmeta = myfmeta; |
| 393 | } |
| 394 | long e = 0; |
| 395 | long f = 0; |
| 396 | for (i = 0; i < nLevels; i++) { |
| 397 | int myResult = 0; |
| 398 | cVector *f2 = dm->getFrame(level[i],vIdx, special, rdId[i], &myResult); |
| 399 | if (result != NULL) |
| 400 | *result |= myResult; |
| 401 | if (f2 != NULL) { |
| 402 | // copy data from f2 into V at the correct position |
| 403 | memcpy(VV->data + e, f2->data, f2->N*sizeof(FLOAT_DMEM)); |
| 404 | // for (n=0; n<f2->N; n++) |
| 405 | // V->data[e++] = f2->data[n]; |
| 406 | e += f2->N; |
| 407 | if (i == 0) |
| 408 | VV->copyTimeMeta(f2->tmeta); // TODO: change this for asynchronous levels... |
| 409 | |
| 410 | // concat fmeta data across levels |
| 411 | if (fmetaUpdate) { |
| 412 | int j; |
| 413 | for (j=0; j<f2->fmeta->N; j++) { |
| 414 | // now copy each field from corresponding frame |
| 415 | myfmeta->field[f++].copyFrom(f2->fmeta->field+j); |
| 416 | } |
| 417 | //f += f2->fmeta->N; |
no test coverage detected