Changeset 16897 for trunk/Mars/mcore
- Timestamp:
- 06/24/13 15:57:53 (11 years ago)
- Location:
- trunk/Mars/mcore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcore/checksum.h
r16670 r16897 47 47 48 48 49 bool add(const char *buf, size_t len )49 bool add(const char *buf, size_t len, bool big_endian = true) 50 50 { 51 51 // Avoid overflows in carry bits … … 73 73 uint32_t *hilo = reinterpret_cast<uint32_t*>(&buffer); 74 74 75 76 const uint16_t *end = sbuf + len/2; 77 78 if (big_endian) 79 addLoopSwapping(sbuf, end, hilo); 80 else 81 addLoop(sbuf, end, hilo); 82 /*const uint16_t *end = sbuf + len/2; 83 while (1) 84 { 85 if (sbuf==end) 86 break; 87 88 hilo[0] += ntohs(*sbuf++); 89 90 if (sbuf==end) 91 break; 92 93 hilo[1] += ntohs(*sbuf++); 94 }*/ 95 96 HandleCarryBits(); 97 98 return true; 99 } 100 101 void addLoopSwapping(const uint16_t *sbuf, const uint16_t *end, uint32_t* hilo) 102 { 75 103 /* 76 104 for (size_t i = 0; i < len/2; i++) … … 83 111 // This is about as twice as fast as the loop above 84 112 // ntohs is CPU optimized, i%2 doesn't need to be computed 85 const uint16_t *end = sbuf + len/2;86 113 while (1) 87 114 { … … 96 123 hilo[1] += ntohs(*sbuf++); 97 124 } 98 99 HandleCarryBits(); 100 101 return true; 102 } 103 104 bool add(const vector<char> &v) 105 { 106 return add(v.data(), v.size()); 125 } 126 127 void addLoop(const uint16_t *sbuf, const uint16_t *end, uint32_t* hilo) 128 { 129 while (1) 130 { 131 if (sbuf==end) 132 break; 133 134 hilo[0] += ntohs(*sbuf++); 135 136 if (sbuf==end) 137 break; 138 139 hilo[1] += ntohs(*sbuf++); 140 } 141 } 142 143 bool add(const vector<char> &v, bool big_endian = true) 144 { 145 return add(v.data(), v.size(), big_endian); 107 146 } 108 147 -
trunk/Mars/mcore/zfits.h
r16890 r16897 70 70 } 71 71 72 virtual bool IsFileOk() const 73 { 74 bool rawsum = true; 75 76 if (HasKey("RAWSUM")) 77 { 78 ostringstream str; 79 str << fRawsum.val(); 80 rawsum = (GetStr("RAWSUM") == str.str()); 81 } 82 83 return fits::IsFileOk() && rawsum; 84 }; 85 72 86 protected: 73 87 … … 130 144 131 145 if (fTable.is_compressed) 132 {133 for (auto it=fTable.sorted_cols.begin(); it!= fTable.sorted_cols.end(); it++)146 for (auto it=fTable.sorted_cols.begin(); it!= fTable.sorted_cols.end(); it++) 147 if (it->comp != kCompFACT) 134 148 { 135 149 if (it->comp == kCompFACT) … … 190 204 vector<size_t> fTileSize; ///< size in bytes of each compressed tile 191 205 vector<vector<size_t>> fTileOffsets; ///< offset from start of tile of a given compressed column 206 207 Checksum fRawsum; ///< Checksum of the uncompressed, raw data 192 208 193 209 // Get buffer space … … 270 286 //overrides fits.h method with empty one 271 287 //work is done in ReadBinaryRow because it requires volatile data from ReadBinaryRow 272 virtual void WriteRowToCopyFile(size_t ) 273 { 274 288 virtual void WriteRowToCopyFile(size_t row) 289 { 290 if (row == fRow+1) 291 fRawsum.add(fBufferRow, false); 275 292 } 276 293
Note:
See TracChangeset
for help on using the changeset viewer.