gpt4 book ai didi

mongodb - 二进制 json (BSON) 中的二进制是什么?

转载 作者:行者123 更新时间:2023-12-03 15:59:37 25 4
gpt4 key购买 nike

为什么二进制字被用于 BSON,当它以如下格式存储数据时

A document such as { "hello": "world" } will be stored as:

Bson:
\x16\x00\x00\x00 // total document size
\x02 // 0x02 = type String
hello\x00 // field name
\x06\x00\x00\x00world\x00 // field value (size of value, value, null terminator)
\x00 // 0x00 = type EOO ('end of object')

对于这种格式,我们还需要解释器来解析并将其转换为机器指令

它以什么方式压缩实际的 JSON 数据并进行快速解释?

最佳答案

这是二进制数据类型的类比语义。 BSON 二进制文件有一个字节数组,表示从 0 到 127 的内部子类型。

例如:字节 0000 0000 1000 代表十六进制“\x08”,表示 BSON 规范中的 bool 类型。

驱动程序将负责将UTF-8格式编码和解码为BSON,存储引擎(例如MongoDB中的WiredTiger)将负责BSON格式数据的序列化和反序列化。

关于mongodb - 二进制 json (BSON) 中的二进制是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54967552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com