|
16 | 16 |
|
17 | 17 | package io.objectbox;
|
18 | 18 |
|
19 |
| -import com.google.flatbuffers.FlatBufferBuilder; |
20 |
| - |
21 | 19 | import org.greenrobot.essentials.collections.LongHashMap;
|
22 | 20 |
|
23 | 21 | import java.io.Closeable;
|
|
49 | 47 | import io.objectbox.exception.DbSchemaException;
|
50 | 48 | import io.objectbox.internal.NativeLibraryLoader;
|
51 | 49 | import io.objectbox.internal.ObjectBoxThreadPool;
|
52 |
| -import io.objectbox.model.FlatStoreOptions; |
53 | 50 | import io.objectbox.reactive.DataObserver;
|
54 | 51 | import io.objectbox.reactive.DataPublisher;
|
55 | 52 | import io.objectbox.reactive.SubscriptionBuilder;
|
@@ -225,7 +222,7 @@ public static boolean isObjectBrowserAvailable() {
|
225 | 222 | canonicalPath = getCanonicalPath(directory);
|
226 | 223 | verifyNotAlreadyOpen(canonicalPath);
|
227 | 224 |
|
228 |
| - handle = nativeCreateWithFlatOptions(buildFlatStoreOptions(builder, canonicalPath), builder.model); |
| 225 | + handle = nativeCreateWithFlatOptions(builder.buildFlatStoreOptions(canonicalPath), builder.model); |
229 | 226 | int debugFlags = builder.debugFlags;
|
230 | 227 | if (debugFlags != 0) {
|
231 | 228 | debugTxRead = (debugFlags & DebugFlags.LOG_TRANSACTIONS_READ) != 0;
|
@@ -268,42 +265,6 @@ public static boolean isObjectBrowserAvailable() {
|
268 | 265 | queryAttempts = Math.max(builder.queryAttempts, 1);
|
269 | 266 | }
|
270 | 267 |
|
271 |
| - private static byte[] buildFlatStoreOptions(BoxStoreBuilder builder, String canonicalPath) { |
272 |
| - FlatBufferBuilder fbb = new FlatBufferBuilder(); |
273 |
| - // FlatBuffer default values are set in generated code, e.g. may be different from here, so always store value. |
274 |
| - fbb.forceDefaults(true); |
275 |
| - |
276 |
| - // Add non-integer values first... |
277 |
| - int directoryPathOffset = fbb.createString(canonicalPath); |
278 |
| - |
279 |
| - FlatStoreOptions.startFlatStoreOptions(fbb); |
280 |
| - |
281 |
| - // ...then build options. |
282 |
| - FlatStoreOptions.addDirectoryPath(fbb, directoryPathOffset); |
283 |
| - FlatStoreOptions.addMaxDbSizeInKByte(fbb, builder.maxSizeInKByte); |
284 |
| - FlatStoreOptions.addFileMode(fbb, builder.fileMode); |
285 |
| - FlatStoreOptions.addMaxReaders(fbb, builder.maxReaders); |
286 |
| - int validateOnOpenMode = builder.validateOnOpenMode; |
287 |
| - if (validateOnOpenMode != 0) { |
288 |
| - FlatStoreOptions.addValidateOnOpen(fbb, validateOnOpenMode); |
289 |
| - long validateOnOpenPageLimit = builder.validateOnOpenPageLimit; |
290 |
| - if (validateOnOpenPageLimit != 0) { |
291 |
| - FlatStoreOptions.addValidateOnOpenPageLimit(fbb, validateOnOpenPageLimit); |
292 |
| - } |
293 |
| - } |
294 |
| - if(builder.skipReadSchema) FlatStoreOptions.addSkipReadSchema(fbb, builder.skipReadSchema); |
295 |
| - if(builder.usePreviousCommit) FlatStoreOptions.addUsePreviousCommit(fbb, builder.usePreviousCommit); |
296 |
| - if(builder.readOnly) FlatStoreOptions.addReadOnly(fbb, builder.readOnly); |
297 |
| - int debugFlags = builder.debugFlags; |
298 |
| - if (debugFlags != 0) { |
299 |
| - FlatStoreOptions.addDebugFlags(fbb, debugFlags); |
300 |
| - } |
301 |
| - |
302 |
| - int offset = FlatStoreOptions.endFlatStoreOptions(fbb); |
303 |
| - fbb.finish(offset); |
304 |
| - return fbb.sizedByteArray(); |
305 |
| - } |
306 |
| - |
307 | 268 | static String getCanonicalPath(File directory) {
|
308 | 269 | if (directory.exists()) {
|
309 | 270 | if (!directory.isDirectory()) {
|
|
0 commit comments