Skip to content

Commit e109699

Browse files
DbFullException: add docs, note that max size can be changed (#164)
1 parent 11f3bc3 commit e109699

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import io.objectbox.annotation.apihint.Experimental;
3535
import io.objectbox.annotation.apihint.Internal;
3636
import io.objectbox.exception.DbException;
37+
import io.objectbox.exception.DbFullException;
38+
import io.objectbox.exception.DbMaxDataSizeExceededException;
3739
import io.objectbox.flatbuffers.FlatBufferBuilder;
3840
import io.objectbox.ideasonly.ModelUpdate;
3941
import io.objectbox.model.FlatStoreOptions;
@@ -333,10 +335,13 @@ BoxStoreBuilder modelUpdate(ModelUpdate modelUpdate) {
333335

334336
/**
335337
* Sets the maximum size the database file can grow to.
336-
* By default this is 1 GB, which should be sufficient for most applications.
338+
* When applying a transaction (e.g. putting an object) would exceed it a {@link DbFullException} is thrown.
337339
* <p>
338-
* In general, a maximum size prevents the DB from growing indefinitely when something goes wrong
339-
* (for example you insert data in an infinite loop).
340+
* By default, this is 1 GB, which should be sufficient for most applications.
341+
* In general, a maximum size prevents the database from growing indefinitely when something goes wrong
342+
* (for example data is put in an infinite loop).
343+
* <p>
344+
* This value can be changed, so increased or also decreased, each time when opening a store.
340345
*/
341346
public BoxStoreBuilder maxSizeInKByte(long maxSizeInKByte) {
342347
if (maxSizeInKByte <= maxDataSizeInKByte) {
@@ -349,13 +354,17 @@ public BoxStoreBuilder maxSizeInKByte(long maxSizeInKByte) {
349354
/**
350355
* This API is experimental and may change or be removed in future releases.
351356
* <p>
352-
* Sets the maximum size the data stored in the database can grow to. Must be below {@link #maxSizeInKByte(long)}.
357+
* Sets the maximum size the data stored in the database can grow to.
358+
* When applying a transaction (e.g. putting an object) would exceed it a {@link DbMaxDataSizeExceededException}
359+
* is thrown.
360+
* <p>
361+
* Must be below {@link #maxSizeInKByte(long)}.
353362
* <p>
354363
* Different from {@link #maxSizeInKByte(long)} this only counts bytes stored in objects, excluding system and
355364
* metadata. However, it is more involved than database size tracking, e.g. it stores an internal counter.
356365
* Only use this if a stricter, more accurate limit is required.
357366
* <p>
358-
* When the data limit is reached data can be removed to get below the limit again (assuming the database size limit
367+
* When the data limit is reached, data can be removed to get below the limit again (assuming the database size limit
359368
* is not also reached).
360369
*/
361370
@Experimental
@@ -455,7 +464,7 @@ public BoxStoreBuilder debugRelations() {
455464
* {@link io.objectbox.exception.DbException} are thrown during query execution).
456465
*
457466
* @param queryAttempts number of attempts a query find operation will be executed before failing.
458-
* Recommended values are in the range of 2 to 5, e.g. a value of 3 as a starting point.
467+
* Recommended values are in the range of 2 to 5, e.g. a value of 3 as a starting point.
459468
*/
460469
@Experimental
461470
public BoxStoreBuilder queryAttempts(int queryAttempts) {

objectbox-java/src/main/java/io/objectbox/exception/DbFullException.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
package io.objectbox.exception;
1818

19+
/**
20+
* Thrown when applying a transaction (e.g. putting an object) would exceed the
21+
* {@link io.objectbox.BoxStoreBuilder#maxSizeInKByte(long) maxSizeInKByte} configured for the store.
22+
*/
1923
public class DbFullException extends DbException {
2024
public DbFullException(String message) {
2125
super(message);

0 commit comments

Comments
 (0)