]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/memtable/memtable_allocator.h
bump version to 12.2.12-pve1
[ceph.git] / ceph / src / rocksdb / memtable / memtable_allocator.h
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under the BSD-style license found in the
3 // LICENSE file in the root directory of this source tree. An additional grant
4 // of patent rights can be found in the PATENTS file in the same directory.
5 //
6 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
7 // Use of this source code is governed by a BSD-style license that can be
8 // found in the LICENSE file. See the AUTHORS file for names of contributors.
9 //
10 // This is used by the MemTable to allocate write buffer memory. It connects
11 // to WriteBufferManager so we can track and enforce overall write buffer
12 // limits.
13
14 #pragma once
15
16 #include <atomic>
17 #include "rocksdb/write_buffer_manager.h"
18 #include "util/allocator.h"
19
20 namespace rocksdb {
21
22 class Logger;
23
24 class MemTableAllocator : public Allocator {
25 public:
26 explicit MemTableAllocator(Allocator* allocator,
27 WriteBufferManager* write_buffer_manager);
28 ~MemTableAllocator();
29
30 // Allocator interface
31 char* Allocate(size_t bytes) override;
32 char* AllocateAligned(size_t bytes, size_t huge_page_size = 0,
33 Logger* logger = nullptr) override;
34 size_t BlockSize() const override;
35
36 // Call when we're finished allocating memory so we can free it from
37 // the write buffer's limit.
38 void DoneAllocating();
39
40 private:
41 Allocator* allocator_;
42 WriteBufferManager* write_buffer_manager_;
43 std::atomic<size_t> bytes_allocated_;
44
45 // No copying allowed
46 MemTableAllocator(const MemTableAllocator&);
47 void operator=(const MemTableAllocator&);
48 };
49
50 } // namespace rocksdb