Class FlatStoreOptions


  • public final class FlatStoreOptions
    extends io.objectbox.flatbuffers.Table
    Options to open a store with. Set only the values you want; defaults are used otherwise. Reminder: enable "force defaults" in the FlatBuffers builder, e.g. to pass in booleans with value "false". NOTE: some setting are for "advanced" purposes that you can typically ignore for regular usage. When using advanced setting, you should know exactly what you are doing.
    • Field Summary

      • Fields inherited from class io.objectbox.flatbuffers.Table

        bb, bb_pos
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      FlatStoreOptions __assign​(int _i, java.nio.ByteBuffer _bb)  
      void __init​(int _i, java.nio.ByteBuffer _bb)  
      static void addBackupFile​(io.objectbox.flatbuffers.FlatBufferBuilder builder, int backupFileOffset)  
      static void addBackupRestoreFlags​(io.objectbox.flatbuffers.FlatBufferBuilder builder, long backupRestoreFlags)  
      static void addDebugFlags​(io.objectbox.flatbuffers.FlatBufferBuilder builder, long debugFlags)  
      static void addDirectoryPath​(io.objectbox.flatbuffers.FlatBufferBuilder builder, int directoryPathOffset)  
      static void addFileMode​(io.objectbox.flatbuffers.FlatBufferBuilder builder, long fileMode)  
      static void addMaxDataSizeInKbyte​(io.objectbox.flatbuffers.FlatBufferBuilder builder, long maxDataSizeInKbyte)  
      static void addMaxDbSizeInKbyte​(io.objectbox.flatbuffers.FlatBufferBuilder builder, long maxDbSizeInKbyte)  
      static void addMaxReaders​(io.objectbox.flatbuffers.FlatBufferBuilder builder, long maxReaders)  
      static void addModelBytes​(io.objectbox.flatbuffers.FlatBufferBuilder builder, int modelBytesOffset)  
      static void addNoReaderThreadLocals​(io.objectbox.flatbuffers.FlatBufferBuilder builder, boolean noReaderThreadLocals)  
      static void addPutPaddingMode​(io.objectbox.flatbuffers.FlatBufferBuilder builder, int putPaddingMode)  
      static void addReadOnly​(io.objectbox.flatbuffers.FlatBufferBuilder builder, boolean readOnly)  
      static void addSkipReadSchema​(io.objectbox.flatbuffers.FlatBufferBuilder builder, boolean skipReadSchema)  
      static void addUsePreviousCommit​(io.objectbox.flatbuffers.FlatBufferBuilder builder, boolean usePreviousCommit)  
      static void addUsePreviousCommitOnValidationFailure​(io.objectbox.flatbuffers.FlatBufferBuilder builder, boolean usePreviousCommitOnValidationFailure)  
      static void addValidateOnOpenKv​(io.objectbox.flatbuffers.FlatBufferBuilder builder, int validateOnOpenKv)  
      static void addValidateOnOpenPageLimit​(io.objectbox.flatbuffers.FlatBufferBuilder builder, long validateOnOpenPageLimit)  
      static void addValidateOnOpenPages​(io.objectbox.flatbuffers.FlatBufferBuilder builder, int validateOnOpenPages)  
      java.lang.String backupFile()
      Restores the database content from the given backup file (note: backup is a server-only feature).
      java.nio.ByteBuffer backupFileAsByteBuffer()  
      java.nio.ByteBuffer backupFileInByteBuffer​(java.nio.ByteBuffer _bb)  
      long backupRestoreFlags()
      Flags to change the default behavior for restoring backups, e.g.
      static int createFlatStoreOptions​(io.objectbox.flatbuffers.FlatBufferBuilder builder, int directoryPathOffset, int modelBytesOffset, long maxDbSizeInKbyte, long fileMode, long maxReaders, int validateOnOpenPages, long validateOnOpenPageLimit, int putPaddingMode, boolean skipReadSchema, boolean usePreviousCommit, boolean usePreviousCommitOnValidationFailure, boolean readOnly, long debugFlags, boolean noReaderThreadLocals, long maxDataSizeInKbyte, int validateOnOpenKv, int backupFileOffset, long backupRestoreFlags)  
      static int createModelBytesVector​(io.objectbox.flatbuffers.FlatBufferBuilder builder, byte[] data)  
      static int createModelBytesVector​(io.objectbox.flatbuffers.FlatBufferBuilder builder, java.nio.ByteBuffer data)  
      long debugFlags()
      For debugging purposes you may want enable specific logging.
      java.lang.String directoryPath()
      Location of the database on disk; this will be a directory containing files.
      java.nio.ByteBuffer directoryPathAsByteBuffer()  
      java.nio.ByteBuffer directoryPathInByteBuffer​(java.nio.ByteBuffer _bb)  
      static int endFlatStoreOptions​(io.objectbox.flatbuffers.FlatBufferBuilder builder)  
      long fileMode()
      File permissions given in Unix style octal bit flags (e.g.
      static void finishFlatStoreOptionsBuffer​(io.objectbox.flatbuffers.FlatBufferBuilder builder, int offset)  
      static void finishSizePrefixedFlatStoreOptionsBuffer​(io.objectbox.flatbuffers.FlatBufferBuilder builder, int offset)  
      static FlatStoreOptions getRootAsFlatStoreOptions​(java.nio.ByteBuffer _bb)  
      static FlatStoreOptions getRootAsFlatStoreOptions​(java.nio.ByteBuffer _bb, FlatStoreOptions obj)  
      long maxDataSizeInKbyte()
      Data size tracking is more involved than DB size tracking, e.g.
      long maxDbSizeInKbyte()
      This maximum size setting is meant to prevent your database from growing to unexpected sizes, e.g.
      long maxReaders()
      The maximum number of readers (related to read transactions).
      int modelBytes​(int j)
      Provide a data model, e.g.
      java.nio.ByteBuffer modelBytesAsByteBuffer()  
      java.nio.ByteBuffer modelBytesInByteBuffer​(java.nio.ByteBuffer _bb)  
      int modelBytesLength()  
      io.objectbox.flatbuffers.ByteVector modelBytesVector()  
      io.objectbox.flatbuffers.ByteVector modelBytesVector​(io.objectbox.flatbuffers.ByteVector obj)  
      boolean noReaderThreadLocals()
      Disables the usage of thread locals for "readers" related to read transactions.
      int putPaddingMode()
      Don't touch unless you know exactly what you are doing: Advanced setting typically meant for language bindings (not end users).
      boolean readOnly()
      Open store in read-only mode: no schema update, no write transactions.
      boolean skipReadSchema()
      Advanced setting meant only for special scenarios: opens the database in a limited, schema-less mode.
      static void startFlatStoreOptions​(io.objectbox.flatbuffers.FlatBufferBuilder builder)  
      static void startModelBytesVector​(io.objectbox.flatbuffers.FlatBufferBuilder builder, int numElems)  
      boolean usePreviousCommit()
      Advanced setting recommended to be used together with read-only mode to ensure no data is lost.
      boolean usePreviousCommitOnValidationFailure()
      NOT IMPLEMENTED YET.
      int validateOnOpenKv()
      When a database is opened, ObjectBox can perform additional consistency checks on its database structure.
      long validateOnOpenPageLimit()
      To fine-tune database validation, you can specify a limit on how much data is looked at.
      int validateOnOpenPages()
      When a database is opened, ObjectBox can perform additional consistency checks on its database structure.
      static void ValidateVersion()  
      • Methods inherited from class io.objectbox.flatbuffers.Table

        __has_identifier, __indirect, __indirect, __offset, __offset, __reset, __reset, __string, __string, __union, __union, __vector, __vector_as_bytebuffer, __vector_in_bytebuffer, __vector_len, compareStrings, compareStrings, getByteBuffer, keysCompare, sortTables
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FlatStoreOptions

        public FlatStoreOptions()
    • Method Detail

      • ValidateVersion

        public static void ValidateVersion()
      • getRootAsFlatStoreOptions

        public static FlatStoreOptions getRootAsFlatStoreOptions​(java.nio.ByteBuffer _bb)
      • __init

        public void __init​(int _i,
                           java.nio.ByteBuffer _bb)
      • __assign

        public FlatStoreOptions __assign​(int _i,
                                         java.nio.ByteBuffer _bb)
      • directoryPath

        public java.lang.String directoryPath()
        Location of the database on disk; this will be a directory containing files.
      • directoryPathAsByteBuffer

        public java.nio.ByteBuffer directoryPathAsByteBuffer()
      • directoryPathInByteBuffer

        public java.nio.ByteBuffer directoryPathInByteBuffer​(java.nio.ByteBuffer _bb)
      • modelBytes

        public int modelBytes​(int j)
        Provide a data model, e.g. to initialize or update the schema.
      • modelBytesLength

        public int modelBytesLength()
      • modelBytesVector

        public io.objectbox.flatbuffers.ByteVector modelBytesVector()
      • modelBytesVector

        public io.objectbox.flatbuffers.ByteVector modelBytesVector​(io.objectbox.flatbuffers.ByteVector obj)
      • modelBytesAsByteBuffer

        public java.nio.ByteBuffer modelBytesAsByteBuffer()
      • modelBytesInByteBuffer

        public java.nio.ByteBuffer modelBytesInByteBuffer​(java.nio.ByteBuffer _bb)
      • maxDbSizeInKbyte

        public long maxDbSizeInKbyte()
        This maximum size setting is meant to prevent your database from growing to unexpected sizes, e.g. caused by programming error. If your app runs into errors like "db full", you may consider to raise the limit.
      • fileMode

        public long fileMode()
        File permissions given in Unix style octal bit flags (e.g. 0644). Ignored on Windows. Note: directories become searchable if the "read" or "write" permission is set (e.g. 0640 becomes 0750).
      • maxReaders

        public long maxReaders()
        The maximum number of readers (related to read transactions). "Readers" are an finite resource for which we need to define a maximum number upfront. The default value is enough for most apps and usually you can ignore it completely. However, if you get the OBX_ERROR_MAX_READERS_EXCEEDED error, you should verify your threading. For each thread, ObjectBox uses multiple readers. Their number (per thread) depends on number of types, relations, and usage patterns. Thus, if you are working with many threads (e.g. in a server-like scenario), it can make sense to increase the maximum number of readers. Note: The internal default is currently 126. So when hitting this limit, try value s around 200-500. Note: Each thread that performed a read transaction and is still alive holds on to a reader slot. These slots only get vacated when the thread ends. Thus be mindful with the number of active threads. Alternatively, you can opt to try the experimental noReaderThreadLocals option flag.
      • validateOnOpenPages

        public int validateOnOpenPages()
        When a database is opened, ObjectBox can perform additional consistency checks on its database structure. Reliable file systems already guarantee consistency, so this is primarily meant to deal with unreliable OSes, file systems, or hardware. Note: ObjectBox builds upon ACID storage, which already has strong consistency mechanisms in place.
      • validateOnOpenPageLimit

        public long validateOnOpenPageLimit()
        To fine-tune database validation, you can specify a limit on how much data is looked at. This is measured in "pages" with a page typically holding 4K. Usually a low number (e.g. 1-20) is sufficient and does not impact startup performance significantly. This is only to be used with ValidateOnOpenMode "Regular" and "WithLeaves".
      • putPaddingMode

        public int putPaddingMode()
        Don't touch unless you know exactly what you are doing: Advanced setting typically meant for language bindings (not end users). See PutPaddingMode description.
      • skipReadSchema

        public boolean skipReadSchema()
        Advanced setting meant only for special scenarios: opens the database in a limited, schema-less mode. If you don't know what this means exactly: ignore this flag.
      • usePreviousCommit

        public boolean usePreviousCommit()
        Advanced setting recommended to be used together with read-only mode to ensure no data is lost. Ignores the latest data snapshot (committed transaction state) and uses the previous snapshot instead. When used with care (e.g. backup the DB files first), this option may also recover data removed by the latest transaction.
      • usePreviousCommitOnValidationFailure

        public boolean usePreviousCommitOnValidationFailure()
        NOT IMPLEMENTED YET. Placeholder for a future version only. If consistency checks fail during opening the DB (see also the pagesToValidateOnOpen setting), ObjectBox automatically switches to the previous commit (see also usePreviousCommit). This way, this constitutes an auto-recover mode from severe failures. HOWEVER, keep in mind that any consistency failure is an indication that something is very wrong with OS/hardware and thus you should also check openedWithPreviousCommit(), e.g. to alert your users.
      • readOnly

        public boolean readOnly()
        Open store in read-only mode: no schema update, no write transactions.
      • debugFlags

        public long debugFlags()
        For debugging purposes you may want enable specific logging.
      • noReaderThreadLocals

        public boolean noReaderThreadLocals()
        Disables the usage of thread locals for "readers" related to read transactions. This can make sense if you are using a lot of threads that are kept alive. Note: This is still experimental, as it comes with subtle behavior changes at a low level and may affect corner cases with e.g. transactions, which may not be fully tested at the moment.
      • maxDataSizeInKbyte

        public long maxDataSizeInKbyte()
        Data size tracking is more involved than DB size tracking, e.g. it stores an internal counter. Thus only use it if a stricter, more accurate limit is required. It tracks the size of actual data bytes of objects (system and metadata is not considered). On the upside, reaching the data limit still allows data to be removed (assuming DB limit is not reached). Max data and DB sizes can be combined; data size must be below the DB size.
      • validateOnOpenKv

        public int validateOnOpenKv()
        When a database is opened, ObjectBox can perform additional consistency checks on its database structure. This enum is used to enable validation checks on a key/value level.
      • backupFile

        public java.lang.String backupFile()
        Restores the database content from the given backup file (note: backup is a server-only feature). By default, actually restoring the backup is only performed if no database already exists (database does not contain data). This behavior can be adjusted with backupRestoreFlags, e.g., to overwrite all existing data in the database. \note Backup files are created from an existing database using ObjectBox API. \note The following error types can occur for different error scenarios: * IO error: the backup file doesn't exist, couldn't be read or has an unexpected size, * format error: the backup-file is malformed * integrity error: the backup file failed integrity checks
      • backupFileAsByteBuffer

        public java.nio.ByteBuffer backupFileAsByteBuffer()
      • backupFileInByteBuffer

        public java.nio.ByteBuffer backupFileInByteBuffer​(java.nio.ByteBuffer _bb)
      • backupRestoreFlags

        public long backupRestoreFlags()
        Flags to change the default behavior for restoring backups, e.g. what should happen to existing data.
      • createFlatStoreOptions

        public static int createFlatStoreOptions​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                                 int directoryPathOffset,
                                                 int modelBytesOffset,
                                                 long maxDbSizeInKbyte,
                                                 long fileMode,
                                                 long maxReaders,
                                                 int validateOnOpenPages,
                                                 long validateOnOpenPageLimit,
                                                 int putPaddingMode,
                                                 boolean skipReadSchema,
                                                 boolean usePreviousCommit,
                                                 boolean usePreviousCommitOnValidationFailure,
                                                 boolean readOnly,
                                                 long debugFlags,
                                                 boolean noReaderThreadLocals,
                                                 long maxDataSizeInKbyte,
                                                 int validateOnOpenKv,
                                                 int backupFileOffset,
                                                 long backupRestoreFlags)
      • startFlatStoreOptions

        public static void startFlatStoreOptions​(io.objectbox.flatbuffers.FlatBufferBuilder builder)
      • addDirectoryPath

        public static void addDirectoryPath​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                            int directoryPathOffset)
      • addModelBytes

        public static void addModelBytes​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                         int modelBytesOffset)
      • createModelBytesVector

        public static int createModelBytesVector​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                                 byte[] data)
      • createModelBytesVector

        public static int createModelBytesVector​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                                 java.nio.ByteBuffer data)
      • startModelBytesVector

        public static void startModelBytesVector​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                                 int numElems)
      • addMaxDbSizeInKbyte

        public static void addMaxDbSizeInKbyte​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                               long maxDbSizeInKbyte)
      • addFileMode

        public static void addFileMode​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                       long fileMode)
      • addMaxReaders

        public static void addMaxReaders​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                         long maxReaders)
      • addValidateOnOpenPages

        public static void addValidateOnOpenPages​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                                  int validateOnOpenPages)
      • addValidateOnOpenPageLimit

        public static void addValidateOnOpenPageLimit​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                                      long validateOnOpenPageLimit)
      • addPutPaddingMode

        public static void addPutPaddingMode​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                             int putPaddingMode)
      • addSkipReadSchema

        public static void addSkipReadSchema​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                             boolean skipReadSchema)
      • addUsePreviousCommit

        public static void addUsePreviousCommit​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                                boolean usePreviousCommit)
      • addUsePreviousCommitOnValidationFailure

        public static void addUsePreviousCommitOnValidationFailure​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                                                   boolean usePreviousCommitOnValidationFailure)
      • addReadOnly

        public static void addReadOnly​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                       boolean readOnly)
      • addDebugFlags

        public static void addDebugFlags​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                         long debugFlags)
      • addNoReaderThreadLocals

        public static void addNoReaderThreadLocals​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                                   boolean noReaderThreadLocals)
      • addMaxDataSizeInKbyte

        public static void addMaxDataSizeInKbyte​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                                 long maxDataSizeInKbyte)
      • addValidateOnOpenKv

        public static void addValidateOnOpenKv​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                               int validateOnOpenKv)
      • addBackupFile

        public static void addBackupFile​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                         int backupFileOffset)
      • addBackupRestoreFlags

        public static void addBackupRestoreFlags​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                                 long backupRestoreFlags)
      • endFlatStoreOptions

        public static int endFlatStoreOptions​(io.objectbox.flatbuffers.FlatBufferBuilder builder)
      • finishFlatStoreOptionsBuffer

        public static void finishFlatStoreOptionsBuffer​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                                        int offset)
      • finishSizePrefixedFlatStoreOptionsBuffer

        public static void finishSizePrefixedFlatStoreOptionsBuffer​(io.objectbox.flatbuffers.FlatBufferBuilder builder,
                                                                    int offset)