-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathc.py
More file actions
1070 lines (779 loc) · 48.4 KB
/
Copy pathc.py
File metadata and controls
1070 lines (779 loc) · 48.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright 2019-2024 ObjectBox Ltd. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import ctypes.util
import os
import platform
from objectbox.version import Version
from typing import *
import numpy as np
from enum import IntEnum
# This file contains C-API bindings based on lib/objectbox.h, linking to the 'objectbox' shared library.
# The bindings are implementing using ctypes, see https://docs.python.org/dev/library/ctypes.html for introduction.
# Version of the library used by the binding. This version is checked at runtime to ensure binary compatibility.
# Don't forget to update download-c-lib.py when upgrading to a newer version.
required_version = "4.0.0"
def shlib_name(library: str) -> str:
"""Returns the platform-specific name of the shared library"""
if platform.system() == 'Linux':
return 'lib' + library + '.so'
elif platform.system() == 'Windows':
return library + '.dll'
elif platform.system() == 'Darwin':
return 'lib' + library + '.dylib'
else:
assert False, 'Unsupported platform: ' + platform.system()
# initialize the C library
lib_path = os.path.dirname(os.path.realpath(__file__))
lib_path = os.path.join(lib_path, 'lib',
platform.machine() if platform.system() != 'Darwin' else 'macos-universal',
shlib_name('objectbox'))
C = ctypes.CDLL(lib_path)
# load the core library version
__major = ctypes.c_int(0)
__minor = ctypes.c_int(0)
__patch = ctypes.c_int(0)
C.obx_version(ctypes.byref(__major), ctypes.byref(
__minor), ctypes.byref(__patch))
# C-api (core library) version
version_core = Version(__major.value, __minor.value, __patch.value)
assert str(version_core) == required_version, \
"Incorrect ObjectBox version loaded: %s instead of expected %s " % (
str(version_core), required_version)
# define some basic types
obx_err = ctypes.c_int
obx_schema_id = ctypes.c_uint32
obx_uid = ctypes.c_uint64
obx_id = ctypes.c_uint64
obx_qb_cond = ctypes.c_int
obx_qb_cond_p = ctypes.POINTER(obx_qb_cond)
# enums
OBXPropertyType = ctypes.c_int
OBXPropertyFlags = ctypes.c_int
OBXDebugFlags = ctypes.c_int
OBXPutMode = ctypes.c_int
OBXPutPaddingMode = ctypes.c_int
OBXOrderFlags = ctypes.c_int
OBXHnswFlags = ctypes.c_int
OBXVectorDistanceType = ctypes.c_int
OBXValidateOnOpenPagesFlags = ctypes.c_int
OBXValidateOnOpenKvFlags = ctypes.c_int
OBXBackupRestoreFlags = ctypes.c_int
OBXLogLevel = ctypes.c_int
from enum import IntEnum
class LogLevel(IntEnum):
Verbose = 10
Debug = 20
Info = 30
Warn = 40
Error = 50
class DebugFlags(IntEnum):
"""Debug flags"""
NONE = 0,
LOG_TRANSACTIONS_READ = 1,
""" Log read transactions """
LOG_TRANSACTIONS_WRITE = 2,
""" Log write transactions """
LOG_QUERIES = 3,
""" Log queries """
LOG_QUERY_PARAMETERS = 8,
""" Log query parameters """
LOG_ASYNC_QUEUE = 16,
""" Log async queue """
LOG_CACHE_HITS = 32,
""" Log cache hits """
LOG_CACHE_ALL = 64,
""" Log cache hits """
LOG_TREE = 128
""" Log tree operations """
class OBX_model(ctypes.Structure):
pass
OBX_model_p = ctypes.POINTER(OBX_model)
class OBX_store(ctypes.Structure):
pass
OBX_store_p = ctypes.POINTER(OBX_store)
class OBX_store_options(ctypes.Structure):
pass
OBX_store_options_p = ctypes.POINTER(OBX_store_options)
class OBX_bytes(ctypes.Structure):
_fields_ = [
('data', ctypes.c_void_p),
('size', ctypes.c_size_t),
]
OBX_bytes_p = ctypes.POINTER(OBX_bytes)
class OBX_bytes_array(ctypes.Structure):
_fields_ = [
('data', OBX_bytes_p),
('count', ctypes.c_size_t),
]
OBX_bytes_array_p = ctypes.POINTER(OBX_bytes_array)
class OBX_bytes_score(ctypes.Structure):
_fields_ = [
('data', ctypes.c_void_p),
('size', ctypes.c_size_t),
('score', ctypes.c_double),
]
OBX_bytes_score_p = ctypes.POINTER(OBX_bytes_score)
class OBX_bytes_score_array(ctypes.Structure):
_fields_ = [
('bytes_scores', OBX_bytes_score_p),
('count', ctypes.c_size_t),
]
OBX_bytes_score_array_p = ctypes.POINTER(OBX_bytes_score_array)
class OBX_id_array(ctypes.Structure):
_fields_ = [
('ids', ctypes.POINTER(obx_id)),
('count', ctypes.c_size_t),
]
OBX_id_array_p = ctypes.POINTER(OBX_id_array)
class OBX_id_score(ctypes.Structure):
_fields_ = [
('id', obx_id),
('score', ctypes.c_double)
]
OBX_id_score_p = ctypes.POINTER(OBX_id_score)
class OBX_id_score_array(ctypes.Structure):
_fields_ = [
('ids_scores', OBX_id_score_p),
('count', ctypes.c_size_t)
]
OBX_id_score_array_p = ctypes.POINTER(OBX_id_score_array)
class OBX_txn(ctypes.Structure):
pass
OBX_txn_p = ctypes.POINTER(OBX_txn)
class OBX_box(ctypes.Structure):
pass
OBX_box_p = ctypes.POINTER(OBX_box)
class OBX_async(ctypes.Structure):
pass
OBX_async_p = ctypes.POINTER(OBX_async)
class OBX_query_builder(ctypes.Structure):
pass
OBX_query_builder_p = ctypes.POINTER(OBX_query_builder)
class OBX_query(ctypes.Structure):
pass
OBX_query_p = ctypes.POINTER(OBX_query)
# manually configure error methods, we can't use `fn()` defined below yet due to circular dependencies
C.obx_last_error_message.restype = ctypes.c_char_p
C.obx_last_error_code.restype = obx_err
class DbErrorCode(IntEnum):
OBX_SUCCESS = 0
OBX_NOT_FOUND = 404
OBX_NO_SUCCESS = 1001
OBX_TIMEOUT = 1002
OBX_ERROR_ILLEGAL_STATE = 10001
OBX_ERROR_ILLEGAL_ARGUMENT = 10002
OBX_ERROR_ALLOCATION = 10003
OBX_ERROR_NUMERIC_OVERFLOW = 10004
OBX_ERROR_FEATURE_NOT_AVAILABLE = 10005
OBX_ERROR_SHUTTING_DOWN = 10006
OBX_ERROR_IO = 10007
OBX_ERROR_BACKUP_FILE_INVALID = 10008
OBX_ERROR_NO_ERROR_INFO = 10097
OBX_ERROR_GENERAL = 10098
OBX_ERROR_UNKNOWN = 10099
OBX_ERROR_DB_FULL = 10101
OBX_ERROR_MAX_READERS_EXCEEDED = 10102
OBX_ERROR_STORE_MUST_SHUTDOWN = 10103
OBX_ERROR_MAX_DATA_SIZE_EXCEEDED = 10104
OBX_ERROR_DB_GENERAL = 10198
OBX_ERROR_STORAGE_GENERAL = 10199
OBX_ERROR_UNIQUE_VIOLATED = 10201
OBX_ERROR_NON_UNIQUE_RESULT = 10202
OBX_ERROR_PROPERTY_TYPE_MISMATCH = 10203
OBX_ERROR_ID_ALREADY_EXISTS = 10210
OBX_ERROR_ID_NOT_FOUND = 10211
OBX_ERROR_TIME_SERIES = 10212
OBX_ERROR_CONSTRAINT_VIOLATED = 10299
OBX_ERROR_STD_ILLEGAL_ARGUMENT = 10301
OBX_ERROR_STD_OUT_OF_RANGE = 10302
OBX_ERROR_STD_LENGTH = 10303
OBX_ERROR_STD_BAD_ALLOC = 10304
OBX_ERROR_STD_RANGE = 10305
OBX_ERROR_STD_OVERFLOW = 10306
OBX_ERROR_STD_OTHER = 10399
OBX_ERROR_SCHEMA = 10501
OBX_ERROR_FILE_CORRUPT = 10502
OBX_ERROR_FILE_PAGES_CORRUPT = 10503
OBX_ERROR_SCHEMA_OBJECT_NOT_FOUND = 10504
OBX_ERROR_TREE_MODEL_INVALID = 10601
OBX_ERROR_TREE_VALUE_TYPE_MISMATCH = 10602
OBX_ERROR_TREE_PATH_NON_UNIQUE = 10603
OBX_ERROR_TREE_PATH_ILLEGAL = 10604
OBX_ERROR_TREE_OTHER = 10699
def check_obx_err(code: obx_err, func, args) -> obx_err:
""" Raises an exception if obx_err is not successful. """
if code != DbErrorCode.OBX_SUCCESS:
from objectbox.exceptions import create_db_error
raise create_db_error(code)
return code
def check_obx_qb_cond(qb_cond: obx_qb_cond, func, args) -> obx_qb_cond:
""" Raises an exception if obx_qb_cond is not successful. """
if qb_cond == 0:
from objectbox.exceptions import create_db_error
raise create_db_error(C.obx_last_error_code())
return qb_cond
# assert that the returned pointer/int is non-empty
def check_result(result, func, args):
if not result:
from objectbox.exceptions import create_db_error
raise create_db_error(C.obx_last_error_code())
return result
# creates a global function "name" with the given restype & argtypes, calling C function with the same name.
# restype is used for error checking: if not None, check_result will throw an exception if the result is empty.
def c_fn(name: str, restype: Optional[type], argtypes):
func = C.__getattr__(name)
func.argtypes = argtypes
func.restype = restype
if restype is not None:
func.errcheck = check_result
return func
# creates a global function "name" with the given restype & argtypes, calling C function with the same name.
# no error checking is done on restype as this is defered to higher-level functions.
def c_fn_nocheck(name: str, restype: type, argtypes):
func = C.__getattr__(name)
func.argtypes = argtypes
func.restype = restype
return func
# like c_fn, but for functions returning obx_err
def c_fn_rc(name: str, argtypes):
""" Like c_fn, but for functions returning obx_err (checks obx_err validity). """
func = C.__getattr__(name)
func.argtypes = argtypes
func.restype = obx_err
func.errcheck = check_obx_err
return func
def c_fn_qb_cond(name: str, argtypes):
""" Like c_fn, but for functions returning obx_qb_cond (checks obx_qb_cond validity). """
func = C.__getattr__(name)
func.argtypes = argtypes
func.restype = obx_qb_cond
func.errcheck = check_obx_qb_cond
return func
def py_str(ptr: ctypes.c_char_p) -> str:
return ctypes.c_char_p(ptr).value.decode("utf-8")
def c_str(string: str) -> ctypes.c_char_p:
return string.encode('utf-8')
def c_voidp_as_bytes(voidp, size):
# TODO verify which of the following two approaches is better. Performance-wise, it seems the same.
# slice the data from the pointer
# return ctypes.cast(voidp, ctypes.POINTER(ctypes.c_char))[:size]
# create a memory view
return memoryview(ctypes.cast(voidp, ctypes.POINTER(ctypes.c_ubyte * size))[0]).tobytes()
def c_array(py_list: Union[List[Any], np.ndarray], c_type):
""" Converts the given python list or ndarray into a C array of c_type. """
if isinstance(py_list, np.ndarray):
if py_list.ndim != 1:
raise Exception(f"ndarray is expected to be 1-dimensional. Input shape: {py_list.shape}")
return py_list.ctypes.data_as(ctypes.POINTER(c_type))
elif isinstance(py_list, list):
return (c_type * len(py_list))(*py_list)
else:
raise Exception(f"Unsupported Python list type: {type(py_list)}")
def c_array_pointer(py_list: Union[List[Any], np.ndarray], c_type):
""" Converts the given python list or ndarray into a C array of c_type. Returns its pointer type. """
return ctypes.cast(c_array(py_list, c_type), ctypes.POINTER(c_type))
# OBX_C_API float obx_vector_distance_float32(OBXVectorDistanceType type, const float* vector1, const float* vector2, size_t dimension);
obx_vector_distance_float32 = c_fn("obx_vector_distance_float32", ctypes.c_float,
[OBXVectorDistanceType, ctypes.POINTER(ctypes.c_float),
ctypes.POINTER(ctypes.c_float), ctypes.c_size_t])
# OBX_C_API float obx_vector_distance_to_relevance(OBXVectorDistanceType type, float distance);
obx_vector_distance_to_relevance = c_fn("obx_vector_distance_to_relevance", ctypes.c_float,
[OBXVectorDistanceType, ctypes.c_float])
# OBX_model* (void);
obx_model = c_fn('obx_model', OBX_model_p, [])
# obx_err (OBX_model* model, const char* name, obx_schema_id entity_id, obx_uid entity_uid);
obx_model_entity = c_fn_rc('obx_model_entity', [
OBX_model_p, ctypes.c_char_p, obx_schema_id, obx_uid])
# obx_err (OBX_model* model, const char* name, OBXPropertyType type, obx_schema_id property_id, obx_uid property_uid);
obx_model_property = c_fn_rc('obx_model_property',
[OBX_model_p, ctypes.c_char_p, OBXPropertyType, obx_schema_id, obx_uid])
# obx_err (OBX_model* model, OBXPropertyFlags flags);
obx_model_property_flags = c_fn_rc('obx_model_property_flags', [OBX_model_p, OBXPropertyFlags])
# obx_err obx_model_property_index_id(OBX_model* model, obx_schema_id index_id, obx_uid index_uid)
obx_model_property_index_id = c_fn_rc('obx_model_property_index_id', [OBX_model_p, obx_schema_id, obx_uid])
# obx_err obx_model_property_index_hnsw_dimensions(OBX_model* model, size_t value)
obx_model_property_index_hnsw_dimensions = \
c_fn_rc('obx_model_property_index_hnsw_dimensions', [OBX_model_p, ctypes.c_size_t])
# obx_err obx_model_property_index_hnsw_neighbors_per_node(OBX_model* model, uint32_t value)
obx_model_property_index_hnsw_neighbors_per_node = \
c_fn_rc('obx_model_property_index_hnsw_neighbors_per_node', [OBX_model_p, ctypes.c_uint32])
# obx_err obx_model_property_index_hnsw_indexing_search_count(OBX_model* model, uint32_t value)
obx_model_property_index_hnsw_indexing_search_count = \
c_fn_rc('obx_model_property_index_hnsw_indexing_search_count', [OBX_model_p, ctypes.c_uint32])
# obx_err obx_model_property_index_hnsw_flags(OBX_model* model, OBXHnswFlags value)
obx_model_property_index_hnsw_flags = \
c_fn_rc('obx_model_property_index_hnsw_flags', [OBX_model_p, OBXHnswFlags])
# obx_err obx_model_property_index_hnsw_distance_type(OBX_model* model, OBXVectorDistanceType value)
obx_model_property_index_hnsw_distance_type = c_fn_rc('obx_model_property_index_hnsw_distance_type',
[OBX_model_p, OBXVectorDistanceType])
# obx_err obx_model_property_index_hnsw_reparation_backlink_probability(OBX_model* model, float value)
obx_model_property_index_hnsw_reparation_backlink_probability = \
c_fn_rc('obx_model_property_index_hnsw_reparation_backlink_probability', [OBX_model_p, ctypes.c_float])
# obx_err obx_model_property_index_hnsw_vector_cache_hint_size_kb(OBX_model* model, size_t value)
obx_model_property_index_hnsw_vector_cache_hint_size_kb = \
c_fn_rc('obx_model_property_index_hnsw_vector_cache_hint_size_kb', [OBX_model_p, ctypes.c_size_t])
# obx_err (OBX_model*, obx_schema_id entity_id, obx_uid entity_uid);
obx_model_last_entity_id = c_fn('obx_model_last_entity_id', None, [
OBX_model_p, obx_schema_id, obx_uid])
# obx_err (OBX_model* model, obx_schema_id index_id, obx_uid index_uid);
obx_model_last_index_id = c_fn('obx_model_last_index_id', None, [
OBX_model_p, obx_schema_id, obx_uid])
# obx_err (OBX_model* model, obx_schema_id relation_id, obx_uid relation_uid);
obx_model_last_relation_id = c_fn('obx_model_last_relation_id', None, [
OBX_model_p, obx_schema_id, obx_uid])
# obx_err (OBX_model* model, obx_schema_id property_id, obx_uid property_uid);
obx_model_entity_last_property_id = c_fn_rc('obx_model_entity_last_property_id',
[OBX_model_p, obx_schema_id, obx_uid])
# OBX_store_options* ();
obx_opt = c_fn('obx_opt', OBX_store_options_p, [])
# OBX_C_API obx_err obx_opt_directory(OBX_store_options* opt, const char* dir);
obx_opt_directory = c_fn_rc('obx_opt_directory', [OBX_store_options_p, ctypes.c_char_p])
# OBX_C_API void obx_opt_max_db_size_in_kb(OBX_store_options* opt, uint64_t size_in_kb);
obx_opt_max_db_size_in_kb = c_fn('obx_opt_max_db_size_in_kb', None, [OBX_store_options_p, ctypes.c_uint64])
# OBX_C_API void obx_opt_max_data_size_in_kb(OBX_store_options* opt, uint64_t size_in_kb);
obx_opt_max_data_size_in_kb = c_fn('obx_opt_max_data_size_in_kb', None, [OBX_store_options_p, ctypes.c_uint64])
# OBX_C_API void obx_opt_file_mode(OBX_store_options* opt, unsigned int file_mode);
obx_opt_file_mode = c_fn('obx_opt_file_mode', None, [OBX_store_options_p, ctypes.c_uint32])
# OBX_C_API void obx_opt_max_readers(OBX_store_options* opt, unsigned int max_readers);
obx_opt_max_readers = c_fn('obx_opt_max_readers', None, [OBX_store_options_p, ctypes.c_uint32])
# OBX_C_API void obx_opt_no_reader_thread_locals(OBX_store_options* opt, bool flag);
obx_opt_no_reader_thread_locals = c_fn('obx_opt_no_reader_thread_locals', None, [OBX_store_options_p, ctypes.c_bool])
# OBX_C_API obx_err obx_opt_model(OBX_store_options* opt, OBX_model* model);
obx_opt_model = c_fn_rc('obx_opt_model', [OBX_store_options_p, OBX_model_p])
# OBX_C_API obx_err obx_opt_model_bytes(OBX_store_options* opt, const void* bytes, size_t size);
obx_opt_model_bytes = c_fn_rc('obx_opt_model_bytes', [OBX_store_options_p, ctypes.c_void_p, ctypes.c_size_t])
# OBX_C_API obx_err obx_opt_model_bytes_direct(OBX_store_options* opt, const void* bytes, size_t size);
obx_opt_model_bytes_direct = c_fn_rc('obx_opt_model_bytes_direct',
[OBX_store_options_p, ctypes.c_void_p, ctypes.c_size_t])
# OBX_C_API void obx_opt_validate_on_open_pages(OBX_store_options* opt, size_t page_limit, uint32_t flags);
obx_opt_validate_on_open_pages = c_fn('obx_opt_validate_on_open_pages', None,
[OBX_store_options_p, ctypes.c_size_t, OBXValidateOnOpenPagesFlags])
# OBX_C_API void obx_opt_validate_on_open_kv(OBX_store_options* opt, uint32_t flags);
obx_opt_validate_on_open_kv = c_fn('obx_opt_validate_on_open_kv', None, [OBX_store_options_p, OBXValidateOnOpenKvFlags])
# OBX_C_API void obx_opt_put_padding_mode(OBX_store_options* opt, OBXPutPaddingMode mode);
obx_opt_put_padding_mode = c_fn('obx_opt_put_padding_mode', None, [OBX_store_options_p, OBXPutPaddingMode])
# OBX_C_API void obx_opt_read_schema(OBX_store_options* opt, bool value);
obx_opt_read_schema = c_fn('obx_opt_read_schema', None, [OBX_store_options_p, ctypes.c_bool])
# OBX_C_API void obx_opt_use_previous_commit(OBX_store_options* opt, bool value);
obx_opt_use_previous_commit = c_fn('obx_opt_use_previous_commit', None, [OBX_store_options_p, ctypes.c_bool])
# OBX_C_API void obx_opt_read_only(OBX_store_options* opt, bool value);
obx_opt_read_only = c_fn('obx_opt_read_only', None, [OBX_store_options_p, ctypes.c_bool])
# OBX_C_API void obx_opt_debug_flags(OBX_store_options* opt, uint32_t flags);
obx_opt_debug_flags = c_fn('obx_opt_debug_flags', None, [OBX_store_options_p, OBXDebugFlags])
# OBX_C_API void obx_opt_add_debug_flags(OBX_store_options* opt, uint32_t flags);
obx_opt_add_debug_flags = c_fn('obx_opt_add_debug_flags', None, [OBX_store_options_p, ctypes.c_uint32])
# OBX_C_API void obx_opt_async_max_queue_length(OBX_store_options* opt, size_t value);
obx_opt_async_max_queue_length = c_fn('obx_opt_async_max_queue_length', None, [OBX_store_options_p, ctypes.c_size_t])
# OBX_C_API void obx_opt_async_throttle_at_queue_length(OBX_store_options* opt, size_t value);
obx_opt_async_throttle_at_queue_length = c_fn('obx_opt_async_throttle_at_queue_length', None,
[OBX_store_options_p, ctypes.c_size_t])
# OBX_C_API void obx_opt_async_throttle_micros(OBX_store_options* opt, uint32_t value);
obx_opt_async_throttle_micros = c_fn('obx_opt_async_throttle_micros', None, [OBX_store_options_p, ctypes.c_uint32])
# OBX_C_API void obx_opt_async_max_in_tx_duration(OBX_store_options* opt, uint32_t micros);
obx_opt_async_max_in_tx_duration = c_fn('obx_opt_async_max_in_tx_duration', None,
[OBX_store_options_p, ctypes.c_uint32])
# OBX_C_API void obx_opt_async_max_in_tx_operations(OBX_store_options* opt, uint32_t value);
obx_opt_async_max_in_tx_operations = c_fn('obx_opt_async_max_in_tx_operations', None,
[OBX_store_options_p, ctypes.c_uint32])
# OBX_C_API void obx_opt_async_pre_txn_delay(OBX_store_options* opt, uint32_t delay_micros);
obx_opt_async_pre_txn_delay = c_fn('obx_opt_async_pre_txn_delay', None, [OBX_store_options_p, ctypes.c_uint32])
# OBX_C_API void obx_opt_async_pre_txn_delay4(OBX_store_options* opt, uint32_t delay_micros, uint32_t delay2_micros, size_t min_queue_length_for_delay2);
obx_opt_async_pre_txn_delay4 = c_fn('obx_opt_async_pre_txn_delay4', None,
[OBX_store_options_p, ctypes.c_uint32, ctypes.c_uint32, ctypes.c_size_t])
# OBX_C_API void obx_opt_async_post_txn_delay(OBX_store_options* opt, uint32_t delay_micros);
obx_opt_async_post_txn_delay = c_fn('obx_opt_async_post_txn_delay', None, [OBX_store_options_p, ctypes.c_uint32])
# OBX_C_API void obx_opt_async_post_txn_delay5(OBX_store_options* opt, uint32_t delay_micros, uint32_t delay2_micros, size_t min_queue_length_for_delay2, bool subtract_processing_time);
obx_opt_async_post_txn_delay5 = c_fn('obx_opt_async_post_txn_delay5', None,
[OBX_store_options_p, ctypes.c_uint32, ctypes.c_uint32, ctypes.c_size_t,
ctypes.c_bool])
# OBX_C_API void obx_opt_async_minor_refill_threshold(OBX_store_options* opt, size_t queue_length);
obx_opt_async_minor_refill_threshold = c_fn('obx_opt_async_minor_refill_threshold', None,
[OBX_store_options_p, ctypes.c_size_t])
# OBX_C_API void obx_opt_async_minor_refill_max_count(OBX_store_options* opt, uint32_t value);
obx_opt_async_minor_refill_max_count = c_fn('obx_opt_async_minor_refill_max_count', None,
[OBX_store_options_p, ctypes.c_uint32])
# OBX_C_API void obx_opt_async_max_tx_pool_size(OBX_store_options* opt, size_t value);
obx_opt_async_max_tx_pool_size = c_fn('obx_opt_async_max_tx_pool_size', None, [OBX_store_options_p, ctypes.c_size_t])
# OBX_C_API void obx_opt_async_object_bytes_max_cache_size(OBX_store_options* opt, uint64_t value);
obx_opt_async_object_bytes_max_cache_size = c_fn('obx_opt_async_object_bytes_max_cache_size', None,
[OBX_store_options_p, ctypes.c_uint64])
# OBX_C_API void obx_opt_async_object_bytes_max_size_to_cache(OBX_store_options* opt, uint64_t value);
obx_opt_async_object_bytes_max_size_to_cache = c_fn('obx_opt_async_object_bytes_max_size_to_cache', None,
[OBX_store_options_p, ctypes.c_uint64])
#typedef void obx_log_callback(OBXLogLevel log_level, const char* message, size_t message_size, void* user_data);
obx_log_callback_fn = ctypes.CFUNCTYPE(None, OBXLogLevel, ctypes.c_char_p, ctypes.c_size_t, ctypes.c_voidp)
# OBX_C_API void obx_opt_log_callback(OBX_store_options* opt, obx_log_callback* callback, void* user_data);
obx_opt_log_callback = c_fn('obx_opt_log_callback', None, [OBX_store_options_p, obx_log_callback_fn, ctypes.c_voidp])
# OBX_C_API void obx_opt_backup_restore(OBX_store_options* opt, const char* backup_file, uint32_t flags);
obx_opt_backup_restore = c_fn('obx_opt_backup_restore', None,
[OBX_store_options_p, ctypes.c_char_p, OBXBackupRestoreFlags])
# OBX_C_API const char* obx_opt_get_directory(OBX_store_options* opt);
obx_opt_get_directory = c_fn('obx_opt_get_directory', ctypes.c_char_p, [OBX_store_options_p])
# OBX_C_API uint64_t obx_opt_get_max_db_size_in_kb(OBX_store_options* opt);
obx_opt_get_max_db_size_in_kb = c_fn('obx_opt_get_max_db_size_in_kb', ctypes.c_uint64, [OBX_store_options_p])
# OBX_C_API uint64_t obx_opt_get_max_data_size_in_kb(OBX_store_options* opt);
obx_opt_get_max_data_size_in_kb = c_fn('obx_opt_get_max_data_size_in_kb', ctypes.c_uint64, [OBX_store_options_p])
# OBX_C_API uint32_t obx_opt_get_debug_flags(OBX_store_options* opt);
obx_opt_get_debug_flags = c_fn('obx_opt_get_debug_flags', ctypes.c_uint32, [OBX_store_options_p])
# OBX_C_API void obx_opt_free(OBX_store_options* opt);
obx_opt_free = c_fn('obx_opt_free', None, [])
# OBX_store* (const OBX_store_options* options);
obx_store_open = c_fn('obx_store_open', OBX_store_p, [OBX_store_options_p])
# obx_err (OBX_store* store);
obx_store_close = c_fn_rc('obx_store_close', [OBX_store_p])
# obx_err obx_remove_db_files(const const* directory);
obx_remove_db_files = c_fn_rc('obx_remove_db_files', [ctypes.c_char_p]) # TODO provide a python wrapper
# OBX_txn* (OBX_store* store);
obx_txn_write = c_fn('obx_txn_write', OBX_txn_p, [OBX_store_p])
# OBX_txn* (OBX_store* store);
obx_txn_read = c_fn('obx_txn_read', OBX_txn_p, [OBX_store_p])
# obx_err (OBX_txn* txn)
obx_txn_close = c_fn_rc('obx_txn_close', [OBX_txn_p])
# obx_err (OBX_txn* txn);
obx_txn_abort = c_fn_rc('obx_txn_abort', [OBX_txn_p])
# obx_err (OBX_txn* txn);
obx_txn_success = c_fn_rc('obx_txn_success', [OBX_txn_p])
# OBX_box* (OBX_store* store, obx_schema_id entity_id);
obx_box = c_fn('obx_box', OBX_box_p, [OBX_store_p, obx_schema_id])
# obx_err (OBX_box* box, obx_id id, const void** data, size_t* size);
obx_box_get = c_fn_nocheck('obx_box_get', obx_err, [
OBX_box_p, obx_id, ctypes.POINTER(ctypes.c_void_p), ctypes.POINTER(ctypes.c_size_t)])
# OBX_bytes_array* (OBX_box* box);
obx_box_get_all = c_fn('obx_box_get_all', OBX_bytes_array_p, [OBX_box_p])
# obx_id (OBX_box* box, obx_id id_or_zero);
obx_box_id_for_put = c_fn('obx_box_id_for_put', obx_id, [OBX_box_p, obx_id])
# obx_err (OBX_box* box, uint64_t count, obx_id* out_first_id);
obx_box_ids_for_put = c_fn_rc('obx_box_ids_for_put', [
OBX_box_p, ctypes.c_uint64, ctypes.POINTER(obx_id)])
# obx_err (OBX_box* box, obx_id id, const void* data, size_t size);
obx_box_put = c_fn_rc('obx_box_put', [OBX_box_p, obx_id, ctypes.c_void_p, ctypes.c_size_t])
# obx_err (OBX_box* box, const OBX_bytes_array* objects, const obx_id* ids, OBXPutMode mode);
obx_box_put_many = c_fn_rc('obx_box_put_many', [
OBX_box_p, OBX_bytes_array_p, ctypes.POINTER(obx_id), OBXPutMode])
# obx_err (OBX_box* box, obx_id id);
obx_box_remove = c_fn_nocheck('obx_box_remove', obx_err, [OBX_box_p, obx_id])
# obx_err (OBX_box* box, uint64_t* out_count);
obx_box_remove_all = c_fn_rc('obx_box_remove_all', [
OBX_box_p, ctypes.POINTER(ctypes.c_uint64)])
# obx_err (OBX_box* box, bool* out_is_empty);
obx_box_is_empty = c_fn_rc('obx_box_is_empty', [
OBX_box_p, ctypes.POINTER(ctypes.c_bool)])
# obx_err obx_box_count(OBX_box* box, uint64_t limit, uint64_t* out_count);
obx_box_count = c_fn_rc('obx_box_count', [
OBX_box_p, ctypes.c_uint64, ctypes.POINTER(ctypes.c_uint64)])
# OBX_query_builder* obx_query_builder(OBX_store* store, obx_schema_id entity_id);
obx_query_builder = c_fn('obx_query_builder', OBX_query_builder_p, [OBX_store_p, obx_schema_id])
# OBX_C_API obx_err obx_qb_close(OBX_query_builder* builder);
obx_qb_close = c_fn_rc('obx_qb_close', [OBX_query_builder_p])
# OBX_C_API OBX_query* obx_query(OBX_query_builder* builder);
obx_query = c_fn('obx_query', OBX_query_p, [OBX_query_builder_p])
# OBX_C_API obx_err obx_qb_error_code(OBX_query_builder* builder);
obx_qb_error_code = c_fn_rc('obx_qb_error_code', [OBX_query_builder_p])
# OBX_C_API const char* obx_qb_error_message(OBX_query_builder* builder);
obx_qb_error_message = c_fn('obx_qb_error_message', ctypes.c_char_p, [OBX_query_builder_p])
# OBX_C_API obx_qb_cond obx_qb_null(OBX_query_builder* builder, obx_schema_id property_id);
obx_qb_null = c_fn('obx_qb_null', obx_qb_cond, [OBX_query_builder_p, obx_schema_id])
# OBX_C_API obx_qb_cond obx_qb_not_null(OBX_query_builder* builder, obx_schema_id property_id);
obx_qb_not_null = c_fn('obx_qb_not_null', obx_qb_cond, [OBX_query_builder_p, obx_schema_id])
# OBX_C_API obx_qb_cond obx_qb_equals_string(OBX_query_builder* builder, obx_schema_id property_id, const char* value,
# bool case_sensitive);
obx_qb_equals_string = c_fn('obx_qb_equals_string', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_char_p, ctypes.c_bool])
# OBX_C_API obx_qb_co nd obx_qb_not_equals_string(OBX_query_builder* builder, obx_schema_id property_id, const char* value,
# bool case_sensitive);
obx_qb_not_equals_string = c_fn('obx_qb_not_equals_string', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_char_p, ctypes.c_bool])
# OBX_C_API obx_qb_cond obx_qb_contains_string(OBX_query_builder* builder, obx_schema_id property_id, const char* value,
# bool case_sensitive);
obx_qb_contains_string = c_fn('obx_qb_contains_string', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_char_p, ctypes.c_bool])
# OBX_C_API obx_qb_cond obx_qb_contains_element_string(OBX_query_builder* builder, obx_schema_id property_id,
# const char* value, bool case_sensitive);
obx_qb_contains_element_string = c_fn('obx_qb_contains_element_string', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_char_p, ctypes.c_bool])
# OBX_C_API obx_qb_cond obx_qb_contains_key_value_string(OBX_query_builder* builder, obx_schema_id property_id,
# const char* key, const char* value, bool case_sensitive);
obx_qb_contains_key_value_string = c_fn('obx_qb_contains_key_value_string', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_char_p, ctypes.c_char_p,
ctypes.c_bool])
# OBX_C_API obx_qb_cond obx_qb_starts_with_string(OBX_query_builder* builder, obx_schema_id property_id,
# const char* value, bool case_sensitive);
obx_qb_starts_with_string = c_fn('obx_qb_starts_with_string', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_char_p, ctypes.c_bool])
# OBX_C_API obx_qb_cond obx_qb_ends_with_string(OBX_query_builder* builder, obx_schema_id property_id, const char* value,
# bool case_sensitive);
obx_qb_ends_with_string = c_fn('obx_qb_ends_with_string', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_char_p, ctypes.c_bool])
# OBX_C_API obx_qb_cond obx_qb_greater_than_string(OBX_query_builder* builder, obx_schema_id property_id,
# const char* value, bool case_sensitive);
obx_qb_greater_than_string = c_fn('obx_qb_greater_than_string', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_char_p, ctypes.c_bool])
# OBX_C_API obx_qb_cond obx_qb_greater_or_equal_string(OBX_query_builder* builder, obx_schema_id property_id,
# const char* value, bool case_sensitive);
obx_qb_greater_or_equal_string = c_fn('obx_qb_greater_or_equal_string', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_char_p, ctypes.c_bool])
# OBX_C_API obx_qb_cond obx_qb_less_than_string(OBX_query_builder* builder, obx_schema_id property_id, const char* value,
# bool case_sensitive);
obx_qb_less_than_string = c_fn('obx_qb_less_than_string', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_char_p, ctypes.c_bool])
# OBX_C_API obx_qb_cond obx_qb_less_or_equal_string(OBX_query_builder* builder, obx_schema_id property_id,
# const char* value, bool case_sensitive);
obx_qb_less_or_equal_string = c_fn('obx_qb_less_or_equal_string', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_char_p, ctypes.c_bool])
# OBX_C_API obx_qb_cond obx_qb_in_strings(OBX_query_builder* builder, obx_schema_id property_id,
# const char* const values[], size_t count, bool case_sensitive);
obx_qb_in_strings = c_fn('obx_qb_in_strings', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.POINTER(ctypes.c_char_p), ctypes.c_size_t,
ctypes.c_bool])
# OBX_C_API obx_qb_cond obx_qb_any_equals_string(OBX_query_builder* builder, obx_schema_id property_id, const char* value,
# bool case_sensitive);
obx_qb_any_equals_string = c_fn('obx_qb_any_equals_string', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_char_p, ctypes.c_bool])
# OBX_C_API obx_qb_cond obx_qb_equals_int(OBX_query_builder* builder, obx_schema_id property_id, int64_t value);
obx_qb_equals_int = c_fn('obx_qb_equals_int', obx_qb_cond, [OBX_query_builder_p, obx_schema_id, ctypes.c_int64])
# OBX_C_API obx_qb_cond obx_qb_not_equals_int(OBX_query_builder* builder, obx_schema_id property_id, int64_t value);
obx_qb_not_equals_int = c_fn('obx_qb_not_equals_int', obx_qb_cond, [OBX_query_builder_p, obx_schema_id, ctypes.c_int64])
# OBX_C_API obx_qb_cond obx_qb_greater_than_int(OBX_query_builder* builder, obx_schema_id property_id, int64_t value);
obx_qb_greater_than_int = c_fn('obx_qb_greater_than_int', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_int64])
# OBX_C_API obx_qb_cond obx_qb_greater_or_equal_int(OBX_query_builder* builder, obx_schema_id property_id, int64_t value);
obx_qb_greater_or_equal_int = c_fn('obx_qb_greater_or_equal_int', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_int64])
# OBX_C_API obx_qb_cond obx_qb_less_than_int(OBX_query_builder* builder, obx_schema_id property_id, int64_t value);
obx_qb_less_than_int = c_fn('obx_qb_less_than_int', obx_qb_cond, [OBX_query_builder_p, obx_schema_id, ctypes.c_int64])
# OBX_C_API obx_qb_cond obx_qb_less_or_equal_int(OBX_query_builder* builder, obx_schema_id property_id, int64_t value);
obx_qb_less_or_equal_int = c_fn('obx_qb_less_or_equal_int', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_int64])
# OBX_C_API obx_qb_cond obx_qb_between_2ints(OBX_query_builder* builder, obx_schema_id property_id, int64_t value_a,
# int64_t value_b);
obx_qb_between_2ints = c_fn('obx_qb_between_2ints', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_int64, ctypes.c_int64])
# OBX_C_API obx_qb_cond obx_qb_in_int64s(OBX_query_builder* builder, obx_schema_id property_id, const int64_t values[],
# size_t count);
obx_qb_in_int64s = c_fn('obx_qb_in_int64s', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.POINTER(ctypes.c_int64), ctypes.c_size_t])
# OBX_C_API obx_qb_cond obx_qb_not_in_int64s(OBX_query_builder* builder, obx_schema_id property_id,
# const int64_t values[], size_t count);
obx_qb_not_in_int64s = c_fn('obx_qb_not_in_int64s', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.POINTER(ctypes.c_int64), ctypes.c_size_t])
# OBX_C_API obx_qb_cond obx_qb_in_int32s(OBX_query_builder* builder, obx_schema_id property_id, const int32_t values[],
# size_t count);
obx_qb_in_int32s = c_fn('obx_qb_in_int32s', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.POINTER(ctypes.c_int32), ctypes.c_size_t])
# OBX_C_API obx_qb_cond obx_qb_not_in_int32s(OBX_query_builder* builder, obx_schema_id property_id,
# const int32_t values[], size_t count);
obx_qb_not_in_int32s = c_fn('obx_qb_not_in_int32s', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.POINTER(ctypes.c_int32), ctypes.c_size_t])
# OBX_C_API obx_qb_cond obx_qb_greater_than_double(OBX_query_builder* builder, obx_schema_id property_id, double value);
obx_qb_greater_than_double = c_fn('obx_qb_greater_than_double', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_double])
# OBX_C_API obx_qb_cond obx_qb_greater_or_equal_double(OBX_query_builder* builder, obx_schema_id property_id,
# double value);
obx_qb_greater_or_equal_double = c_fn('obx_qb_greater_or_equal_double', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_double])
# OBX_C_API obx_qb_cond obx_qb_less_than_double(OBX_query_builder* builder, obx_schema_id property_id, double value);
obx_qb_less_than_double = c_fn('obx_qb_less_than_double', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_double])
# OBX_C_API obx_qb_cond obx_qb_less_or_equal_double(OBX_query_builder* builder, obx_schema_id property_id, double value);
obx_qb_less_or_equal_double = c_fn('obx_qb_less_or_equal_double', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_double])
# OBX_C_API obx_qb_cond obx_qb_between_2doubles(OBX_query_builder* builder, obx_schema_id property_id, double value_a,
# double value_b);
obx_qb_between_2doubles = c_fn('obx_qb_between_2doubles', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_double, ctypes.c_double])
# OBX_C_API obx_qb_cond obx_qb_equals_bytes(OBX_query_builder* builder, obx_schema_id property_id, const void* value,
# size_t size);
obx_qb_equals_bytes = c_fn('obx_qb_equals_bytes', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_void_p, ctypes.c_size_t])
# OBX_C_API obx_qb_cond obx_qb_greater_than_bytes(OBX_query_builder* builder, obx_schema_id property_id,
# const void* value, size_t size);
obx_qb_greater_than_bytes = c_fn('obx_qb_greater_than_bytes', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_void_p, ctypes.c_size_t])
# OBX_C_API obx_qb_cond obx_qb_greater_or_equal_bytes(OBX_query_builder* builder, obx_schema_id property_id,
# const void* value, size_t size);
obx_qb_greater_or_equal_bytes = c_fn('obx_qb_greater_or_equal_bytes', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_void_p, ctypes.c_size_t])
# OBX_C_API obx_qb_cond obx_qb_less_than_bytes(OBX_query_builder* builder, obx_schema_id property_id, const void* value,
# size_t size);
obx_qb_less_than_bytes = c_fn('obx_qb_less_than_bytes', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_void_p, ctypes.c_size_t])
# OBX_C_API obx_qb_cond obx_qb_less_or_equal_bytes(OBX_query_builder* builder, obx_schema_id property_id,
# const void* value, size_t size);
obx_qb_less_or_equal_bytes = c_fn('obx_qb_less_or_equal_bytes', obx_qb_cond,
[OBX_query_builder_p, obx_schema_id, ctypes.c_void_p, ctypes.c_size_t])
# OBX_C_API obx_qb_cond obx_qb_all(OBX_query_builder* builder, const obx_qb_cond conditions[], size_t count);
obx_qb_all = c_fn('obx_qb_all', obx_qb_cond, [OBX_query_builder_p, obx_qb_cond_p, ctypes.c_size_t])
# OBX_C_API obx_qb_cond obx_qb_any(OBX_query_builder* builder, const obx_qb_cond conditions[], size_t count);
obx_qb_any = c_fn('obx_qb_any', obx_qb_cond, [OBX_query_builder_p, obx_qb_cond_p, ctypes.c_size_t])
# OBX_C_API obx_err obx_qb_param_alias(OBX_query_builder* builder, const char* alias);
obx_qb_param_alias = c_fn_rc('obx_qb_param_alias', [OBX_query_builder_p, ctypes.c_char_p])
# OBX_C_API obx_err obx_query_param_string(OBX_query* query, obx_schema_id entity_id, obx_schema_id property_id, const char* value);
obx_query_param_string = c_fn_rc('obx_query_param_string', [OBX_query_p, obx_schema_id, obx_schema_id, ctypes.c_char_p])
# OBX_C_API obx_err obx_query_param_int(OBX_query* query, obx_schema_id entity_id, obx_schema_id property_id, int64_t value);
obx_query_param_int = c_fn_rc('obx_query_param_int', [OBX_query_p, obx_schema_id, obx_schema_id, ctypes.c_int64])
# OBX_C_API obx_err obx_query_param_vector_float32(OBX_query* query, obx_schema_id entity_id, obx_schema_id property_id, const float* value, size_t element_count);
obx_query_param_vector_float32 = c_fn_rc('obx_query_param_vector_float32',
[OBX_query_p, obx_schema_id, obx_schema_id, ctypes.POINTER(ctypes.c_float),
ctypes.c_size_t])
# OBX_C_API obx_err obx_query_param_alias_vector_float32(OBX_query* query, const char* alias, const float* value, size_t element_count);
obx_query_param_alias_vector_float32 = c_fn_rc('obx_query_param_alias_vector_float32',
[OBX_query_p, ctypes.c_char_p, ctypes.POINTER(ctypes.c_float),
ctypes.c_size_t])
# OBX_C_API obx_err obx_query_param_alias_string(OBX_query* query, const char* alias, const char* value);
obx_query_param_alias_string = c_fn_rc('obx_query_param_alias_string', [OBX_query_p, ctypes.c_char_p, ctypes.c_char_p])
# OBX_C_API obx_err obx_query_param_alias_int(OBX_query* query, const char* alias, int64_t value);
obx_query_param_alias_int = c_fn_rc('obx_query_param_alias_int', [OBX_query_p, ctypes.c_char_p, ctypes.c_int64])
# OBX_C_API obx_err obx_qb_order(OBX_query_builder* builder, obx_schema_id property_id, OBXOrderFlags flags);
obx_qb_order = c_fn_rc('obx_qb_order', [OBX_query_builder_p, obx_schema_id, OBXOrderFlags])
# OBX_C_API obx_qb_cond obx_qb_nearest_neighbors_f32(OBX_query_builder* builder, obx_schema_id vector_property_id, const float* query_vector, size_t max_result_count)
obx_qb_nearest_neighbors_f32 = c_fn_qb_cond('obx_qb_nearest_neighbors_f32',
[OBX_query_builder_p, obx_schema_id, ctypes.POINTER(ctypes.c_float),
ctypes.c_size_t])
# OBX_C_API OBX_query* obx_query(OBX_query_builder* builder);
obx_query = c_fn('obx_query', OBX_query_p, [OBX_query_builder_p])
# OBX_C_API obx_err obx_query_close(OBX_query* query);
obx_query_close = c_fn_rc('obx_query_close', [OBX_query_p])
# OBX_C_API OBX_query* obx_query_clone(OBX_query* query);
obx_query_clone = c_fn('obx_query_clone', OBX_query_p, [OBX_query_p])
# OBX_C_API obx_err obx_query_offset(OBX_query* query, size_t offset);
obx_query_offset = c_fn_rc('obx_query_offset', [OBX_query_p, ctypes.c_size_t])
# OBX_C_API obx_err obx_query_offset_limit(OBX_query* query, size_t offset, size_t limit);
obx_query_offset_limit = c_fn_rc('obx_query_offset_limit', [OBX_query_p, ctypes.c_size_t, ctypes.c_size_t])
# OBX_C_API obx_err obx_query_limit(OBX_query* query, size_t limit);
obx_query_limit = c_fn_rc('obx_query_limit', [OBX_query_p, ctypes.c_size_t])
# OBX_C_API OBX_bytes_array* obx_query_find(OBX_query* query);
obx_query_find = c_fn('obx_query_find', OBX_bytes_array_p, [OBX_query_p])
# OBX_C_API obx_err obx_query_find_first(OBX_query* query, const void** data, size_t* size);
obx_query_find_first = c_fn_rc('obx_query_find_first',
[OBX_query_p, ctypes.POINTER(ctypes.c_void_p), ctypes.POINTER(ctypes.c_size_t)])
# OBX_C_API obx_err obx_query_find_unique(OBX_query* query, const void** data, size_t* size);
obx_query_find_unique = c_fn_rc('obx_query_find_unique',
[OBX_query_p, ctypes.POINTER(ctypes.c_void_p), ctypes.POINTER(ctypes.c_size_t)])
# OBX_C_API OBX_bytes_score_array* obx_query_find_with_scores(OBX_query* query);
obx_query_find_with_scores = c_fn('obx_query_find_with_scores', OBX_bytes_score_array_p, [OBX_query_p])
# typedef bool obx_data_visitor(void* user_data, const void* data, size_t size);
# OBX_C_API obx_err obx_query_visit(OBX_query* query, obx_data_visitor* visitor, void* user_data);
# obx_query_visit = fn('obx_query_visit', obx_err, [OBX_query_p, obx_data_visitor_p, ctypes.c_void_p])
# OBX_C_API OBX_id_array* obx_query_find_ids(OBX_query* query);
obx_query_find_ids = c_fn('obx_query_find_ids', OBX_id_array_p, [OBX_query_p])
# OBX_C_API OBX_id_score_array* obx_query_find_ids_with_scores(OBX_query* query);
obx_query_find_ids_with_scores = c_fn('obx_query_find_ids_with_scores', OBX_id_score_array_p, [OBX_query_p])
# OBX_C_API OBX_id_array* obx_query_find_ids_by_score(OBX_query* query);
obx_query_find_ids_by_score = c_fn('obx_query_find_ids_by_score', OBX_id_array_p, [OBX_query_p])
# OBX_C_API obx_err obx_query_count(OBX_query* query, uint64_t* out_count);
obx_query_count = c_fn_rc('obx_query_count', [OBX_query_p, ctypes.POINTER(ctypes.c_uint64)])
# OBX_C_API obx_err obx_query_remove(OBX_query* query, uint64_t* out_count);
obx_query_remove = c_fn_rc('obx_query_remove', [OBX_query_p, ctypes.POINTER(ctypes.c_uint64)])
# OBX_C_API const char* obx_query_describe(OBX_query* query);
obx_query_describe = c_fn('obx_query_describe', ctypes.c_char_p, [OBX_query_p])
# OBX_C_API const char* obx_query_describe_params(OBX_query* query);
obx_query_describe_params = c_fn('obx_query_describe_params', ctypes.c_char_p, [OBX_query_p])
# OBX_bytes_array* (size_t count);
obx_bytes_array = c_fn('obx_bytes_array', OBX_bytes_array_p, [ctypes.c_size_t])
# obx_err (OBX_bytes_array* array, size_t index, const void* data, size_t size);
obx_bytes_array_set = c_fn_rc('obx_bytes_array_set', [
OBX_bytes_array_p, ctypes.c_size_t, ctypes.c_void_p, ctypes.c_size_t])
# void (OBX_bytes_array * array);
obx_bytes_array_free = c_fn('obx_bytes_array_free', None, [OBX_bytes_array_p])
# OBX_C_API void obx_id_array_free(OBX_id_array* array);
obx_id_array_free = c_fn('obx_id_array_free', None, [OBX_id_array_p])
# OBX_C_API void obx_bytes_score_array_free(OBX_bytes_score_array* array)
obx_bytes_score_array_free = c_fn('obx_bytes_score_array_free', None, [OBX_bytes_score_array_p])
# OBX_C_API void obx_id_score_array_free(OBX_id_score_array* array)
obx_id_score_array_free = c_fn('obx_id_score_array_free', None, [OBX_id_score_array_p])
OBXPropertyType_Bool = 1
OBXPropertyType_Byte = 2
OBXPropertyType_Short = 3
OBXPropertyType_Char = 4
OBXPropertyType_Int = 5
OBXPropertyType_Long = 6
OBXPropertyType_Float = 7
OBXPropertyType_Double = 8
OBXPropertyType_String = 9
OBXPropertyType_Date = 10
OBXPropertyType_Relation = 11
OBXPropertyType_DateNano = 12
OBXPropertyType_Flex = 13
OBXPropertyType_BoolVector = 22
OBXPropertyType_ByteVector = 23
OBXPropertyType_ShortVector = 24
OBXPropertyType_CharVector = 25
OBXPropertyType_IntVector = 26
OBXPropertyType_LongVector = 27
OBXPropertyType_FloatVector = 28
OBXPropertyType_DoubleVector = 29
OBXPropertyType_StringVector = 30
OBXPropertyFlags_ID = 1
OBXPropertyFlags_NON_PRIMITIVE_TYPE = 2
OBXPropertyFlags_NOT_NULL = 4
OBXPropertyFlags_INDEXED = 8
OBXPropertyFlags_RESERVED = 16
OBXPropertyFlags_UNIQUE = 32
OBXPropertyFlags_ID_MONOTONIC_SEQUENCE = 64
OBXPropertyFlags_ID_SELF_ASSIGNABLE = 128
OBXPropertyFlags_INDEX_PARTIAL_SKIP_NULL = 256