From 54cada92b1426749aa11a6d55f1628508d6f3454 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Wed, 17 Sep 2014 15:08:19 -0700 Subject: [PATCH] Run make format on PR #249 --- table/block.cc | 3 +-- table/block.h | 4 +++- table/block_based_filter_block.cc | 8 +++---- table/block_based_table_builder.cc | 2 +- table/block_based_table_reader.cc | 10 ++++----- table/format.cc | 35 +++++++++++++++++++----------- table/format.h | 31 +++++++++++++------------- table/full_filter_block.cc | 9 ++++---- table/meta_blocks.cc | 12 ++++++---- 9 files changed, 62 insertions(+), 52 deletions(-) diff --git a/table/block.cc b/table/block.cc index 1a1accb2f..c3066cf5b 100644 --- a/table/block.cc +++ b/table/block.cc @@ -298,8 +298,7 @@ uint32_t Block::NumRestarts() const { } Block::Block(const BlockContents& contents) - : data_(contents.data.data()), - size_(contents.data.size()) { + : data_(contents.data.data()), size_(contents.data.size()) { if (size_ < sizeof(uint32_t)) { size_ = 0; // Error marker } else { diff --git a/table/block.h b/table/block.h index 21dacc395..b86b615bc 100644 --- a/table/block.h +++ b/table/block.h @@ -39,7 +39,9 @@ class Block { const char* data() const { return data_; } bool cachable() const { return contents_.cachable; } uint32_t NumRestarts() const; - CompressionType compression_type() const { return contents_.compression_type; } + CompressionType compression_type() const { + return contents_.compression_type; + } // If hash index lookup is enabled and `use_hash_index` is true. This block // will do hash lookup for the key prefix. diff --git a/table/block_based_filter_block.cc b/table/block_based_filter_block.cc index bed605a68..05d5beb88 100644 --- a/table/block_based_filter_block.cc +++ b/table/block_based_filter_block.cc @@ -137,8 +137,7 @@ void BlockBasedFilterBlockBuilder::GenerateFilter() { BlockBasedFilterBlockReader::BlockBasedFilterBlockReader( const SliceTransform* prefix_extractor, - const BlockBasedTableOptions& table_opt, - const Slice& contents) + const BlockBasedTableOptions& table_opt, const Slice& contents) : policy_(table_opt.filter_policy.get()), prefix_extractor_(prefix_extractor), whole_key_filtering_(table_opt.whole_key_filtering), @@ -159,9 +158,8 @@ BlockBasedFilterBlockReader::BlockBasedFilterBlockReader( BlockBasedFilterBlockReader::BlockBasedFilterBlockReader( const SliceTransform* prefix_extractor, - const BlockBasedTableOptions& table_opt, - BlockContents &&contents) - : BlockBasedFilterBlockReader (prefix_extractor, table_opt, contents.data) { + const BlockBasedTableOptions& table_opt, BlockContents&& contents) + : BlockBasedFilterBlockReader(prefix_extractor, table_opt, contents.data) { contents_ = std::move(contents); } diff --git a/table/block_based_table_builder.cc b/table/block_based_table_builder.cc index eb32e9942..2f373fff1 100644 --- a/table/block_based_table_builder.cc +++ b/table/block_based_table_builder.cc @@ -635,7 +635,7 @@ Status BlockBasedTableBuilder::InsertBlockInCache(const Slice& block_contents, Cache::Handle* cache_handle = nullptr; size_t size = block_contents.size(); - std::unique_ptr ubuf(new char[size+1]); + std::unique_ptr ubuf(new char[size + 1]); memcpy(ubuf.get(), block_contents.data(), size); ubuf[size] = type; diff --git a/table/block_based_table_reader.cc b/table/block_based_table_reader.cc index 1b41085af..2e883632f 100644 --- a/table/block_based_table_reader.cc +++ b/table/block_based_table_reader.cc @@ -298,8 +298,7 @@ class HashIndexReader : public IndexReader { private: HashIndexReader(const Comparator* comparator, Block* index_block) - : IndexReader(comparator), - index_block_(index_block) { + : IndexReader(comparator), index_block_(index_block) { assert(index_block_ != nullptr); } @@ -746,15 +745,16 @@ FilterBlockReader* BlockBasedTable::ReadFilter( assert(rep->filter_policy); if (kFilterBlockPrefix == filter_block_prefix) { - return new BlockBasedFilterBlockReader(rep->ioptions.prefix_extractor, - rep->table_options, std::move(block)); + return new BlockBasedFilterBlockReader( + rep->ioptions.prefix_extractor, rep->table_options, std::move(block)); } else if (kFullFilterBlockPrefix == filter_block_prefix) { auto filter_bits_reader = rep->filter_policy-> GetFilterBitsReader(block.data); if (filter_bits_reader != nullptr) { return new FullFilterBlockReader(rep->ioptions.prefix_extractor, - rep->table_options, std::move(block), filter_bits_reader); + rep->table_options, std::move(block), + filter_bits_reader); } } return nullptr; diff --git a/table/format.cc b/table/format.cc index 255e1e834..db11f9d4a 100644 --- a/table/format.cc +++ b/table/format.cc @@ -257,19 +257,20 @@ Status ReadBlock(RandomAccessFile* file, const Footer& footer, Status ReadBlockContents(RandomAccessFile* file, const Footer& footer, const ReadOptions& options, const BlockHandle& handle, - BlockContents *contents, Env* env, + BlockContents* contents, Env* env, bool decompression_requested) { Status status; Slice slice; size_t n = static_cast(handle.size()); std::unique_ptr heap_buf; char stack_buf[DefaultStackBufferSize]; - char *used_buf = nullptr; + char* used_buf = nullptr; rocksdb::CompressionType compression_type; - if (decompression_requested && n + kBlockTrailerSize < DefaultStackBufferSize) { - //If we've got a small enough hunk of data, read it in to the - //trivially allocated stack buffer instead of needing a full malloc() + if (decompression_requested && + n + kBlockTrailerSize < DefaultStackBufferSize) { + // If we've got a small enough hunk of data, read it in to the + // trivially allocated stack buffer instead of needing a full malloc() used_buf = &stack_buf[0]; } else { heap_buf = std::unique_ptr(new char[n + kBlockTrailerSize]); @@ -331,40 +332,48 @@ Status UncompressBlockContents(const char* data, size_t n, break; } case kZlibCompression: - ubuf = std::unique_ptr(port::Zlib_Uncompress(data, n, &decompress_size)); + ubuf = std::unique_ptr( + port::Zlib_Uncompress(data, n, &decompress_size)); static char zlib_corrupt_msg[] = "Zlib not supported or corrupted Zlib compressed block contents"; if (!ubuf) { return Status::Corruption(zlib_corrupt_msg); } - *contents = BlockContents(std::move(ubuf), decompress_size, true, kNoCompression); + *contents = + BlockContents(std::move(ubuf), decompress_size, true, kNoCompression); break; case kBZip2Compression: - ubuf = std::unique_ptr(port::BZip2_Uncompress(data, n, &decompress_size)); + ubuf = std::unique_ptr( + port::BZip2_Uncompress(data, n, &decompress_size)); static char bzip2_corrupt_msg[] = "Bzip2 not supported or corrupted Bzip2 compressed block contents"; if (!ubuf) { return Status::Corruption(bzip2_corrupt_msg); } - *contents = BlockContents(std::move(ubuf), decompress_size, true, kNoCompression); + *contents = + BlockContents(std::move(ubuf), decompress_size, true, kNoCompression); break; case kLZ4Compression: - ubuf = std::unique_ptr(port::LZ4_Uncompress(data, n, &decompress_size)); + ubuf = std::unique_ptr( + port::LZ4_Uncompress(data, n, &decompress_size)); static char lz4_corrupt_msg[] = "LZ4 not supported or corrupted LZ4 compressed block contents"; if (!ubuf) { return Status::Corruption(lz4_corrupt_msg); } - *contents = BlockContents(std::move(ubuf), decompress_size, true, kNoCompression); + *contents = + BlockContents(std::move(ubuf), decompress_size, true, kNoCompression); break; case kLZ4HCCompression: - ubuf = std::unique_ptr(port::LZ4_Uncompress(data, n, &decompress_size)); + ubuf = std::unique_ptr( + port::LZ4_Uncompress(data, n, &decompress_size)); static char lz4hc_corrupt_msg[] = "LZ4HC not supported or corrupted LZ4HC compressed block contents"; if (!ubuf) { return Status::Corruption(lz4hc_corrupt_msg); } - *contents = BlockContents(std::move(ubuf), decompress_size, true, kNoCompression); + *contents = + BlockContents(std::move(ubuf), decompress_size, true, kNoCompression); break; default: return Status::Corruption("bad block type"); diff --git a/table/format.h b/table/format.h index 9f5d6ce89..986164d81 100644 --- a/table/format.h +++ b/table/format.h @@ -163,28 +163,27 @@ struct BlockContents { CompressionType compression_type; std::unique_ptr allocation; - BlockContents() - : cachable(false), - compression_type(kNoCompression) {} - - BlockContents(const Slice &_data, bool _cachable, CompressionType _compression_type) - : data(_data), - cachable(_cachable), - compression_type(_compression_type) {} - - BlockContents(std::unique_ptr &&_data, size_t _size, bool _cachable, CompressionType _compression_type) - : data(_data.get(), _size), - cachable(_cachable), - compression_type(_compression_type), - allocation(std::move(_data)) {} + BlockContents() : cachable(false), compression_type(kNoCompression) {} + + BlockContents(const Slice& _data, bool _cachable, + CompressionType _compression_type) + : data(_data), cachable(_cachable), compression_type(_compression_type) {} + + BlockContents(std::unique_ptr&& _data, size_t _size, bool _cachable, + CompressionType _compression_type) + : data(_data.get(), _size), + cachable(_cachable), + compression_type(_compression_type), + allocation(std::move(_data)) {} }; // Read the block identified by "handle" from "file". On failure // return non-OK. On success fill *result and return OK. extern Status ReadBlockContents(RandomAccessFile* file, const Footer& footer, const ReadOptions& options, - const BlockHandle& handle, BlockContents* contents, - Env* env, bool do_uncompress); + const BlockHandle& handle, + BlockContents* contents, Env* env, + bool do_uncompress); // The 'data' points to the raw block contents read in from file. // This method allocates a new heap buffer and the raw block diff --git a/table/full_filter_block.cc b/table/full_filter_block.cc index b0efef39a..4113ec57a 100644 --- a/table/full_filter_block.cc +++ b/table/full_filter_block.cc @@ -54,8 +54,7 @@ Slice FullFilterBlockBuilder::Finish() { FullFilterBlockReader::FullFilterBlockReader( const SliceTransform* prefix_extractor, - const BlockBasedTableOptions& table_opt, - const Slice& contents, + const BlockBasedTableOptions& table_opt, const Slice& contents, FilterBitsReader* filter_bits_reader) : prefix_extractor_(prefix_extractor), whole_key_filtering_(table_opt.whole_key_filtering), @@ -66,10 +65,10 @@ FullFilterBlockReader::FullFilterBlockReader( FullFilterBlockReader::FullFilterBlockReader( const SliceTransform* prefix_extractor, - const BlockBasedTableOptions& table_opt, - BlockContents&& contents, + const BlockBasedTableOptions& table_opt, BlockContents&& contents, FilterBitsReader* filter_bits_reader) - : FullFilterBlockReader(prefix_extractor, table_opt, contents.data, filter_bits_reader) { + : FullFilterBlockReader(prefix_extractor, table_opt, contents.data, + filter_bits_reader) { block_contents_ = std::move(contents); } diff --git a/table/meta_blocks.cc b/table/meta_blocks.cc index ebbe0f5a5..5aabffcb0 100644 --- a/table/meta_blocks.cc +++ b/table/meta_blocks.cc @@ -229,8 +229,8 @@ Status ReadTableProperties(RandomAccessFile* file, uint64_t file_size, BlockContents metaindex_contents; ReadOptions read_options; read_options.verify_checksums = false; - s = ReadBlockContents(file, footer, read_options, metaindex_handle, &metaindex_contents, - env, false); + s = ReadBlockContents(file, footer, read_options, metaindex_handle, + &metaindex_contents, env, false); if (!s.ok()) { return s; } @@ -303,7 +303,9 @@ Status ReadMetaBlock(RandomAccessFile* file, uint64_t file_size, Status status; Footer footer(table_magic_number); status = ReadFooterFromFile(file, file_size, &footer); - if (!status.ok()) return status; + if (!status.ok()) { + return status; + } // Reading metaindex block auto metaindex_handle = footer.metaindex_handle(); @@ -312,7 +314,9 @@ Status ReadMetaBlock(RandomAccessFile* file, uint64_t file_size, read_options.verify_checksums = false; status = ReadBlockContents(file, footer, read_options, metaindex_handle, &metaindex_contents, env, false); - if (!status.ok()) return status; + if (!status.ok()) { + return status; + } // Finding metablock Block metaindex_block(std::move(metaindex_contents));