Firebase Firestore“地图"存储大小 [英] Firebase Firestore 'Map' storage size

查看:57
本文介绍了Firebase Firestore“地图"存储大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,如果我在Firestore的文档中保存了地图,则:

If I have a map saved in a document in Firestore, for example:

aMap: {
  exampleKey1: 'value',
}

会变成...

  • 5个字节,地图名称
  • 12个字节,每个字段名称的总和
  • 6个字节,每个字段值的总和

...然后根据 https://firebase.google.com/docs/firestore/storage-size 地图"存储大小的计算方法与文档大小相同,其中包括 32个额外字节,并且文档名称添加了额外16个字节.

...Then according to https://firebase.google.com/docs/firestore/storage-size a 'Map' storage size is calculated the same as document size, which includes 32 additional bytes, and document name adds an extra 16 bytes.

地图会像文档一样引起这些额外的字节吗?

Do Maps incur theses additional bytes like documents do?

推荐答案

文档指出:

地图的大小与文档大小.

意味着在计算Map内容的大小时需要添加这32个额外的字节.但是,应该计算其他16个字节.这是因为这16个字节引用了文档名称,在这种情况下,没有文档名称,而是一个Map名称,该名称的计算方式为名称的长度加1个字节.您的情况是5个字节.

Meaning that you need to add those 32 additional bytes when you calculate the size of the content of a Map. However, the other 16 bytes should not be calculated. This is because those 16 bytes are referring to the document name and in this case, there is no document name, there is a Map name, which is calculated as the length of the name plus 1 byte. In your case, 5 bytes.

对于Android,有一个库可以帮助您计算文档的确切大小:

For Android, there is a library that can help you calculate the exact size of the document:

这篇关于Firebase Firestore“地图"存储大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆