@taladb/react-native 0.11.2 → 0.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/jniLibs/arm64-v8a/libtaladb_ffi.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libtaladb_ffi.so +0 -0
- package/android/src/main/jniLibs/x86_64/libtaladb_ffi.so +0 -0
- package/cpp/TalaDBHostObject.cpp +71 -20
- package/cpp/TalaDBHostObject.h +4 -4
- package/cpp/taladb.h +308 -216
- package/ios/TalaDBFfi.xcframework/ios-arm64/Headers/TalaDBHostObject.cpp +71 -20
- package/ios/TalaDBFfi.xcframework/ios-arm64/Headers/TalaDBHostObject.h +4 -4
- package/ios/TalaDBFfi.xcframework/ios-arm64/Headers/taladb.h +308 -216
- package/ios/TalaDBFfi.xcframework/ios-arm64/libtaladb_ffi.a +0 -0
- package/ios/TalaDBFfi.xcframework/ios-arm64_x86_64-simulator/Headers/TalaDBHostObject.cpp +71 -20
- package/ios/TalaDBFfi.xcframework/ios-arm64_x86_64-simulator/Headers/TalaDBHostObject.h +4 -4
- package/ios/TalaDBFfi.xcframework/ios-arm64_x86_64-simulator/Headers/taladb.h +308 -216
- package/ios/TalaDBFfi.xcframework/ios-arm64_x86_64-simulator/libtaladb_ffi_sim.a +0 -0
- package/package.json +3 -3
- package/src/NativeTalaDB.ts +12 -0
- package/src/index.tsx +309 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
#ifndef TALADB_FFI_H
|
|
3
|
-
#define TALADB_FFI_H
|
|
4
|
-
|
|
5
1
|
/*
|
|
6
2
|
* TalaDB C FFI header.
|
|
7
3
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
4
|
+
* GENERATED FILE — do not edit. Regenerate with:
|
|
5
|
+
* pnpm --filter @taladb/react-native build:cbindgen
|
|
6
|
+
* CI fails if this file and rust/src/lib.rs disagree.
|
|
7
|
+
*
|
|
8
|
+
* This is the stable C interface between the Rust taladb-ffi crate and the C++
|
|
9
|
+
* JSI HostObject (cpp/TalaDBHostObject.cpp, cpp/TalaDBJni.cpp) and the iOS
|
|
10
|
+
* TurboModule (ios/TalaDB.mm).
|
|
11
11
|
*
|
|
12
12
|
* Ownership rules
|
|
13
13
|
* ---------------
|
|
@@ -15,291 +15,383 @@
|
|
|
15
15
|
* - Strings OUT : heap-allocated by Rust; caller must free with
|
|
16
16
|
* taladb_free_string().
|
|
17
17
|
* - Handles : allocated by taladb_open(); freed by taladb_close().
|
|
18
|
-
* - Errors : string functions return NULL; integer functions return -1
|
|
18
|
+
* - Errors : string functions return NULL; integer functions return -1,
|
|
19
|
+
* with detail available from taladb_last_error().
|
|
19
20
|
*/
|
|
20
21
|
|
|
22
|
+
|
|
23
|
+
#ifndef TALADB_FFI_H
|
|
24
|
+
#define TALADB_FFI_H
|
|
25
|
+
|
|
26
|
+
#pragma once
|
|
27
|
+
|
|
28
|
+
#include <stdarg.h>
|
|
29
|
+
#include <stdbool.h>
|
|
21
30
|
#include <stdint.h>
|
|
22
31
|
#include <stdlib.h>
|
|
23
32
|
|
|
24
|
-
#ifdef __cplusplus
|
|
25
|
-
extern "C" {
|
|
26
|
-
#endif
|
|
27
33
|
|
|
28
|
-
/* -------------------------------------------------------------------------
|
|
29
|
-
* Opaque database handle
|
|
30
|
-
* ---------------------------------------------------------------------- */
|
|
31
34
|
typedef struct TalaDbHandle TalaDbHandle;
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
+
/**
|
|
37
|
+
* A background job handle. Opaque to the caller.
|
|
38
|
+
*/
|
|
39
|
+
typedef struct TalaDbJob TalaDbJob;
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
#ifdef __cplusplus
|
|
42
|
+
extern "C" {
|
|
43
|
+
#endif // __cplusplus
|
|
39
44
|
|
|
40
45
|
/**
|
|
41
|
-
*
|
|
46
|
+
* Return the last error message as a null-terminated C string, or NULL if no error.
|
|
47
|
+
*
|
|
48
|
+
* The message always describes the most recent `taladb_*` call on this thread:
|
|
49
|
+
* every entry point clears the slot before doing any work, so a NULL return
|
|
50
|
+
* means that call succeeded rather than that it forgot to report.
|
|
42
51
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
52
|
+
* The returned pointer is valid until the next taladb_* call on this thread.
|
|
53
|
+
* Do NOT free the returned string.
|
|
45
54
|
*/
|
|
46
|
-
|
|
55
|
+
const char *taladb_last_error(void);
|
|
47
56
|
|
|
48
|
-
/**
|
|
49
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Open (or create) a TalaDB database at `path`.
|
|
59
|
+
*
|
|
60
|
+
* Returns an opaque handle, or NULL on failure.
|
|
61
|
+
* The handle must be freed with `taladb_close`.
|
|
62
|
+
*/
|
|
63
|
+
struct TalaDbHandle *taladb_open(const char *path);
|
|
50
64
|
|
|
51
65
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
66
|
+
* Open (or create) a TalaDB database at `path` with an optional config.
|
|
67
|
+
*
|
|
68
|
+
* `config_json` — JSON-serialised `TalaDbConfig` (durability, plus an optional
|
|
69
|
+
* `passphrase` for encryption at rest), or NULL for defaults. Change webhooks
|
|
70
|
+
* are delivered by the `taladb` TypeScript client, not by this binding.
|
|
71
|
+
*
|
|
72
|
+
* Unknown config keys are ignored so one config file can be shared with the TS
|
|
73
|
+
* client — **except** a key that differs from `passphrase` only in spelling, and
|
|
74
|
+
* a `passphrase` that is present but not a string. Both are errors rather than
|
|
75
|
+
* a silent unencrypted open; see [`passphrase_from_config`].
|
|
76
|
+
*
|
|
77
|
+
* Returns an opaque handle, or NULL on failure.
|
|
78
|
+
* The handle must be freed with `taladb_close`.
|
|
54
79
|
*/
|
|
55
|
-
|
|
80
|
+
struct TalaDbHandle *taladb_open_with_config(const char *path, const char *config_json);
|
|
56
81
|
|
|
57
|
-
/**
|
|
58
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Compact the underlying storage file for this database handle.
|
|
84
|
+
* No-op on in-memory databases. Returns 1 on success, -1 on error.
|
|
85
|
+
*/
|
|
86
|
+
int32_t taladb_compact(struct TalaDbHandle *handle);
|
|
59
87
|
|
|
60
|
-
|
|
61
|
-
*
|
|
62
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Close the database and free the handle.
|
|
90
|
+
*/
|
|
91
|
+
void taladb_close(struct TalaDbHandle *handle);
|
|
63
92
|
|
|
64
93
|
/**
|
|
65
|
-
*
|
|
94
|
+
* Free a string returned by any taladb_* function.
|
|
95
|
+
*/
|
|
96
|
+
void taladb_free_string(char *s);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Insert a document (JSON object string).
|
|
66
100
|
* Returns the new document's ULID as a C string, or NULL on error.
|
|
67
|
-
* Caller must free with taladb_free_string
|
|
101
|
+
* Caller must free the returned string with `taladb_free_string`.
|
|
68
102
|
*/
|
|
69
|
-
char *taladb_insert(TalaDbHandle *handle,
|
|
70
|
-
const char *collection,
|
|
71
|
-
const char *doc_json);
|
|
103
|
+
char *taladb_insert(struct TalaDbHandle *handle, const char *collection, const char *doc_json);
|
|
72
104
|
|
|
73
105
|
/**
|
|
74
106
|
* Insert multiple documents (JSON array of objects).
|
|
75
107
|
* Returns a JSON array of ULID strings, or NULL on error.
|
|
76
|
-
* Caller must free with taladb_free_string
|
|
108
|
+
* Caller must free with `taladb_free_string`.
|
|
109
|
+
*
|
|
110
|
+
* **All or nothing.** If any element of the array is not an object, the whole
|
|
111
|
+
* call fails and nothing is written. It previously skipped unparseable
|
|
112
|
+
* elements and returned a shorter id array, so a caller zipping the returned
|
|
113
|
+
* ids back onto its input silently mis-associated every document after the
|
|
114
|
+
* first bad one — and had no way to learn which had been dropped.
|
|
77
115
|
*/
|
|
78
|
-
char *taladb_insert_many(TalaDbHandle *handle,
|
|
79
|
-
const char
|
|
80
|
-
const char
|
|
81
|
-
|
|
82
|
-
/* -------------------------------------------------------------------------
|
|
83
|
-
* Find
|
|
84
|
-
* ---------------------------------------------------------------------- */
|
|
116
|
+
char *taladb_insert_many(struct TalaDbHandle *handle,
|
|
117
|
+
const char *collection,
|
|
118
|
+
const char *docs_json);
|
|
85
119
|
|
|
86
120
|
/**
|
|
87
|
-
* Find all documents matching filter_json
|
|
88
|
-
* Pass "{}" or "null" to match all.
|
|
121
|
+
* Find all documents matching `filter_json`.
|
|
122
|
+
* Pass `"{}"` or `"null"` to match all.
|
|
89
123
|
* Returns a JSON array string, or NULL on error.
|
|
90
|
-
* Caller must free with taladb_free_string
|
|
124
|
+
* Caller must free with `taladb_free_string`.
|
|
91
125
|
*/
|
|
92
|
-
char *taladb_find(TalaDbHandle *handle,
|
|
93
|
-
const char *collection,
|
|
94
|
-
const char *filter_json);
|
|
126
|
+
char *taladb_find(struct TalaDbHandle *handle, const char *collection, const char *filter_json);
|
|
95
127
|
|
|
96
128
|
/**
|
|
97
|
-
* Find
|
|
98
|
-
*
|
|
99
|
-
* Caller must free with taladb_free_string().
|
|
129
|
+
* Find one document matching `filter_json`, or JSON `null` if none.
|
|
130
|
+
* Caller must free with `taladb_free_string`.
|
|
100
131
|
*/
|
|
101
|
-
char *taladb_find_one(TalaDbHandle *handle,
|
|
102
|
-
const char *collection,
|
|
103
|
-
const char *filter_json);
|
|
132
|
+
char *taladb_find_one(struct TalaDbHandle *handle, const char *collection, const char *filter_json);
|
|
104
133
|
|
|
105
|
-
|
|
106
|
-
* Update
|
|
107
|
-
*
|
|
134
|
+
/**
|
|
135
|
+
* Update the first matching document.
|
|
136
|
+
* Returns 1 if updated, 0 if not found, -1 on error.
|
|
137
|
+
*/
|
|
138
|
+
int32_t taladb_update_one(struct TalaDbHandle *handle,
|
|
139
|
+
const char *collection,
|
|
140
|
+
const char *filter_json,
|
|
141
|
+
const char *update_json);
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Update all matching documents.
|
|
145
|
+
* Returns count updated, or -1 on error.
|
|
146
|
+
*/
|
|
147
|
+
int32_t taladb_update_many(struct TalaDbHandle *handle,
|
|
148
|
+
const char *collection,
|
|
149
|
+
const char *filter_json,
|
|
150
|
+
const char *update_json);
|
|
108
151
|
|
|
109
|
-
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
152
|
+
/**
|
|
153
|
+
* Delete the first matching document.
|
|
154
|
+
* Returns 1 if deleted, 0 if not found, -1 on error.
|
|
155
|
+
*/
|
|
156
|
+
int32_t taladb_delete_one(struct TalaDbHandle *handle,
|
|
157
|
+
const char *collection,
|
|
158
|
+
const char *filter_json);
|
|
114
159
|
|
|
115
|
-
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
160
|
+
/**
|
|
161
|
+
* Delete all matching documents.
|
|
162
|
+
* Returns count deleted, or -1 on error.
|
|
163
|
+
*/
|
|
164
|
+
int32_t taladb_delete_many(struct TalaDbHandle *handle,
|
|
165
|
+
const char *collection,
|
|
166
|
+
const char *filter_json);
|
|
120
167
|
|
|
121
|
-
|
|
122
|
-
*
|
|
123
|
-
*
|
|
168
|
+
/**
|
|
169
|
+
* Count documents matching `filter_json`.
|
|
170
|
+
* Returns count, or -1 on error.
|
|
171
|
+
*/
|
|
172
|
+
int32_t taladb_count(struct TalaDbHandle *handle, const char *collection, const char *filter_json);
|
|
124
173
|
|
|
125
|
-
/**
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
174
|
+
/**
|
|
175
|
+
* Run an aggregation pipeline (`pipeline_json` is a JSON array of stages).
|
|
176
|
+
* Returns a JSON array of result documents, or NULL on error.
|
|
177
|
+
* Caller must free with `taladb_free_string`.
|
|
178
|
+
*/
|
|
179
|
+
char *taladb_aggregate(struct TalaDbHandle *handle,
|
|
180
|
+
const char *collection,
|
|
181
|
+
const char *pipeline_json);
|
|
129
182
|
|
|
130
|
-
/**
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
183
|
+
/**
|
|
184
|
+
* User collection names (reserved `_`-prefixed excluded), as a JSON array
|
|
185
|
+
* string. Backs the sync orchestration's "sync all collections" default.
|
|
186
|
+
* NULL on error. Caller must free with `taladb_free_string`.
|
|
187
|
+
*/
|
|
188
|
+
char *taladb_list_collection_names(struct TalaDbHandle *handle);
|
|
134
189
|
|
|
135
|
-
|
|
136
|
-
*
|
|
137
|
-
*
|
|
190
|
+
/**
|
|
191
|
+
* Read the current application migration version (0 if never set), or -1 on
|
|
192
|
+
* error. Backs the `openDB({ migrations })` runner.
|
|
193
|
+
*/
|
|
194
|
+
int64_t taladb_user_version(struct TalaDbHandle *handle);
|
|
138
195
|
|
|
139
|
-
/**
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
196
|
+
/**
|
|
197
|
+
* Persist the application migration version. Returns 0 on success, -1 on error.
|
|
198
|
+
*/
|
|
199
|
+
int32_t taladb_set_user_version(struct TalaDbHandle *handle, uint32_t version);
|
|
143
200
|
|
|
144
|
-
|
|
145
|
-
*
|
|
146
|
-
*
|
|
201
|
+
/**
|
|
202
|
+
* Force any batched (eventual-durability) writes to disk. Returns 0 on
|
|
203
|
+
* success, -1 on error. No-op under the default immediate durability.
|
|
204
|
+
*/
|
|
205
|
+
int32_t taladb_flush(struct TalaDbHandle *handle);
|
|
147
206
|
|
|
148
207
|
/**
|
|
149
|
-
*
|
|
150
|
-
* Returns a JSON array of result documents, or NULL on error.
|
|
151
|
-
* Caller must free with taladb_free_string().
|
|
208
|
+
* Create a secondary index on `field`. No-op if already exists.
|
|
152
209
|
*/
|
|
153
|
-
|
|
154
|
-
const char *collection,
|
|
155
|
-
const char *pipeline_json);
|
|
210
|
+
void taladb_create_index(struct TalaDbHandle *handle, const char *collection, const char *field);
|
|
156
211
|
|
|
157
212
|
/**
|
|
158
|
-
*
|
|
159
|
-
* Returns NULL on error. Caller must free with taladb_free_string().
|
|
213
|
+
* Drop a secondary index on `field`.
|
|
160
214
|
*/
|
|
161
|
-
|
|
215
|
+
void taladb_drop_index(struct TalaDbHandle *handle, const char *collection, const char *field);
|
|
162
216
|
|
|
163
217
|
/**
|
|
164
|
-
*
|
|
165
|
-
* taladb_user_version returns the version (0 if unset) or -1 on error;
|
|
166
|
-
* taladb_set_user_version returns 0 on success, -1 on error.
|
|
218
|
+
* Create a compound index over `fields_json` (a JSON array of field names).
|
|
167
219
|
*/
|
|
168
|
-
|
|
169
|
-
|
|
220
|
+
void taladb_create_compound_index(struct TalaDbHandle *handle,
|
|
221
|
+
const char *collection,
|
|
222
|
+
const char *fields_json);
|
|
170
223
|
|
|
171
224
|
/**
|
|
172
|
-
*
|
|
173
|
-
* -1 on error. No-op under the default immediate durability. Backs db.flush().
|
|
225
|
+
* Drop a compound index by its ordered field list (`fields_json`).
|
|
174
226
|
*/
|
|
175
|
-
|
|
227
|
+
void taladb_drop_compound_index(struct TalaDbHandle *handle,
|
|
228
|
+
const char *collection,
|
|
229
|
+
const char *fields_json);
|
|
176
230
|
|
|
177
|
-
|
|
178
|
-
*
|
|
179
|
-
|
|
231
|
+
/**
|
|
232
|
+
* Create a full-text search index on `field`.
|
|
233
|
+
*/
|
|
234
|
+
void taladb_create_fts_index(struct TalaDbHandle *handle,
|
|
235
|
+
const char *collection,
|
|
236
|
+
const char *field);
|
|
180
237
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
void taladb_drop_fts_index
|
|
238
|
+
/**
|
|
239
|
+
* Drop a full-text search index on `field`.
|
|
240
|
+
*/
|
|
241
|
+
void taladb_drop_fts_index(struct TalaDbHandle *handle, const char *collection, const char *field);
|
|
185
242
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
243
|
+
/**
|
|
244
|
+
* Rank documents against a free-text query using BM25 (OR semantics).
|
|
245
|
+
*
|
|
246
|
+
* `filter_json` / `options_json` may be NULL. `options_json` accepts
|
|
247
|
+
* `{ k1, b }`.
|
|
248
|
+
*
|
|
249
|
+
* Returns a JSON array string `[{document, score}, ...]`, or NULL on error.
|
|
250
|
+
* Caller must free with `taladb_free_string`.
|
|
251
|
+
*/
|
|
252
|
+
char *taladb_search_text(struct TalaDbHandle *handle,
|
|
253
|
+
const char *collection,
|
|
254
|
+
const char *field,
|
|
255
|
+
const char *query,
|
|
256
|
+
uintptr_t top_k,
|
|
257
|
+
const char *filter_json,
|
|
258
|
+
const char *options_json);
|
|
189
259
|
|
|
190
|
-
|
|
191
|
-
*
|
|
260
|
+
/**
|
|
261
|
+
* Hybrid retrieval — BM25 and vector similarity fused with reciprocal rank
|
|
262
|
+
* fusion.
|
|
192
263
|
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* ---------------------------------------------------------------------- */
|
|
196
|
-
|
|
197
|
-
int32_t taladb_create_vector_index(TalaDbHandle *handle,
|
|
198
|
-
const char *collection,
|
|
199
|
-
const char *field,
|
|
200
|
-
size_t dimensions,
|
|
201
|
-
const char *metric,
|
|
202
|
-
const char *hnsw_json);
|
|
203
|
-
|
|
204
|
-
int32_t taladb_drop_vector_index (TalaDbHandle *handle, const char *collection, const char *field);
|
|
205
|
-
int32_t taladb_upgrade_vector_index(TalaDbHandle *handle, const char *collection, const char *field);
|
|
206
|
-
|
|
207
|
-
/* -------------------------------------------------------------------------
|
|
208
|
-
* findNearest — Float32 zero-copy fast path
|
|
264
|
+
* `vector_ptr` must point to `vector_len` consecutive `f32` values.
|
|
265
|
+
* `options_json` accepts `{ rrfK, textWeight, vectorWeight, candidates, k1, b }`.
|
|
209
266
|
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* filter_json may be NULL / "{}" / "null" to search without a pre-filter.
|
|
267
|
+
* Returns a JSON array string `[{document, score, textRank, vectorRank}, ...]`,
|
|
268
|
+
* or NULL on error. Caller must free with `taladb_free_string`.
|
|
213
269
|
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
char *
|
|
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
|
-
|
|
270
|
+
* # Safety
|
|
271
|
+
* `vector_ptr` must be valid for `vector_len` `f32` reads.
|
|
272
|
+
*/
|
|
273
|
+
char *taladb_hybrid_search(struct TalaDbHandle *handle,
|
|
274
|
+
const char *collection,
|
|
275
|
+
const char *text_field,
|
|
276
|
+
const char *text,
|
|
277
|
+
const char *vector_field,
|
|
278
|
+
const float *vector_ptr,
|
|
279
|
+
uintptr_t vector_len,
|
|
280
|
+
uintptr_t top_k,
|
|
281
|
+
const char *filter_json,
|
|
282
|
+
const char *options_json);
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Create a vector index. `metric` and `hnsw_json` may be NULL.
|
|
286
|
+
* Returns 1 on success, -1 on error.
|
|
287
|
+
*/
|
|
288
|
+
int32_t taladb_create_vector_index(struct TalaDbHandle *handle,
|
|
289
|
+
const char *collection,
|
|
290
|
+
const char *field,
|
|
291
|
+
uintptr_t dimensions,
|
|
292
|
+
const char *metric,
|
|
293
|
+
const char *hnsw_json);
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Drop a vector index. Returns 1 on success, -1 on error.
|
|
297
|
+
*/
|
|
298
|
+
int32_t taladb_drop_vector_index(struct TalaDbHandle *handle,
|
|
299
|
+
const char *collection,
|
|
300
|
+
const char *field);
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Promote a flat/legacy vector index or compact its persistent HNSW graph.
|
|
304
|
+
* Returns 1 on success, -1 on error.
|
|
305
|
+
*/
|
|
306
|
+
int32_t taladb_upgrade_vector_index(struct TalaDbHandle *handle,
|
|
307
|
+
const char *collection,
|
|
308
|
+
const char *field);
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Rebuild every configured persistent HNSW graph in the database.
|
|
255
312
|
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
* while (taladb_job_poll(j) == 0) { } // yield to JS event loop
|
|
260
|
-
* char *json = taladb_job_take_result(j); // frees the job
|
|
313
|
+
* This walks the stored HNSW options and rebuilds each one, so a caller does
|
|
314
|
+
* not have to know which collections and fields were configured as HNSW —
|
|
315
|
+
* unlike `taladb_upgrade_vector_index`, which rebuilds a single named field.
|
|
261
316
|
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
317
|
+
* It reads and re-inserts every indexed vector, so call it for maintenance or
|
|
318
|
+
* legacy migration and off any latency-sensitive path. Normal startup does
|
|
319
|
+
* not need a rebuild. Returns 1 on success, -1 on error.
|
|
320
|
+
*/
|
|
321
|
+
int32_t taladb_rebuild_hnsw_indexes(struct TalaDbHandle *handle);
|
|
264
322
|
|
|
265
|
-
|
|
323
|
+
/**
|
|
324
|
+
* Synchronous `find_nearest` with a zero-copy Float32 query vector.
|
|
325
|
+
*
|
|
326
|
+
* `query_ptr` — pointer to `query_len` consecutive f32 values (caller-owned).
|
|
327
|
+
* `filter_json` — optional pre-filter JSON (may be NULL / "{}" / "null").
|
|
328
|
+
*
|
|
329
|
+
* Returns a JSON array string `[{document, score}, ...]`, or NULL on error.
|
|
330
|
+
* Caller must free with `taladb_free_string`.
|
|
331
|
+
*/
|
|
332
|
+
char *taladb_find_nearest(struct TalaDbHandle *handle,
|
|
333
|
+
const char *collection,
|
|
334
|
+
const char *field,
|
|
335
|
+
const float *query_ptr,
|
|
336
|
+
uintptr_t query_len,
|
|
337
|
+
uintptr_t top_k,
|
|
338
|
+
const char *filter_json);
|
|
266
339
|
|
|
267
|
-
/**
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const float *query_ptr,
|
|
272
|
-
size_t query_len,
|
|
273
|
-
size_t top_k,
|
|
274
|
-
const char *filter_json);
|
|
340
|
+
/**
|
|
341
|
+
* Non-blocking poll. Returns 1 if the job has finished, 0 if still running.
|
|
342
|
+
*/
|
|
343
|
+
int32_t taladb_job_poll(struct TalaDbJob *job);
|
|
275
344
|
|
|
276
|
-
/**
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
345
|
+
/**
|
|
346
|
+
* Wait for the job to complete, take its result, and free the job.
|
|
347
|
+
* Returns the result JSON string on success, or NULL on error (see
|
|
348
|
+
* `taladb_last_error`). Always consumes and frees the job.
|
|
349
|
+
* Caller must free the returned string with `taladb_free_string`.
|
|
350
|
+
*/
|
|
351
|
+
char *taladb_job_take_result(struct TalaDbJob *job);
|
|
280
352
|
|
|
281
|
-
/**
|
|
282
|
-
|
|
353
|
+
/**
|
|
354
|
+
* Cancel (detach) the job and free its handle. The worker owns a clone of all
|
|
355
|
+
* database state it needs, so it can safely finish after the caller closes the
|
|
356
|
+
* original database handle.
|
|
357
|
+
*/
|
|
358
|
+
void taladb_job_cancel(struct TalaDbJob *job);
|
|
283
359
|
|
|
284
360
|
/**
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
361
|
+
* Start a bounded JSON operation on a background worker.
|
|
362
|
+
*
|
|
363
|
+
* # Safety
|
|
364
|
+
* The handle must be live; both strings must be valid NUL-terminated UTF-8
|
|
365
|
+
* for this call. All arguments are copied before returning.
|
|
288
366
|
*/
|
|
289
|
-
|
|
367
|
+
struct TalaDbJob *taladb_call_start(struct TalaDbHandle *handle,
|
|
368
|
+
const char *op,
|
|
369
|
+
const char *args_json);
|
|
290
370
|
|
|
291
|
-
/**
|
|
292
|
-
|
|
371
|
+
/**
|
|
372
|
+
* Start a `find_nearest` in a background thread. Returns a job handle, or
|
|
373
|
+
* NULL on immediate error (bad args). The Float32 query vector is copied
|
|
374
|
+
* into the thread before the call returns, so `query_ptr` may be freed
|
|
375
|
+
* immediately after this function returns.
|
|
376
|
+
*/
|
|
377
|
+
struct TalaDbJob *taladb_find_nearest_start(struct TalaDbHandle *handle,
|
|
378
|
+
const char *collection,
|
|
379
|
+
const char *field,
|
|
380
|
+
const float *query_ptr,
|
|
381
|
+
uintptr_t query_len,
|
|
382
|
+
uintptr_t top_k,
|
|
383
|
+
const char *filter_json);
|
|
293
384
|
|
|
294
385
|
/**
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
* Do NOT free.
|
|
386
|
+
* Start a `find` in a background thread. Returns a job handle, or NULL on
|
|
387
|
+
* immediate error.
|
|
298
388
|
*/
|
|
299
|
-
|
|
389
|
+
struct TalaDbJob *taladb_find_start(struct TalaDbHandle *handle,
|
|
390
|
+
const char *collection,
|
|
391
|
+
const char *filter_json);
|
|
300
392
|
|
|
301
393
|
#ifdef __cplusplus
|
|
302
|
-
}
|
|
303
|
-
#endif
|
|
394
|
+
} // extern "C"
|
|
395
|
+
#endif // __cplusplus
|
|
304
396
|
|
|
305
|
-
#endif
|
|
397
|
+
#endif /* TALADB_FFI_H */
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taladb/react-native",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4",
|
|
4
4
|
"description": "TalaDB React Native module — document and vector database via JSI HostObject",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"types": "src/index.tsx",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"react-native": "^0.83.0"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"taladb": "0.11.
|
|
52
|
+
"taladb": "0.11.4"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"typecheck": "tsc --noEmit",
|
|
56
56
|
"build:ios": "sh scripts/build-ios.sh",
|
|
57
57
|
"build:android": "sh scripts/build-android.sh",
|
|
58
|
-
"build:cbindgen": "cbindgen --config
|
|
58
|
+
"build:cbindgen": "cd rust && cbindgen --config cbindgen.toml --crate taladb-ffi --output ../cpp/taladb.h"
|
|
59
59
|
}
|
|
60
60
|
}
|