aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/include
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/zencore/include
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/zencore/include')
-rw-r--r--src/zencore/include/zencore/compress.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/zencore/include/zencore/compress.h b/src/zencore/include/zencore/compress.h
index c51b5407f..5e761ceef 100644
--- a/src/zencore/include/zencore/compress.h
+++ b/src/zencore/include/zencore/compress.h
@@ -130,9 +130,41 @@ public:
/** Returns the hash of the raw data. Zero on error or if this is null. */
[[nodiscard]] ZENCORE_API IoHash DecodeRawHash() const;
+ /**
+ * Returns a block aligned range of a compressed buffer.
+ *
+ * This extracts a sub-range from the compressed buffer, if the buffer is block-compressed
+ * it will align start and end to end up on block boundaries.
+ *
+ * The resulting segments in the CompressedBuffer will are allocated and the data is copied
+ * from the source buffers.
+ *
+ * A new header will be allocated and generated.
+ *
+ * The RawHash field of the header will be zero as we do not calculate the raw hash for the sub-range
+ *
+ * @return A sub-range from the compressed buffer that encompasses RawOffset and RawSize
+ */
[[nodiscard]] ZENCORE_API CompressedBuffer CopyRange(uint64_t RawOffset, uint64_t RawSize = ~uint64_t(0)) const;
/**
+ * Returns a block aligned range of a compressed buffer.
+ *
+ * This extracts a sub-range from the compressed buffer, if the buffer is block-compressed
+ * it will align start and end to end up on block boundaries.
+ *
+ * The resulting segments in the CompressedBuffer will reference the source buffers so it won't
+ * allocate memory and copy data for the compressed data blocks.
+ *
+ * A new header will be allocated and generated.
+ *
+ * The RawHash field of the header will be zero as we do not calculate the raw hash for the sub-range
+ *
+ * @return A sub-range from the compressed buffer that encompasses RawOffset and RawSize
+ */
+ [[nodiscard]] ZENCORE_API CompressedBuffer GetRange(uint64_t RawOffset, uint64_t RawSize = ~uint64_t(0)) const;
+
+ /**
* Returns the compressor and compression level used by this buffer.
*
* The compressor and compression level may differ from those specified when creating the buffer