jiacai2050 commented on code in PR #1604:
URL: https://github.com/apache/horaedb/pull/1604#discussion_r1877759763


##########
horaedb/metric_engine/src/manifest.rs:
##########
@@ -184,6 +203,264 @@ impl Manifest {
     }
 }
 
+#[repr(packed)]
+#[derive(Debug)]
+struct SnapshotHeader {
+    pub magic: u32,
+    pub version: u8,
+    pub flag: u8,
+    pub length: u64,
+}
+
+impl SnapshotHeader {
+    // format: | magic(u32) | version(u8) |  flags(u8) | length(u64) |
+    // The Magic field (u32) is used to ensure the validity of the data source.
+    // The Flags field (u8) is reserved for future extensibility, such as 
enabling
+    // compression or supporting additional features.
+    // The length field (u64) represents the total length of the subsequent 
records
+    // and serves as a straightforward method for verifying their integrity.
+    // (length = record_length
+    // * record_count)
+
+    // use #[repr(packed)] to force unalignment and avoid hard code internal 
types
+    // here, better solutions?
+    pub const LENGTH: usize = size_of::<SnapshotHeader>();

Review Comment:
   I think you can write it directly: `length = 4 /*magic*/ + 1 /*version*/ + 1 
+ 8 `



##########
horaedb/metric_engine/src/manifest.rs:
##########
@@ -184,6 +203,264 @@ impl Manifest {
     }
 }
 
+#[repr(packed)]
+#[derive(Debug)]
+struct SnapshotHeader {
+    pub magic: u32,
+    pub version: u8,
+    pub flag: u8,
+    pub length: u64,
+}
+
+impl SnapshotHeader {
+    // format: | magic(u32) | version(u8) |  flags(u8) | length(u64) |
+    // The Magic field (u32) is used to ensure the validity of the data source.
+    // The Flags field (u8) is reserved for future extensibility, such as 
enabling
+    // compression or supporting additional features.
+    // The length field (u64) represents the total length of the subsequent 
records
+    // and serves as a straightforward method for verifying their integrity.
+    // (length = record_length
+    // * record_count)

Review Comment:
   No newline here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@horaedb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@horaedb.apache.org
For additional commands, e-mail: commits-h...@horaedb.apache.org

Reply via email to