Skip to content

Commit b568219

Browse files
greenrobotgreenrobot-team
authored andcommitted
External type: update FlatBuffers generated code objectbox-java#239
Also adds a new DebugFlag value.
1 parent b5bd9e4 commit b568219

File tree

5 files changed

+184
-19
lines changed

5 files changed

+184
-19
lines changed

objectbox-java/src/main/java/io/objectbox/config/DebugFlags.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 ObjectBox Ltd. All rights reserved.
2+
* Copyright 2025 ObjectBox Ltd. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,5 +43,9 @@ private DebugFlags() { }
4343
* Run a quick self-test to verify basic threading; somewhat paranoia to check the platform and the library setup.
4444
*/
4545
public static final int RUN_THREADING_SELF_TEST = 512;
46+
/**
47+
* Enables debug logs for write-ahead logging
48+
*/
49+
public static final int LOG_WAL = 1024;
4650
}
4751

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*
2+
* Copyright 2025 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+
* A property type of an external system (e.g. another database) that has no default mapping to an ObjectBox type.
23+
* External property types numeric values start at 100 to avoid overlaps with ObjectBox's PropertyType.
24+
* (And if we ever support one of these as a primary type, we could share the numeric value?)
25+
*/
26+
@SuppressWarnings("unused")
27+
public final class ExternalPropertyType {
28+
private ExternalPropertyType() { }
29+
/**
30+
* Not a real type: represents uninitialized state and can be used for forward compatibility.
31+
*/
32+
public static final short Unknown = 0;
33+
/**
34+
* Representing type: ByteVector
35+
* Encoding: 1:1 binary representation, little endian (16 bytes)
36+
*/
37+
public static final short Int128 = 100;
38+
public static final short Reserved1 = 101;
39+
/**
40+
* Representing type: ByteVector
41+
* Encoding: 1:1 binary representation (16 bytes)
42+
*/
43+
public static final short Uuid = 102;
44+
/**
45+
* IEEE 754 decimal128 type, e.g. supported by MongoDB
46+
* Representing type: ByteVector
47+
* Encoding: 1:1 binary representation (16 bytes)
48+
*/
49+
public static final short Decimal128 = 103;
50+
public static final short Reserved2 = 104;
51+
public static final short Reserved3 = 105;
52+
public static final short Reserved4 = 106;
53+
/**
54+
* A key/value map; e.g. corresponds to a JSON object or a MongoDB document (although not keeping the key order).
55+
* Unlike the Flex type, this must contain a map value (e.g. not a vector or a scalar).
56+
* Representing type: Flex
57+
* Encoding: Flex
58+
*/
59+
public static final short FlexMap = 107;
60+
/**
61+
* A vector (aka list or array) of flexible elements; e.g. corresponds to a JSON array or a MongoDB array.
62+
* Unlike the Flex type, this must contain a vector value (e.g. not a map or a scalar).
63+
* Representing type: Flex
64+
* Encoding: Flex
65+
*/
66+
public static final short FlexVector = 108;
67+
/**
68+
* Placeholder (not yet used) for a JSON document.
69+
* Representing type: String
70+
*/
71+
public static final short Json = 109;
72+
/**
73+
* Placeholder (not yet used) for a BSON document.
74+
* Representing type: ByteVector
75+
*/
76+
public static final short Bson = 110;
77+
/**
78+
* JavaScript source code
79+
* Representing type: String
80+
*/
81+
public static final short JavaScript = 111;
82+
public static final short Reserved5 = 112;
83+
public static final short Reserved6 = 113;
84+
public static final short Reserved7 = 114;
85+
public static final short Reserved8 = 115;
86+
/**
87+
* A vector (array) of Int128 values
88+
*/
89+
public static final short Int128Vector = 116;
90+
public static final short Reserved9 = 117;
91+
/**
92+
* A vector (array) of Int128 values
93+
*/
94+
public static final short UuidVector = 118;
95+
public static final short Reserved10 = 119;
96+
public static final short Reserved11 = 120;
97+
public static final short Reserved12 = 121;
98+
public static final short Reserved13 = 122;
99+
/**
100+
* The 12-byte ObjectId type in MongoDB
101+
* Representing type: ByteVector
102+
* Encoding: 1:1 binary representation (12 bytes)
103+
*/
104+
public static final short MongoId = 123;
105+
/**
106+
* A vector (array) of MongoId values
107+
*/
108+
public static final short MongoIdVector = 124;
109+
/**
110+
* Representing type: Long
111+
* Encoding: Two unsigned 32-bit integers merged into a 64-bit integer.
112+
*/
113+
public static final short MongoTimestamp = 125;
114+
/**
115+
* Representing type: ByteVector
116+
* Encoding: 3 zero bytes (reserved, functions as padding), fourth byte is the sub-type,
117+
* followed by the binary data.
118+
*/
119+
public static final short MongoBinary = 126;
120+
/**
121+
* Representing type: string vector with 2 elements (index 0: pattern, index 1: options)
122+
* Encoding: 1:1 string representation
123+
*/
124+
public static final short MongoRegex = 127;
125+
126+
public static final String[] names = { "Unknown", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Int128", "Reserved1", "Uuid", "Decimal128", "Reserved2", "Reserved3", "Reserved4", "FlexMap", "FlexVector", "Json", "Bson", "JavaScript", "Reserved5", "Reserved6", "Reserved7", "Reserved8", "Int128Vector", "Reserved9", "UuidVector", "Reserved10", "Reserved11", "Reserved12", "Reserved13", "MongoId", "MongoIdVector", "MongoTimestamp", "MongoBinary", "MongoRegex", };
127+
128+
public static String name(int e) { return names[e]; }
129+
}
130+

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 ObjectBox Ltd. All rights reserved.
2+
* Copyright 2025 ObjectBox Ltd. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,6 +35,9 @@
3535
import java.nio.ByteBuffer;
3636
import java.nio.ByteOrder;
3737

38+
/**
39+
* The type/class of an entity object.
40+
*/
3841
@SuppressWarnings("unused")
3942
public final class ModelEntity extends Table {
4043
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
@@ -70,8 +73,14 @@ public final class ModelEntity extends Table {
7073
public String nameSecondary() { int o = __offset(16); return o != 0 ? __string(o + bb_pos) : null; }
7174
public ByteBuffer nameSecondaryAsByteBuffer() { return __vector_as_bytebuffer(16, 1); }
7275
public ByteBuffer nameSecondaryInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 16, 1); }
76+
/**
77+
* Optional name used in an external system, e.g. another database that ObjectBox syncs with.
78+
*/
79+
public String externalName() { int o = __offset(18); return o != 0 ? __string(o + bb_pos) : null; }
80+
public ByteBuffer externalNameAsByteBuffer() { return __vector_as_bytebuffer(18, 1); }
81+
public ByteBuffer externalNameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 18, 1); }
7382

74-
public static void startModelEntity(FlatBufferBuilder builder) { builder.startTable(7); }
83+
public static void startModelEntity(FlatBufferBuilder builder) { builder.startTable(8); }
7584
public static void addId(FlatBufferBuilder builder, int idOffset) { builder.addStruct(0, idOffset, 0); }
7685
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(1, nameOffset, 0); }
7786
public static void addProperties(FlatBufferBuilder builder, int propertiesOffset) { builder.addOffset(2, propertiesOffset, 0); }
@@ -83,6 +92,7 @@ public final class ModelEntity extends Table {
8392
public static void startRelationsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
8493
public static void addFlags(FlatBufferBuilder builder, long flags) { builder.addInt(5, (int) flags, (int) 0L); }
8594
public static void addNameSecondary(FlatBufferBuilder builder, int nameSecondaryOffset) { builder.addOffset(6, nameSecondaryOffset, 0); }
95+
public static void addExternalName(FlatBufferBuilder builder, int externalNameOffset) { builder.addOffset(7, externalNameOffset, 0); }
8696
public static int endModelEntity(FlatBufferBuilder builder) {
8797
int o = builder.endTable();
8898
return o;

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 ObjectBox Ltd. All rights reserved.
2+
* Copyright 2025 ObjectBox Ltd. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -90,8 +90,19 @@ public final class ModelProperty extends Table {
9090
*/
9191
public io.objectbox.model.HnswParams hnswParams() { return hnswParams(new io.objectbox.model.HnswParams()); }
9292
public io.objectbox.model.HnswParams hnswParams(io.objectbox.model.HnswParams obj) { int o = __offset(22); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
93+
/**
94+
* Optional type used in an external system, e.g. another database that ObjectBox syncs with.
95+
* Note that the supported mappings from ObjectBox types to external types are limited.
96+
*/
97+
public int externalType() { int o = __offset(24); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
98+
/**
99+
* Optional name used in an external system, e.g. another database that ObjectBox syncs with.
100+
*/
101+
public String externalName() { int o = __offset(26); return o != 0 ? __string(o + bb_pos) : null; }
102+
public ByteBuffer externalNameAsByteBuffer() { return __vector_as_bytebuffer(26, 1); }
103+
public ByteBuffer externalNameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 26, 1); }
93104

94-
public static void startModelProperty(FlatBufferBuilder builder) { builder.startTable(10); }
105+
public static void startModelProperty(FlatBufferBuilder builder) { builder.startTable(12); }
95106
public static void addId(FlatBufferBuilder builder, int idOffset) { builder.addStruct(0, idOffset, 0); }
96107
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(1, nameOffset, 0); }
97108
public static void addType(FlatBufferBuilder builder, int type) { builder.addShort(2, (short) type, (short) 0); }
@@ -102,6 +113,8 @@ public final class ModelProperty extends Table {
102113
public static void addNameSecondary(FlatBufferBuilder builder, int nameSecondaryOffset) { builder.addOffset(7, nameSecondaryOffset, 0); }
103114
public static void addMaxIndexValueLength(FlatBufferBuilder builder, long maxIndexValueLength) { builder.addInt(8, (int) maxIndexValueLength, (int) 0L); }
104115
public static void addHnswParams(FlatBufferBuilder builder, int hnswParamsOffset) { builder.addOffset(9, hnswParamsOffset, 0); }
116+
public static void addExternalType(FlatBufferBuilder builder, int externalType) { builder.addShort(10, (short) externalType, (short) 0); }
117+
public static void addExternalName(FlatBufferBuilder builder, int externalNameOffset) { builder.addOffset(11, externalNameOffset, 0); }
105118
public static int endModelProperty(FlatBufferBuilder builder) {
106119
int o = builder.endTable();
107120
return o;

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

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 ObjectBox Ltd. All rights reserved.
2+
* Copyright 2025 ObjectBox Ltd. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,23 +18,17 @@
1818

1919
package io.objectbox.model;
2020

21+
import java.nio.ByteBuffer;
22+
import java.nio.ByteOrder;
23+
2124
import io.objectbox.flatbuffers.BaseVector;
22-
import io.objectbox.flatbuffers.BooleanVector;
23-
import io.objectbox.flatbuffers.ByteVector;
2425
import io.objectbox.flatbuffers.Constants;
25-
import io.objectbox.flatbuffers.DoubleVector;
2626
import io.objectbox.flatbuffers.FlatBufferBuilder;
27-
import io.objectbox.flatbuffers.FloatVector;
28-
import io.objectbox.flatbuffers.IntVector;
29-
import io.objectbox.flatbuffers.LongVector;
30-
import io.objectbox.flatbuffers.ShortVector;
31-
import io.objectbox.flatbuffers.StringVector;
32-
import io.objectbox.flatbuffers.Struct;
3327
import io.objectbox.flatbuffers.Table;
34-
import io.objectbox.flatbuffers.UnionVector;
35-
import java.nio.ByteBuffer;
36-
import java.nio.ByteOrder;
3728

29+
/**
30+
* A many-to-many relation between two entity types.
31+
*/
3832
@SuppressWarnings("unused")
3933
public final class ModelRelation extends Table {
4034
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
@@ -50,11 +44,25 @@ public final class ModelRelation extends Table {
5044
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 6, 1); }
5145
public io.objectbox.model.IdUid targetEntityId() { return targetEntityId(new io.objectbox.model.IdUid()); }
5246
public io.objectbox.model.IdUid targetEntityId(io.objectbox.model.IdUid obj) { int o = __offset(8); return o != 0 ? obj.__assign(o + bb_pos, bb) : null; }
47+
/**
48+
* Optional type used in an external system, e.g. another database that ObjectBox syncs with.
49+
* Note that the supported mappings from ObjectBox types to external types are limited.
50+
* Here, external relation types must be vectors, i.e. a list of IDs.
51+
*/
52+
public int externalType() { int o = __offset(10); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
53+
/**
54+
* Optional name used in an external system, e.g. another database that ObjectBox syncs with.
55+
*/
56+
public String externalName() { int o = __offset(12); return o != 0 ? __string(o + bb_pos) : null; }
57+
public ByteBuffer externalNameAsByteBuffer() { return __vector_as_bytebuffer(12, 1); }
58+
public ByteBuffer externalNameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 12, 1); }
5359

54-
public static void startModelRelation(FlatBufferBuilder builder) { builder.startTable(3); }
60+
public static void startModelRelation(FlatBufferBuilder builder) { builder.startTable(5); }
5561
public static void addId(FlatBufferBuilder builder, int idOffset) { builder.addStruct(0, idOffset, 0); }
5662
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(1, nameOffset, 0); }
5763
public static void addTargetEntityId(FlatBufferBuilder builder, int targetEntityIdOffset) { builder.addStruct(2, targetEntityIdOffset, 0); }
64+
public static void addExternalType(FlatBufferBuilder builder, int externalType) { builder.addShort(3, (short) externalType, (short) 0); }
65+
public static void addExternalName(FlatBufferBuilder builder, int externalNameOffset) { builder.addOffset(4, externalNameOffset, 0); }
5866
public static int endModelRelation(FlatBufferBuilder builder) {
5967
int o = builder.endTable();
6068
return o;

0 commit comments

Comments
 (0)