vldb-sqlite 0.1.5

A Rust gRPC, library, and FFI gateway for SQLite with JSON and Arrow IPC query paths.
Documentation
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
#ifndef VLDB_SQLITE_H
#define VLDB_SQLITE_H

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * FFI 状态码;0 表示成功,1 表示失败。
 * FFI status code; 0 means success and 1 means failure.
 */
typedef enum VldbSqliteStatusCode {
    VLDB_SQLITE_STATUS_SUCCESS = 0,
    VLDB_SQLITE_STATUS_FAILURE = 1
} VldbSqliteStatusCode;

/*
 * FFI 分词模式枚举。
 * FFI tokenizer mode enum.
 */
typedef enum VldbSqliteFfiTokenizerMode {
    VLDB_SQLITE_TOKENIZER_NONE = 0,
    VLDB_SQLITE_TOKENIZER_JIEBA = 1
} VldbSqliteFfiTokenizerMode;

/*
 * Runtime 句柄前置声明。
 * Forward declaration of the runtime handle.
 */
typedef struct VldbSqliteRuntimeHandle VldbSqliteRuntimeHandle;

/*
 * 数据库句柄前置声明。
 * Forward declaration of the database handle.
 */
typedef struct VldbSqliteDatabaseHandle VldbSqliteDatabaseHandle;

/*
 * 分词结果句柄前置声明。
 * Forward declaration of the tokenize-result handle.
 */
typedef struct VldbSqliteTokenizeResultHandle VldbSqliteTokenizeResultHandle;

/*
 * 自定义词列表句柄前置声明。
 * Forward declaration of the custom-word list handle.
 */
typedef struct VldbSqliteCustomWordListHandle VldbSqliteCustomWordListHandle;

/*
 * 检索结果句柄前置声明。
 * Forward declaration of the search-result handle.
 */
typedef struct VldbSqliteSearchResultHandle VldbSqliteSearchResultHandle;

/*
 * 通用 SQL 执行结果句柄前置声明。
 * Forward declaration of the shared SQL execution-result handle.
 */
typedef struct VldbSqliteExecuteResultHandle VldbSqliteExecuteResultHandle;

/*
 * JSON 查询结果句柄前置声明。
 * Forward declaration of the JSON-query result handle.
 */
typedef struct VldbSqliteQueryJsonResultHandle VldbSqliteQueryJsonResultHandle;

/*
 * Arrow IPC chunk 查询结果句柄前置声明。
 * Forward declaration of the Arrow IPC chunk query-result handle.
 */
typedef struct VldbSqliteQueryStreamHandle VldbSqliteQueryStreamHandle;

/*
 * 自定义词修改结果结构。
 * Custom-word mutation result structure.
 */
typedef struct VldbSqliteDictionaryMutationResultPod {
    uint8_t success;
    uint64_t affected_rows;
} VldbSqliteDictionaryMutationResultPod;

/*
 * FTS 索引确保结果结构。
 * FTS ensure-index result structure.
 */
typedef struct VldbSqliteEnsureFtsIndexResultPod {
    uint8_t success;
    uint32_t tokenizer_mode;
} VldbSqliteEnsureFtsIndexResultPod;

/*
 * FTS 索引重建结果结构。
 * FTS rebuild-index result structure.
 */
typedef struct VldbSqliteRebuildFtsIndexResultPod {
    uint8_t success;
    uint32_t tokenizer_mode;
    uint64_t reindexed_rows;
} VldbSqliteRebuildFtsIndexResultPod;

/*
 * FTS 文档写入/删除结果结构。
 * FTS document mutation result structure.
 */
typedef struct VldbSqliteFtsMutationResultPod {
    uint8_t success;
    uint64_t affected_rows;
} VldbSqliteFtsMutationResultPod;

/*
 * 字节视图结构,供 FFI 输入 bytes 参数使用。
 * Byte-view structure used for FFI input bytes parameters.
 */
typedef struct VldbSqliteByteView {
    const uint8_t* data;
    uint64_t len;
} VldbSqliteByteView;

/*
 * 可释放字节缓冲区结构,供 QueryStream chunk getter 返回。
 * Releasable byte-buffer structure returned by QueryStream chunk getters.
 */
typedef struct VldbSqliteByteBuffer {
    uint8_t* data;
    uint64_t len;
    uint64_t cap;
} VldbSqliteByteBuffer;

/*
 * FFI SQL 值类型枚举。
 * FFI SQL value-kind enum.
 */
typedef enum VldbSqliteFfiValueKind {
    VLDB_SQLITE_VALUE_NULL = 0,
    VLDB_SQLITE_VALUE_INT64 = 1,
    VLDB_SQLITE_VALUE_FLOAT64 = 2,
    VLDB_SQLITE_VALUE_STRING = 3,
    VLDB_SQLITE_VALUE_BYTES = 4,
    VLDB_SQLITE_VALUE_BOOL = 5
} VldbSqliteFfiValueKind;

/*
 * FFI SQL 参数值结构。
 * FFI SQL parameter value structure.
 */
typedef struct VldbSqliteFfiValue {
    VldbSqliteFfiValueKind kind;
    int64_t int64_value;
    double float64_value;
    const char* string_value;
    VldbSqliteByteView bytes_value;
    uint8_t bool_value;
} VldbSqliteFfiValue;

/*
 * FFI SQL 参数切片结构。
 * FFI SQL parameter-slice structure.
 */
typedef struct VldbSqliteFfiValueSlice {
    const VldbSqliteFfiValue* values;
    uint64_t len;
} VldbSqliteFfiValueSlice;

/*
 * 返回 `vldb-sqlite` 当前库模式元信息 JSON。
 * Return the current library-mode metadata JSON for `vldb-sqlite`.
 */
char* vldb_sqlite_library_info_json(void);

/*
 * 创建默认多库 runtime 句柄。
 * Create a default multi-database runtime handle.
 */
VldbSqliteRuntimeHandle* vldb_sqlite_runtime_create_default(void);

/*
 * 释放多库 runtime 句柄。
 * Destroy a multi-database runtime handle.
 */
void vldb_sqlite_runtime_destroy(VldbSqliteRuntimeHandle* handle);

/*
 * 打开或复用指定路径的数据库句柄。
 * Open or reuse a database handle for the specified path.
 */
VldbSqliteDatabaseHandle* vldb_sqlite_runtime_open_database(
    VldbSqliteRuntimeHandle* runtime,
    const char* db_path
);

/*
 * 关闭 runtime 中缓存的数据库。
 * Close a cached database from the runtime.
 */
uint8_t vldb_sqlite_runtime_close_database(
    VldbSqliteRuntimeHandle* runtime,
    const char* db_path
);

/*
 * 释放数据库句柄。
 * Destroy a database handle.
 */
void vldb_sqlite_database_destroy(VldbSqliteDatabaseHandle* handle);

/*
 * 返回数据库句柄绑定的路径字符串。
 * Return the bound database path string for a database handle.
 */
char* vldb_sqlite_database_db_path(VldbSqliteDatabaseHandle* handle);

/*
 * 释放由本库分配的字符串。
 * Free a string allocated by this library.
 */
void vldb_sqlite_string_free(char* value);

/*
 * 释放由 QueryStream chunk getter 返回的字节缓冲区。
 * Free a byte buffer returned by a QueryStream chunk getter.
 */
void vldb_sqlite_bytes_free(VldbSqliteByteBuffer buffer);

/*
 * 获取最近一次 FFI 错误消息;返回指针在下一次错误更新或 clear 后失效。
 * Return the latest FFI error message; the pointer becomes invalid after the next error update or clear.
 */
const char* vldb_sqlite_last_error_message(void);

/*
 * 清理最近一次 FFI 错误消息。
 * Clear the latest FFI error message.
 */
void vldb_sqlite_clear_last_error(void);

/*
 * 返回 JSON 指针是否为空。
 * Return whether the JSON pointer is null.
 */
uint8_t vldb_sqlite_json_is_null(const char* value);

/*
 * 通过数据库句柄执行脚本或单条 SQL。
 * Execute a script or a single SQL statement through a database handle.
 */
VldbSqliteExecuteResultHandle* vldb_sqlite_database_execute_script(
    VldbSqliteDatabaseHandle* handle,
    const char* sql,
    const VldbSqliteFfiValue* params,
    uint64_t params_len,
    const char* params_json
);

/*
 * 通过数据库句柄执行批量 SQL。
 * Execute batch SQL through a database handle.
 */
VldbSqliteExecuteResultHandle* vldb_sqlite_database_execute_batch(
    VldbSqliteDatabaseHandle* handle,
    const char* sql,
    const VldbSqliteFfiValueSlice* items,
    uint64_t items_len
);

/*
 * 通过数据库句柄执行 JSON 查询。
 * Execute a JSON query through a database handle.
 */
VldbSqliteQueryJsonResultHandle* vldb_sqlite_database_query_json(
    VldbSqliteDatabaseHandle* handle,
    const char* sql,
    const VldbSqliteFfiValue* params,
    uint64_t params_len,
    const char* params_json
);

/*
 * 通过数据库句柄执行 Arrow IPC chunk 查询。
 * Execute an Arrow IPC chunk query through a database handle.
 */
VldbSqliteQueryStreamHandle* vldb_sqlite_database_query_stream(
    VldbSqliteDatabaseHandle* handle,
    const char* sql,
    const VldbSqliteFfiValue* params,
    uint64_t params_len,
    const char* params_json,
    uint64_t chunk_bytes
);

/*
 * 释放通用 SQL 执行结果句柄。
 * Destroy a shared SQL execution-result handle.
 */
void vldb_sqlite_execute_result_destroy(VldbSqliteExecuteResultHandle* handle);

/*
 * 返回通用 SQL 执行结果中的 success 标志。
 * Return the success flag from a shared SQL execution result.
 */
uint8_t vldb_sqlite_execute_result_success(VldbSqliteExecuteResultHandle* handle);

/*
 * 返回通用 SQL 执行结果中的 message。
 * Return the message from a shared SQL execution result.
 */
char* vldb_sqlite_execute_result_message(VldbSqliteExecuteResultHandle* handle);

/*
 * 返回通用 SQL 执行结果中的 rows_changed。
 * Return rows_changed from a shared SQL execution result.
 */
int64_t vldb_sqlite_execute_result_rows_changed(VldbSqliteExecuteResultHandle* handle);

/*
 * 返回通用 SQL 执行结果中的 last_insert_rowid。
 * Return last_insert_rowid from a shared SQL execution result.
 */
int64_t vldb_sqlite_execute_result_last_insert_rowid(VldbSqliteExecuteResultHandle* handle);

/*
 * 返回通用 SQL 执行结果中的 statements_executed。
 * Return statements_executed from a shared SQL execution result.
 */
int64_t vldb_sqlite_execute_result_statements_executed(VldbSqliteExecuteResultHandle* handle);

/*
 * 释放 JSON 查询结果句柄。
 * Destroy a JSON-query result handle.
 */
void vldb_sqlite_query_json_result_destroy(VldbSqliteQueryJsonResultHandle* handle);

/*
 * 返回 JSON 查询结果中的 JSON 行集字符串。
 * Return the JSON row-set string from a JSON-query result.
 */
char* vldb_sqlite_query_json_result_json_data(VldbSqliteQueryJsonResultHandle* handle);

/*
 * 返回 JSON 查询结果中的行数。
 * Return the row count from a JSON-query result.
 */
uint64_t vldb_sqlite_query_json_result_row_count(VldbSqliteQueryJsonResultHandle* handle);

/*
 * 释放 Arrow IPC chunk 查询结果句柄。
 * Destroy an Arrow IPC chunk query-result handle.
 */
void vldb_sqlite_query_stream_destroy(VldbSqliteQueryStreamHandle* handle);

/*
 * 返回 Arrow IPC chunk 数量。
 * Return the number of Arrow IPC chunks.
 */
uint64_t vldb_sqlite_query_stream_chunk_count(VldbSqliteQueryStreamHandle* handle);

/*
 * 返回 Arrow IPC chunk 查询结果中的行数。
 * Return the row count from an Arrow IPC chunk query result.
 */
uint64_t vldb_sqlite_query_stream_row_count(VldbSqliteQueryStreamHandle* handle);

/*
 * 返回 Arrow IPC chunk 查询结果的总字节数。
 * Return the total byte count from an Arrow IPC chunk query result.
 */
uint64_t vldb_sqlite_query_stream_total_bytes(VldbSqliteQueryStreamHandle* handle);

/*
 * 返回指定下标的 Arrow IPC chunk。
 * Return the Arrow IPC chunk at the specified index.
 */
VldbSqliteByteBuffer vldb_sqlite_query_stream_get_chunk(
    VldbSqliteQueryStreamHandle* handle,
    uint64_t index
);

/*
 * 通过数据库句柄执行分词主接口,返回结果句柄。
 * Execute the main tokenize interface from a database handle and return a result handle.
 */
VldbSqliteTokenizeResultHandle* vldb_sqlite_database_tokenize_text(
    VldbSqliteDatabaseHandle* handle,
    VldbSqliteFfiTokenizerMode tokenizer_mode,
    const char* text,
    uint8_t search_mode
);

/*
 * 释放分词结果句柄。
 * Destroy a tokenize-result handle.
 */
void vldb_sqlite_tokenize_result_destroy(VldbSqliteTokenizeResultHandle* handle);

/*
 * 返回分词结果中的规范化文本。
 * Return the normalized text from a tokenize result.
 */
char* vldb_sqlite_tokenize_result_normalized_text(VldbSqliteTokenizeResultHandle* handle);

/*
 * 返回分词结果中的 FTS 查询表达式。
 * Return the FTS query expression from a tokenize result.
 */
char* vldb_sqlite_tokenize_result_fts_query(VldbSqliteTokenizeResultHandle* handle);

/*
 * 返回分词结果中的词元数量。
 * Return the token count from a tokenize result.
 */
uint64_t vldb_sqlite_tokenize_result_token_count(VldbSqliteTokenizeResultHandle* handle);

/*
 * 返回指定下标的词元字符串。
 * Return the token string at the specified index.
 */
char* vldb_sqlite_tokenize_result_get_token(
    VldbSqliteTokenizeResultHandle* handle,
    uint64_t index
);

/*
 * 通过数据库句柄写入或更新自定义词。
 * Upsert a custom dictionary word through a database handle.
 */
int32_t vldb_sqlite_database_upsert_custom_word(
    VldbSqliteDatabaseHandle* handle,
    const char* word,
    uint64_t weight,
    VldbSqliteDictionaryMutationResultPod* out_result
);

/*
 * 通过数据库句柄删除自定义词。
 * Remove a custom dictionary word through a database handle.
 */
int32_t vldb_sqlite_database_remove_custom_word(
    VldbSqliteDatabaseHandle* handle,
    const char* word,
    VldbSqliteDictionaryMutationResultPod* out_result
);

/*
 * 通过数据库句柄列出自定义词,返回列表句柄。
 * List custom words through a database handle and return a list handle.
 */
VldbSqliteCustomWordListHandle* vldb_sqlite_database_list_custom_words(
    VldbSqliteDatabaseHandle* handle
);

/*
 * 释放自定义词列表句柄。
 * Destroy a custom-word list handle.
 */
void vldb_sqlite_custom_word_list_destroy(VldbSqliteCustomWordListHandle* handle);

/*
 * 返回自定义词列表长度。
 * Return the number of custom words in the list.
 */
uint64_t vldb_sqlite_custom_word_list_len(VldbSqliteCustomWordListHandle* handle);

/*
 * 返回指定自定义词条目的词文本。
 * Return the word text of a specific custom-word entry.
 */
char* vldb_sqlite_custom_word_list_get_word(
    VldbSqliteCustomWordListHandle* handle,
    uint64_t index
);

/*
 * 返回指定自定义词条目的权重。
 * Return the weight of a specific custom-word entry.
 */
uint64_t vldb_sqlite_custom_word_list_get_weight(
    VldbSqliteCustomWordListHandle* handle,
    uint64_t index
);

/*
 * 通过数据库句柄确保 FTS 索引存在。
 * Ensure an FTS index exists through a database handle.
 */
int32_t vldb_sqlite_database_ensure_fts_index(
    VldbSqliteDatabaseHandle* handle,
    const char* index_name,
    VldbSqliteFfiTokenizerMode tokenizer_mode,
    VldbSqliteEnsureFtsIndexResultPod* out_result
);

/*
 * 通过数据库句柄重建 FTS 索引。
 * Rebuild an FTS index through a database handle.
 */
int32_t vldb_sqlite_database_rebuild_fts_index(
    VldbSqliteDatabaseHandle* handle,
    const char* index_name,
    VldbSqliteFfiTokenizerMode tokenizer_mode,
    VldbSqliteRebuildFtsIndexResultPod* out_result
);

/*
 * 通过数据库句柄写入或更新 FTS 文档。
 * Upsert an FTS document through a database handle.
 */
int32_t vldb_sqlite_database_upsert_fts_document(
    VldbSqliteDatabaseHandle* handle,
    const char* index_name,
    VldbSqliteFfiTokenizerMode tokenizer_mode,
    const char* id,
    const char* file_path,
    const char* title,
    const char* content,
    VldbSqliteFtsMutationResultPod* out_result
);

/*
 * 通过数据库句柄删除 FTS 文档。
 * Delete an FTS document through a database handle.
 */
int32_t vldb_sqlite_database_delete_fts_document(
    VldbSqliteDatabaseHandle* handle,
    const char* index_name,
    const char* id,
    VldbSqliteFtsMutationResultPod* out_result
);

/*
 * 通过数据库句柄执行 FTS 检索并返回结果句柄。
 * Execute FTS search through a database handle and return a result handle.
 */
VldbSqliteSearchResultHandle* vldb_sqlite_database_search_fts(
    VldbSqliteDatabaseHandle* handle,
    const char* index_name,
    VldbSqliteFfiTokenizerMode tokenizer_mode,
    const char* query,
    uint32_t limit,
    uint32_t offset
);

/*
 * 释放 FTS 检索结果句柄。
 * Destroy an FTS search-result handle.
 */
void vldb_sqlite_search_result_destroy(VldbSqliteSearchResultHandle* handle);

/*
 * 返回 FTS 检索总命中数。
 * Return the total hit count of an FTS search result.
 */
uint64_t vldb_sqlite_search_result_total(VldbSqliteSearchResultHandle* handle);

/*
 * 返回 FTS 检索当前页命中数。
 * Return the page hit count of an FTS search result.
 */
uint64_t vldb_sqlite_search_result_len(VldbSqliteSearchResultHandle* handle);

/*
 * 返回检索结果的来源标签。
 * Return the source label of a search result.
 */
char* vldb_sqlite_search_result_source(VldbSqliteSearchResultHandle* handle);

/*
 * 返回检索结果的查询模式标签。
 * Return the query-mode label of a search result.
 */
char* vldb_sqlite_search_result_query_mode(VldbSqliteSearchResultHandle* handle);

/*
 * 返回指定命中的业务 ID。
 * Return the business ID of the specified hit.
 */
char* vldb_sqlite_search_result_get_id(VldbSqliteSearchResultHandle* handle, uint64_t index);

/*
 * 返回指定命中的文件路径。
 * Return the file path of the specified hit.
 */
char* vldb_sqlite_search_result_get_file_path(
    VldbSqliteSearchResultHandle* handle,
    uint64_t index
);

/*
 * 返回指定命中的标题。
 * Return the title of the specified hit.
 */
char* vldb_sqlite_search_result_get_title(VldbSqliteSearchResultHandle* handle, uint64_t index);

/*
 * 返回指定命中的高亮标题。
 * Return the highlighted title of the specified hit.
 */
char* vldb_sqlite_search_result_get_title_highlight(
    VldbSqliteSearchResultHandle* handle,
    uint64_t index
);

/*
 * 返回指定命中的内容片段。
 * Return the content snippet of the specified hit.
 */
char* vldb_sqlite_search_result_get_content_snippet(
    VldbSqliteSearchResultHandle* handle,
    uint64_t index
);

/*
 * 返回指定命中的标准化分数。
 * Return the normalized score of the specified hit.
 */
double vldb_sqlite_search_result_get_score(VldbSqliteSearchResultHandle* handle, uint64_t index);

/*
 * 返回指定命中的名次。
 * Return the rank of the specified hit.
 */
uint64_t vldb_sqlite_search_result_get_rank(VldbSqliteSearchResultHandle* handle, uint64_t index);

/*
 * 返回指定命中的原始 BM25 分数。
 * Return the raw BM25 score of the specified hit.
 */
double vldb_sqlite_search_result_get_raw_score(
    VldbSqliteSearchResultHandle* handle,
    uint64_t index
);

/*
 * 通过 JSON 请求执行脚本或单条 SQL。
 * Execute a script or a single SQL statement from a JSON request.
 */
char* vldb_sqlite_execute_script_json(const char* request_json);

/*
 * 通过 JSON 请求执行批量 SQL。
 * Execute batch SQL from a JSON request.
 */
char* vldb_sqlite_execute_batch_json(const char* request_json);

/*
 * 通过 JSON 请求执行 JSON 查询。
 * Execute a JSON query from a JSON request.
 */
char* vldb_sqlite_query_json_json(const char* request_json);

/*
 * 通过 JSON 请求执行 Arrow IPC chunk 查询。
 * Execute an Arrow IPC chunk query from a JSON request.
 */
char* vldb_sqlite_query_stream_json(const char* request_json);

/*
 * 通过 JSON 请求读取指定 QueryStream 句柄中的单个 chunk。
 * Read a single chunk from a JSON QueryStream handle.
 */
char* vldb_sqlite_query_stream_chunk_json(const char* request_json);

/*
 * 通过 JSON 请求关闭 QueryStream 句柄并释放缓存结果。
 * Close a JSON QueryStream handle and release cached results.
 */
char* vldb_sqlite_query_stream_close_json(const char* request_json);

/*
 * 通过 JSON 请求执行分词;请求和响应都使用 UTF-8 JSON 字符串。
 * Execute tokenization from a JSON request; both request and response are UTF-8 JSON strings.
 */
char* vldb_sqlite_tokenize_text_json(const char* request_json);

/*
 * 通过 JSON 请求写入或更新自定义词。
 * Upsert a custom dictionary word from a JSON request.
 */
char* vldb_sqlite_upsert_custom_word_json(const char* request_json);

/*
 * 通过 JSON 请求删除自定义词。
 * Remove a custom dictionary word from a JSON request.
 */
char* vldb_sqlite_remove_custom_word_json(const char* request_json);

/*
 * 通过 JSON 请求列出当前库中的自定义词。
 * List custom dictionary words from a JSON request.
 */
char* vldb_sqlite_list_custom_words_json(const char* request_json);

/*
 * 通过 JSON 请求确保 FTS 索引存在。
 * Ensure an FTS index exists from a JSON request.
 */
char* vldb_sqlite_ensure_fts_index_json(const char* request_json);

/*
 * 通过 JSON 请求重建 FTS 索引。
 * Rebuild an FTS index from a JSON request.
 */
char* vldb_sqlite_rebuild_fts_index_json(const char* request_json);

/*
 * 通过 JSON 请求写入或更新 FTS 文档。
 * Upsert an FTS document from a JSON request.
 */
char* vldb_sqlite_upsert_fts_document_json(const char* request_json);

/*
 * 通过 JSON 请求删除 FTS 文档。
 * Delete an FTS document from a JSON request.
 */
char* vldb_sqlite_delete_fts_document_json(const char* request_json);

/*
 * 通过 JSON 请求执行标准化 FTS 检索。
 * Execute normalized FTS search from a JSON request.
 */
char* vldb_sqlite_search_fts_json(const char* request_json);

#ifdef __cplusplus
}
#endif

#endif /* VLDB_SQLITE_H */