Fix compile

Summary: gcc on our dev boxes is not happy about __attribute__((unused))

Test Plan: compiles now

Reviewers: sdong, ljin

Reviewed By: ljin

Subscribers: leveldb

Differential Revision: https://reviews.facebook.net/D22707
main
Igor Canadi 10 years ago
parent 990df99a61
commit 076bd01a29
  1. 4
      table/block_based_table_builder.cc
  2. 6
      table/block_builder.cc
  3. 3
      table/block_builder.h
  4. 5
      table/block_test.cc
  5. 8
      table/meta_blocks.cc
  6. 5
      table/table_test.cc

@ -116,7 +116,7 @@ class ShortenedIndexBuilder : public IndexBuilder {
public: public:
explicit ShortenedIndexBuilder(const Comparator* comparator) explicit ShortenedIndexBuilder(const Comparator* comparator)
: IndexBuilder(comparator), : IndexBuilder(comparator),
index_block_builder_(1 /* block_restart_interval == 1 */, comparator) {} index_block_builder_(1 /* block_restart_interval == 1 */) {}
virtual void AddIndexEntry(std::string* last_key_in_current_block, virtual void AddIndexEntry(std::string* last_key_in_current_block,
const Slice* first_key_in_next_block, const Slice* first_key_in_next_block,
@ -420,7 +420,7 @@ struct BlockBasedTableBuilder::Rep {
table_options(table_opt), table_options(table_opt),
internal_comparator(icomparator), internal_comparator(icomparator),
file(f), file(f),
data_block(table_options.block_restart_interval, &internal_comparator), data_block(table_options.block_restart_interval),
internal_prefix_transform(options.prefix_extractor.get()), internal_prefix_transform(options.prefix_extractor.get()),
index_builder(CreateIndexBuilder( index_builder(CreateIndexBuilder(
table_options.index_type, &internal_comparator, table_options.index_type, &internal_comparator,

@ -41,10 +41,8 @@
namespace rocksdb { namespace rocksdb {
BlockBuilder::BlockBuilder(int block_restart_interval, BlockBuilder::BlockBuilder(int block_restart_interval)
const Comparator* comparator)
: block_restart_interval_(block_restart_interval), : block_restart_interval_(block_restart_interval),
comparator_(comparator),
restarts_(), restarts_(),
counter_(0), counter_(0),
finished_(false) { finished_(false) {
@ -96,8 +94,6 @@ void BlockBuilder::Add(const Slice& key, const Slice& value) {
Slice last_key_piece(last_key_); Slice last_key_piece(last_key_);
assert(!finished_); assert(!finished_);
assert(counter_ <= block_restart_interval_); assert(counter_ <= block_restart_interval_);
assert(buffer_.empty() // No values yet?
|| comparator_->Compare(key, last_key_piece) > 0);
size_t shared = 0; size_t shared = 0;
if (counter_ < block_restart_interval_) { if (counter_ < block_restart_interval_) {
// See how much sharing to do with previous string // See how much sharing to do with previous string

@ -22,7 +22,7 @@ class BlockBuilder {
BlockBuilder(const BlockBuilder&) = delete; BlockBuilder(const BlockBuilder&) = delete;
void operator=(const BlockBuilder&) = delete; void operator=(const BlockBuilder&) = delete;
BlockBuilder(int block_restart_interval, const Comparator* comparator); explicit BlockBuilder(int block_restart_interval);
// Reset the contents as if the BlockBuilder was just constructed. // Reset the contents as if the BlockBuilder was just constructed.
void Reset(); void Reset();
@ -50,7 +50,6 @@ class BlockBuilder {
private: private:
const int block_restart_interval_; const int block_restart_interval_;
const Comparator* comparator_ __attribute__((unused)); // only used in assert
std::string buffer_; // Destination buffer std::string buffer_; // Destination buffer
std::vector<uint32_t> restarts_; // Restart points std::vector<uint32_t> restarts_; // Restart points

@ -76,7 +76,7 @@ TEST(BlockTest, SimpleTest) {
std::vector<std::string> keys; std::vector<std::string> keys;
std::vector<std::string> values; std::vector<std::string> values;
BlockBuilder builder(16, ic.get()); BlockBuilder builder(16);
int num_records = 100000; int num_records = 100000;
GenerateRandomKVs(&keys, &values, 0, num_records); GenerateRandomKVs(&keys, &values, 0, num_records);
@ -132,8 +132,7 @@ BlockContents GetBlockContents(std::unique_ptr<BlockBuilder> *builder,
const std::vector<std::string> &keys, const std::vector<std::string> &keys,
const std::vector<std::string> &values, const std::vector<std::string> &values,
const int prefix_group_size = 1) { const int prefix_group_size = 1) {
builder->reset( builder->reset(new BlockBuilder(1 /* restart interval */));
new BlockBuilder(1 /* restart interval */, BytewiseComparator()));
// Add only half of the keys // Add only half of the keys
for (size_t i = 0; i < keys.size(); ++i) { for (size_t i = 0; i < keys.size(); ++i) {

@ -16,9 +16,7 @@
namespace rocksdb { namespace rocksdb {
MetaIndexBuilder::MetaIndexBuilder() MetaIndexBuilder::MetaIndexBuilder()
: meta_index_block_( : meta_index_block_(new BlockBuilder(1 /* restart interval */)) {}
new BlockBuilder(1 /* restart interval */, BytewiseComparator())) {
}
void MetaIndexBuilder::Add(const std::string& key, void MetaIndexBuilder::Add(const std::string& key,
const BlockHandle& handle) { const BlockHandle& handle) {
@ -35,9 +33,7 @@ Slice MetaIndexBuilder::Finish() {
} }
PropertyBlockBuilder::PropertyBlockBuilder() PropertyBlockBuilder::PropertyBlockBuilder()
: properties_block_( : properties_block_(new BlockBuilder(1 /* restart interval */)) {}
new BlockBuilder(1 /* restart interval */, BytewiseComparator())) {
}
void PropertyBlockBuilder::Add(const std::string& name, void PropertyBlockBuilder::Add(const std::string& name,
const std::string& val) { const std::string& val) {

@ -244,8 +244,7 @@ class BlockConstructor: public Constructor {
const KVMap& data) { const KVMap& data) {
delete block_; delete block_;
block_ = nullptr; block_ = nullptr;
BlockBuilder builder(table_options.block_restart_interval, BlockBuilder builder(table_options.block_restart_interval);
&internal_comparator);
for (KVMap::const_iterator it = data.begin(); for (KVMap::const_iterator it = data.begin();
it != data.end(); it != data.end();
@ -1054,7 +1053,7 @@ TEST(BlockBasedTableTest, BasicBlockBasedTableProperties) {
ASSERT_EQ("", props.filter_policy_name); // no filter policy is used ASSERT_EQ("", props.filter_policy_name); // no filter policy is used
// Verify data size. // Verify data size.
BlockBuilder block_builder(1, options.comparator); BlockBuilder block_builder(1);
for (const auto& item : kvmap) { for (const auto& item : kvmap) {
block_builder.Add(item.first, item.second); block_builder.Add(item.first, item.second);
} }

Loading…
Cancel
Save