-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinfinity.thrift
651 lines (556 loc) · 11.8 KB
/
infinity.thrift
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
namespace py infinity_thrift_rpc
namespace cpp infinity_thrift_rpc
// https://github.com/apache/thrift/blob/master/test/Recursive.thrift
enum LogicType{
Boolean,
TinyInt,
SmallInt,
Integer,
BigInt,
HugeInt,
Decimal,
Float,
Double,
Varchar,
Embedding,
Tensor,
TensorArray,
Invalid
}
enum CreateConflict {
Ignore,
Error,
Replace,
}
enum DropConflict {
Ignore,
Error,
}
struct Property {
1: string key,
2: string value
}
struct CreateOption {
1: CreateConflict conflict_type,
2: list<Property> properties = [],
}
struct DropOption {
1: DropConflict conflict_type,
}
struct NumberType {}
struct VarcharType {}
enum ElementType {
ElementBit,
ElementInt8,
ElementInt16,
ElementInt32,
ElementInt64,
ElementFloat32,
ElementFloat64,
}
struct EmbeddingType {
1: i32 dimension,
2: ElementType element_type,
}
union PhysicalType {
1: NumberType number_type,
2: VarcharType varchar_type,
3: EmbeddingType embedding_type,
}
struct DataType {
1: LogicType logic_type,
2: PhysicalType physical_type,
}
enum Constraint {
PrimaryKey,
NotNull,
Null,
Unique,
}
enum LiteralType {
Boolean,
Double,
String,
Int64,
Null,
IntegerArray,
DoubleArray,
IntegerTensorArray,
DoubleTensorArray,
}
union ParsedExprType {
1: ConstantExpr & constant_expr,
2: ColumnExpr & column_expr,
3: FunctionExpr & function_expr,
4: BetweenExpr & between_expr,
5: KnnExpr & knn_expr,
6: MatchExpr & match_expr,
7: FusionExpr & fusion_expr,
8: SearchExpr & search_expr,
}
struct ParsedExpr {
1: ParsedExprType type,
2: string alias_name,
}
struct ColumnExpr {
1: list<string> column_name = [],
2: bool star,
}
enum KnnDistanceType{
L2,
Cosine,
InnerProduct,
Hamming,
}
union EmbeddingData {
1: list<bool> bool_array_value,
2: list<binary> i8_array_value,
3: list<i16> i16_array_value,
4: list<i32> i32_array_value,
5: list<i64> i64_array_value,
6: list<double> f32_array_value,
7: list<double> f64_array_value,
}
struct InitParameter {
1: string param_name,
2: string param_value,
}
struct ConstantExpr {
1: LiteralType literal_type,
2: optional bool bool_value,
3: optional i64 i64_value,
4: optional double f64_value,
5: optional string str_value,
6: optional list<i64> i64_array_value,
7: optional list<double> f64_array_value,
8: optional list<list<list<i64>>> i64_tensor_array_value,
9: optional list<list<list<double>>> f64_tensor_array_value,
}
struct KnnExpr {
1: ColumnExpr column_expr,
2: EmbeddingData embedding_data,
3: ElementType embedding_data_type,
4: KnnDistanceType distance_type,
5: i64 topn,
6: list<InitParameter> opt_params = [],
}
struct MatchTensorExpr {
1: string search_method,
2: ColumnExpr column_expr,
3: ElementType embedding_data_type,
4: EmbeddingData embedding_data,
5: string extra_options,
}
struct MatchExpr {
1: string fields,
2: string matching_text,
3: string options_text,
}
struct FusionExpr {
1: string method,
2: string options_text,
3: optional MatchTensorExpr optional_match_tensor_expr,
}
struct SearchExpr {
1: optional list<MatchExpr> match_exprs,
2: optional list<KnnExpr> knn_exprs,
3: optional list<MatchTensorExpr> match_tensor_exprs,
4: optional list<FusionExpr> fusion_exprs,
}
struct FunctionExpr {
1: string function_name,
2: list<ParsedExpr> arguments,
}
struct BetweenExpr {
1: ParsedExpr value,
2: ParsedExpr upper_bound,
3: ParsedExpr lower_bound,
}
struct UpdateExpr {
1: string column_name,
2: ParsedExpr value,
}
struct OrderByExpr {
1: ParsedExpr expr,
2: bool asc,
}
struct ColumnDef {
1: i32 id,
2: string name,
3: DataType data_type,
4: list<Constraint> constraints = [],
5: ConstantExpr constant_expr,
}
struct Field {
1: list<ParsedExpr> parse_exprs = [],
}
enum CopyFileType {
CSV,
JSON,
JSONL,
FVECS,
CSR,
BVECS,
}
enum ColumnType {
ColumnBool,
ColumnInt8,
ColumnInt16,
ColumnInt32,
ColumnInt64,
ColumnFloat32,
ColumnFloat64,
ColumnVarchar,
ColumnEmbedding,
ColumnTensor,
ColumnTensorArray,
ColumnRowID,
ColumnInvalid,
}
struct ColumnField {
1: ColumnType column_type,
2: list<binary> column_vectors = [],
3: string column_name,
}
struct ImportOption {
1: string delimiter,
2: bool has_header,
3: CopyFileType copy_file_type,
}
struct ExportOption {
1: string delimiter,
2: bool has_header,
3: CopyFileType copy_file_type,
}
struct ConnectRequest {
1: i64 client_version,
}
struct CommonRequest {
1: i64 session_id,
}
struct CommonResponse {
1: i64 error_code,
2: string error_msg,
3: i64 session_id,
}
struct ListDatabaseRequest {
1: i64 session_id,
}
struct ListDatabaseResponse {
1: i64 error_code,
2: string error_msg,
3: list<string> db_names = [],
}
struct ListTableRequest {
1: string db_name,
2: i64 session_id,
}
struct ListTableResponse {
1: i64 error_code,
2: string error_msg,
3: list<string> table_names = [],
}
struct ListIndexRequest {
1: string db_name,
2: string table_name,
3: i64 session_id,
}
struct ListIndexResponse {
1: i64 error_code,
2: string error_msg,
3: list<string> index_names = [],
}
struct ShowDatabaseRequest {
1: string db_name,
2: i64 session_id,
}
struct ShowDatabaseResponse {
1: i64 error_code,
2: string error_msg,
3: string database_name,
4: string store_dir,
5: i64 table_count,
}
struct ShowTableRequest {
1: string db_name,
2: string table_name,
3: i64 session_id,
}
struct ShowTableResponse {
1: i64 error_code,
2: string error_msg,
3: string database_name,
4: string table_name,
5: string store_dir,
6: i64 column_count,
7: i64 segment_count,
8: i64 row_count,
}
struct ShowColumnsRequest {
1: string db_name,
2: string table_name,
3: i64 session_id,
}
struct GetTableRequest {
1: string db_name,
2: string table_name,
3: i64 session_id,
}
enum IndexType {
IVFFlat,
HnswLVQ,
Hnsw,
FullText,
}
struct IndexInfo {
1: string column_name,
2: IndexType index_type,
3: list<InitParameter> index_param_list = [],
}
struct CreateIndexRequest {
1: string db_name,
2: string table_name,
3: string index_name,
5: list<IndexInfo> index_info_list = [],
6: i64 session_id,
7: CreateOption create_option,
}
struct DropIndexRequest {
1: string db_name,
2: string table_name,
3: string index_name,
4: i64 session_id,
5: DropOption drop_option,
}
struct ShowIndexRequest {
1: string db_name,
2: string table_name,
3: string index_name,
4: i64 session_id,
}
struct ShowIndexResponse {
1: i64 error_code,
2: string error_msg,
3: string db_name,
4: string table_name,
5: string index_name,
6: string index_type,
7: string index_column_names,
8: string index_column_ids,
9: string other_parameters,
10: string store_dir,
11: string store_size,
12: string segment_index_count,
}
struct GetDatabaseRequest {
1: string db_name,
2: i64 session_id,
}
struct CreateDatabaseRequest {
1: string db_name,
2: i64 session_id,
3: CreateOption create_option,
}
struct DropDatabaseRequest {
1: string db_name,
2: i64 session_id,
3: DropOption drop_option,
}
struct CreateTableRequest {
1: string db_name,
2: string table_name,
3: list<ColumnDef> column_defs = [],
6: i64 session_id,
7: CreateOption create_option,
}
struct DropTableRequest {
1: string db_name,
2: string table_name,
3: i64 session_id,
4: DropOption drop_option,
}
struct InsertRequest {
1: string db_name,
2: string table_name,
3: list<string> column_names = [],
4: list<Field> fields = [],
5: i64 session_id,
}
struct ImportRequest{
1: string db_name,
2: string table_name,
3: string file_name,
4: ImportOption import_option,
5: i64 session_id,
}
struct ExportRequest{
1: string db_name,
2: string table_name,
3: list<string> columns,
4: string file_name,
5: ExportOption export_option,
6: i64 session_id,
}
enum ExplainType {
Analyze,
Ast,
UnOpt,
Opt,
Physical,
Pipeline,
Fragment,
}
struct ExplainRequest {
1: i64 session_id,
2: string db_name,
3: string table_name,
4: list<ParsedExpr> select_list = [],
5: optional SearchExpr search_expr,
6: optional ParsedExpr where_expr,
7: optional list<ParsedExpr> group_by_list = [],
8: optional ParsedExpr having_expr,
9: optional ParsedExpr limit_expr,
10: optional ParsedExpr offset_expr,
11: optional list<OrderByExpr> order_by_list = [],
12: ExplainType explain_type,
}
struct ExplainResponse {
1: i64 error_code,
2: string error_msg,
3: list<ColumnDef> column_defs = [],
4: list<ColumnField> column_fields = [];
}
struct SelectRequest {
1: i64 session_id,
2: string db_name,
3: string table_name,
4: list<ParsedExpr> select_list = [],
5: optional SearchExpr search_expr,
6: optional ParsedExpr where_expr,
7: optional list<ParsedExpr> group_by_list = [],
8: optional ParsedExpr having_expr,
9: optional ParsedExpr limit_expr,
10: optional ParsedExpr offset_expr,
11: optional list<OrderByExpr> order_by_list = [],
}
struct SelectResponse {
1: i64 error_code,
2: string error_msg,
3: list<ColumnDef> column_defs = [],
4: list<ColumnField> column_fields = [];
}
struct DeleteRequest {
1: string db_name,
2: string table_name,
3: ParsedExpr where_expr,
4: i64 session_id,
}
struct UpdateRequest {
1: string db_name,
2: string table_name,
3: ParsedExpr where_expr,
4: list<UpdateExpr> update_expr_array = [],
5: i64 session_id,
}
struct ShowTablesRequest{
1: i64 session_id,
2: string db_name,
}
struct ShowSegmentsRequest {
1: i64 session_id,
2: string db_name,
3: string table_name,
}
struct ShowSegmentRequest {
1: i64 session_id,
2: string db_name,
3: string table_name,
4: i64 segment_id,
}
struct ShowSegmentResponse {
1: i64 error_code,
2: string error_msg,
3: i64 segment_id,
4: string status,
5: string path,
6: string size,
7: i64 block_count,
8: i64 row_capacity,
9: i64 row_count,
10: i64 room,
11: i64 column_count,
}
struct ShowBlocksRequest {
1: i64 session_id,
2: string db_name,
3: string table_name,
4: i64 segment_id,
}
struct ShowBlockRequest {
1: i64 session_id,
2: string db_name,
3: string table_name,
4: i64 segment_id,
5: i64 block_id,
}
struct ShowBlockResponse {
1: i64 error_code,
2: string error_msg,
3: i64 block_id,
4: string path,
5: string size,
6: i64 row_capacity,
7: i64 row_count,
8: i64 column_count,
}
struct ShowBlockColumnRequest {
1: i64 session_id,
2: string db_name,
3: string table_name,
4: i64 segment_id,
5: i64 block_id,
6: i64 column_id,
}
struct ShowBlockColumnResponse {
1: i64 error_code,
2: string error_msg,
3: string column_name,
4: i64 column_id,
5: string data_type,
6: string path,
7: i64 extra_file_count,
8: string extra_file_names,
}
// Service
service InfinityService {
CommonResponse Connect(1:ConnectRequest request),
CommonResponse Disconnect(1:CommonRequest request),
CommonResponse CreateDatabase(1:CreateDatabaseRequest request),
CommonResponse DropDatabase(1:DropDatabaseRequest request),
CommonResponse CreateTable(1:CreateTableRequest request),
CommonResponse DropTable(1:DropTableRequest request),
CommonResponse Insert(1:InsertRequest request),
CommonResponse Import(1:ImportRequest request),
CommonResponse Export(1:ExportRequest request),
SelectResponse Select(1:SelectRequest request),
SelectResponse Explain(1:ExplainRequest request),
CommonResponse Delete(1:DeleteRequest request),
CommonResponse Update(1:UpdateRequest request),
ListDatabaseResponse ListDatabase(1:ListDatabaseRequest request),
ListTableResponse ListTable(1:ListTableRequest request),
ListIndexResponse ListIndex(1:ListIndexRequest request),
ShowTableResponse ShowTable(1:ShowTableRequest request),
SelectResponse ShowColumns(1:ShowColumnsRequest request),
ShowDatabaseResponse ShowDatabase(1:ShowDatabaseRequest request),
SelectResponse ShowTables(1:ShowTablesRequest request),
SelectResponse ShowSegments(1:ShowSegmentsRequest request),
ShowSegmentResponse ShowSegment(1:ShowSegmentRequest request),
SelectResponse ShowBlocks(1:ShowBlocksRequest request),
ShowBlockResponse ShowBlock(1:ShowBlockRequest request),
ShowBlockColumnResponse ShowBlockColumn(1:ShowBlockColumnRequest request),
CommonResponse GetDatabase(1:GetDatabaseRequest request),
CommonResponse GetTable(1:GetTableRequest request),
CommonResponse CreateIndex(1:CreateIndexRequest request),
CommonResponse DropIndex(1:DropIndexRequest request),
ShowIndexResponse ShowIndex(1:ShowIndexRequest request),
}