2020-10-15 20:02:44 +00:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cinttypes>
|
|
|
|
|
|
|
|
#include "cache/cache_helpers.h"
|
|
|
|
#include "rocksdb/rocksdb_namespace.h"
|
|
|
|
#include "util/mutexlock.h"
|
|
|
|
|
|
|
|
namespace ROCKSDB_NAMESPACE {
|
|
|
|
|
|
|
|
class Cache;
|
2021-05-05 20:59:21 +00:00
|
|
|
struct ImmutableOptions;
|
2020-10-15 20:02:44 +00:00
|
|
|
struct FileOptions;
|
|
|
|
class HistogramImpl;
|
|
|
|
class Status;
|
|
|
|
class BlobFileReader;
|
|
|
|
class Slice;
|
2021-02-16 17:47:12 +00:00
|
|
|
class IOTracer;
|
2020-10-15 20:02:44 +00:00
|
|
|
|
|
|
|
class BlobFileCache {
|
|
|
|
public:
|
2021-05-05 20:59:21 +00:00
|
|
|
BlobFileCache(Cache* cache, const ImmutableOptions* immutable_options,
|
2020-10-15 20:02:44 +00:00
|
|
|
const FileOptions* file_options, uint32_t column_family_id,
|
2021-02-16 17:47:12 +00:00
|
|
|
HistogramImpl* blob_file_read_hist,
|
|
|
|
const std::shared_ptr<IOTracer>& io_tracer);
|
2020-10-15 20:02:44 +00:00
|
|
|
|
|
|
|
BlobFileCache(const BlobFileCache&) = delete;
|
|
|
|
BlobFileCache& operator=(const BlobFileCache&) = delete;
|
|
|
|
|
|
|
|
Status GetBlobFileReader(uint64_t blob_file_number,
|
|
|
|
CacheHandleGuard<BlobFileReader>* blob_file_reader);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Cache* cache_;
|
|
|
|
// Note: mutex_ below is used to guard against multiple threads racing to open
|
|
|
|
// the same file.
|
|
|
|
Striped<port::Mutex, Slice> mutex_;
|
2021-06-16 23:50:43 +00:00
|
|
|
const ImmutableOptions* immutable_options_;
|
2020-10-15 20:02:44 +00:00
|
|
|
const FileOptions* file_options_;
|
|
|
|
uint32_t column_family_id_;
|
|
|
|
HistogramImpl* blob_file_read_hist_;
|
2021-02-16 17:47:12 +00:00
|
|
|
std::shared_ptr<IOTracer> io_tracer_;
|
2020-10-15 20:02:44 +00:00
|
|
|
|
|
|
|
static constexpr size_t kNumberOfMutexStripes = 1 << 7;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace ROCKSDB_NAMESPACE
|