Firebase Firestore 'Map' storage size

安稳与你 提交于 2020-06-16 04:12:48

问题


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

aMap: {
  exampleKey1: 'value',
}

does that come to...

  • 5 bytes, Map name
  • 12 bytes, sum of each field name
  • 6 bytes, sum of each field value

...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?


回答1:


The docs states:

The size of the map calculated the same way as document size.

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.

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

  • FirestoreDocument-Android


来源:https://stackoverflow.com/questions/61549638/firebase-firestore-map-storage-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!