diff options
| author | Dan Engelbrecht <[email protected]> | 2022-11-23 15:23:27 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-11-23 06:23:27 -0800 |
| commit | f95d166d58a14d9a4567687079d302d2683937a9 (patch) | |
| tree | 5a5b1184d03ea7cac6d2a96151816a462af223e4 /zenstore/blockstore.cpp | |
| parent | 0.1.9-pre3 (diff) | |
| download | zen-f95d166d58a14d9a4567687079d302d2683937a9.tar.xz zen-f95d166d58a14d9a4567687079d302d2683937a9.zip | |
Don't resize block store block file to max size at creation (#193)
* Don't resize block store block file to max size at creation
* changelog
Diffstat (limited to 'zenstore/blockstore.cpp')
| -rw-r--r-- | zenstore/blockstore.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/zenstore/blockstore.cpp b/zenstore/blockstore.cpp index 38371124d..682cc4472 100644 --- a/zenstore/blockstore.cpp +++ b/zenstore/blockstore.cpp @@ -57,12 +57,11 @@ BlockStoreFile::Create(uint64_t InitialSize) } m_File.Open(m_Path, BasicFile::Mode::kTruncateDelete); - if (InitialSize > 0) - { - m_File.SetFileSize(InitialSize); - } void* FileHandle = m_File.Handle(); - m_IoBuffer = IoBuffer(IoBuffer::File, FileHandle, 0, InitialSize); + + // We map our m_IoBuffer beyond the file size as we will grow it over time and want + // to be able to create sub-buffers of all the written range later + m_IoBuffer = IoBuffer(IoBuffer::File, FileHandle, 0, InitialSize); } uint64_t @@ -204,6 +203,7 @@ BlockStore::Close() m_WriteBlock = nullptr; m_CurrentInsertOffset = 0; m_WriteBlockIndex = 0; + m_ChunkBlocks.clear(); m_BlocksBasePath.clear(); } @@ -786,7 +786,7 @@ TEST_CASE("blockstore.blockfile") { BlockStoreFile File1(RootDirectory / "1"); File1.Create(16384); - CHECK(File1.FileSize() == 16384); + CHECK(File1.FileSize() == 0); File1.Write("data", 5, 0); IoBuffer DataChunk = File1.GetChunk(0, 5); File1.Write("boop", 5, 5); @@ -796,6 +796,7 @@ TEST_CASE("blockstore.blockfile") const char* Boop = static_cast<const char*>(BoopChunk.GetData()); CHECK(std::string(Boop) == "boop"); File1.Flush(); + CHECK(File1.FileSize() == 10); } { BlockStoreFile File1(RootDirectory / "1"); |