知识卡片
可变长字段的边界
长度前缀先写数据所占长度,再紧接原字节,解码器可直接计算字段起止并跳过内容。以零结尾的字符串要扫描到终止字节才知道边界;长度前缀也可用于数组或其它二进制数据。连续多个变长字段既可累加先前长度求起点,也可在固定区保存偏移和长度分别访问。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 3. File Formats Primitive Types · 查看原书依据
An alternative to Pascal strings is null-terminated strings, where the reader consumes the string byte-wise until the end-of-string symbol is reached. The Pascal string approach has several advantages: it allows finding out a length of a
参考来源
- 位置:《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#idm46104533282840,段 38)
- 结论依据:原文直接对照长度前缀与空终止,并举出按长度切割字节序列的用途。
- 原始内容:An alternative to Pascal strings is null-terminated strings, where the reader consumes the string byte-wise until the end-of-string symbol is reached. The Pascal string approach has several advantages: it allows finding out a length of a