diff --git a/include/rocksdb/memtablerep.h b/include/rocksdb/memtablerep.h index 4610e9f00..1c9567125 100644 --- a/include/rocksdb/memtablerep.h +++ b/include/rocksdb/memtablerep.h @@ -180,7 +180,8 @@ public: // over the entire collection is rare. // // Parameters: -// transform: The SliceTransform to bucket user keys on. +// transform: The SliceTransform to bucket user keys on. TransformRepFactory +// assumes it does not own the pointer. // bucket_count: Passed to the constructor of the underlying // std::unordered_map of each TransformRep. On initialization, the // underlying array will be at least bucket_count size. @@ -206,9 +207,13 @@ public: // // Parameters: See TransformRepFactory. class UnsortedRepFactory : public TransformRepFactory { + const SliceTransform* transform_; public: explicit UnsortedRepFactory(size_t bucket_count = 0, size_t num_locks = 1000) - : TransformRepFactory(NewNoopTransform(), bucket_count, num_locks) { } + : TransformRepFactory(transform_ = NewNoopTransform(), + bucket_count, + num_locks) { } + virtual ~UnsortedRepFactory() { delete transform_; } }; // PrefixHashReps bin user keys based on a fixed-size prefix. This optimizes for diff --git a/util/transformrep.cc b/util/transformrep.cc index 2020a71d6..9add0b7d5 100644 --- a/util/transformrep.cc +++ b/util/transformrep.cc @@ -149,7 +149,8 @@ class PrefixHashRep : public TransformRep { public: PrefixHashRep(const KeyComparator& compare, Arena* arena, const SliceTransform* transform, size_t bucket_size, - size_t num_locks) : TransformRep(compare, arena, transform, + size_t num_locks) + : TransformRep(compare, arena, transform, bucket_size, num_locks) { } virtual std::shared_ptr GetPrefixIterator(