Skip to content

Commit 953655c

Browse files
committed
add FlatStoreOptions
1 parent 5235c6e commit 953655c

File tree

2 files changed

+215
-0
lines changed

2 files changed

+215
-0
lines changed
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
/*
2+
* Copyright 2020 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+
import java.nio.*;
22+
import java.lang.*;
23+
import java.util.*;
24+
import com.google.flatbuffers.*;
25+
26+
@SuppressWarnings("unused")
27+
/**
28+
* Options to open a store with. Set only the values you want; defaults are used otherwise.
29+
* Reminder: enable "force defaults" in the FlatBuffers builder, e.g. to pass in booleans with value "false".
30+
*/
31+
public final class FlatStoreOptions extends Table {
32+
public static void ValidateVersion() { Constants.FLATBUFFERS_1_12_0(); }
33+
public static FlatStoreOptions getRootAsFlatStoreOptions(ByteBuffer _bb) { return getRootAsFlatStoreOptions(_bb, new FlatStoreOptions()); }
34+
public static FlatStoreOptions getRootAsFlatStoreOptions(ByteBuffer _bb, FlatStoreOptions obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
35+
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
36+
public FlatStoreOptions __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
37+
38+
public String directoryPath() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
39+
public ByteBuffer directoryPathAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
40+
public ByteBuffer directoryPathInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
41+
public int modelBytes(int j) { int o = __offset(6); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; }
42+
public int modelBytesLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
43+
public ByteVector modelBytesVector() { return modelBytesVector(new ByteVector()); }
44+
public ByteVector modelBytesVector(ByteVector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
45+
public ByteBuffer modelBytesAsByteBuffer() { return __vector_as_bytebuffer(6, 1); }
46+
public ByteBuffer modelBytesInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 6, 1); }
47+
public long maxDbSizeInKByte() { int o = __offset(8); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
48+
public long fileMode() { int o = __offset(10); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0L; }
49+
/**
50+
* The maximum number of readers.
51+
* "Readers" are an finite resource for which we need to define a maximum number upfront.
52+
* The default value is enough for most apps and usually you can ignore it completely.
53+
* However, if you get the OBX_ERROR_MAX_READERS_EXCEEDED error, you should verify your
54+
* threading. For each thread, ObjectBox uses multiple readers. Their number (per thread) depends
55+
* on number of types, relations, and usage patterns. Thus, if you are working with many threads
56+
* (e.g. in a server-like scenario), it can make sense to increase the maximum number of readers.
57+
* Note: The internal default is currently around 120.
58+
* So when hitting this limit, try values around 200-500.
59+
*/
60+
public long maxReaders() { int o = __offset(12); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0L; }
61+
/**
62+
* When a database is opened, ObjectBox can perform additional consistency checks on its database structure.
63+
* Reliable file systems already guarantee consistency, so this is primarily meant to deal with unreliable
64+
* OSes, file systems, or hardware.
65+
* Note: ObjectBox builds upon ACID storage, which already has strong consistency mechanisms in place.
66+
*/
67+
public int validateOnOpen() { int o = __offset(14); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
68+
/**
69+
* To fine-tune database validation, you can specify a limit on how much data is looked at.
70+
* This is measured in "pages" with a page typically holding 4K.
71+
* Usually a low number (e.g. 1-20) is sufficient and does not impact startup performance significantly.
72+
* This is only to be used with ValidateOnOpenMode "Regular" and "WithLeaves".
73+
*/
74+
public long validateOnOpenPageLimit() { int o = __offset(16); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
75+
public int putPaddingMode() { int o = __offset(18); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
76+
public boolean readSchema() { int o = __offset(20); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
77+
/**
78+
* Recommended to be used together with read-only mode to ensure no data is lost.
79+
* Ignores the latest data snapshot (committed transaction state) and uses the previous snapshot instead.
80+
* When used with care (e.g. backup the DB files first), this option may also recover data removed by the latest
81+
* transaction.
82+
*/
83+
public boolean usePreviousCommit() { int o = __offset(22); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
84+
/**
85+
* If consistency checks fail during opening the DB (see also the pagesToValidateOnOpen setting), ObjectBox
86+
* automatically switches to the previous commit (see also usePreviousCommit). This way, this constitutes
87+
* an auto-recover mode from severe failures. HOWEVER, keep in mind that any consistency failure
88+
* is an indication that something is very wrong with OS/hardware and thus you should also check
89+
* openedWithPreviousCommit(), e.g. to alert your users.
90+
*/
91+
public boolean usePreviousCommitOnValidationFailure() { int o = __offset(24); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
92+
/**
93+
* Open store in read-only mode: no schema update, no write transactions.
94+
*/
95+
public boolean readOnly() { int o = __offset(26); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
96+
public long debugFlags() { int o = __offset(28); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0L; }
97+
98+
public static int createFlatStoreOptions(FlatBufferBuilder builder,
99+
int directoryPathOffset,
100+
int modelBytesOffset,
101+
long maxDbSizeInKByte,
102+
long fileMode,
103+
long maxReaders,
104+
int validateOnOpen,
105+
long validateOnOpenPageLimit,
106+
int putPaddingMode,
107+
boolean readSchema,
108+
boolean usePreviousCommit,
109+
boolean usePreviousCommitOnValidationFailure,
110+
boolean readOnly,
111+
long debugFlags) {
112+
builder.startTable(13);
113+
FlatStoreOptions.addValidateOnOpenPageLimit(builder, validateOnOpenPageLimit);
114+
FlatStoreOptions.addMaxDbSizeInKByte(builder, maxDbSizeInKByte);
115+
FlatStoreOptions.addDebugFlags(builder, debugFlags);
116+
FlatStoreOptions.addMaxReaders(builder, maxReaders);
117+
FlatStoreOptions.addFileMode(builder, fileMode);
118+
FlatStoreOptions.addModelBytes(builder, modelBytesOffset);
119+
FlatStoreOptions.addDirectoryPath(builder, directoryPathOffset);
120+
FlatStoreOptions.addPutPaddingMode(builder, putPaddingMode);
121+
FlatStoreOptions.addValidateOnOpen(builder, validateOnOpen);
122+
FlatStoreOptions.addReadOnly(builder, readOnly);
123+
FlatStoreOptions.addUsePreviousCommitOnValidationFailure(builder, usePreviousCommitOnValidationFailure);
124+
FlatStoreOptions.addUsePreviousCommit(builder, usePreviousCommit);
125+
FlatStoreOptions.addReadSchema(builder, readSchema);
126+
return FlatStoreOptions.endFlatStoreOptions(builder);
127+
}
128+
129+
public static void startFlatStoreOptions(FlatBufferBuilder builder) { builder.startTable(13); }
130+
public static void addDirectoryPath(FlatBufferBuilder builder, int directoryPathOffset) { builder.addOffset(0, directoryPathOffset, 0); }
131+
public static void addModelBytes(FlatBufferBuilder builder, int modelBytesOffset) { builder.addOffset(1, modelBytesOffset, 0); }
132+
public static int createModelBytesVector(FlatBufferBuilder builder, byte[] data) { return builder.createByteVector(data); }
133+
public static int createModelBytesVector(FlatBufferBuilder builder, ByteBuffer data) { return builder.createByteVector(data); }
134+
public static void startModelBytesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); }
135+
public static void addMaxDbSizeInKByte(FlatBufferBuilder builder, long maxDbSizeInKByte) { builder.addLong(2, maxDbSizeInKByte, 0L); }
136+
public static void addFileMode(FlatBufferBuilder builder, long fileMode) { builder.addInt(3, (int)fileMode, (int)0L); }
137+
public static void addMaxReaders(FlatBufferBuilder builder, long maxReaders) { builder.addInt(4, (int)maxReaders, (int)0L); }
138+
public static void addValidateOnOpen(FlatBufferBuilder builder, int validateOnOpen) { builder.addShort(5, (short)validateOnOpen, (short)0); }
139+
public static void addValidateOnOpenPageLimit(FlatBufferBuilder builder, long validateOnOpenPageLimit) { builder.addLong(6, validateOnOpenPageLimit, 0L); }
140+
public static void addPutPaddingMode(FlatBufferBuilder builder, int putPaddingMode) { builder.addShort(7, (short)putPaddingMode, (short)0); }
141+
public static void addReadSchema(FlatBufferBuilder builder, boolean readSchema) { builder.addBoolean(8, readSchema, false); }
142+
public static void addUsePreviousCommit(FlatBufferBuilder builder, boolean usePreviousCommit) { builder.addBoolean(9, usePreviousCommit, false); }
143+
public static void addUsePreviousCommitOnValidationFailure(FlatBufferBuilder builder, boolean usePreviousCommitOnValidationFailure) { builder.addBoolean(10, usePreviousCommitOnValidationFailure, false); }
144+
public static void addReadOnly(FlatBufferBuilder builder, boolean readOnly) { builder.addBoolean(11, readOnly, false); }
145+
public static void addDebugFlags(FlatBufferBuilder builder, long debugFlags) { builder.addInt(12, (int)debugFlags, (int)0L); }
146+
public static int endFlatStoreOptions(FlatBufferBuilder builder) {
147+
int o = builder.endTable();
148+
return o;
149+
}
150+
public static void finishFlatStoreOptionsBuffer(FlatBufferBuilder builder, int offset) { builder.finish(offset); }
151+
public static void finishSizePrefixedFlatStoreOptionsBuffer(FlatBufferBuilder builder, int offset) { builder.finishSizePrefixed(offset); }
152+
153+
public static final class Vector extends BaseVector {
154+
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
155+
156+
public FlatStoreOptions get(int j) { return get(new FlatStoreOptions(), j); }
157+
public FlatStoreOptions get(FlatStoreOptions obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
158+
}
159+
}
160+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2020 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+
* Defines if and how the database is checked for structural consistency when opening it.
23+
*/
24+
public final class ValidateOnOpenMode {
25+
private ValidateOnOpenMode() { }
26+
/**
27+
* Not a real type, just best practice (e.g. forward compatibility)
28+
*/
29+
public static final short Unknown = 0;
30+
/**
31+
* No additional checks are performed. This is fine if your file system is reliable (which it typically should be).
32+
*/
33+
public static final short None = 1;
34+
/**
35+
* Performs a limited number of checks on the most important database structures (e.g. "branch pages").
36+
*/
37+
public static final short Regular = 2;
38+
/**
39+
* Performs a limited number of checks on database structures including "data leaves".
40+
*/
41+
public static final short WithLeaves = 3;
42+
/**
43+
* Performs a unlimited number of checks on the most important database structures (e.g. "branch pages").
44+
*/
45+
public static final short AllBranches = 4;
46+
/**
47+
* Performs a unlimited number of checks on database structures including "data leaves".
48+
*/
49+
public static final short Full = 5;
50+
51+
public static final String[] names = { "Unknown", "None", "Regular", "WithLeaves", "AllBranches", "Full", };
52+
53+
public static String name(int e) { return names[e]; }
54+
}
55+

0 commit comments

Comments
 (0)