@@ -182,6 +182,8 @@ class CompressionFile : public VirtualReadOnlyFile {
182182 }
183183
184184 int build (const uint32_t *ibuf, size_t n, off_t offset_begin, uint32_t block_size) {
185+ partial_offset.clear ();
186+ deltas.clear ();
185187 group_size = (uinttype_max + 1 ) / block_size;
186188 partial_offset.reserve (n / group_size + 1 );
187189 deltas.reserve (n + 1 );
@@ -196,8 +198,8 @@ class CompressionFile : public VirtualReadOnlyFile {
196198 continue ;
197199 }
198200 if ((uint64_t )deltas[i - 1 ] + ibuf[i - 1 ] >= (uint64_t )uinttype_max) {
199- LOG_ERRNO_RETURN (ERANGE, -1 , " build block[`] length failed `+` > ` (exceed)" ,
200- deltas[i-1 ], ibuf[i-1 ], (uint64_t )uinttype_max);
201+ LOG_ERROR_RETURN (ERANGE, -1 , " build block[`] length failed `+` > ` (exceed)" ,
202+ i- 1 , deltas[i-1 ], ibuf[i-1 ], (uint64_t )uinttype_max);
201203 }
202204 deltas.push_back (deltas[i - 1 ] + ibuf[i - 1 ]);
203205 }
@@ -255,14 +257,16 @@ class CompressionFile : public VirtualReadOnlyFile {
255257 int reload (size_t idx) {
256258 auto read_size = get_blocks_length (idx, idx + 1 );
257259 auto begin_offset = m_zfile->m_jump_table [idx];
260+ LOG_WARN (" trim and reload. (idx: `, offset: `, len: `)" , idx, begin_offset, read_size);
258261 int trim_res = m_zfile->m_file ->trim (begin_offset, read_size);
259262 if (trim_res < 0 ) {
260- LOG_ERROR_RETURN (0 , -1 , " failed to trim block idx: `" , idx);
263+ LOG_ERRNO_RETURN (0 , -1 , " trim block failed. (idx: `, offset: `, len: `)" ,
264+ idx, begin_offset, read_size);
261265 }
262266 auto readn = m_zfile->m_file ->pread (m_buf + m_buf_offset, read_size, begin_offset);
263267 if (readn != (ssize_t )read_size) {
264- LOG_ERRNO_RETURN (0 , -1 , " read compressed blocks failed. (offset: `, len: `)" ,
265- begin_offset, read_size);
268+ LOG_ERRNO_RETURN (0 , -1 , " read compressed blocks failed. (idx: `, offset: `, len: `)" ,
269+ idx, begin_offset, read_size);
266270 }
267271 return 0 ;
268272 }
@@ -716,9 +720,12 @@ bool load_jump_table(IFile *file, CompressionFile::HeaderTrailer *pheader_traile
716720 if (ret < (ssize_t )index_bytes) {
717721 LOG_ERRNO_RETURN (0 , false , " failed to read index" );
718722 }
719- jump_table.build (ibuf.get (), pht->index_size ,
723+ ret = jump_table.build (ibuf.get (), pht->index_size ,
720724 CompressionFile::HeaderTrailer::SPACE + pht->opt .dict_size ,
721725 pht->opt .block_size );
726+ if (ret != 0 ) {
727+ LOG_ERRNO_RETURN (0 , false , " failed to build jump table" );
728+ }
722729 if (pheader_trailer)
723730 *pheader_trailer = *pht;
724731 return true ;
0 commit comments