diff options
| author | Dan Engelbrecht <[email protected]> | 2022-03-18 00:06:13 +0100 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-03-31 11:28:32 +0200 |
| commit | dcb1476e9ad18c676b4af1fedb93564a028ec636 (patch) | |
| tree | 81228d94fd24f2275561c49130a61b51db89fdd4 /zenstore/compactcas.h | |
| parent | Don't store maxblocksize in index header (diff) | |
| download | zen-dcb1476e9ad18c676b4af1fedb93564a028ec636.tar.xz zen-dcb1476e9ad18c676b4af1fedb93564a028ec636.zip | |
Levarage payload alignment when storing offset
Diffstat (limited to 'zenstore/compactcas.h')
| -rw-r--r-- | zenstore/compactcas.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/zenstore/compactcas.h b/zenstore/compactcas.h index 91c7c6981..95c98bd01 100644 --- a/zenstore/compactcas.h +++ b/zenstore/compactcas.h @@ -36,11 +36,17 @@ struct CasDiskLocation constexpr static uint32_t MaxBlockIndex = (1ul << CasDiskLocation::MaxBlockIndexBits) - 1ul; constexpr static uint32_t MaxOffset = (1ul << CasDiskLocation::MaxOffsetBits) - 1ul; - explicit CasDiskLocation(const CasLocation& Location) { Init(Location.BlockIndex, Location.Offset, Location.Size); } + CasDiskLocation(const CasLocation& Location, uint64_t OffsetAlignement) + { + Init(Location.BlockIndex, Location.Offset / OffsetAlignement, Location.Size); + } CasDiskLocation() = default; - inline CasLocation operator*() const { return {.BlockIndex = BlockIndex(), .Offset = Offset(), .Size = Size()}; } + inline CasLocation Get(uint64_t OffsetAlignement) const + { + return {.BlockIndex = BlockIndex(), .Offset = Offset() * OffsetAlignement, .Size = Size()}; + } private: inline uint32_t BlockIndex() const { return (static_cast<uint32_t>(m_BlockIndexAndOffsetHighBits & 0xf) << 16) | m_BlockIndexLowBits; } |