template<class ArrayT>
Definition at line 99 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(), Impala::Util::IOBuffer::ReadLine(), and Impala::Util::IOBuffer::SetPosition(). Referenced by ReadFile(), and ReadRaw(). 00100 { 00101 typedef typename ArrayT::StorType StorT; 00102 00103 ILOG_VAR(Impala.Core.Array.ReadRaw); 00104 String typeStr = Element::TypeString<StorT>(0); 00105 String formatStr = "version: 1, binary: %lld, type: " + typeStr + 00106 ", elemSize: %lld, width: %lld, height: %lld, nr: %lld"; 00107 00108 Int64 binary; 00109 Int64 elemSize; 00110 Int64 width; 00111 Int64 height; 00112 Int64 nrA; 00113 char buf[200]; 00114 for (int i=0 ; i<200 ; i++) 00115 buf[i] = 0; 00116 Util::IOBuffer::PositionType startPos = buffer->GetPosition(); 00117 buffer->Gets(buf, 200); 00118 int res = sscanf(buf, formatStr.c_str(), 00119 &binary, &elemSize, &width, &height, &nrA); 00120 if ((res != 5) || (elemSize != ArrayT::ElemSize()) || (nrA != 1)) 00121 { 00122 ILOG_ERROR("Header is not compatible: res==" << res << 00123 " (should be 5), elemSize==" << elemSize << " (should be " 00124 << ArrayT::ElemSize() << "), nrA==" << nrA << 00125 " (should be 1), buf==[" << buf << "]"); 00126 return; 00127 } 00128 size_t blockSize = width*height*elemSize; 00129 if (dst == 0) 00130 dst = ArrayCreate<ArrayT>(width, height); 00131 StorT* dstPtr = dst->CPB(0, 0); 00132 if (binary) 00133 { 00134 buffer->SetPosition(startPos + 200); 00135 for (Int64 n=0 ; n<nrA ; n++) 00136 { 00137 size_t nrRead = buffer->Read(dstPtr, sizeof(StorT) * blockSize); 00138 if (nrRead != sizeof(StorT) * blockSize) 00139 ILOG_ERROR("read " << nrRead << " bytes instead of " 00140 << sizeof(StorT) * blockSize); 00141 dstPtr += blockSize; 00142 } 00143 Endian(dst, dst); 00144 } 00145 else 00146 { 00147 for (Int64 n=0 ; n<nrA ; n++) 00148 { 00149 for(Int64 i=0 ; i<height ; i++) 00150 { 00151 for(Int64 j=0 ; j<width ; j++) 00152 { 00153 for (Int64 k=0 ; k<elemSize ; k++) 00154 { 00155 buffer->NativeTypeRead(dstPtr); 00156 dstPtr++; 00157 } 00158 } 00159 } 00160 } 00161 buffer->ReadLine(); 00162 } 00163 }
Here is the call graph for this function:
|