fluss-rs 0.1.0

The official rust client of Apache Fluss (Incubating)
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
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 */

syntax = "proto2";

package proto;

message ErrorResponse {
  required int32 error_code = 1;
  optional string error_message = 2;
}

// metadata request and response, request send from client to each server.
message MetadataRequest {
  repeated PbTablePath table_path = 1;
  repeated PbPhysicalTablePath partitions_path = 2;

  // note: currently, we assume the partition ids must belong to the table_paths in the
  // metadata request
  // todo: we won't need the assumption after we introduce metadata cache in server
  repeated int64 partitions_id = 3 [packed = true];
}

message MetadataResponse {
  optional PbServerNode coordinator_server = 1;
  repeated PbServerNode tablet_servers = 2;
  repeated PbTableMetadata table_metadata = 3;
  repeated PbPartitionMetadata partition_metadata = 4;
}

// produce log request and response
message ProduceLogRequest {
  required int32 acks = 1;
  required int64 table_id = 2;
  required int32 timeout_ms = 3;
  repeated PbProduceLogReqForBucket buckets_req = 4;
}


message ProduceLogResponse {
  repeated PbProduceLogRespForBucket buckets_resp = 1;
}


// --------------- Inner classes ----------------
message PbTablePath {
  required string database_name = 1;
  required string table_name = 2;
}

message PbPhysicalTablePath {
  required string database_name = 1;
  required string table_name = 2;
  optional string partition_name = 3;
}

// For MetadataResponse, host and port are still used for all versions.
// For UpdateMetadataRequest,
//   * versions <= 0.6: host and port are used.
//   * versions >= 0.7: listeners is used to replace host and port.
message PbServerNode {
  required int32 node_id = 1;
  required string host = 2;
  required int32 port = 3;
  optional string listeners = 4;
}

message PbTableMetadata {
  required PbTablePath table_path = 1;
  required int64 table_id = 2;
  required int32 schema_id = 3;
  required bytes table_json = 4;
  repeated PbBucketMetadata bucket_metadata = 5;
  required int64 created_time = 6;
  required int64 modified_time = 7;
}

message PbPartitionMetadata {
  required int64 table_id = 1;
  // the partition name and id for the partition
  required string partition_name = 2;
  required int64 partition_id = 3;
  repeated PbBucketMetadata bucket_metadata = 4;
}

message PbBucketMetadata {
  required int32 bucket_id = 1;
  // optional as some time the leader may not elected yet
  optional int32 leader_id = 2;
  repeated int32 replica_id = 3 [packed = true];
  // TODO: Add isr here.
}

message PbProduceLogReqForBucket {
  optional int64 partition_id = 1;
  required int32 bucket_id = 2;
  required bytes records = 3;
}

message PbProduceLogRespForBucket {
  optional int64 partition_id = 1;
  required int32 bucket_id = 2;
  optional int32 error_code = 3;
  optional string error_message = 4;
  optional int64 base_offset = 5;
}

// put kv request and response
message PutKvRequest {
  required int32 acks = 1;
  required int64 table_id = 2;
  required int32 timeout_ms = 3;
  // the indexes for the columns to write,
  // if empty, means write all columns
  repeated int32 target_columns = 4 [packed = true];
  repeated PbPutKvReqForBucket buckets_req = 5;
}

message PutKvResponse {
  repeated PbPutKvRespForBucket buckets_resp = 1;
}

message PbPutKvReqForBucket {
  optional int64 partition_id = 1;
  required int32 bucket_id = 2;
  required bytes records = 3;
}

message PbPutKvRespForBucket {
  optional int64 partition_id = 1;
  required int32 bucket_id = 2;
  optional int32 error_code = 3;
  optional string error_message = 4;
}

message CreateTableRequest {
  required PbTablePath table_path = 1;
  required bytes table_json = 2;
  required bool ignore_if_exists = 3;
}

message CreateTableResponse {
}

message DropTableRequest {
  required PbTablePath table_path = 1;
  required bool ignore_if_not_exists = 2;
}

message DropTableResponse {
}

message TableExistsRequest {
  required PbTablePath table_path = 1;
}

message TableExistsResponse {
  required bool exists = 1;
}

message GetTableInfoRequest {
  required PbTablePath table_path = 1;
}

message GetTableInfoResponse {
  required int64 table_id = 1;
  required int32 schema_id = 2;
  required bytes table_json = 3;
  required int64 created_time = 4;
  required int64 modified_time = 5;
}

message ListTablesRequest {
  required string database_name = 1;
}

message ListTablesResponse {
  repeated string table_name = 1;
}

message CreateDatabaseRequest {
  required string database_name = 1;
  required bool ignore_if_exists = 2;
  optional bytes database_json = 3;
}

message CreateDatabaseResponse {
}

message GetDatabaseInfoRequest {
  required string database_name = 1;
}

message GetDatabaseInfoResponse {
  required bytes database_json = 3;
  required int64 created_time = 4;
  required int64 modified_time = 5;
}

message DropDatabaseRequest {
  required string database_name = 1;
  required bool ignore_if_not_exists = 2;
  required bool cascade = 3;
}

message DropDatabaseResponse {
}

message DatabaseExistsRequest {
  required string database_name = 1;
}

message DatabaseExistsResponse {
  required bool exists = 1;
}

message ListDatabasesRequest {
}

message ListDatabasesResponse {
  repeated string database_name = 1;
}

// list offsets request and response
message ListOffsetsRequest {
  required int32 follower_server_id = 1;  // value -1 indicate the request from client.
  required int32 offset_type = 2; // value can be 0,1,2 (see ListOffsetsParam for more details)
  required int64 table_id = 3;
  optional int64 partition_id = 4;
  repeated int32 bucket_id = 5 [packed = true]; // it is recommended to use packed for repeated numerics to get more efficient encoding
  optional int64 startTimestamp = 6;
}
message ListOffsetsResponse {
  repeated PbListOffsetsRespForBucket buckets_resp = 1;
}


// fetch log request and response
message FetchLogRequest {
  required int32 follower_server_id = 1;  // value -1 indicate the request from client.
  required int32 max_bytes = 2;
  repeated PbFetchLogReqForTable tables_req = 3;
  optional int32 max_wait_ms = 4;
  optional int32 min_bytes = 5;
}

message FetchLogResponse {
  repeated PbFetchLogRespForTable tables_resp = 1;
}

message PbFetchLogReqForTable {
  required int64 table_id = 1;
  required bool projection_pushdown_enabled = 2;
  repeated int32 projected_fields = 3 [packed = true];
  repeated PbFetchLogReqForBucket buckets_req = 4;
}


message PbFetchLogReqForBucket {
  optional int64 partition_id = 1;
  required int32 bucket_id = 2;
  // TODO leader epoch
  required int64 fetch_offset = 3;
  required int32 max_fetch_bytes = 4;
}


message PbFetchLogRespForTable {
  required int64 table_id = 1;
  repeated PbFetchLogRespForBucket buckets_resp = 2;
}
message PbFetchLogRespForBucket {
  optional int64 partition_id = 1;
  required int32 bucket_id = 2;
  optional int32 error_code = 3;
  optional string error_message = 4;
  optional int64 high_watermark = 5;
  optional int64 log_start_offset = 6; // TODO now we don't introduce log start offset, but remain it in protobuf
  optional PbRemoteLogFetchInfo remote_log_fetch_info = 7;
  optional bytes records = 8;
}

message PbRemoteLogFetchInfo {
  required string remote_log_tablet_dir = 1;
  optional string partition_name = 2;
  repeated PbRemoteLogSegment remote_log_segments = 3;
  optional int32 first_start_pos = 4;
}

message PbRemoteLogSegment {
  required string remote_log_segment_id = 1;
  required int64 remote_log_start_offset = 2;
  required int64 remote_log_end_offset = 3;
  required int32 segment_size_in_bytes = 4;
  optional int64 max_timestamp = 5;
}

message PbListOffsetsRespForBucket {
  required int32 bucket_id = 1;
  optional int32 error_code = 2;
  optional string error_message = 3;
  optional int64 offset = 4;
}

// fetch latest lake snapshot
message GetLatestLakeSnapshotRequest {
  required PbTablePath table_path = 1;
}

message GetLatestLakeSnapshotResponse {
  required int64 table_id = 1;
  required int64 snapshotId = 2;
  repeated PbLakeSnapshotForBucket bucket_snapshots = 3;
}

message PbLakeSnapshotForBucket {
  optional int64 partition_id = 1;
  required int32 bucket_id = 2;
  optional int64 log_offset = 3;
}

message PbKeyValue {
  required string key = 1;
  required string value = 2;
}

message GetFileSystemSecurityTokenRequest {
}

message GetFileSystemSecurityTokenResponse {
  required string schema = 1;
  required bytes token = 2;
  optional int64 expiration_time = 3;
  repeated PbKeyValue addition_info = 4;
}

// lookup request and response
message LookupRequest {
  required int64 table_id = 1;
  repeated PbLookupReqForBucket buckets_req = 2;
}

message LookupResponse {
  repeated PbLookupRespForBucket buckets_resp = 1;
}

message PbLookupReqForBucket {
  optional int64 partition_id = 1;
  required int32 bucket_id = 2;
  repeated bytes key = 3;
}

message PbLookupRespForBucket {
  optional int64 partition_id = 1;
  required int32 bucket_id = 2;
  optional int32 error_code = 3;
  optional string error_message = 4;
  repeated PbValue values = 5;
}

message PbValue {
  optional bytes values = 1;
}

message PbPartitionSpec {
  repeated PbKeyValue partition_key_values = 1;
}

message PbPartitionInfo {
  required int64 partition_id = 1;
  required PbPartitionSpec partition_spec = 2;
}

message ListPartitionInfosRequest {
  required PbTablePath table_path = 1;
  optional PbPartitionSpec partial_partition_spec = 2;
}

message ListPartitionInfosResponse {
  repeated PbPartitionInfo partitions_info = 1;
}

message CreatePartitionRequest {
  required PbTablePath table_path = 1;
  required PbPartitionSpec partition_spec = 2;
  required bool ignore_if_exists = 3;
}

message CreatePartitionResponse {}

message DropPartitionRequest {
  required PbTablePath table_path = 1;
  required PbPartitionSpec partition_spec = 2;
  required bool ignore_if_not_exists = 3;
}

message DropPartitionResponse {}

message AuthenticateRequest {
  required string protocol = 1;
  required bytes token = 2;
}

message AuthenticateResponse {
  optional bytes challenge = 1;
}

// init writer request and response
message InitWriterRequest {
  repeated PbTablePath table_path = 1;
}

message InitWriterResponse {
  required int64 writer_id = 1;
}