sapling/eden/fs/store/ObjectStore.h
Adam Simpkins 32f4c458fe begin adding a new ObjectStore class
Summary:
Add a new ObjectStore class, which will eventually contain both a LocalStore
and a BackingStore.  The LocalStore will be a cache of data loaded from the
authoritative BackingStore.  The ObjectStore API will hide the work of querying
the BackingStore and updating the LocalStore when data is not already available
in the LocalStore.

For now ObjectStore only contains the LocalStore, but I will add BackingStore
functionality in subsequent diffs.  This diff simply updates all call sites to
use the ObjectStore instead of directly accessing the LocalStore.

Reviewed By: bolinfest

Differential Revision: D3403898

fbshipit-source-id: 47b8c51a7717a4c7c29911a7085b382521a8c0db
2016-06-08 19:01:13 -07:00

64 lines
1.8 KiB
C++

/*
* Copyright (c) 2016, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include <memory>
namespace facebook {
namespace eden {
class Blob;
class Hash;
class LocalStore;
class Tree;
/**
* ObjectStore is a content-addressed store for eden object data.
*
* The ObjectStore class itself is primarily a wrapper around two other
* underlying storage types:
* - LocalStore, which caches object data locally in a RocksDB instance
* - BackingStore, which represents the authoritative source for the object
* data. The BackingStore is generally more expensive to query for object
* data, and may not be available during offline operation.
*/
class ObjectStore {
public:
explicit ObjectStore(std::shared_ptr<LocalStore> localStore);
virtual ~ObjectStore();
std::unique_ptr<Tree> getTree(const Hash& id) const;
std::unique_ptr<Blob> getBlob(const Hash& id) const;
/**
* Return the SHA1 hash of the blob contents.
*
* (Note that this is different than the Hash identifying the blob. The
* hash identifying the blob may be computed using a separate mechanism, and
* may not be the same as the SHA1-hash of its contents.)
*/
std::unique_ptr<Hash> getSha1ForBlob(const Hash& id) const;
private:
// Forbidden copy constructor and assignment operator
ObjectStore(ObjectStore const&) = delete;
ObjectStore& operator=(ObjectStore const&) = delete;
/*
* The LocalStore.
*
* Multiple ObjectStores (for different mount points) may share the same
* LocalStore.
*/
std::shared_ptr<LocalStore> localStore_;
};
}
} // facebook::eden