]>
git.proxmox.com Git - ceph.git/blob - 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.
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.
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
17 #include "rocksdb/write_buffer_manager.h"
18 #include "util/allocator.h"
24 class MemTableAllocator
: public Allocator
{
26 explicit MemTableAllocator(Allocator
* allocator
,
27 WriteBufferManager
* write_buffer_manager
);
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
;
36 // Call when we're finished allocating memory so we can free it from
37 // the write buffer's limit.
38 void DoneAllocating();
41 Allocator
* allocator_
;
42 WriteBufferManager
* write_buffer_manager_
;
43 std::atomic
<size_t> bytes_allocated_
;
46 MemTableAllocator(const MemTableAllocator
&);
47 void operator=(const MemTableAllocator
&);
50 } // namespace rocksdb