Skip to content

Commit 0c78bed

Browse files
janezhang10meta-codesync[bot]
authored andcommitted
Add FilteredBAckingStore::co_getBlobAuxData
Summary: Add coroutine (now_task) version of getBlobAuxData. Reviewed By: SBones Differential Revision: D103303864 fbshipit-source-id: 5d8951c84f4cfb7c677e8ba9ba57b61193cd2751
1 parent 84b9f54 commit 0c78bed

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

eden/fs/store/FilteredBackingStore.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,19 @@ FilteredBackingStore::getBlobAuxData(
545545
return backingStore_->getBlobAuxData(filteredId.object(), context);
546546
}
547547

548+
folly::coro::now_task<BackingStore::GetBlobAuxResult>
549+
FilteredBackingStore::co_getBlobAuxData(
550+
const ObjectId& id,
551+
const ObjectFetchContextPtr& context) {
552+
if (isSlOid(id)) {
553+
co_return co_await backingStore_->getBlobAuxData(id, context);
554+
}
555+
556+
auto filteredId = FilteredObjectId::fromObjectId(id);
557+
co_return co_await backingStore_->getBlobAuxData(
558+
filteredId.object(), context);
559+
}
560+
548561
folly::SemiFuture<BackingStore::GetBlobResult> FilteredBackingStore::getBlob(
549562
const ObjectId& id,
550563
const ObjectFetchContextPtr& context) {

eden/fs/store/FilteredBackingStore.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class FilteredBackingStore
145145
FRIEND_TEST(SaplingFilteredBackingStoreTest, testMercurialFFIInvalidFOID);
146146
FRIEND_TEST(FakeSubstringFilteredBackingStoreTest, getNonExistent);
147147
FRIEND_TEST(FakeSubstringFilteredBackingStoreTest, getBlob);
148+
FRIEND_TEST(FakeSubstringFilteredBackingStoreTest, co_getBlobAuxData);
148149
FRIEND_TEST(FakeSubstringFilteredBackingStoreTest, getTree);
149150
FRIEND_TEST(FakeSubstringFilteredBackingStoreTest, getRootTree);
150151
FRIEND_TEST(FakeSubstringFilteredBackingStoreTest, getGlobFiles);
@@ -187,6 +188,10 @@ class FilteredBackingStore
187188
const ObjectId& id,
188189
const ObjectFetchContextPtr& context) override;
189190

191+
folly::coro::now_task<GetBlobAuxResult> co_getBlobAuxData(
192+
const ObjectId& id,
193+
const ObjectFetchContextPtr& context);
194+
190195
[[nodiscard]] folly::SemiFuture<folly::Unit> prefetchBlobs(
191196
ObjectIdRange ids,
192197
const ObjectFetchContextPtr& context) override;

eden/fs/store/test/FilteredBackingStoreTest.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,23 @@ TEST_F(FakeSubstringFilteredBackingStoreTest, getBlob) {
286286
EXPECT_EQ("foobar", blobContents(*std::move(future6).get(0ms).blob));
287287
}
288288

289+
CO_TEST_F(FakeSubstringFilteredBackingStoreTest, co_getBlobAuxData) {
290+
auto id = makeTestId("1");
291+
auto filteredId = ObjectId{
292+
FilteredObjectId{id, FilteredObjectIdType::OBJECT_TYPE_BLOB}.getValue()};
293+
auto* storedBlob = wrappedStore_->putBlob(id, "foobar");
294+
storedBlob->setReady();
295+
296+
auto result = co_await filteredStore_->co_getBlobAuxData(
297+
filteredId, ObjectFetchContext::getNullContext());
298+
299+
EXPECT_NE(result.blobAux, nullptr);
300+
EXPECT_EQ(result.blobAux->size, 6);
301+
EXPECT_EQ(
302+
result.blobAux->sha1,
303+
Hash20::sha1(folly::ByteRange{folly::StringPiece{"foobar"}}));
304+
}
305+
289306
TEST_F(FakeSubstringFilteredBackingStoreTest, getTree) {
290307
// Populate some files in the store
291308
auto [runme, runme_id] =

0 commit comments

Comments
 (0)