Skip to content

Commit a4ca543

Browse files
greenrobotgitbook-bot
authored andcommitted
GITBOOK-105: Add missing return in main()
1 parent 26e2dfc commit a4ca543

16 files changed

+2195
-1
lines changed

.gitbook/assets/many-to-many.png

30.3 KB
Loading

README.md

Lines changed: 202 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,202 @@
1-
Dummy for GitBook Sync
1+
---
2+
description: >-
3+
This is the ObjectBox documentation for our C and C++ APIs. We strive to
4+
provide you with the easiest and fastest solution to store and retrieve data.
5+
---
6+
7+
# ObjectBox C / C++ Database
8+
9+
{% hint style="info" %}
10+
Jobs: We're looking for a [C++ Developer](https://objectbox.io/jobs/objectbox-senior-c-plusplus-developer/) with a ❤️ for performant code
11+
{% endhint %}
12+
13+
Are you ready use ObjectBox? These two pages will get you up to speed:
14+
15+
{% content-ref url="installation.md" %}
16+
[installation.md](installation.md)
17+
{% endcontent-ref %}
18+
19+
{% content-ref url="getting-started.md" %}
20+
[getting-started.md](getting-started.md)
21+
{% endcontent-ref %}
22+
23+
Alternatively, you can also dive into [some examples on GitHub](https://github.com/objectbox/objectbox-c/tree/main/examples) right away.
24+
25+
Your opinion matters to us! To make ObjectBox better for our users, we have set up an [Anonymous Feedback Form](https://forms.gle/bdktGBUmL4m48ruj7). Please do fill this in (it only takes 2 minutes). Every response is highly appreciated. To rate this documentation, you can use the "Was this page helpful?" smiley at the end of each page.
26+
27+
Otherwise, feel free to open an issue on [GitHub ](https://github.com/objectbox/objectbox-c/issues)or send us your comments to contact\[at]objectbox.io - Thank you! - and if you like what you see, we also appreciate a shoutout :) 
28+
29+
## Latest Versions (Changelogs)
30+
31+
<div align="left">
32+
33+
<img src="https://img.shields.io/github/v/release/objectbox/objectbox-c?style=for-the-badge" alt="">
34+
35+
</div>
36+
37+
### 4.0 (2024-11-11)
38+
39+
Note: 4.0.3 the first 4.0.x version working with ObjectBox Generator 4.0 and thus is the first full 4.0 release. For individual changes in the runtime library check the GitHub release notes: [4.0.0](https://github.com/objectbox/objectbox-c/releases/tag/v4.0.0), [4.0.1](https://github.com/objectbox/objectbox-c/releases/tag/v4.0.1) and [4.0.2](https://github.com/objectbox/objectbox-c/releases/tag/v4.0.2).
40+
41+
* CMake stubs to easily integrate with [ObjectBox Generator 4.0](https://github.com/objectbox/objectbox-generator/releases/tag/v4.0.0)
42+
* ObjectBox now supports vector search ("vector database") to enable efficient similarity searches.\
43+
This is particularly useful for AI/ML/RAG applications, e.g. image, audio, or text similarity.\
44+
Other use cases include semantic search or recommendation engines.\
45+
See [https://docs.objectbox.io/ann-vector-search](https://docs.objectbox.io/ann-vector-search) for details.
46+
* Adjusting the version number to match the core version (4.0); we will be aligning on major versions from now on.
47+
* Made closing the store more robust; e.g. it waits for ongoing queries and transactions to finish\
48+
(please still ensure to clean up properly on your side, this is an additional safety net)
49+
* Made Box API more robust when racing against store closing
50+
* Add "vectorsearch-cities" example
51+
52+
### 0.21.0 (2024-02-13)
53+
54+
* In-memory databases (simply provide a "memory:" prefixed "directory")
55+
56+
#### Sync:
57+
58+
* New client/server statistics API
59+
* New server API to enable authenticators
60+
* Sync server: support for sync permissions, blocks client updates with no write permission
61+
* Added sync-level login/write permissions for Admin Users DB and Web-UI
62+
* New authenticator "ObjectBox Admin" with support for authorization
63+
* New client API for username/password credentials
64+
* New client-side error listener API; initially reports "receive-only" downgrade due to no write permissions.
65+
66+
### 0.20.0 (2023-12-11)
67+
68+
* Added OBXFeature\_Backup to query for the feature's availability
69+
* Internal: added a DB store abstraction layer (another announcement about this will follow)
70+
* Tree API: fix for meta IDs vs. IDs
71+
* Various internal improvements
72+
73+
#### Sync
74+
75+
* Sync clients may now supply multiple URLs; for each connection attempt a random one is chosen. This allows for client-side load balancing and failover with an ObjectBox Sync cluster.
76+
77+
### 0.19.0 (2023-09-04)
78+
79+
* New K/V validation option on opening the store
80+
* Additions cursor API: get current ID, ID-based seeks (seek to first ID, seek to next ID)
81+
* Support scalar vector types with basic queries (APIs only, no generator support)
82+
* Various tree API improvements, e.g. introspection
83+
* Minor API clean up: e.g. using int types for bit flags not enums
84+
* Fixes query link condition in combination with some "or" conditions
85+
* Fixes query "less" condition for case-sensitive strings with value indexes (default is hashed index)
86+
* Updated Linux toolchain; now requires glibc 2.28 or higher (and GLIBCXX\_3.4.25); e.g. the following minium versions are fine: Debian Buster 10 (2019), Ubuntu 20.04, RHEL 8 (2019)
87+
* Various internal improvements
88+
* Sync: various additions and improvements (client and server)
89+
90+
### 0.18.1 (2023-01-30)
91+
92+
Recommended bugfix release; please update.
93+
94+
* Fixes "Could not put (-30786)", which may occur in some corner cases on some platforms.
95+
96+
### 0.18.0 (2022-10-31)
97+
98+
* Date properties can now be tagged as expiration time; which can be then be easily evicted
99+
* Tree API: various additions and improvements, e.g. OBXTreeOptionFlags to configure the tree behavior
100+
* New query condition to match objects that have a given number of relations
101+
* New "max data size" store setting
102+
* Enabled stricter compiler settings
103+
* Added stacktraces on errors (Linux only; very lightweight as it uses external addr2line or llvm-symbolizer)
104+
* Added log callback for most important logs
105+
* Consolidated "user data" passing as the last parameter
106+
* Various internal improvements
107+
108+
#### C++
109+
110+
* Added BoxTypeless, QueryBuilderBase and QueryBase: these can be used without generated code and template types.
111+
* New APIs to get the schema IDs for entity types and properties
112+
* Added two methods to Store to await asynchronous processing
113+
* Added "internal" namespace so that internal members do not spill into the obx namespace
114+
* Move more implementations to OBX\_CPP\_FILE
115+
116+
#### Sync
117+
118+
* Custom protocols for Sync: plugin your own messaging protocol, which ObjectBox Sync will run on
119+
* Improvements to run Sync Server with limited disk space (e.g. on small devices)
120+
* Tree Sync improvements; e.g. consolidate conflicts
121+
* WebSockets (sync protocol) is now a feature, which can be turned off (special build version)
122+
* Performance optimizations
123+
124+
### 0.17.0 (2022-06-15)
125+
126+
* Added a "weak store" API providing weak reference for stores (typically used by background threads)
127+
* Added Store ID API, e.g. getting a store by its ID
128+
* Various internal improvements including minor optimizations for binary size and performance
129+
130+
#### C++
131+
132+
* New "OBX\_CPP\_FILE" define to place declarations in a single .cpp/.cc file: improves compilation time and results
133+
* New "Exception" base class for all thrown exceptions
134+
* Various internal improvements, e.g. a "internal" namespace to better distinguish from userland API
135+
136+
### 0.16.0 (2022-05-06)
137+
138+
* Allow UTF-8 for database directories on Windows (available for other platforms before)
139+
* Various internal improvements
140+
141+
#### C++
142+
143+
* Promoted `Options` to a top level class, as nested classes cannot be declared forward
144+
* New `#define` to disable FlatBuffers includes to simplify new project setup
145+
* Rename `Exception` to `DbException`
146+
* Minor improvements
147+
148+
### V0.15.2 (2022-02-15)
149+
150+
* Add store cloning
151+
* Fix attaching to a reopened store
152+
153+
### V0.15.1 (2022-01-26)
154+
155+
* Fix non-unique indexes triggering unique constraint violations in corner cases (requires at least two unique constraints in an entity and a specific order; introduced in 0.15.0)
156+
* Admin UI now supports multiple sessions to the same host using different ports (session ID via HTTP request)
157+
* Minor performance improvements with hashed indexes
158+
159+
#### Sync
160+
161+
* Performance improvements for compression and decompression
162+
163+
### V0.15.0 (2021-12-09)
164+
165+
* New "Flex" data type that can contain data of various types like integers, floating points, strings, lists and maps
166+
* New query conditions for Flex lists to find a specific element
167+
* New query conditions for Flex maps to find elements with a specific key or key/value pair
168+
* New unique on-conflict strategy: replace conflicting objects (OBXPropertyFlags\_UNIQUE\_ON\_CONFLICT\_REPLACE)
169+
* New functions to attach to existing stores using only the file path (in the same process)
170+
* New APIs for ObjectBox Admin, the web based UI (formerly known as Object Browser): obx\_admin\_\*
171+
* Minor performance improvements for indexed access
172+
* Major performance improvements for tree/GraphQL queries
173+
* ARM binaries are now built for minimal size reducing the library size significantly
174+
* New "no\_reader\_thread\_locals" store option
175+
* Enable debug logging (requires a special build)
176+
* API: Type for query offsets and limits was changed from uint64\_t to size\_t
177+
* API: rarely used obx\_txn\_mark\_success() was removed; use obx\_txn\_success()
178+
* API: feature checks consolidated to only use obx\_has\_feature()
179+
* Many internal improvements
180+
* Core version 3.0.1-2021-12-09
181+
182+
#### Sync
183+
184+
* New API for embedded server mode: obx\_sync\_server\_\* (implementation available on request)
185+
186+
### Earlier Versions
187+
188+
The changelogs of earlier versions are available as part of the [GitHub releases](https://github.com/objectbox/objectbox-c/releases).
189+
190+
Provides native dynamic/shared library (.so/.dylib/.dll)
191+
192+
* Provides C & C++ headers (objectbox.h & objectbox.hpp)
193+
194+
## ObjectBox Generator
195+
196+
<div align="left">
197+
198+
<img src="https://img.shields.io/github/v/release/objectbox/objectbox-generator?style=for-the-badge" alt="">
199+
200+
</div>
201+
202+
Check the [ObjectBox Generator](https://github.com/objectbox/objectbox-generator/releases) releases for details.

SUMMARY.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Table of contents
2+
3+
* [ObjectBox C / C++ Database](README.md)
4+
* [Installation](installation.md)
5+
* [How to get started](getting-started.md)
6+
* [Entity Annotations](entity-annotations.md)
7+
* [Generator](generator.md)
8+
* [Store](store.md)
9+
* [Queries](queries.md)
10+
* [Relations](relations.md)
11+
* [Transactions](transactions.md)
12+
* [Schema Changes](schema-changes.md)
13+
* [Time Series Data](time-series-data.md)
14+
* [Dev Tools and Debugging](dev-tools-and-debugging.md)
15+
* [FAQ](faq.md)
16+
* [GitHub](https://github.com/objectbox/objectbox-c)
17+
* [ObjectBox Generator](https://github.com/objectbox/objectbox-generator)
18+
* [C API docs](https://objectbox.io/docfiles/c/current/)
19+
* [Golang Database](https://golang.objectbox.io/)
20+
* [Swift Database](https://swift.objectbox.io/)
21+
* [Java Database](https://docs.objectbox.io/)

dev-tools-and-debugging.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
description: >-
3+
ObjectBox has tools that help during development. Learn more about looking at
4+
data inside the database and how to enable debug logs for additional
5+
information.
6+
---
7+
8+
# Dev Tools and Debugging
9+
10+
## Database Viewer
11+
12+
[ObjectBox Admin](https://docs.objectbox.io/data-browser) is a web-app that can be used to view inside the ObjectBox database. Since it is available as a Docker container with a developer-friendly front-end script you can use it right from a developer console to get insights into your database.\
13+
\
14+
Example: Using just "docker" to run ObjectBox Admin on a database on path `./myapp` : &#x20;
15+
16+
```shell-session
17+
$ docker run --rm -it --volume ./myapp:/db -u $(id -u) -p 8081:8081 objectboxio/admin:latest
18+
Starting server on http://0.0.0.0:8081
19+
001-10:37:02.7767 [INFO ] [SvHttp] Running in single-store mode, store path: /db
20+
001-10:37:02.7767 [INFO ] [SvHttp] Listening on http://0.0.0.0:8081
21+
001-10:37:02.7767 [INFO ] [SvHttp] User management: enabled
22+
001-10:37:02.7771 [INFO ] [SvHttp] HttpServer listening on all interfaces, port 8081
23+
```
24+
25+
Opening the URL `http://localhost:8081` with your browser will open the ObjectBox Admin UI:
26+
27+
<figure><img src="https://2056134408-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LETufmyus5LFkviJjr4%2Fuploads%2F4l4B1wXLIHFxdoxtBEAn%2Fadmin-data.png?alt=media&#x26;token=b2faf98f-75a0-448b-8154-4cefcdcaa05f" alt=""><figcaption></figcaption></figure>
28+
29+
{% hint style="info" %}
30+
See [ObjectBox Admin](https://docs.objectbox.io/data-browser) Documentation for further details and to download developer-friendly front-end launcher shell script.
31+
{% endhint %}
32+
33+
## Logging
34+
35+
ObjectBox includes a logging facility for tracing, amongst others, transaction operations. \
36+
The following C++ code below gives an example how to enable logging for transactions at the info level.
37+
38+
```cpp
39+
obx::Options options(create_obx_model());
40+
options.addDebugFlags(
41+
OBXDebugFlags_LOG_TRANSACTIONS_READ
42+
| OBXDebugFlags_LOG_TRANSACTIONS_WRITE
43+
);
44+
45+
obx::Store store(options);
46+
```
47+
48+
A sample output of the debug log is given below:
49+
50+
```sh
51+
$ ./build/myapp
52+
[..]
53+
001-10:23:41.6403 [INFO ] TX #4 (read)
54+
001-10:23:41.6403 [INFO ] TX #4 to be destroyed on owner thread (last committed: TX #2)...
55+
001-10:23:41.6403 [INFO ] TX #4 destroyed
56+
001-10:23:41.6403 [INFO ] TX #5 (write)
57+
001-10:23:41.6403 [INFO ] TX #5 committing...
58+
001-10:23:41.6546 [INFO ] TX #5 to be destroyed on owner thread (last committed: TX #5)...
59+
001-10:23:41.6546 [INFO ] TX #5 destroyed
60+
[..]
61+
```
62+
63+
{% hint style="info" %}
64+
See [C API Documentation of OBXDebugFlag](https://objectbox.io/docfiles/c/current/group\_\_c.html#gade842fb1271541e05f848925f32efa9d) for a list of available debug flags.&#x20;
65+
{% endhint %}
66+
67+
{% hint style="info" %}
68+
ObjectBox also offers a **DebugLog** which gives insights at a very detail level. This is typically not used by an application end-user but might be helpful when things go wrong or when developing improvements, enhancements and features. \
69+
\
70+
This feature is not available in the public release but on request.
71+
{% endhint %}
72+

entity-annotations.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
description: >-
3+
ObjectBox database persistence for C and C++ is based on objects. Learn how to
4+
persist entities with entity annotations in this tutorial section.
5+
---
6+
7+
# Entity Annotations
8+
9+
The source FlatBuffer schema can contain some ObjectBox-specific annotations, declared as specially formatted comments to `table` and `field` FlatBuffer schema elements.&#x20;
10+
11+
## Annotated schema example
12+
13+
Have a look at the following FlatBuffers schema example showing some ObjectBox annotations:
14+
15+
{% code title="schema.fbs" %}
16+
```
17+
/// This entity is not annotated and serves as a relation target in this example
18+
table Simple {
19+
id:ulong;
20+
}
21+
22+
/// objectbox: name=AnnotatedEntity
23+
table Annotated {
24+
/// Objectbox requires an ID property. Recognized automatically
25+
/// if it has a right name ("id"), otherwise it must be annotated.
26+
/// objectbox:id
27+
identifier:ulong;
28+
29+
/// objectbox:name="name",index=hash64
30+
fullName:string;
31+
32+
/// objectbox:id-companion, date
33+
time:int64;
34+
35+
/// objectbox:transient
36+
skippedField:[uint64];
37+
38+
/// objectbox:relation=Simple
39+
relId:ulong;
40+
}
41+
42+
/// This entity is synchronized between clients.
43+
/// Requires ObjectBox Sync (see below and https://objectbox.io/sync/)
44+
/// objectbox:sync
45+
table SharedInfo {
46+
id:ulong;
47+
48+
...
49+
}
50+
```
51+
{% endcode %}
52+
53+
## Annotation format
54+
55+
To ensure that the annotations are recognized, follow these guidelines:
56+
57+
* Must be a comment immediately preceding an Entity or a Property (no empty lines between them).
58+
* The comment must start with three slashes so it's picked up by FlatBuffer schema parser as a "documentation".
59+
* Spaces between words inside the comment are skipped so you can use them for better readability if you like. See e.g. `Annotated`, `time`.
60+
* The comment must start with the text `objectbox:` and is followed by one or more annotations, separated by commas.
61+
* Each annotation has a name and some annotations also support specifying a value (some even require a value, e.g. the `name` annotation). See e.g. `Annotated`, `relId`.
62+
* Value, if present, is added to the annotation by adding an equal sign and the actual value.
63+
* A value may additionally be surrounded by double quotes but it's not necessary. See e.g. `fullName` showing both variants.
64+
65+
## Supported annotations
66+
67+
The following annotations are currently supported:
68+
69+
### **Entity annotations**
70+
71+
* **name** - specifies the name to use in the database if it's desired to be different than what the FlatBuffer schema "table" is called.
72+
* **transient** - this entity is skipped, no code is generated for it. Useful if you have custom FlatBuffer handling but still want to generate ObjectBox binding code for some parts of the same file.
73+
* **uid** - used to explicitly specify UID used with this entity; used when renaming entities. See [Schema changes](schema-changes.md) for more details.
74+
* **relation** - adds a standalone (many-to-many) relation, usually to another entity. Example: creating a relation to the authors of a book: `objectbox:relation(name=authors,to=Author)`
75+
* **sync** - enables synchronization for the entity - only relevant with [ObjectBox Sync](https://objectbox.io/sync/) library builds. Entities not marked with this annotation will not be synchronized to the server, i.e. they're local-only.
76+
* `sync(sharedGlobalIds)` can be used to switch from the default behaviour (ID-mapping) to using a global ID space. This flag tells ObjectBox to treat object IDs globally and thus no ID mapping (local <-> global) is performed. Often this is used with `id(assignable)` annotation and some special ID scheme.
77+
78+
### **Property annotations**
79+
80+
* **date** - tells ObjectBox the property is a timestamp in milliseconds, ObjectBox expects the value to be the number of milliseconds since UNIX epoch.
81+
* **date-nano** - tells ObjectBox the property is a timestamp in nanoseconds, ObjectBox expects the value to be the number of nanoseconds since UNIX epoch.
82+
* **id** - specifies this property is a unique identifier of the object - used for all CRUD operations.
83+
* assignable IDs (set as `id(assignable)`) to switch from the default (ObjectBox assigns object IDs during insert, following auto-increment order). This will allow putting an object with any valid ID. You can still set the ID to zero to let ObjectBox auto-assign a new ID.
84+
* **id-companion** - identifies a companion property, currently only supported on `date/date-nano` properties in time-series databases.
85+
* **index** - creates a database index. This can improve performance when querying for that property. You can specify an index type as the annotation value:
86+
* not specified - automatically choose the index type based on the property type (`hash` for string, `value` for others).
87+
* `value` - uses property values to build the index. For string, this may require more storage than a hash-based index.
88+
* `hash` - uses a 32-bit hash of property value to build the index. Occasional collisions may occur which should not have any performance impact in practice (with normal value distribution). Usually, a better choice than `hash64`, as it requires less storage.
89+
* `hash64` - uses a long hash of property values to build the index. Requires more storage than `hash` and thus should not be the first choice in most cases.
90+
* **relation** - declares the field as a relation ID, linking to another Entity which must be specified as a value of this annotation.
91+
* **name** - specifies the name to use in the database if it's desired to be different than what the FlatBuffer schema "field" is called.
92+
* **transient** - this property is skipped, no code is generated for it. Useful if you have custom FlatBuffer handling but still want to generate ObjectBox binding code for the entity.
93+
* **uid** - used to explicitly specify UID used with this property; used when renaming properties. See [Schema changes](schema-changes.md) for more details.
94+
* **unique** - set to enforce that values are unique before an entity is inserted/updated. A `put` operation will abort and return an error if the unique constraint is violated.

0 commit comments

Comments
 (0)