summaryrefslogtreecommitdiff
path: root/table
diff options
context:
space:
mode:
authorChris Mumford <cmumford@google.com>2019-05-03 09:31:18 -0700
committerChris Mumford <cmumford@google.com>2019-05-03 09:48:57 -0700
commit9bd23c767601a2420478eec158927882b879bada (patch)
tree1b40c3712c8d882bab5d339a572e56527c145b56 /table
parentc784d63b931d07895833fb80185b10d44ad63cce (diff)
downloadleveldb-9bd23c767601a2420478eec158927882b879bada.tar.gz
Correct class/structure declaration order.
1. Correct the class/struct declaration order to be IAW the Google C++ style guide[1]. 2. For non-copyable classes, switched from non-implemented private methods to explicitly deleted[2] methods. 3. Minor const and member initialization fixes. [1] https://google.github.io/styleguide/cppguide.html#Declaration_Order [2] http://eel.is/c++draft/dcl.fct.def.delete PiperOrigin-RevId: 246521844
Diffstat (limited to 'table')
-rw-r--r--table/block.h11
-rw-r--r--table/block_builder.h7
-rw-r--r--table/filter_block.h7
-rw-r--r--table/format.h16
-rw-r--r--table/merger.cc6
-rw-r--r--table/table_builder.cc32
6 files changed, 38 insertions, 41 deletions
diff --git a/table/block.h b/table/block.h
index 3d4b03c..c8f1f7b 100644
--- a/table/block.h
+++ b/table/block.h
@@ -20,24 +20,23 @@ class Block {
// Initialize the block with the specified contents.
explicit Block(const BlockContents& contents);
+ Block(const Block&) = delete;
+ Block& operator=(const Block&) = delete;
+
~Block();
size_t size() const { return size_; }
Iterator* NewIterator(const Comparator* comparator);
private:
+ class Iter;
+
uint32_t NumRestarts() const;
const char* data_;
size_t size_;
uint32_t restart_offset_; // Offset in data_ of restart array
bool owned_; // Block owns data_[]
-
- // No copying allowed
- Block(const Block&);
- void operator=(const Block&);
-
- class Iter;
};
} // namespace leveldb
diff --git a/table/block_builder.h b/table/block_builder.h
index d0d9b6e..f91f5e6 100644
--- a/table/block_builder.h
+++ b/table/block_builder.h
@@ -19,6 +19,9 @@ class BlockBuilder {
public:
explicit BlockBuilder(const Options* options);
+ BlockBuilder(const BlockBuilder&) = delete;
+ BlockBuilder& operator=(const BlockBuilder&) = delete;
+
// Reset the contents as if the BlockBuilder was just constructed.
void Reset();
@@ -45,10 +48,6 @@ class BlockBuilder {
int counter_; // Number of entries emitted since restart
bool finished_; // Has Finish() been called?
std::string last_key_;
-
- // No copying allowed
- BlockBuilder(const BlockBuilder&);
- void operator=(const BlockBuilder&);
};
} // namespace leveldb
diff --git a/table/filter_block.h b/table/filter_block.h
index 1b034dc..73b5399 100644
--- a/table/filter_block.h
+++ b/table/filter_block.h
@@ -32,6 +32,9 @@ class FilterBlockBuilder {
public:
explicit FilterBlockBuilder(const FilterPolicy*);
+ FilterBlockBuilder(const FilterBlockBuilder&) = delete;
+ FilterBlockBuilder& operator=(const FilterBlockBuilder&) = delete;
+
void StartBlock(uint64_t block_offset);
void AddKey(const Slice& key);
Slice Finish();
@@ -45,10 +48,6 @@ class FilterBlockBuilder {
std::string result_; // Filter data computed so far
std::vector<Slice> tmp_keys_; // policy_->CreateFilter() argument
std::vector<uint32_t> filter_offsets_;
-
- // No copying allowed
- FilterBlockBuilder(const FilterBlockBuilder&);
- void operator=(const FilterBlockBuilder&);
};
class FilterBlockReader {
diff --git a/table/format.h b/table/format.h
index dacaa9f..2ad145c 100644
--- a/table/format.h
+++ b/table/format.h
@@ -23,6 +23,9 @@ struct ReadOptions;
// block or a meta block.
class BlockHandle {
public:
+ // Maximum encoding length of a BlockHandle
+ enum { kMaxEncodedLength = 10 + 10 };
+
BlockHandle();
// The offset of the block in the file.
@@ -36,9 +39,6 @@ class BlockHandle {
void EncodeTo(std::string* dst) const;
Status DecodeFrom(Slice* input);
- // Maximum encoding length of a BlockHandle
- enum { kMaxEncodedLength = 10 + 10 };
-
private:
uint64_t offset_;
uint64_t size_;
@@ -48,6 +48,11 @@ class BlockHandle {
// end of every table file.
class Footer {
public:
+ // Encoded length of a Footer. Note that the serialization of a
+ // Footer will always occupy exactly this many bytes. It consists
+ // of two block handles and a magic number.
+ enum { kEncodedLength = 2 * BlockHandle::kMaxEncodedLength + 8 };
+
Footer() {}
// The block handle for the metaindex block of the table
@@ -61,11 +66,6 @@ class Footer {
void EncodeTo(std::string* dst) const;
Status DecodeFrom(Slice* input);
- // Encoded length of a Footer. Note that the serialization of a
- // Footer will always occupy exactly this many bytes. It consists
- // of two block handles and a magic number.
- enum { kEncodedLength = 2 * BlockHandle::kMaxEncodedLength + 8 };
-
private:
BlockHandle metaindex_handle_;
BlockHandle index_handle_;
diff --git a/table/merger.cc b/table/merger.cc
index 3a5c3e4..1bbc6cf 100644
--- a/table/merger.cc
+++ b/table/merger.cc
@@ -129,6 +129,9 @@ class MergingIterator : public Iterator {
}
private:
+ // Which direction is the iterator moving?
+ enum Direction { kForward, kReverse };
+
void FindSmallest();
void FindLargest();
@@ -139,9 +142,6 @@ class MergingIterator : public Iterator {
IteratorWrapper* children_;
int n_;
IteratorWrapper* current_;
-
- // Which direction is the iterator moving?
- enum Direction { kForward, kReverse };
Direction direction_;
};
diff --git a/table/table_builder.cc b/table/table_builder.cc
index 9afff76..278febf 100644
--- a/table/table_builder.cc
+++ b/table/table_builder.cc
@@ -19,6 +19,22 @@
namespace leveldb {
struct TableBuilder::Rep {
+ Rep(const Options& opt, WritableFile* f)
+ : options(opt),
+ index_block_options(opt),
+ file(f),
+ offset(0),
+ data_block(&options),
+ index_block(&index_block_options),
+ num_entries(0),
+ closed(false),
+ filter_block(opt.filter_policy == nullptr
+ ? nullptr
+ : new FilterBlockBuilder(opt.filter_policy)),
+ pending_index_entry(false) {
+ index_block_options.block_restart_interval = 1;
+ }
+
Options options;
Options index_block_options;
WritableFile* file;
@@ -44,22 +60,6 @@ struct TableBuilder::Rep {
BlockHandle pending_handle; // Handle to add to index block
std::string compressed_output;
-
- Rep(const Options& opt, WritableFile* f)
- : options(opt),
- index_block_options(opt),
- file(f),
- offset(0),
- data_block(&options),
- index_block(&index_block_options),
- num_entries(0),
- closed(false),
- filter_block(opt.filter_policy == nullptr
- ? nullptr
- : new FilterBlockBuilder(opt.filter_policy)),
- pending_index_entry(false) {
- index_block_options.block_restart_interval = 1;
- }
};
TableBuilder::TableBuilder(const Options& options, WritableFile* file)