objectbox-java
objectbox-java copied to clipboard
Get database size and available capacity
Add ways to retrieve information about sizes, e.g.:
- database size on disk
- current size limit on disk
- information about free space in the current file. This is not trivial and could be e.g. based on free pages and pages with capacity. Might be an approximation. Could be a percentage or an absolute number.
- optional(?): approximate remaining capacity until we reach max size (and/or disk limit). Details tbd...
Great.
With these APIs, I can better improve my logic for dynamically expanding DB file size.
Although according to your design, this is not very realistic, if you can solve the DbFullException generated by calling io.objectbox.Box # remove or io.objectbox.Box # removeAll methods when the DB file capacity reaches its limit, it will be more perfect. So I don’t need to use these "rescue" methods
https://gist.github.com/greenrobot/5078a4c86f4fadc5c25711b0a90ecf3a or https://gist.github.com/teffy/1a4c1bd3c4e3eb776efb837f830efed2
FYI: 2.7.0 has BoxStore.sizeOnDisk()
FYI: 2.7.0 has
BoxStore.sizeOnDisk()
remove entries does not make sizeOnDisk be smaller, so the method who returns unused 'pages' is needed for me.
In my story, the when db is full I will try to delete some oldest entries ( those data are time series data). I cannot remove all db files, thus customers will kill me for sure.
One possible way for now :
- Do not set the max db size when initialize box store
- Record the max db count when it reached the max size in first time.
- Delete entries when reach max count when it has been set, delete 10% of total count of box store
In this way, db size should be nearly shaped to max db size. I guess so....
@srdgame Maybe the new experimental maxDataSizeInKByte property is helpful in this case.
@srdgame Maybe the new experimental
maxDataSizeInKByteproperty is helpful in this case.
Possibly, but I won't test it any more, which is a painful time.