diff --git a/db/db_test.cc b/db/db_test.cc index 6802e4a341..1db529c447 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -335,7 +335,7 @@ class DBTest { options.memtable_factory.reset(new UnsortedRepFactory); break; case kVectorRep: - options.memtable_factory.reset(new VectorRepFactory); + options.memtable_factory.reset(new VectorRepFactory(100)); break; case kUniversalCompaction: options.compaction_style = kCompactionStyleUniversal; diff --git a/include/rocksdb/memtablerep.h b/include/rocksdb/memtablerep.h index a2cb63f8f8..209249837d 100644 --- a/include/rocksdb/memtablerep.h +++ b/include/rocksdb/memtablerep.h @@ -152,7 +152,7 @@ class MemTableRepFactory { // Parameters: // count: Passed to the constructor of the underlying std::vector of each // VectorRep. On initialization, the underlying array will be at least count -// size. +// bytes reserved for usage. class VectorRepFactory : public MemTableRepFactory { const size_t count_; public: diff --git a/util/vectorrep.cc b/util/vectorrep.cc index 8770f60b98..744c9304c2 100644 --- a/util/vectorrep.cc +++ b/util/vectorrep.cc @@ -123,10 +123,10 @@ size_t VectorRep::ApproximateMemoryUsage() { } VectorRep::VectorRep(const KeyComparator& compare, Arena* arena, size_t count) - : bucket_(new Bucket(count)), + : bucket_(new Bucket()), immutable_(false), sorted_(false), - compare_(compare) { } + compare_(compare) { bucket_.get()->reserve(count); } VectorRep::Iterator::Iterator(class VectorRep* vrep, std::shared_ptr> bucket,