Skip to content

Commit 48331e7

Browse files
committed
Add maxDataSizeInKbyte to FlatStoreOptions, add TreeOptionFlags
Also reapply: "Update SyncFlags: rename to DebugLogIdMapping, add ClientKeepDataOnSyncError"
1 parent f84ca11 commit 48331e7

File tree

3 files changed

+68
-8
lines changed

3 files changed

+68
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ byte[] buildFlatStoreOptions(String canonicalPath) {
482482

483483
// ...then build options.
484484
FlatStoreOptions.addDirectoryPath(fbb, directoryPathOffset);
485-
FlatStoreOptions.addMaxDbSizeInKByte(fbb, maxSizeInKByte);
485+
FlatStoreOptions.addMaxDbSizeInKbyte(fbb, maxSizeInKByte);
486486
FlatStoreOptions.addFileMode(fbb, fileMode);
487487
FlatStoreOptions.addMaxReaders(fbb, maxReaders);
488488
if (validateOnOpenMode != 0) {

objectbox-java/src/main/java/io/objectbox/model/FlatStoreOptions.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public final class FlatStoreOptions extends Table {
5757
* e.g. caused by programming error.
5858
* If your app runs into errors like "db full", you may consider to raise the limit.
5959
*/
60-
public long maxDbSizeInKByte() { int o = __offset(8); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
60+
public long maxDbSizeInKbyte() { int o = __offset(8); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
6161
/**
6262
* File permissions given in Unix style octal bit flags (e.g. 0644). Ignored on Windows.
6363
* Note: directories become searchable if the "read" or "write" permission is set (e.g. 0640 becomes 0750).
@@ -135,11 +135,19 @@ public final class FlatStoreOptions extends Table {
135135
* corner cases with e.g. transactions, which may not be fully tested at the moment.
136136
*/
137137
public boolean noReaderThreadLocals() { int o = __offset(30); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
138+
/**
139+
* Data size tracking is more involved than DB size tracking, e.g. it stores an internal counter.
140+
* Thus only use it if a stricter, more accurate limit is required.
141+
* It tracks the size of actual data bytes of objects (system and metadata is not considered).
142+
* On the upside, reaching the data limit still allows data to be removed (assuming DB limit is not reached).
143+
* Max data and DB sizes can be combined; data size must be below the DB size.
144+
*/
145+
public long maxDataSizeInKbyte() { int o = __offset(32); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
138146

139147
public static int createFlatStoreOptions(FlatBufferBuilder builder,
140148
int directoryPathOffset,
141149
int modelBytesOffset,
142-
long maxDbSizeInKByte,
150+
long maxDbSizeInKbyte,
143151
long fileMode,
144152
long maxReaders,
145153
int validateOnOpen,
@@ -150,10 +158,12 @@ public static int createFlatStoreOptions(FlatBufferBuilder builder,
150158
boolean usePreviousCommitOnValidationFailure,
151159
boolean readOnly,
152160
long debugFlags,
153-
boolean noReaderThreadLocals) {
154-
builder.startTable(14);
161+
boolean noReaderThreadLocals,
162+
long maxDataSizeInKbyte) {
163+
builder.startTable(15);
164+
FlatStoreOptions.addMaxDataSizeInKbyte(builder, maxDataSizeInKbyte);
155165
FlatStoreOptions.addValidateOnOpenPageLimit(builder, validateOnOpenPageLimit);
156-
FlatStoreOptions.addMaxDbSizeInKByte(builder, maxDbSizeInKByte);
166+
FlatStoreOptions.addMaxDbSizeInKbyte(builder, maxDbSizeInKbyte);
157167
FlatStoreOptions.addDebugFlags(builder, debugFlags);
158168
FlatStoreOptions.addMaxReaders(builder, maxReaders);
159169
FlatStoreOptions.addFileMode(builder, fileMode);
@@ -169,13 +179,13 @@ public static int createFlatStoreOptions(FlatBufferBuilder builder,
169179
return FlatStoreOptions.endFlatStoreOptions(builder);
170180
}
171181

172-
public static void startFlatStoreOptions(FlatBufferBuilder builder) { builder.startTable(14); }
182+
public static void startFlatStoreOptions(FlatBufferBuilder builder) { builder.startTable(15); }
173183
public static void addDirectoryPath(FlatBufferBuilder builder, int directoryPathOffset) { builder.addOffset(0, directoryPathOffset, 0); }
174184
public static void addModelBytes(FlatBufferBuilder builder, int modelBytesOffset) { builder.addOffset(1, modelBytesOffset, 0); }
175185
public static int createModelBytesVector(FlatBufferBuilder builder, byte[] data) { return builder.createByteVector(data); }
176186
public static int createModelBytesVector(FlatBufferBuilder builder, ByteBuffer data) { return builder.createByteVector(data); }
177187
public static void startModelBytesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); }
178-
public static void addMaxDbSizeInKByte(FlatBufferBuilder builder, long maxDbSizeInKByte) { builder.addLong(2, maxDbSizeInKByte, 0L); }
188+
public static void addMaxDbSizeInKbyte(FlatBufferBuilder builder, long maxDbSizeInKbyte) { builder.addLong(2, maxDbSizeInKbyte, 0L); }
179189
public static void addFileMode(FlatBufferBuilder builder, long fileMode) { builder.addInt(3, (int) fileMode, (int) 0L); }
180190
public static void addMaxReaders(FlatBufferBuilder builder, long maxReaders) { builder.addInt(4, (int) maxReaders, (int) 0L); }
181191
public static void addValidateOnOpen(FlatBufferBuilder builder, int validateOnOpen) { builder.addShort(5, (short) validateOnOpen, (short) 0); }
@@ -187,6 +197,7 @@ public static int createFlatStoreOptions(FlatBufferBuilder builder,
187197
public static void addReadOnly(FlatBufferBuilder builder, boolean readOnly) { builder.addBoolean(11, readOnly, false); }
188198
public static void addDebugFlags(FlatBufferBuilder builder, long debugFlags) { builder.addInt(12, (int) debugFlags, (int) 0L); }
189199
public static void addNoReaderThreadLocals(FlatBufferBuilder builder, boolean noReaderThreadLocals) { builder.addBoolean(13, noReaderThreadLocals, false); }
200+
public static void addMaxDataSizeInKbyte(FlatBufferBuilder builder, long maxDataSizeInKbyte) { builder.addLong(14, maxDataSizeInKbyte, 0L); }
190201
public static int endFlatStoreOptions(FlatBufferBuilder builder) {
191202
int o = builder.endTable();
192203
return o;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2022 ObjectBox Ltd. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// automatically generated by the FlatBuffers compiler, do not modify
18+
19+
package io.objectbox.model;
20+
21+
/**
22+
* Options flags for trees.
23+
*/
24+
@SuppressWarnings("unused")
25+
public final class TreeOptionFlags {
26+
private TreeOptionFlags() { }
27+
/**
28+
* If true, debug logs are always disabled for this tree regardless of the store's debug flags.
29+
*/
30+
public static final int DebugLogsDisable = 1;
31+
/**
32+
* If true, debug logs are always enabled for this tree regardless of the store's debug flags.
33+
*/
34+
public static final int DebugLogsEnable = 2;
35+
/**
36+
* By default, a path such as "a/b/c" can address a branch and a leaf at the same time.
37+
* E.g. under the common parent path "a/b", a branch "c" and a "c" leaf may exist.
38+
* To disable this, set this flag to true.
39+
* This will enable an additional check when inserting new leafs and new branches for the existence of the other.
40+
*/
41+
public static final int EnforceUniquePath = 4;
42+
/**
43+
* In some scenarios, e.g. when using Sync, multiple node objects of the same type (e.g. branch or leaf) at the
44+
* same path may exist temporarily. By enabling this flag, this is not considered an error situation. Instead, the
45+
* first node is picked.
46+
*/
47+
public static final int AllowNonUniqueNodes = 8;
48+
}
49+

0 commit comments

Comments
 (0)