Skip to content

Commit 5775414

Browse files
committed
Clarify BoxStore.removeAllObjects() docs (does not reclaim disk space), and instruct how to reclaim space
1 parent d2abc2f commit 5775414

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

objectbox-java/src/main/java/io/objectbox/BoxStore.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static boolean isFileOpen(final String canonicalPath) {
276276
synchronized (openFiles) {
277277
if (!openFiles.contains(canonicalPath)) return false;
278278
}
279-
if(openFilesCheckerThread == null || !openFilesCheckerThread.isAlive()) {
279+
if (openFilesCheckerThread == null || !openFilesCheckerThread.isAlive()) {
280280
// Use a thread to avoid finalizers that block us
281281
openFilesCheckerThread = new Thread() {
282282
@Override
@@ -576,10 +576,19 @@ public static boolean deleteAllFiles(@Nullable File baseDirectoryOrNull, @Nullab
576576
}
577577

578578
/**
579-
* Removes all objects from all boxes, e.g. deletes all database content.
580-
*
581-
* Internally reads the current schema, drops all database content,
582-
* then restores the schema in a single transaction.
579+
* Removes all objects from all types ("boxes"), e.g. deletes all database content
580+
* (excluding meta data like the data model).
581+
* This typically performs very quickly (e.g. faster than {@link Box#removeAll()}).
582+
* <p>
583+
* Note that this does not reclaim disk space: the already reserved space for the DB file(s) is used in the future
584+
* resulting in better performance because no/less disk allocation has to be done.
585+
* <p>
586+
* If you want to reclaim disk space, delete the DB file(s) instead:
587+
* <ul>
588+
* <li>{@link #close()} the BoxStore (and ensure that no thread access it)</li>
589+
* <li>{@link #deleteAllFiles()} of the BoxStore</li>
590+
* <li>Open a new BoxStore</li>
591+
* </ul>
583592
*/
584593
public void removeAllObjects() {
585594
nativeDropAllData(handle);
@@ -1013,7 +1022,7 @@ long panicModeRemoveAllObjects(int entityId) {
10131022
* 3) you pass the native store pointer to your native code (e.g. via JNI)<br>
10141023
* 4) your native code calls obx_store_wrap() with the native store pointer to get a OBX_store pointer<br>
10151024
* 5) Using the OBX_store pointer, you can use the C API.
1016-
*
1025+
* <p>
10171026
* Note: Once you {@link #close()} this BoxStore, do not use it from the C API.
10181027
*/
10191028
public long getNativeStore() {

0 commit comments

Comments
 (0)