/src/rocksdb/db/blob/blob_fetcher.h
Line | Count | Source |
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 "rocksdb/options.h" |
9 | | #include "rocksdb/status.h" |
10 | | |
11 | | namespace ROCKSDB_NAMESPACE { |
12 | | |
13 | | class BlobFileCache; |
14 | | class Version; |
15 | | class Slice; |
16 | | class FilePrefetchBuffer; |
17 | | class PinnableSlice; |
18 | | class BlobIndex; |
19 | | |
20 | | // A thin wrapper around blob retrieval. By default it reads through Version, |
21 | | // and it can optionally fall back to direct-write blob files that are not yet |
22 | | // manifest-visible. |
23 | | class BlobFetcher { |
24 | | public: |
25 | | BlobFetcher(const Version* version, const ReadOptions& read_options, |
26 | | BlobFileCache* blob_file_cache = nullptr, |
27 | | bool allow_write_path_fallback = false) |
28 | 18.5k | : version_(version), |
29 | 18.5k | read_options_(read_options), |
30 | 18.5k | blob_file_cache_(blob_file_cache), |
31 | 18.5k | allow_write_path_fallback_(allow_write_path_fallback) {} |
32 | | |
33 | | Status FetchBlob(const Slice& user_key, const Slice& blob_index_slice, |
34 | | FilePrefetchBuffer* prefetch_buffer, |
35 | | PinnableSlice* blob_value, uint64_t* bytes_read) const; |
36 | | |
37 | | Status FetchBlob(const Slice& user_key, const BlobIndex& blob_index, |
38 | | FilePrefetchBuffer* prefetch_buffer, |
39 | | PinnableSlice* blob_value, uint64_t* bytes_read) const; |
40 | | |
41 | | private: |
42 | | const Version* version_; |
43 | | ReadOptions read_options_; |
44 | | BlobFileCache* blob_file_cache_; |
45 | | bool allow_write_path_fallback_; |
46 | | }; |
47 | | } // namespace ROCKSDB_NAMESPACE |