]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/db/blob/blob_file_cache.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / rocksdb / db / blob / blob_file_cache.h
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
5
6 #pragma once
7
8 #include <cinttypes>
9
10 #include "cache/cache_helpers.h"
11 #include "rocksdb/rocksdb_namespace.h"
12 #include "util/mutexlock.h"
13
14 namespace ROCKSDB_NAMESPACE {
15
16 class Cache;
17 struct ImmutableCFOptions;
18 struct FileOptions;
19 class HistogramImpl;
20 class Status;
21 class BlobFileReader;
22 class Slice;
23
24 class BlobFileCache {
25 public:
26 BlobFileCache(Cache* cache, const ImmutableCFOptions* immutable_cf_options,
27 const FileOptions* file_options, uint32_t column_family_id,
28 HistogramImpl* blob_file_read_hist);
29
30 BlobFileCache(const BlobFileCache&) = delete;
31 BlobFileCache& operator=(const BlobFileCache&) = delete;
32
33 Status GetBlobFileReader(uint64_t blob_file_number,
34 CacheHandleGuard<BlobFileReader>* blob_file_reader);
35
36 private:
37 Cache* cache_;
38 // Note: mutex_ below is used to guard against multiple threads racing to open
39 // the same file.
40 Striped<port::Mutex, Slice> mutex_;
41 const ImmutableCFOptions* immutable_cf_options_;
42 const FileOptions* file_options_;
43 uint32_t column_family_id_;
44 HistogramImpl* blob_file_read_hist_;
45
46 static constexpr size_t kNumberOfMutexStripes = 1 << 7;
47 };
48
49 } // namespace ROCKSDB_NAMESPACE