当前位置:网站首页>bson,json
bson,json
2022-06-10 06:41:00 【General_zy】
BSON是由10gen开发的一个数据格式,目前主要用于MongoDB中,是MongoDB的数据存储格式。BSON基于JSON格式,选择JSON进行改造的原因主要是JSON的通用性及JSON的schemaless的特性。
BSON主要会实现以下三点目标:
1.更快的遍历速度
对JSON格式来说,太大的JSON结构会导致数据遍历非常慢。在JSON中,要跳过一个文档进行数据读取,需要对此文档进行扫描才行,需要进行麻烦的数据结构匹配,比如括号的匹配,而BSON对JSON的一大改进就是,它会将JSON的每一个元素的长度存在元素的头部,这样你只需要读取到元素长度就能直接seek到指定的点上进行读取了。
2.操作更简易
对JSON来说,数据存储是无类型的,比如你要修改基本一个值,从9到10,由于从一个字符变成了两个,所以可能其后面的所有内容都需要往后移一位才可以。而使用BSON,你可以指定这个列为数字列,那么无论数字从9长到10还是100,我们都只是在存储数字的那一位上进行修改,不会导致数据总长变大。当然,在MongoDB中,如果数字从整形增大到长整型,还是会导致数据总长变大的。
3.增加了额外的数据类型
JSON是一个很方便的数据交换格式,但是其类型比较有限。BSON在其基础上增加了“byte array”数据类型。这使得二进制的存储不再需要先base64转换后再存成JSON。大大减少了计算开销和数据大小。
当然,在有的时候,BSON相对JSON来说也并没有空间上的优势,比如对{“field”:7},在JSON的存储上7只使用了一个字节,而如果用BSON,那就是至少4个字节(32位)
目前在10gen的努力下,BSON已经有了针对多种语言的编码解码包。并且都是Apache 2 license下开源的。并且还在随着MongoDB进一步地发展。关于BSON,
边栏推荐
- Rsync+inotify remote synchronization
- Po ME21N enhanced control line text required
- 深度解析智能运维下告警关联频繁项集挖掘算法原理
- Problem: interceptor missile
- SQL practice: SQL optimization problems
- Efficiency improvement: realize personal task management and monitoring with notation
- 一本通1258.数字金字塔 题解 动态规划
- Thoroughly conquer function pointer
- [today in history] March 2: Yahoo was officially established; PC design pioneer was born; [email protected] Bankruptcy
- Practical experience exchange meeting on digital transformation of manufacturing industry held in Yizhuang
猜你喜欢

电脑新加内存条后 游戏崩溃 浏览器卡死 电脑蓝屏

LabVIEW控制Arduino实现红外测距(进阶篇—6)

QT upper computer controls ABB in real time through EGM

Teacher lihongyi's notes on machine learning -4.1 self attention

Teacher lihongyi's notes on machine learning -5 transformer

Qt--- create dialog 2: quick dialog design

Qt--- create dialog box 3: implementation of shape variable dialog box

Stm32f1 and stm32subeide quick start - overview of interrupts, NVIC and exti

SQL practice: SQL foundation and execution sequence

Leetcode game 79 biweekly - complete all questions
随机推荐
Write the data in the JSON file to the database
Jerry's aicmd_ SET_ BT_ Addr command format [chapter]
Unlock TRPC high performance password: introduction to network scheme!
Jacobo accurate to line collation
Notes for beginners
scala fastjson 获取jsonArray中 某个key的最大值
刘勇智:一码通缺陷分析与架构设计方案丨声网开发者创业讲堂 Vol.02
3DMAX Dragon
原博客的地址
基于对应点关系的——两片点云剔除(保留)重复点
Business topic: ab test experiment design and evaluation
SQL practice: SQL window functions and real problems
2022-2027 (New Edition) forecast report on application status and development potential of China's superhard material industry
CMD of Jerry's AI protocol_ SET_ BLE_ Visibility [chapter]
面试当中该说的和不该说的——2022-05-23
Proteus仿真p时出现Cannot open‘***\LISA5476.SDF’的错误
Firefox browser settings point to proxy mode
SQL practice: SQL foundation and execution sequence
The game crashed after the computer added a new memory module, and the browser blocked the blue screen of the computer
How to solve mysql1045 and find the prompt is not an internal command