Skip to content

Commit

Permalink
radixdb: dedicate a header field for compression
Browse files Browse the repository at this point in the history
  • Loading branch information
toru committed Oct 22, 2024
1 parent b16da60 commit 745503d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const (
// fileFormatVersionLen represents the size of fileFormatVersion in bytes.
fileFormatVersionLen = sizeOfUint8

// compressionAlgoLen represents the size of compressionAlgo in bytes.
compressionAlgoLen = sizeOfUint8

// nodeCountLen represents the size of nodeCount in bytes.
nodeCountLen = sizeOfUint64

Expand All @@ -57,7 +60,7 @@ const (
headerChecksumLen = sizeOfUint32

// reservedTotalLen represents the total size of the reserved region.
reservedTotalLen = sizeOfUint8 + sizeOfUint8
reservedTotalLen = sizeOfUint8

// createdAtOffset represents the starting position of the createdAt field.
createdAtOffset = magicByteLen + fileFormatVersion + reservedTotalLen + nodeCountLen + recordCountLen + blobCountLen + radixTreeOffsetLen + blobStoreOffsetLen
Expand All @@ -82,6 +85,7 @@ type fileHeader []byte
func fileHeaderSize() int {
return magicByteLen +
fileFormatVersionLen +
compressionAlgoLen +
reservedTotalLen +
nodeCountLen +
recordCountLen +
Expand All @@ -100,7 +104,7 @@ func newFileHeader() fileHeader {
// 0 1 2 3
// 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
// +---------------+---------------+---------------+---------------+
// 0 | Magic ('R') | Version | Reserverd | Reserved |
// 0 | Magic ('R') | Version | Compression | Reserved |
// +---------------+---------------+---------------+---------------+
// 4 | Node Count |
// + +
Expand Down Expand Up @@ -136,10 +140,10 @@ func newFileHeader() fileHeader {

buf.WriteByte(magicByte)
buf.WriteByte(fileFormatVersion)
buf.WriteByte(byte(0)) // compression

// Reserve space for future use.
buf.WriteByte(byte(0)) // reserved
buf.WriteByte(byte(0)) // reserved

// Reserve space for nodeCount, recordCount and blobCount.
binary.Write(&buf, binary.LittleEndian, uint64(0)) // nodeCount
Expand Down

0 comments on commit 745503d

Please sign in to comment.