mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-27 11:43:49 +00:00
e8cb32ed67
Summary: The patch adds blob file support to the `Get` API by extending `Version` so that whenever a blob reference is read from a file, the blob is retrieved from the corresponding blob file and passed back to the caller. (This is assuming the blob reference is valid and the blob file is actually part of the given `Version`.) It also introduces a cache of `BlobFileReader`s called `BlobFileCache` that enables sharing `BlobFileReader`s between callers. `BlobFileCache` uses the same backing cache as `TableCache`, so `max_open_files` (if specified) limits the total number of open (table + blob) files. TODO: proactively open/cache blob files and pin the cache handles of the readers in the metadata objects similarly to what `VersionBuilder::LoadTableHandlers` does for table files. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7540 Test Plan: `make check` Reviewed By: riversand963 Differential Revision: D24260219 Pulled By: ltamasi fbshipit-source-id: a8a2a4f11d3d04d6082201b52184bc4d7b0857ba
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
// 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;
|
|
struct ImmutableCFOptions;
|
|
struct FileOptions;
|
|
class HistogramImpl;
|
|
class Status;
|
|
class BlobFileReader;
|
|
class Slice;
|
|
|
|
class BlobFileCache {
|
|
public:
|
|
BlobFileCache(Cache* cache, const ImmutableCFOptions* immutable_cf_options,
|
|
const FileOptions* file_options, uint32_t column_family_id,
|
|
HistogramImpl* blob_file_read_hist);
|
|
|
|
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_;
|
|
const ImmutableCFOptions* immutable_cf_options_;
|
|
const FileOptions* file_options_;
|
|
uint32_t column_family_id_;
|
|
HistogramImpl* blob_file_read_hist_;
|
|
|
|
static constexpr size_t kNumberOfMutexStripes = 1 << 7;
|
|
};
|
|
|
|
} // namespace ROCKSDB_NAMESPACE
|