diff options
author | Yu Zhang <yuzhangyu@fb.com> | 2024-01-30 09:49:32 -0800 |
---|---|---|
committer | Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> | 2024-01-30 09:49:32 -0800 |
commit | b10c171e58bd04668eb7a625db20742c81c54c1d (patch) | |
tree | 4b194f345af0d5af09815e3197f57069a843d82f /test_util | |
parent | aacf60dda2a138f9d3826c25818a3bcf250859fd (diff) |
Remove WritableFile(FSWritableFile)::GetFileSize default implementation (#12303)
Summary:
As titled. This changes public API behavior, and subclasses of `WritableFile` and `FSWritableFile` need to explicitly provide an implementation for the `GetFileSize` method after this change.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/12303
Reviewed By: ajkr
Differential Revision: D53205769
Pulled By: jowlyzhang
fbshipit-source-id: 2e613ca3650302913821b33159b742bdf1d24bc7
Diffstat (limited to 'test_util')
-rw-r--r-- | test_util/testutil.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test_util/testutil.h b/test_util/testutil.h index c484db649..5643c82b6 100644 --- a/test_util/testutil.h +++ b/test_util/testutil.h @@ -189,6 +189,11 @@ class StringSink : public FSWritableFile { } } + uint64_t GetFileSize(const IOOptions& /*options*/, + IODebugContext* /*dbg*/) override { + return contents_.size(); + } + private: Slice* reader_contents_; size_t last_flush_; @@ -285,6 +290,11 @@ class OverwritingStringSink : public FSWritableFile { if (last_flush_ > contents_.size()) last_flush_ = contents_.size(); } + uint64_t GetFileSize(const IOOptions& /*options*/, + IODebugContext* /*dbg*/) override { + return contents_.size(); + } + private: std::string contents_; Slice* reader_contents_; @@ -562,6 +572,14 @@ class StringFS : public FileSystemWrapper { return IOStatus::OK(); } + uint64_t GetFileSize(const IOOptions& /*options*/, + IODebugContext* /*dbg*/) override { + if (contents_ != nullptr) { + return contents_->size(); + } + return 0; + } + private: std::string* contents_; }; |