aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/vfs/vfsimpl.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-03-20 15:13:03 +0100
committerGitHub Enterprise <[email protected]>2024-03-20 15:13:03 +0100
commitd6071e029b7cb9eec6abfa612b16abc16c84e6a3 (patch)
tree21745ab3bb73594a56b2fc548022d900df8ea62f /src/zenserver/vfs/vfsimpl.cpp
parentremove hv tags on actions since they are no longer useful (diff)
downloadzen-d6071e029b7cb9eec6abfa612b16abc16c84e6a3.tar.xz
zen-d6071e029b7cb9eec6abfa612b16abc16c84e6a3.zip
non memory copy compressed range (#13)
* Add CompressedBuffer::GetRange that references source data rather than make a memory copy * Use Compressed.CopyRange in project store GetChunkRange * docs for CompressedBuffer::CopyRange and CompressedBuffer::GetRange
Diffstat (limited to 'src/zenserver/vfs/vfsimpl.cpp')
-rw-r--r--src/zenserver/vfs/vfsimpl.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/zenserver/vfs/vfsimpl.cpp b/src/zenserver/vfs/vfsimpl.cpp
index f528b2620..5ef89ee77 100644
--- a/src/zenserver/vfs/vfsimpl.cpp
+++ b/src/zenserver/vfs/vfsimpl.cpp
@@ -38,21 +38,23 @@ VfsOplogDataSource::ReadNamedData(std::string_view Path, void* Buffer, uint64_t
void
VfsOplogDataSource::ReadChunkData(const Oid& ChunkId, void* Buffer, uint64_t ByteOffset, uint64_t ByteCount)
{
- IoBuffer ChunkBuffer;
- auto Result =
- m_ProjectStore->GetChunkRange(m_ProjectId, m_OplogId, ChunkId, 0, ~0ull, ZenContentType::kCompressedBinary, /* out */ ChunkBuffer);
+ CompositeBuffer ChunkBuffer;
+ ZenContentType ContentType;
+ auto Result = m_ProjectStore->GetChunkRange(m_ProjectId,
+ m_OplogId,
+ ChunkId,
+ 0,
+ ~0ull,
+ ZenContentType::kCompressedBinary,
+ /* out */ ChunkBuffer,
+ /* out */ ContentType);
if (Result.first == HttpResponseCode::OK)
{
- const uint8_t* SourceBuffer = reinterpret_cast<const uint8_t*>(ChunkBuffer.GetData());
- uint64_t AvailableBufferBytes = ChunkBuffer.GetSize();
-
- ZEN_ASSERT(AvailableBufferBytes >= ByteOffset);
- AvailableBufferBytes -= ByteOffset;
- SourceBuffer += ByteOffset;
-
- ZEN_ASSERT(AvailableBufferBytes >= ByteCount);
- memcpy(Buffer, SourceBuffer, ByteCount);
+ ZEN_ASSERT(ChunkBuffer.GetSize() >= ByteOffset);
+ ZEN_ASSERT(ChunkBuffer.GetSize() - ByteOffset >= ByteCount);
+ MutableMemoryView Target(Buffer, ByteCount);
+ ChunkBuffer.CopyTo(Target, ByteOffset);
}
}