aboutsummaryrefslogtreecommitdiff
path: root/zenstore/caslog.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-04-01 08:41:51 +0200
committerDan Engelbrecht <[email protected]>2022-04-01 09:07:21 +0200
commitac573e90a5698c64451a99beb1a14d00540aa835 (patch)
treef246b21daef1b8ce99abe275cbda96a481531467 /zenstore/caslog.cpp
parentcall Initialize before replay on caslog (diff)
downloadzen-ac573e90a5698c64451a99beb1a14d00540aa835.tar.xz
zen-ac573e90a5698c64451a99beb1a14d00540aa835.zip
reserve space for log entries before replay
Diffstat (limited to 'zenstore/caslog.cpp')
-rw-r--r--zenstore/caslog.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/zenstore/caslog.cpp b/zenstore/caslog.cpp
index 906c97348..3737e9f45 100644
--- a/zenstore/caslog.cpp
+++ b/zenstore/caslog.cpp
@@ -120,6 +120,19 @@ CasLogFile::GetLogSize()
return m_File.FileSize();
}
+uint64_t
+CasLogFile::GetLogCount()
+{
+ uint64_t LogFileSize = m_File.FileSize();
+ if (LogFileSize < sizeof(FileHeader))
+ {
+ return 0;
+ }
+ const uint64_t LogBaseOffset = sizeof(FileHeader);
+ const size_t LogEntryCount = (LogFileSize - LogBaseOffset) / m_RecordSize;
+ return LogEntryCount;
+}
+
void
CasLogFile::Replay(std::function<void(const void*)>&& Handler)
{