template<class ArrayT>
Definition at line 23 of file WriteRaw.h. References Impala::Util::IOBuffer::cBzipBlockSize, Endian(), ILOG_ERROR, ILOG_VAR, Impala::Util::IOBuffer::Write(), Impala::Util::IOBuffer::WriteBzip(), and Impala::Util::IOBuffer::WriteZlib(). Referenced by WriteFile(), and WriteRaw(). 00024 { 00025 typedef typename ArrayT::StorType StorT; 00026 ILOG_VAR(Impala.Core.Array.WriteRaw); 00027 00028 if (mode == 0) 00029 { 00030 ILOG_ERROR("Non-binary write has been eliminated"); 00031 return; 00032 } 00033 00034 #ifndef BZIP2_USED 00035 if (mode == 2) 00036 mode = 1; 00037 #endif // BZIP2_USED 00038 #ifndef ZLIB_USED 00039 if (mode == 3) 00040 mode = 1; 00041 #endif //ZLIB_USED 00042 00043 String typeStr = Element::TypeString<StorT>(0); 00044 String formatStr; 00045 if (mode == 2) 00046 { 00047 formatStr = "version: 3, binary: 1, type: " + typeStr + 00048 ", elemSize: %lld, width: %lld, height: %lld, nr: %lld, bzip: %lld"; 00049 } 00050 else if (mode == 3) 00051 { 00052 formatStr = "version: 3, binary: 1, type: " + typeStr + 00053 ", elemSize: %lld, width: %lld, height: %lld, nr: %lld, zlib: %lld"; 00054 } 00055 else 00056 { 00057 formatStr = "version: 1, binary: 1, type: " + typeStr + 00058 ", elemSize: %lld, width: %lld, height: %lld, nr: %lld"; 00059 } 00060 00061 Int64 width = src->CW(); 00062 Int64 height = src->CH(); 00063 Int64 elemSize = ArrayT::ElemSize(); 00064 Int64 nrA = 1; 00065 Int64 lineSize = sizeof(StorT) * width * elemSize; 00066 Int64 bzipI = 0; 00067 if (mode > 1) 00068 { 00069 bzipI = Util::IOBuffer::cBzipBlockSize / lineSize; 00070 if (src->BW() != 0) 00071 bzipI = 1; 00072 } 00073 char buf[200]; 00074 memset(buf, 0, 200); 00075 if (mode > 1) 00076 sprintf(buf, formatStr.c_str(), elemSize, width, height, nrA, bzipI); 00077 else 00078 sprintf(buf, formatStr.c_str(), elemSize, width, height, nrA); 00079 buffer->Write(buf, 200); 00080 00081 Endian(src, src); 00082 if (bzipI > 0) 00083 { 00084 int y = 0; 00085 while (y < height) 00086 { 00087 int end = y + bzipI; 00088 if (end > height) 00089 end = height; 00090 int dY = end - y; 00091 StorT* srcPtr = src->CPB(0, y); 00092 size_t nrBytes = lineSize * dY; 00093 if (mode == 3) 00094 buffer->WriteZlib(srcPtr, nrBytes); 00095 else 00096 buffer->WriteBzip(srcPtr, nrBytes); 00097 y += dY; 00098 } 00099 } 00100 else 00101 { 00102 if (src->BW() == 0) 00103 { 00104 StorT* srcPtr = src->CPB(0, 0); 00105 size_t nrBytes = lineSize * height; 00106 buffer->Write(srcPtr, nrBytes); 00107 } 00108 else 00109 { 00110 for (Int64 y=0 ; y<height ; y++) 00111 { 00112 StorT* srcPtr = src->CPB(0, y); 00113 buffer->Write(srcPtr, lineSize); 00114 } 00115 } 00116 } 00117 }
Here is the call graph for this function:
|