Fix memory issue introduced by 2f1a3a4d74

Summary: Closes https://github.com/facebook/rocksdb/pull/3256

Differential Revision: D6541714

Pulled By: siying

fbshipit-source-id: 40efd89b68587a9d58cfe6f4eebd771c2d9f1542
main
Siying Dong 7 years ago committed by Facebook Github Bot
parent bb5ed4b1d1
commit a9c8d4ef15
  1. 22
      table/block_based_table_reader.cc

@ -410,12 +410,13 @@ class HashIndexReader : public IndexReader {
return Status::OK(); return Status::OK();
} }
Slice dummy_comp_dict;
// Read contents for the blocks // Read contents for the blocks
BlockContents prefixes_contents; BlockContents prefixes_contents;
BlockFetcher prefixes_block_fetcher( BlockFetcher prefixes_block_fetcher(
file, prefetch_buffer, footer, ReadOptions(), prefixes_handle, file, prefetch_buffer, footer, ReadOptions(), prefixes_handle,
&prefixes_contents, ioptions, true /* decompress */, &prefixes_contents, ioptions, true /* decompress */,
Slice() /*compression dict*/, cache_options); dummy_comp_dict /*compression dict*/, cache_options);
s = prefixes_block_fetcher.ReadBlockContents(); s = prefixes_block_fetcher.ReadBlockContents();
if (!s.ok()) { if (!s.ok()) {
return s; return s;
@ -424,7 +425,7 @@ class HashIndexReader : public IndexReader {
BlockFetcher prefixes_meta_block_fetcher( BlockFetcher prefixes_meta_block_fetcher(
file, prefetch_buffer, footer, ReadOptions(), prefixes_meta_handle, file, prefetch_buffer, footer, ReadOptions(), prefixes_meta_handle,
&prefixes_meta_contents, ioptions, true /* decompress */, &prefixes_meta_contents, ioptions, true /* decompress */,
Slice() /*compression dict*/, cache_options); dummy_comp_dict /*compression dict*/, cache_options);
prefixes_meta_block_fetcher.ReadBlockContents(); prefixes_meta_block_fetcher.ReadBlockContents();
if (!s.ok()) { if (!s.ok()) {
// TODO: log error // TODO: log error
@ -1143,10 +1144,12 @@ FilterBlockReader* BlockBasedTable::ReadFilter(
} }
BlockContents block; BlockContents block;
BlockFetcher block_fetcher( Slice dummy_comp_dict;
rep->file.get(), prefetch_buffer, rep->footer, ReadOptions(),
filter_handle, &block, rep->ioptions, false /* decompress */, BlockFetcher block_fetcher(rep->file.get(), prefetch_buffer, rep->footer,
Slice() /*compression dict*/, rep->persistent_cache_options); ReadOptions(), filter_handle, &block,
rep->ioptions, false /* decompress */,
dummy_comp_dict, rep->persistent_cache_options);
Status s = block_fetcher.ReadBlockContents(); Status s = block_fetcher.ReadBlockContents();
if (!s.ok()) { if (!s.ok()) {
@ -1913,10 +1916,11 @@ Status BlockBasedTable::VerifyChecksumInBlocks(InternalIterator* index_iter) {
break; break;
} }
BlockContents contents; BlockContents contents;
Slice dummy_comp_dict;
BlockFetcher block_fetcher(rep_->file.get(), nullptr /* prefetch buffer */, BlockFetcher block_fetcher(rep_->file.get(), nullptr /* prefetch buffer */,
rep_->footer, ReadOptions(), handle, &contents, rep_->footer, ReadOptions(), handle, &contents,
rep_->ioptions, false /* decompress */, rep_->ioptions, false /* decompress */,
Slice() /*compression dict*/, dummy_comp_dict /*compression dict*/,
rep_->persistent_cache_options); rep_->persistent_cache_options);
s = block_fetcher.ReadBlockContents(); s = block_fetcher.ReadBlockContents();
if (!s.ok()) { if (!s.ok()) {
@ -2203,10 +2207,12 @@ Status BlockBasedTable::DumpTable(WritableFile* out_file) {
BlockHandle handle; BlockHandle handle;
if (FindMetaBlock(meta_iter.get(), filter_block_key, &handle).ok()) { if (FindMetaBlock(meta_iter.get(), filter_block_key, &handle).ok()) {
BlockContents block; BlockContents block;
Slice dummy_comp_dict;
BlockFetcher block_fetcher( BlockFetcher block_fetcher(
rep_->file.get(), nullptr /* prefetch_buffer */, rep_->footer, rep_->file.get(), nullptr /* prefetch_buffer */, rep_->footer,
ReadOptions(), handle, &block, rep_->ioptions, false /*decompress*/, ReadOptions(), handle, &block, rep_->ioptions, false /*decompress*/,
Slice() /*compression dict*/, rep_->persistent_cache_options); dummy_comp_dict /*compression dict*/,
rep_->persistent_cache_options);
s = block_fetcher.ReadBlockContents(); s = block_fetcher.ReadBlockContents();
if (!s.ok()) { if (!s.ok()) {
rep_->filter.reset(new BlockBasedFilterBlockReader( rep_->filter.reset(new BlockBasedFilterBlockReader(

Loading…
Cancel
Save