Renamed functions to refer to blobs

Summary: `getSize` and `getSha1` were misleading function names, since the functions refer to the size and hash of a given blob and not the object store itself. These functions have been renamed to `getBlobSize` and `getBlobSha1`.

Reviewed By: chadaustin

Differential Revision: D15696510

fbshipit-source-id: 4dd31659f60969fa90d8e2b39f43c46a2b7dff7c
This commit is contained in:
Brian Strauch 2019-06-12 17:44:39 -07:00 committed by Facebook Github Bot
parent e9d67b364c
commit 13796362f5
5 changed files with 13 additions and 11 deletions

View File

@ -320,8 +320,8 @@ class ModifiedBlobDiffEntry : public DeferredDiffEntry {
currentBlobHash_{currentBlobHash} {}
folly::Future<folly::Unit> run() override {
auto f1 = context_->store->getSha1(scmEntry_.getHash());
auto f2 = context_->store->getSha1(currentBlobHash_);
auto f1 = context_->store->getBlobSha1(scmEntry_.getHash());
auto f2 = context_->store->getBlobSha1(currentBlobHash_);
return folly::collect(f1, f2).thenValue(
[this](const std::tuple<Hash, Hash>& info) {
if (std::get<0>(info) != std::get<1>(info)) {

View File

@ -532,7 +532,7 @@ folly::Future<bool> FileInode::isSameAs(
}
auto f1 = getSha1();
auto f2 = getMount()->getObjectStore()->getSha1(blobID);
auto f2 = getMount()->getObjectStore()->getBlobSha1(blobID);
return folly::collect(f1, f2).thenValue([](std::tuple<Hash, Hash>&& result) {
return std::get<0>(result) == std::get<1>(result);
});
@ -589,7 +589,7 @@ Future<Hash> FileInode::getSha1() {
case State::BLOB_NOT_LOADING:
case State::BLOB_LOADING:
// If a file is not materialized, it should have a hash value.
return getObjectStore()->getSha1(state->hash.value());
return getObjectStore()->getBlobSha1(state->hash.value());
case State::MATERIALIZED_IN_OVERLAY:
return getOverlayFileAccess(state)->getSha1(getNodeId());
}
@ -886,7 +886,7 @@ void FileInode::materializeNow(
// value in the overlay for this file.
// Since this uses state->hash we perform this before calling
// state.setMaterialized().
auto blobSha1Future = getObjectStore()->getSha1(state->hash.value());
auto blobSha1Future = getObjectStore()->getBlobSha1(state->hash.value());
std::optional<Hash> blobSha1;
if (blobSha1Future.isReady()) {
blobSha1 = blobSha1Future.value();

View File

@ -191,12 +191,12 @@ Future<BlobMetadata> ObjectStore::getBlobMetadata(const Hash& id) const {
});
}
Future<size_t> ObjectStore::getSize(const Hash& id) const {
Future<size_t> ObjectStore::getBlobSize(const Hash& id) const {
return getBlobMetadata(id).thenValue(
[](const BlobMetadata& metadata) { return metadata.size; });
}
Future<Hash> ObjectStore::getSha1(const Hash& id) const {
Future<Hash> ObjectStore::getBlobSha1(const Hash& id) const {
return getBlobMetadata(id).thenValue(
[](const BlobMetadata& metadata) { return metadata.sha1; });
}

View File

@ -86,12 +86,12 @@ class ObjectStore : public IObjectStore,
/**
* Returns the size of the contents of the blob with the given ID.
*/
folly::Future<size_t> getSize(const Hash& id) const;
folly::Future<size_t> getBlobSize(const Hash& id) const;
/**
* Returns the SHA-1 hash of the contents of the blob with the given ID.
*/
folly::Future<Hash> getSha1(const Hash& id) const;
folly::Future<Hash> getBlobSha1(const Hash& id) const;
/**
* Get the LocalStore used by this ObjectStore

View File

@ -39,7 +39,7 @@ TEST_F(ObjectStoreTest, getBlobSize) {
Blob blob = storedBlob->get();
Hash id = blob.getHash();
size_t size = objectStore_->getSize(id).get();
size_t size = objectStore_->getBlobSize(id).get();
EXPECT_EQ(data.size(), size);
}
@ -47,5 +47,7 @@ TEST_F(ObjectStoreTest, getBlobSizeNotFound) {
Hash id;
EXPECT_THROW_RE(
objectStore_->getSize(id).get(), std::domain_error, "blob .* not found");
objectStore_->getBlobSize(id).get(),
std::domain_error,
"blob .* not found");
}