mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 23:38:50 +03:00
ae684f3993
Summary: This is fairly mechanical diff that finalizes split of Hash into ObjectId and Hash20. More specifically this diff does two things: * Replaces `Hash` with `Hash20` * Removes alias `using Hash = Hash20` Reviewed By: chadaustin Differential Revision: D31324202 fbshipit-source-id: 780b6d2a422ddf6d0f3cfc91e3e70ad10ebaa8b4
85 lines
2.6 KiB
C++
85 lines
2.6 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "eden/fs/store/BackingStore.h"
|
|
|
|
namespace facebook::eden {
|
|
|
|
class BackingStore;
|
|
class LocalStore;
|
|
class EdenStats;
|
|
|
|
/**
|
|
* Implementation of a BackingStore that caches the returned data from another
|
|
* BackingStore onto the LocalStore.
|
|
*
|
|
* Reads will first attempt to read from the LocalStore, and will only read
|
|
* from the underlying BackingStore if the data wasn't found in the LocalStore.
|
|
*
|
|
* This should be used for BackingStores that either do not have local caching
|
|
* builtin, or when reading from this cache is significantly slower than
|
|
* reading from the LocalStore.
|
|
*/
|
|
class LocalStoreCachedBackingStore : public BackingStore {
|
|
public:
|
|
LocalStoreCachedBackingStore(
|
|
std::shared_ptr<BackingStore> backingStore,
|
|
std::shared_ptr<LocalStore> localStore,
|
|
std::shared_ptr<EdenStats> stats);
|
|
|
|
folly::SemiFuture<std::unique_ptr<Tree>> getRootTree(
|
|
const RootId& rootId,
|
|
ObjectFetchContext& context) override;
|
|
|
|
folly::SemiFuture<std::unique_ptr<TreeEntry>> getTreeEntryForRootId(
|
|
const RootId& rootId,
|
|
TreeEntryType treeEntryType,
|
|
facebook::eden::PathComponentPiece pathComponentPiece,
|
|
ObjectFetchContext& context) override;
|
|
folly::SemiFuture<GetTreeRes> getTree(
|
|
const ObjectId& id,
|
|
ObjectFetchContext& context) override;
|
|
folly::SemiFuture<GetBlobRes> getBlob(
|
|
const ObjectId& id,
|
|
ObjectFetchContext& context) override;
|
|
|
|
FOLLY_NODISCARD folly::SemiFuture<folly::Unit> prefetchBlobs(
|
|
ObjectIdRange ids,
|
|
ObjectFetchContext& context) override;
|
|
|
|
void periodicManagementTask() override;
|
|
|
|
void startRecordingFetch() override;
|
|
std::unordered_set<std::string> stopRecordingFetch() override;
|
|
|
|
folly::SemiFuture<folly::Unit> importManifestForRoot(
|
|
const RootId& rootId,
|
|
const Hash20& manifest) override;
|
|
|
|
RootId parseRootId(folly::StringPiece rootId) override;
|
|
std::string renderRootId(const RootId& rootId) override;
|
|
|
|
std::optional<folly::StringPiece> getRepoName() override;
|
|
|
|
/**
|
|
* Get the underlying BackingStore. This should only be used for operations
|
|
* that need to be made directly on the BackingStore, like getting a TraceBus
|
|
*/
|
|
const std::shared_ptr<BackingStore>& getBackingStore() {
|
|
return backingStore_;
|
|
}
|
|
|
|
private:
|
|
std::shared_ptr<BackingStore> backingStore_;
|
|
std::shared_ptr<LocalStore> localStore_;
|
|
std::shared_ptr<EdenStats> stats_;
|
|
};
|
|
|
|
} // namespace facebook::eden
|