template<class ArrayT>
Definition at line 285 of file ReadRaw.h. References Endian(), Impala::Util::IOBuffer::GetPosition(), Impala::Util::IOBuffer::Gets(), ILOG_ERROR, ILOG_VAR, Impala::Util::IOBuffer::NativeTypeRead(), Impala::Util::IOBuffer::Read(), and Impala::Util::IOBuffer::SetPosition(). Referenced by ReadRawListVar(). 00286 { 00287 typedef typename ArrayT::StorType StorT; 00288 00289 ILOG_VAR(Impala.Core.Array.ReadRawListVar); 00290 String typeStr = Element::TypeString<StorT>(0); 00291 String formatStr = "version: 2, binary: %lld, type: " + typeStr + 00292 ", elemSize: %lld, nr: %lld"; 00293 00294 Int64 binary; 00295 Int64 elemSize; 00296 Int64 nrA; 00297 char buf[200]; 00298 Util::IOBuffer::PositionType startPos = buffer->GetPosition(); 00299 buffer->Gets(buf, 200); 00300 int res = sscanf(buf, formatStr.c_str(), &binary, &elemSize, &nrA); 00301 if ((res != 3) || (elemSize != ArrayT::ElemSize())) 00302 { 00303 ILOG_ERROR("Header is not compatible"); 00304 return; 00305 } 00306 if (binary) 00307 { 00308 buffer->SetPosition(startPos + 200); 00309 for (Int64 n=0 ; n<nrA ; n++) 00310 { 00311 Int64 width; 00312 Int64 height; 00313 buffer->Read(buf, 20); 00314 sscanf(buf, "%lld %lld ", &width, &height); 00315 size_t blockSize = width*height*elemSize; 00316 ArrayT* a = ArrayCreate<ArrayT>(width, height); 00317 StorT* dstPtr = a->CPB(0, 0); 00318 size_t nrRead = buffer->Read(dstPtr, sizeof(StorT) * blockSize); 00319 if (nrRead != sizeof(StorT) * blockSize) 00320 ILOG_ERROR("read " << nrRead << " bytes instead of " 00321 << sizeof(StorT) * blockSize); 00322 Endian(a, a); 00323 list.push_back(a); 00324 } 00325 } 00326 else 00327 { 00328 for (Int64 n=0 ; n<nrA ; n++) 00329 { 00330 Int64 width; 00331 Int64 height; 00332 buffer->NativeTypeRead(&width); 00333 buffer->NativeTypeRead(&height); 00334 Int64 blockSize = width*height*elemSize; 00335 ArrayT* a = ArrayCreate<ArrayT>(width, height); 00336 for(Int64 i=0 ; i<height ; i++) 00337 { 00338 StorT* dstPtr = a->CPB(0, i); 00339 for(Int64 j=0 ; j<width ; j++) 00340 { 00341 for (Int64 k=0 ; k<elemSize ; k++) 00342 { 00343 buffer->NativeTypeRead(dstPtr); 00344 dstPtr++; 00345 } 00346 } 00347 } 00348 list.push_back(a); 00349 } 00350 } 00351 }
Here is the call graph for this function:
|