Skip to content

Commit 7179755

Browse files
committed
0.8.0
1 parent 64b9ce8 commit 7179755

File tree

4 files changed

+95
-29
lines changed

4 files changed

+95
-29
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
0.8.0 (2019-12-05)
2+
------------------
3+
* Property queries compute sums and averages more precisely (improved algorithms and wider types)
4+
* Property queries now consider unsigned types
5+
* Added an additional out parameter for count obx_query_prop_*()
6+
* Added put alternatives to "put" with cursor: obx_cursor_insert() and obx_cursor_update()
7+
* Added obx_query_clone() to allow clones to run in parallel on separate threads
8+
19
0.7.2 (2019-10-30)
210
------------------
311
* new obx_store_wrap() (use with Java version 2.4.1)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ ObjectBox C API
44
Using this C API, you can us ObjectBox as an embedded database in your C/C++ application.
55
In this embedded mode, it runs within your application process.
66

7-
**Latest version: 0.7.2** (2019-10-30). See [changelog](CHANGELOG.md) for more details.
7+
**Latest version: 0.8.0** (2019-12-05). See [changelog](CHANGELOG.md) for more details.
88

99
Some features
1010
-------------
1111
* ACID compliant object storage based on [FlatBuffers](https://google.github.io/flatbuffers/)
12-
* Lightweight for smart devices with less than 1 MB binary size
12+
* Lightweight for smart devices; its binary size is only around 1 MB
1313
(special feature reduced versions with 1/3 - 1/2 size are available on request)
1414
* Zero-copy reads
1515
* Secondary indexes based on object properties

doxygen/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "ObjectBox C API"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = "0.7.2"
41+
PROJECT_NUMBER = "0.8.0"
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

include/objectbox.h

Lines changed: 84 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ extern "C" {
3838
// ObjectBox version codes
3939
//----------------------------------------------
4040

41-
/// When using ObjectBox as a dynamic library, you should verify that a compatible version was linked using obx_version() or obx_version_is_at_least().
41+
/// When using ObjectBox as a dynamic library, you should verify that a compatible version was linked using
42+
/// obx_version() or obx_version_is_at_least().
4243
#define OBX_VERSION_MAJOR 0
43-
#define OBX_VERSION_MINOR 7
44-
#define OBX_VERSION_PATCH 2 // values >= 100 are reserved for dev releases leading to the next minor/major increase
44+
#define OBX_VERSION_MINOR 8
45+
#define OBX_VERSION_PATCH 0 // values >= 100 are reserved for dev releases leading to the next minor/major increase
4546

4647
/// Returns the version of the library as ints. Pointers may be null.
4748
void obx_version(int* major, int* minor, int* patch);
@@ -82,6 +83,7 @@ bool obx_supports_bytes_array(void);
8283
#define OBX_ERROR_ILLEGAL_STATE 10001
8384
#define OBX_ERROR_ILLEGAL_ARGUMENT 10002
8485
#define OBX_ERROR_ALLOCATION 10003
86+
#define OBX_ERROR_OVERFLOW 10004
8587
#define OBX_ERROR_NO_ERROR_INFO 10097
8688
#define OBX_ERROR_GENERAL 10098
8789
#define OBX_ERROR_UNKNOWN 10099
@@ -144,8 +146,8 @@ typedef bool obx_data_visitor(void* user_data, const void* data, size_t size);
144146

145147
/// Returns the error status on the current thread and clears the error state.
146148
/// The buffer returned in out_message is valid only until the next call into ObjectBox.
147-
/// @param out_error receives the error code; may be NULL
148-
/// @param out_message receives the pointer to the error messages; may be NULL
149+
/// @param out_error receives the error code; optional: may be NULL
150+
/// @param out_message receives the pointer to the error messages; optional: may be NULL
149151
/// @returns true if an error was pending
150152
bool obx_last_error_pop(obx_err* out_error, const char** out_message);
151153

@@ -175,14 +177,14 @@ void obx_last_error_clear(void);
175177
//----------------------------------------------
176178

177179
typedef enum {
178-
OBXPropertyType_Bool = 1, ///< 1 byte
179-
OBXPropertyType_Byte = 2, ///< 1 byte
180-
OBXPropertyType_Short = 3, ///< 2 bytes
181-
OBXPropertyType_Char = 4, ///< 1 byte
182-
OBXPropertyType_Int = 5, ///< 4 bytes
183-
OBXPropertyType_Long = 6, ///< 8 bytes
184-
OBXPropertyType_Float = 7, ///< 4 bytes
185-
OBXPropertyType_Double = 8, ///< 8 bytes
180+
OBXPropertyType_Bool = 1, ///< 1 byte
181+
OBXPropertyType_Byte = 2, ///< 1 byte
182+
OBXPropertyType_Short = 3, ///< 2 bytes
183+
OBXPropertyType_Char = 4, ///< 1 byte
184+
OBXPropertyType_Int = 5, ///< 4 bytes
185+
OBXPropertyType_Long = 6, ///< 8 bytes
186+
OBXPropertyType_Float = 7, ///< 4 bytes
187+
OBXPropertyType_Double = 8, ///< 8 bytes
186188
OBXPropertyType_String = 9,
187189
OBXPropertyType_Date = 10, ///< Unix timestamp (milliseconds since 1970) in 8 bytes
188190
OBXPropertyType_Relation = 11,
@@ -249,7 +251,8 @@ typedef struct OBX_model OBX_model;
249251
///
250252
/// For manual creation, these are the basic steps:
251253
/// - define entity types using obx_model_entity() and obx_model_property()
252-
/// - Pass the last ever used IDs with obx_model_last_entity_id(), obx_model_last_index_id(), obx_model_last_relation_id()
254+
/// - Pass the last ever used IDs with obx_model_last_entity_id(), obx_model_last_index_id(),
255+
/// obx_model_last_relation_id()
253256
/// @returns NULL if the operation failed, see functions like obx_last_error_code() to get error details.
254257
/// Note that obx_model_* functions handle OBX_model NULL pointers (will indicate an error but not crash).
255258
OBX_model* obx_model(void);
@@ -512,13 +515,33 @@ obx_err obx_cursor_close(OBX_cursor* cursor);
512515
/// @seealso obx_box_id_for_put()
513516
obx_id obx_cursor_id_for_put(OBX_cursor* cursor, obx_id id_or_zero);
514517

518+
/// ATTENTION: ensure that the given value memory is allocated to the next 4 bytes boundary.
519+
/// ObjectBox needs to store bytes with sizes divisible by 4 for internal reasons.
520+
/// Use obx_cursor_put_padded() otherwise.
521+
/// @param id non-zero
522+
obx_err obx_cursor_put_mode(OBX_cursor* cursor, obx_id id, const void* data, size_t size, OBXPutMode mode);
523+
515524
/// ATTENTION: ensure that the given value memory is allocated to the next 4 bytes boundary.
516525
/// ObjectBox needs to store bytes with sizes dividable by 4 for internal reasons.
517526
/// Use obx_cursor_put_padded() otherwise.
518527
/// @param id non-zero
519528
obx_err obx_cursor_put(OBX_cursor* cursor, obx_id id, const void* data, size_t size, bool checkForPreviousValue);
520529

521-
/// Prefer obx_cursor_put (non-padded) if possible, as this does a memcpy if the size is not dividable by 4.
530+
/// ATTENTION: ensure that the given value memory is allocated to the next 4 bytes boundary.
531+
/// ObjectBox needs to store bytes with sizes dividable by 4 for internal reasons.
532+
/// Use obx_cursor_put_padded() otherwise.
533+
/// @param id non-zero
534+
/// @returns OBX_ERROR_ID_ALREADY_EXISTS if an insert fails because of an colliding ID
535+
obx_err obx_cursor_insert(OBX_cursor* cursor, obx_id id, const void* data, size_t size);
536+
537+
/// ATTENTION: ensure that the given value memory is allocated to the next 4 bytes boundary.
538+
/// ObjectBox needs to store bytes with sizes dividable by 4 for internal reasons.
539+
/// Use obx_cursor_put_padded() otherwise.
540+
/// @param id non-zero
541+
/// @returns OBX_ERROR_ID_NOT_FOUND if an update fails because the given ID does not represent any object
542+
obx_err obx_cursor_update(OBX_cursor* cursor, obx_id id, const void* data, size_t size);
543+
544+
/// Prefer obx_cursor_put (non-padded) if possible, as this does a memcpy if the size is not divisible by 4.
522545
obx_err obx_cursor_put_padded(OBX_cursor* cursor, obx_id id, const void* data, size_t size, bool checkForPreviousValue);
523546

524547
obx_err obx_cursor_get(OBX_cursor* cursor, obx_id id, void** data, size_t* size);
@@ -643,11 +666,11 @@ obx_err obx_box_remove(OBX_box* box, obx_id id);
643666
/// Note that this method will not fail if the object is not found (e.g. already removed).
644667
/// In case you need to strictly check whether all of the objects exist before removing them,
645668
/// execute obx_box_contains_ids() and obx_box_remove_ids() inside a single write transaction.
646-
/// @param out_count Pointer to retrieve the number of removed objects; may be NULL.
669+
/// @param out_count Pointer to retrieve the number of removed objects; optional: may be NULL.
647670
obx_err obx_box_remove_many(OBX_box* box, const OBX_id_array* ids, uint64_t* out_count);
648671

649672
/// Remove all objects and set the out_count the the number of removed objects.
650-
/// @param out_count Pointer to retrieve the number of removed objects; may be NULL.
673+
/// @param out_count Pointer to retrieve the number of removed objects; optional: may be NULL.
651674
obx_err obx_box_remove_all(OBX_box* box, uint64_t* out_count);
652675

653676
/// Checks whether there are any objects for this entity and updates the out_is_empty accordingly
@@ -862,12 +885,14 @@ typedef struct OBX_query OBX_query;
862885
OBX_query* obx_query(OBX_query_builder* builder);
863886
obx_err obx_query_close(OBX_query* query);
864887

888+
/// Create a clone of the given query such that it can be run on a separate thread
889+
OBX_query* obx_query_clone(OBX_query* query);
890+
865891
/// Finds entities matching the query; NOTE: the returned data is only valid as long the transaction is active!
866892
OBX_bytes_array* obx_query_find(OBX_query* query, uint64_t offset, uint64_t limit);
867893

868894
/// Walks over matching objects using the given data visitor
869-
obx_err obx_query_visit(OBX_query* query, obx_data_visitor* visitor, void* user_data, uint64_t offset,
870-
uint64_t limit);
895+
obx_err obx_query_visit(OBX_query* query, obx_data_visitor* visitor, void* user_data, uint64_t offset, uint64_t limit);
871896

872897
/// Returns IDs of all matching objects
873898
OBX_id_array* obx_query_find_ids(OBX_query* query, uint64_t offset, uint64_t limit);
@@ -955,25 +980,58 @@ obx_err obx_query_prop_distinct_string(OBX_query_prop* query, bool distinct, boo
955980
obx_err obx_query_prop_count(OBX_query_prop* query, uint64_t* out_count);
956981

957982
/// Calculate an average value for the given numeric property across all objects matching the query
958-
obx_err obx_query_prop_avg(OBX_query_prop* query, double* out_average);
983+
/// @param query the query to run
984+
/// @param out_average the result of the query
985+
/// @param out_count (optional: may be NULL) number of entities contributing to the result
986+
obx_err obx_query_prop_avg(OBX_query_prop* query, double* out_average, uint64_t* out_count);
987+
988+
/// Calculate an average value for the given numeric property across all objects matching the query
989+
/// @param query the query to run
990+
/// @param out_average the result of the query
991+
/// @param out_count (optional: may be NULL) number of entities contributing to the result
992+
/// @returns OBX_ERROR_OVERFLOW if the result does not fit into an int64_t
993+
obx_err obx_query_prop_avg_int(OBX_query_prop* query, int64_t* out_average, uint64_t* out_count);
959994

960995
/// Find the minimum value of the given floating-point property across all objects matching the query
961-
obx_err obx_query_prop_min(OBX_query_prop* query, double* out_minimum);
996+
/// @param query the query to run
997+
/// @param out_minimum the result of the query
998+
/// @param out_count (optional: may be NULL) number of entities contributing to the result; in case an index is used,
999+
/// either 0 or 1 is returned, not the actual count of entities matching the query
1000+
obx_err obx_query_prop_min(OBX_query_prop* query, double* out_minimum, uint64_t* out_count);
9621001

9631002
/// Find the maximum value of the given floating-point property across all objects matching the query
964-
obx_err obx_query_prop_max(OBX_query_prop* query, double* out_maximum);
1003+
/// @param query the query to run
1004+
/// @param out_maximum the result of the query
1005+
/// @param out_count (optional: may be NULL) number of entities contributing to the result; in case an index is used,
1006+
/// either 0 or 1 is returned, not the actual count of entities matching the query
1007+
obx_err obx_query_prop_max(OBX_query_prop* query, double* out_maximum, uint64_t* out_count);
9651008

9661009
/// Calculate the sum of the given floating-point property across all objects matching the query
967-
obx_err obx_query_prop_sum(OBX_query_prop* query, double* out_sum);
1010+
/// @param query the query to run
1011+
/// @param out_sum the result of the query
1012+
/// @param out_count (optional: may be NULL) number of entities contributing to the result
1013+
obx_err obx_query_prop_sum(OBX_query_prop* query, double* out_sum, uint64_t* out_count);
9681014

9691015
/// Find the minimum value of the given property across all objects matching the query
970-
obx_err obx_query_prop_min_int(OBX_query_prop* query, int64_t* out_minimum);
1016+
/// @param query the query to run
1017+
/// @param out_minimum the result of the query
1018+
/// @param out_count (optional: may be NULL) number of entities contributing to the result; in case an index is used,
1019+
/// either 0 or 1 is returned, not the actual count of entities matching the query
1020+
obx_err obx_query_prop_min_int(OBX_query_prop* query, int64_t* out_minimum, uint64_t* out_count);
9711021

9721022
/// Find the maximum value of the given property across all objects matching the query
973-
obx_err obx_query_prop_max_int(OBX_query_prop* query, int64_t* out_maximum);
1023+
/// @param query the query to run
1024+
/// @param out_maximum the result of the query
1025+
/// @param out_count (optional: may be NULL) number of entities contributing to the result; in case an index is used,
1026+
/// either 0 or 1 is returned, not the actual count of entities matching the query
1027+
obx_err obx_query_prop_max_int(OBX_query_prop* query, int64_t* out_maximum, uint64_t* out_count);
9741028

9751029
/// Calculate the sum of the given property across all objects matching the query
976-
obx_err obx_query_prop_sum_int(OBX_query_prop* query, int64_t* out_sum);
1030+
/// @param query the query to run
1031+
/// @param out_sum the result of the query
1032+
/// @param out_count (optional: may be NULL) number of entities contributing to the result
1033+
/// @returns OBX_ERROR_OVERFLOW if the result does not fit into an int64_t
1034+
obx_err obx_query_prop_sum_int(OBX_query_prop* query, int64_t* out_sum, uint64_t* out_count);
9771035

9781036
/// Returns an array of strings stored as the given property across all objects matching the query
9791037
/// @param value_if_null value that should be used in place of NULL values on object fields;

0 commit comments

Comments
 (0)