424a524ac9
Summary: Implement a mem table, in which keys are hashed based on prefixes. In each bucket, entries are organized in a sorted linked list. It has the same thread safety guarantee as skip list. The motivation is to optimize memory usage for the case that prefix hashing is primary way of seeking to the entry. Compared to hash skip list implementation, this implementation is more memory efficient, but inside each bucket, search is always linear. The target scenario is that there are only very limited number of records in each hash bucket. Test Plan: Add a test case in db_test Reviewers: haobo, kailiu, dhruba Reviewed By: haobo CC: igor, nkg-, leveldb Differential Revision: https://reviews.facebook.net/D14979
40 lines
1.2 KiB
C++
40 lines
1.2 KiB
C++
// Copyright (c) 2013, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under the BSD-style license found in the
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
#pragma once
|
|
#include "rocksdb/slice_transform.h"
|
|
#include "rocksdb/memtablerep.h"
|
|
|
|
namespace rocksdb {
|
|
|
|
class HashLinkListRepFactory : public MemTableRepFactory {
|
|
public:
|
|
explicit HashLinkListRepFactory(
|
|
const SliceTransform* transform,
|
|
size_t bucket_count)
|
|
: transform_(transform),
|
|
bucket_count_(bucket_count) { }
|
|
|
|
virtual ~HashLinkListRepFactory() { delete transform_; }
|
|
|
|
virtual std::shared_ptr<MemTableRep> CreateMemTableRep(
|
|
MemTableRep::KeyComparator& compare, Arena* arena) override;
|
|
|
|
virtual const char* Name() const override {
|
|
return "HashLinkListRepFactory";
|
|
}
|
|
|
|
const SliceTransform* GetTransform() { return transform_; }
|
|
|
|
private:
|
|
const SliceTransform* transform_;
|
|
const size_t bucket_count_;
|
|
};
|
|
|
|
}
|