Skip to content

Commit a6c4801

Browse files
committed
Added openStream helper in Bucket
1 parent ad0ef62 commit a6c4801

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/bucket/Bucket.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,21 @@ Bucket::Bucket()
7777
{
7878
}
7979

80+
std::unique_ptr<XDRInputFileStream>
81+
Bucket::openStream()
82+
{
83+
releaseAssertOrThrow(!mFilename.empty());
84+
auto streamPtr = std::make_unique<XDRInputFileStream>();
85+
streamPtr->open(mFilename.string());
86+
return std::move(streamPtr);
87+
}
88+
8089
XDRInputFileStream&
8190
Bucket::getIndexStream()
8291
{
8392
if (!mIndexStream)
8493
{
85-
mIndexStream = std::make_unique<XDRInputFileStream>();
86-
releaseAssertOrThrow(!mFilename.empty());
87-
mIndexStream->open(mFilename.string());
94+
mIndexStream = openStream();
8895
}
8996
return *mIndexStream;
9097
}
@@ -94,9 +101,7 @@ Bucket::getEvictionStream()
94101
{
95102
if (!mEvictionStream)
96103
{
97-
mEvictionStream = std::make_unique<XDRInputFileStream>();
98-
releaseAssertOrThrow(!mFilename.empty());
99-
mEvictionStream->open(mFilename.string());
104+
mEvictionStream = openStream();
100105
}
101106
return *mEvictionStream;
102107
}

src/bucket/Bucket.h

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class Bucket : public std::enable_shared_from_this<Bucket>,
7070
std::optional<BucketEntry>
7171
getEntryAtOffset(LedgerKey const& k, std::streamoff pos, size_t pageSize);
7272

73+
std::unique_ptr<XDRInputFileStream> openStream();
74+
7375
static std::string randomFileName(std::string const& tmpDir,
7476
std::string ext);
7577

0 commit comments

Comments
 (0)