tablestore-ruby-sdk 0.0.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0b784a1d0f57951fa5484ccb62cd715d87fdef19
4
+ data.tar.gz: 2ae0e59098a30d02ce793ad45bb93acd6c9c7dda
5
+ SHA512:
6
+ metadata.gz: 6e1fbf83b244ccdcb443c6beda9523d4640b82c753ddd2303338fc826a38fece5ee44160d003d81dda7203ce79ffdbaa6d68437a943f4e117a2d234476ce675e
7
+ data.tar.gz: 4727b56252ca0a6f08ee4ad411d19d979e38305535448373fd77826131138344f11dbff5137a2d24028a5d848dfb10c26825055704d1e51ccf6ef5f9bcccacea
data/lib/consts.rb ADDED
@@ -0,0 +1,44 @@
1
+ require 'os'
2
+
3
+ HEADER = 0x75
4
+
5
+ # tag type
6
+ TAG_ROW_PK = 0x1
7
+ TAG_ROW_DATA = 0x2
8
+ TAG_CELL = 0x3
9
+ TAG_CELL_NAME = 0x4
10
+ TAG_CELL_VALUE = 0x5
11
+ TAG_CELL_TYPE = 0x6
12
+ TAG_CELL_TIMESTAMP = 0x7
13
+ TAG_DELETE_ROW_MARKER = 0x8
14
+ TAG_ROW_CHECKSUM = 0x9
15
+ TAG_CELL_CHECKSUM = 0x0A
16
+
17
+ # cell op type
18
+ DELETE_ALL_VERSION = 0x1
19
+ DELETE_ONE_VERSION = 0x3
20
+
21
+ # variant type
22
+ VT_INTEGER = 0x0
23
+ VT_DOUBLE = 0x1
24
+ VT_BOOLEAN = 0x2
25
+ VT_STRING = 0x3
26
+ VT_NULL = 0x6
27
+ VT_BLOB = 0x7
28
+ VT_INF_MIN = 0x9
29
+ VT_INF_MAX = 0xa
30
+ VT_AUTO_INCREMENT = 0xb
31
+
32
+ # othber
33
+ LITTLE_ENDIAN_32_SIZE = 4
34
+ LITTLE_ENDIAN_64_SIZE = 8
35
+ MAX_BUFFER_SIZE = 64 * 1024 * 1024
36
+
37
+ SYS_BITS = OS.bits.to_i
38
+ if SYS_BITS == 64
39
+ LITTLE_ENDIAN_SIZE = LITTLE_ENDIAN_64_SIZE
40
+ else
41
+ LITTLE_ENDIAN_SIZE = LITTLE_ENDIAN_32_SIZE
42
+ end
43
+
44
+
@@ -0,0 +1,374 @@
1
+ package com.aliyun.tablestore.protocol;
2
+
3
+ syntax = "proto3";
4
+
5
+ message Error {
6
+ string code = 1;
7
+ string message = 2;
8
+ }
9
+
10
+ enum PrimaryKeyType {
11
+ NULL = 0;
12
+ INTEGER = 1;
13
+ STRING = 2;
14
+ BINARY = 3;
15
+ }
16
+
17
+ enum PrimaryKeyOption {
18
+ DEFAULT = 0;
19
+ AUTO_INCREMENT = 1;
20
+ }
21
+
22
+ message PrimaryKeySchema {
23
+ string name = 1;
24
+ PrimaryKeyType type = 2;
25
+ PrimaryKeyOption option = 3;
26
+ }
27
+
28
+ message PartitionRange {
29
+ bytes begin = 1; // encoded as SQLVariant
30
+ bytes end = 2; // encoded as SQLVariant
31
+ }
32
+
33
+ message TableOptions {
34
+ int32 time_to_live = 1; // 可以动态更改
35
+ int32 max_versions = 2; // 可以动态更改
36
+ int64 deviation_cell_version_in_sec = 5; // 可以动态修改
37
+ }
38
+
39
+ message TableMeta {
40
+ string table_name = 1;
41
+ repeated PrimaryKeySchema primary_key = 2;
42
+ }
43
+
44
+ enum RowExistenceExpectation {
45
+ IGNORE = 0;
46
+ EXPECT_EXIST = 1;
47
+ EXPECT_NOT_EXIST = 2;
48
+ }
49
+
50
+ message Condition {
51
+ RowExistenceExpectation row_existence = 1;
52
+ bytes column_condition = 2;
53
+ }
54
+
55
+ message CapacityUnit {
56
+ int32 read = 1;
57
+ int32 write = 2;
58
+ }
59
+
60
+ message ReservedThroughputDetails {
61
+ CapacityUnit capacity_unit = 1; // 表当前的预留吞吐量的值。
62
+ int64 last_increase_time = 2; // 最后一次上调预留吞吐量的时间。
63
+ int64 last_decrease_time = 3; // 最后一次下调预留吞吐量的时间。
64
+ }
65
+
66
+ message ReservedThroughput {
67
+ CapacityUnit capacity_unit = 1;
68
+ }
69
+
70
+ message ConsumedCapacity {
71
+ CapacityUnit capacity_unit = 1;
72
+ }
73
+
74
+ /* ############################################# CreateTable ############################################# */
75
+ /**
76
+ * table_meta用于存储表中不可更改的schema属性,可以更改的ReservedThroughput和TableOptions独立出来,作为UpdateTable的参数。
77
+ * 加入GlobalIndex和LocalIndex之后,结构会变为:
78
+ * message CreateTableRequest {
79
+ * TableMeta table_meta = 1;
80
+ * ReservedThroughput reserved_throughput = 2;
81
+ * TableOptions table_options = 3;
82
+ * repeated LocalIndex local_indexes = 4; // LocalIndex不再单独包含ReservedThroughput和TableOptions,其与主表共享配置。
83
+ * repeated GlobalIndex global_indexes = 5; // GlobalIndex内单独包含ReservedThroughput和TableOptions
84
+ * }
85
+ */
86
+ message CreateTableRequest {
87
+ TableMeta table_meta = 1;
88
+ ReservedThroughput reserved_throughput = 2; // 未放在TableOptions内,原因是UpdateTableResponse中会返回ReservedThroughputDetails,而TableOptions没有类似的返回结构。
89
+ TableOptions table_options = 3;
90
+ repeated PartitionRange partitions = 4;
91
+ }
92
+
93
+ message CreateTableResponse {
94
+ }
95
+
96
+ /* ######################################################################################################### */
97
+
98
+
99
+ /* ############################################# UpdateTable ############################################# */
100
+ message UpdateTableRequest {
101
+ string table_name = 1;
102
+ ReservedThroughput reserved_throughput = 2;
103
+ TableOptions table_options = 3;
104
+ }
105
+
106
+ message UpdateTableResponse {
107
+ ReservedThroughputDetails reserved_throughput_details = 1;
108
+ TableOptions table_options = 2;
109
+ }
110
+ /* ######################################################################################################### */
111
+
112
+ /* ############################################# DescribeTable ############################################# */
113
+ message DescribeTableRequest {
114
+ string table_name = 1;
115
+ }
116
+
117
+ message DescribeTableResponse {
118
+ TableMeta table_meta = 1;
119
+ ReservedThroughputDetails reserved_throughput_details = 2;
120
+ TableOptions table_options = 3;
121
+ repeated bytes shard_splits = 6;
122
+ }
123
+ /* ########################################################################################################### */
124
+
125
+ /* ############################################# ListTable ############################################# */
126
+ message ListTableRequest {
127
+ }
128
+
129
+ /**
130
+ * 当前只返回一个简单的名称列表,需要讨论是否有业务场景需要获取除了表名之外的其他信息。
131
+ * 其他信息可以包含预留吞吐量以及表的状态,这个信息只能是一个粗略的信息,表的详细信息还是需要通过DescribeTable来获取。
132
+ */
133
+ message ListTableResponse {
134
+ repeated string table_names = 1;
135
+ }
136
+ /* ####################################################################################################### */
137
+
138
+ /* ############################################# DeleteTable ############################################# */
139
+ message DeleteTableRequest {
140
+ string table_name = 1;
141
+ }
142
+
143
+ message DeleteTableResponse {
144
+ }
145
+ /* ######################################################################################################### */
146
+
147
+ /* ############################################# LoadTable ############################################# */
148
+ message LoadTableRequest {
149
+ string table_name = 1;
150
+ }
151
+
152
+ message LoadTableResponse {
153
+ }
154
+ /* ######################################################################################################### */
155
+
156
+ /* ############################################# UnloadTable ############################################# */
157
+ message UnloadTableRequest {
158
+ string table_name = 1;
159
+ }
160
+
161
+ message UnloadTableResponse {
162
+
163
+ }
164
+ /* ########################################################################################################## */
165
+
166
+ /**
167
+ * 时间戳的取值最小值为0,最大值为INT64.MAX
168
+ * 1. 若要查询一个范围,则指定start_time和end_time
169
+ * 2. 若要查询一个特定时间戳,则指定specific_time
170
+ */
171
+ message TimeRange {
172
+ int64 start_time = 1;
173
+ int64 end_time = 2;
174
+ int64 specific_time = 3;
175
+ }
176
+
177
+ /* ############################################# GetRow ############################################# */
178
+
179
+ enum ReturnType {
180
+ RT_NONE = 0;
181
+ RT_PK = 1;
182
+ }
183
+
184
+ message ReturnContent {
185
+ ReturnType return_type = 1;
186
+ }
187
+
188
+ /**
189
+ * 1. 支持用户指定版本时间戳范围或者特定的版本时间来读取指定版本的列
190
+ * 2. 目前暂不支持行内的断点
191
+ */
192
+ message GetRowRequest {
193
+ string table_name = 1;
194
+ bytes primary_key = 2; // encoded as InplaceRowChangeSet, but only has primary key
195
+ repeated string columns_to_get = 3; // 不指定则读出所有的列
196
+ TimeRange time_range = 4;
197
+ int32 max_versions = 5;
198
+ bytes filter = 7;
199
+ string start_column = 8;
200
+ string end_column = 9;
201
+ bytes token = 10;
202
+ }
203
+
204
+ message GetRowResponse {
205
+ ConsumedCapacity consumed = 1;
206
+ bytes row = 2; // encoded as InplaceRowChangeSet
207
+ bytes next_token = 3;
208
+ }
209
+ /* #################################################################################################### */
210
+
211
+ /* ############################################# UpdateRow ############################################# */
212
+ message UpdateRowRequest {
213
+ string table_name = 1;
214
+ bytes row_change = 2;
215
+ Condition condition = 3;
216
+ ReturnContent return_content = 4;
217
+ }
218
+
219
+ message UpdateRowResponse {
220
+ ConsumedCapacity consumed = 1;
221
+ bytes row = 2;
222
+ }
223
+ /* ####################################################################################################### */
224
+
225
+ /* ############################################# PutRow ############################################# */
226
+
227
+
228
+ /**
229
+ * 这里允许用户为每列单独设置timestamp,而不是强制整行统一一个timestamp。
230
+ * 原因是列都是用统一的结构,该结构本身是带timestamp的,其次强制统一timestamp增强了规范性但是丧失了灵活性,且该规范性没有明显的好处,反而带来了结构的复杂。
231
+ */
232
+ message PutRowRequest {
233
+ string table_name = 1;
234
+ bytes row = 2; // encoded as InplaceRowChangeSet
235
+ Condition condition = 3;
236
+ ReturnContent return_content = 4;
237
+ }
238
+
239
+ message PutRowResponse {
240
+ ConsumedCapacity consumed = 1;
241
+ bytes row = 2; // encoded as InplaceRowChangeSet
242
+ }
243
+ /* #################################################################################################### */
244
+
245
+ /* ############################################# DeleteRow ############################################# */
246
+ /**
247
+ * OTS只支持删除该行的所有列所有版本,不支持:
248
+ * 1. 删除所有列的所有小于等于某个版本的所有版本
249
+ */
250
+ message DeleteRowRequest {
251
+ string table_name = 1;
252
+ bytes primary_key = 2; // encoded as InplaceRowChangeSet, but only has primary key
253
+ Condition condition = 3;
254
+ ReturnContent return_content = 4;
255
+ }
256
+
257
+ message DeleteRowResponse {
258
+ ConsumedCapacity consumed = 1;
259
+ bytes row = 2;
260
+ }
261
+ /* ####################################################################################################### */
262
+
263
+ /* ############################################# BatchGetRow ############################################# */
264
+ message TableInBatchGetRowRequest {
265
+ string table_name = 1;
266
+ repeated bytes primary_key = 2; // encoded as InplaceRowChangeSet, but only has primary key
267
+ repeated bytes token = 3;
268
+ repeated string columns_to_get = 4; // 不指定则读出所有的列
269
+ TimeRange time_range = 5;
270
+ int32 max_versions = 6;
271
+ bytes filter = 8;
272
+ string start_column = 9;
273
+ string end_column = 10;
274
+ }
275
+
276
+ message BatchGetRowRequest {
277
+ repeated TableInBatchGetRowRequest tables = 1;
278
+ }
279
+
280
+ message RowInBatchGetRowResponse {
281
+ bool is_ok = 1;
282
+ Error error = 2;
283
+ ConsumedCapacity consumed = 3;
284
+ bytes row = 4; // encoded as InplaceRowChangeSet
285
+ bytes next_token = 5;
286
+ }
287
+
288
+ message TableInBatchGetRowResponse {
289
+ string table_name = 1;
290
+ repeated RowInBatchGetRowResponse rows = 2;
291
+ }
292
+
293
+ message BatchGetRowResponse {
294
+ repeated TableInBatchGetRowResponse tables = 1;
295
+ }
296
+ /* ######################################################################################################### */
297
+
298
+ /* ############################################# BatchWriteRow ############################################# */
299
+
300
+ enum OperationType {
301
+ POST = 0;
302
+ PUT = 1;
303
+ UPDATE = 2;
304
+ DELETE = 3;
305
+ }
306
+
307
+ message RowInBatchWriteRowRequest {
308
+ OperationType type = 1;
309
+ bytes row_change = 2; // encoded as InplaceRowChangeSet
310
+ Condition condition = 3;
311
+ ReturnContent return_content = 4;
312
+ }
313
+
314
+ message TableInBatchWriteRowRequest {
315
+ string table_name = 1;
316
+ repeated RowInBatchWriteRowRequest rows = 2;
317
+ }
318
+
319
+ message BatchWriteRowRequest {
320
+ repeated TableInBatchWriteRowRequest tables = 1;
321
+ }
322
+
323
+ message RowInBatchWriteRowResponse {
324
+ bool is_ok = 1;
325
+ Error error = 2;
326
+ ConsumedCapacity consumed = 3;
327
+ bytes row = 4; // encoded as InplaceRowChangeSet
328
+ }
329
+
330
+ message TableInBatchWriteRowResponse {
331
+ string table_name = 1;
332
+ repeated RowInBatchWriteRowResponse rows = 2;
333
+ }
334
+
335
+ message BatchWriteRowResponse {
336
+ repeated TableInBatchWriteRowResponse tables = 1;
337
+ }
338
+ /* ########################################################################################################### */
339
+
340
+ /* ############################################# GetRange ############################################# */
341
+ enum Direction {
342
+ FORWARD = 0;
343
+ BACKWARD = 1;
344
+ }
345
+
346
+ /**
347
+ * HBase支持以下参数:
348
+ * 1. TimeRange或指定time
349
+ * 2. Filter(根据列值或列名来过滤)
350
+ * 我们只支持给同版本的选择条件。
351
+ */
352
+ message GetRangeRequest {
353
+ string table_name = 1;
354
+ Direction direction = 2;
355
+ repeated string columns_to_get = 3; // 不指定则读出所有的列
356
+ TimeRange time_range = 4;
357
+ int32 max_versions = 5;
358
+ int32 limit = 6;
359
+ bytes inclusive_start_primary_key = 7; // encoded as InplaceRowChangeSet, but only has primary key
360
+ bytes exclusive_end_primary_key = 8; // encoded as InplaceRowChangeSet, but only has primary key
361
+ bytes filter = 10;
362
+ string start_column = 11;
363
+ string end_column = 12;
364
+ bytes token = 13;
365
+ }
366
+
367
+ message GetRangeResponse {
368
+ ConsumedCapacity consumed = 1;
369
+ bytes rows = 2; // encoded as InplaceRowChangeSet
370
+ bytes next_start_primary_key = 3; // 若为空,则代表数据全部读取完毕. encoded as InplaceRowChangeSet, but only has primary key
371
+ bytes next_token = 4;
372
+ }
373
+ /* ###################################################################################################### */
374
+
@@ -0,0 +1,48 @@
1
+ syntax = "proto3";
2
+
3
+ enum FilterType {
4
+ FT_DEFAULT = 0;
5
+ FT_SINGLE_COLUMN_VALUE = 1;
6
+ FT_COMPOSITE_COLUMN_VALUE = 2;
7
+ FT_COLUMN_PAGINATION = 3;
8
+ }
9
+
10
+ enum ComparatorType {
11
+ CT_DEFAULT = 0;
12
+ CT_EQUAL = 1;
13
+ CT_NOT_EQUAL = 2;
14
+ CT_GREATER_THAN = 3;
15
+ CT_GREATER_EQUAL = 4;
16
+ CT_LESS_THAN = 5;
17
+ CT_LESS_EQUAL = 6;
18
+ }
19
+
20
+ message SingleColumnValueFilter {
21
+ ComparatorType comparator = 1;
22
+ string column_name = 2;
23
+ bytes column_value = 3; // Serialized SQLVariant
24
+ bool filter_if_missing = 4;
25
+ bool latest_version_only = 5;
26
+ }
27
+
28
+ enum LogicalOperator {
29
+ LO_DEFAULT = 0;
30
+ LO_NOT = 1;
31
+ LO_AND = 2;
32
+ LO_OR = 3;
33
+ }
34
+
35
+ message CompositeColumnValueFilter {
36
+ LogicalOperator combinator = 1;
37
+ repeated Filter sub_filters = 2;
38
+ }
39
+
40
+ message ColumnPaginationFilter {
41
+ int32 offset = 1;
42
+ int32 limit = 2;
43
+ }
44
+
45
+ message Filter {
46
+ FilterType type = 1;
47
+ bytes filter = 2; // Serialized string of filter of the type
48
+ }