知识卡片
固定宽度数值的编码
持久文件要明确整数的字节数和字节序,编码和解码按同一协议。32 位无符号示例 0xAABBCCDD 在大端从 AA 到 DD,在小端从 DD 到 AA。浮点通常使用含符号、阶码、有效位的 IEEE 754 表示,并可能近似原十进制值。直接把内存结构体写上磁盘会连同平台对齐与本机字节序写入,格式应明确约定每个字段的布局。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 3. File Formats Primitive Types · 查看原书依据
Most numeric data types are represented as fixed-size values. When working with multibyte numeric values, it is important to use the same byte-order (endianness) for both encoding and decoding.
参考来源
- 位置:《Database Internals》Chapter 3. File Formats(book-source:extracted/Database Internals A deep-dive into how distributed data systems work (Alex Petrov)/_epub-src/OEBPS/ch03.html#idm46104533288984,段 20)
- 结论依据:原文强调多字节数字的端序一致性,后面列出整数宽度、浮点编码及填充约束。
- 原始内容:Most numeric data types are represented as fixed-size values. When working with multibyte numeric values, it is important to use the same byte-order (endianness) for both encoding and decoding.