领域文件的大小如何发展? [英] How does the size of a realm-file develop?

查看:109
本文介绍了领域文件的大小如何发展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

领域文件的大小如何发展?

How does the size of a realm-file develop ?

首先,我有一个具有几个属性的realm文件,其中一个是860个条目的数组,每个数组条目又包含几个属性. 一种数组属性指出了条目的名称.

To start with: I have a realm-file with several properties and one of them being an array of 860 entries and each array-entry consists of a couple of properties again. One array-property states the name of the entry.

我观察到以下情况:

  • 如果名称属性为"Criteria_A1"(直到"Criteria_A860"),则领域文件为1.6 MB大
  • 如果名称属性为"A1"(直到"A860")-则领域文件只有786 kB大

为什么数组名称属性中的多余字母会使realm文件变得更大?

Why is the extra letters in the array-name-property making the realm-file this much bigger ??

第二次观察:

  • 如果我添加更多对象(每个对象又有一个包含860个条目的数组),那么文件大小将再次变大1.6MB(无论我添加了多少个对象;直到大小再次变为三倍的临界值时为止……)还是我错了??.

在我看来,一旦添加了某些内容(具有更多字母的属性或添加的对象),则786 kB的领域文件的大小就会增加一倍.为什么realm文件会加倍达到临界值,而不会随着添加的内容的增加而线性增加??

It almost seems to me that the realm-file at 786 kB is doubled in size as soon as something is added (either a property that has more letters or an object that is added). Why does the realm-file double at a critical value and not linearly increase in size with more content added ??

感谢您对此进行澄清.

推荐答案

观察得很好. :-) Realm文件的起始大小约为4k,一旦其可用空间用尽,大小将增加一倍.它一直加倍直到128M,然后不断增加128M.

It's pretty well observed. :-) The Realm file starts out at about 4k and will double in size once it runs out of free space. It keeps doubling until 128M and then adds constantly 128M thereafter.

将文件加倍而不只是线性增长的原因仅是由于性能.这是动态数据结构不断加倍的常见算法.

The reason to double the file and not just grow linearly is only due to performance. It's a common algorithm for dynamic data structures to just keep doubling.

您可以使用如下所示的可用方法来编写压缩副本,以删除文件中的所有可用空间.如果您不再添加新数据,想运送静态数据库或想通过网络发送文件,这将很有用.

You can use the methods available as seen below to write a compacted copy removing all free space in the file. This can be useful if you don't add new data anymore, want to ship a static database or want to send the file over the network.

上述阈值和算法是当前的阈值和算法,但是在将来的版本中可能会发生变化.

Those thresholds and algorithm mentioned are the current ones, and may change in future versions though.

希望这可以澄清吗?

这篇关于领域文件的大小如何发展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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