tablestore-ruby-sdk 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/consts.rb +44 -0
- data/lib/protobuf/ots.proto +374 -0
- data/lib/protobuf/ots_filiter.proto +48 -0
- data/lib/protobuf/ots_filiter_pb.rb +55 -0
- data/lib/protobuf/ots_pb.rb +307 -0
- data/lib/tablestore-ruby-sdk.rb +99 -0
- data/lib/tablestore/connection.rb +22 -0
- data/lib/tablestore/crc8_auto.rb +36 -0
- data/lib/tablestore/error.rb +57 -0
- data/lib/tablestore/main.rb +51 -0
- data/lib/tablestore/metadata.rb +413 -0
- data/lib/tablestore/ots.rb +481 -0
- data/lib/tablestore/plain_buffer_coded_input_stream.rb +217 -0
- data/lib/tablestore/plain_buffer_coded_output_stream.rb +252 -0
- data/lib/tablestore/plain_buffer_crc8.rb +21 -0
- data/lib/tablestore/plain_buffer_input_stream.rb +92 -0
- data/lib/tablestore/plain_buffer_output_stream.rb +59 -0
- data/lib/tablestore/protocol.rb +161 -0
- metadata +117 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: ots_filiter.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
7
|
+
add_message "SingleColumnValueFilter" do
|
8
|
+
optional :comparator, :enum, 1, "ComparatorType"
|
9
|
+
optional :column_name, :string, 2
|
10
|
+
optional :column_value, :bytes, 3
|
11
|
+
optional :filter_if_missing, :bool, 4
|
12
|
+
optional :latest_version_only, :bool, 5
|
13
|
+
end
|
14
|
+
add_message "CompositeColumnValueFilter" do
|
15
|
+
optional :combinator, :enum, 1, "LogicalOperator"
|
16
|
+
repeated :sub_filters, :message, 2, "Filter"
|
17
|
+
end
|
18
|
+
add_message "ColumnPaginationFilter" do
|
19
|
+
optional :offset, :int32, 1
|
20
|
+
optional :limit, :int32, 2
|
21
|
+
end
|
22
|
+
add_message "Filter" do
|
23
|
+
optional :type, :enum, 1, "FilterType"
|
24
|
+
optional :filter, :bytes, 2
|
25
|
+
end
|
26
|
+
add_enum "FilterType" do
|
27
|
+
value :FT_DEFAULT, 0
|
28
|
+
value :FT_SINGLE_COLUMN_VALUE, 1
|
29
|
+
value :FT_COMPOSITE_COLUMN_VALUE, 2
|
30
|
+
value :FT_COLUMN_PAGINATION, 3
|
31
|
+
end
|
32
|
+
add_enum "ComparatorType" do
|
33
|
+
value :CT_DEFAULT, 0
|
34
|
+
value :CT_EQUAL, 1
|
35
|
+
value :CT_NOT_EQUAL, 2
|
36
|
+
value :CT_GREATER_THAN, 3
|
37
|
+
value :CT_GREATER_EQUAL, 4
|
38
|
+
value :CT_LESS_THAN, 5
|
39
|
+
value :CT_LESS_EQUAL, 6
|
40
|
+
end
|
41
|
+
add_enum "LogicalOperator" do
|
42
|
+
value :LO_DEFAULT, 0
|
43
|
+
value :LO_NOT, 1
|
44
|
+
value :LO_AND, 2
|
45
|
+
value :LO_OR, 3
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
SingleColumnValueFilter = Google::Protobuf::DescriptorPool.generated_pool.lookup("SingleColumnValueFilter").msgclass
|
50
|
+
CompositeColumnValueFilter = Google::Protobuf::DescriptorPool.generated_pool.lookup("CompositeColumnValueFilter").msgclass
|
51
|
+
ColumnPaginationFilter = Google::Protobuf::DescriptorPool.generated_pool.lookup("ColumnPaginationFilter").msgclass
|
52
|
+
Filter = Google::Protobuf::DescriptorPool.generated_pool.lookup("Filter").msgclass
|
53
|
+
FilterType = Google::Protobuf::DescriptorPool.generated_pool.lookup("FilterType").enummodule
|
54
|
+
ComparatorType = Google::Protobuf::DescriptorPool.generated_pool.lookup("ComparatorType").enummodule
|
55
|
+
LogicalOperator = Google::Protobuf::DescriptorPool.generated_pool.lookup("LogicalOperator").enummodule
|
@@ -0,0 +1,307 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: ots.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
7
|
+
add_message "Error" do
|
8
|
+
optional :code, :string, 1
|
9
|
+
optional :message, :string, 2
|
10
|
+
end
|
11
|
+
add_message "PrimaryKeySchema" do
|
12
|
+
optional :name, :string, 1
|
13
|
+
optional :type, :enum, 2, "PrimaryKeyType"
|
14
|
+
optional :option, :enum, 3, "PrimaryKeyOption"
|
15
|
+
end
|
16
|
+
add_message "PartitionRange" do
|
17
|
+
optional :begin, :bytes, 1
|
18
|
+
optional :end, :bytes, 2
|
19
|
+
end
|
20
|
+
add_message "TableOptions" do
|
21
|
+
optional :time_to_live, :int32, 1
|
22
|
+
optional :max_versions, :int32, 2
|
23
|
+
optional :deviation_cell_version_in_sec, :int64, 5
|
24
|
+
end
|
25
|
+
add_message "TableMeta" do
|
26
|
+
optional :table_name, :string, 1
|
27
|
+
repeated :primary_key, :message, 2, "PrimaryKeySchema"
|
28
|
+
end
|
29
|
+
add_message "Condition" do
|
30
|
+
optional :row_existence, :enum, 1, "RowExistenceExpectation"
|
31
|
+
optional :column_condition, :bytes, 2
|
32
|
+
end
|
33
|
+
add_message "CapacityUnit" do
|
34
|
+
optional :read, :int32, 1
|
35
|
+
optional :write, :int32, 2
|
36
|
+
end
|
37
|
+
add_message "ReservedThroughputDetails" do
|
38
|
+
optional :capacity_unit, :message, 1, "CapacityUnit"
|
39
|
+
optional :last_increase_time, :int64, 2
|
40
|
+
optional :last_decrease_time, :int64, 3
|
41
|
+
end
|
42
|
+
add_message "ReservedThroughput" do
|
43
|
+
optional :capacity_unit, :message, 1, "CapacityUnit"
|
44
|
+
end
|
45
|
+
add_message "ConsumedCapacity" do
|
46
|
+
optional :capacity_unit, :message, 1, "CapacityUnit"
|
47
|
+
end
|
48
|
+
add_message "CreateTableRequest" do
|
49
|
+
optional :table_meta, :message, 1, "TableMeta"
|
50
|
+
optional :reserved_throughput, :message, 2, "ReservedThroughput"
|
51
|
+
optional :table_options, :message, 3, "TableOptions"
|
52
|
+
repeated :partitions, :message, 4, "PartitionRange"
|
53
|
+
end
|
54
|
+
add_message "CreateTableResponse" do
|
55
|
+
end
|
56
|
+
add_message "UpdateTableRequest" do
|
57
|
+
optional :table_name, :string, 1
|
58
|
+
optional :reserved_throughput, :message, 2, "ReservedThroughput"
|
59
|
+
optional :table_options, :message, 3, "TableOptions"
|
60
|
+
end
|
61
|
+
add_message "UpdateTableResponse" do
|
62
|
+
optional :reserved_throughput_details, :message, 1, "ReservedThroughputDetails"
|
63
|
+
optional :table_options, :message, 2, "TableOptions"
|
64
|
+
end
|
65
|
+
add_message "DescribeTableRequest" do
|
66
|
+
optional :table_name, :string, 1
|
67
|
+
end
|
68
|
+
add_message "DescribeTableResponse" do
|
69
|
+
optional :table_meta, :message, 1, "TableMeta"
|
70
|
+
optional :reserved_throughput_details, :message, 2, "ReservedThroughputDetails"
|
71
|
+
optional :table_options, :message, 3, "TableOptions"
|
72
|
+
optional :shard_splits, :bytes, 6
|
73
|
+
end
|
74
|
+
add_message "ListTableRequest" do
|
75
|
+
end
|
76
|
+
add_message "ListTableResponse" do
|
77
|
+
repeated :table_names, :string, 1
|
78
|
+
end
|
79
|
+
add_message "DeleteTableRequest" do
|
80
|
+
optional :table_name, :string, 1
|
81
|
+
end
|
82
|
+
add_message "DeleteTableResponse" do
|
83
|
+
end
|
84
|
+
add_message "LoadTableRequest" do
|
85
|
+
optional :table_name, :string, 1
|
86
|
+
end
|
87
|
+
add_message "LoadTableResponse" do
|
88
|
+
end
|
89
|
+
add_message "UnloadTableRequest" do
|
90
|
+
optional :table_name, :string, 1
|
91
|
+
end
|
92
|
+
add_message "UnloadTableResponse" do
|
93
|
+
end
|
94
|
+
add_message "TimeRange" do
|
95
|
+
optional :start_time, :int64, 1
|
96
|
+
optional :end_time, :int64, 2
|
97
|
+
optional :specific_time, :int64, 3
|
98
|
+
end
|
99
|
+
add_message "ReturnContent" do
|
100
|
+
optional :return_type, :enum, 1, "ReturnType"
|
101
|
+
end
|
102
|
+
add_message "GetRowRequest" do
|
103
|
+
optional :table_name, :string, 1
|
104
|
+
optional :primary_key, :bytes, 2
|
105
|
+
repeated :columns_to_get, :string, 3
|
106
|
+
optional :time_range, :message, 4, "TimeRange"
|
107
|
+
optional :max_versions, :int32, 5
|
108
|
+
optional :filter, :bytes, 7
|
109
|
+
optional :start_column, :string, 8
|
110
|
+
optional :end_column, :string, 9
|
111
|
+
optional :token, :bytes, 10
|
112
|
+
end
|
113
|
+
add_message "GetRowResponse" do
|
114
|
+
optional :consumed, :message, 1, "ConsumedCapacity"
|
115
|
+
optional :row, :bytes, 2
|
116
|
+
optional :next_token, :bytes, 3
|
117
|
+
end
|
118
|
+
add_message "UpdateRowRequest" do
|
119
|
+
optional :table_name, :string, 1
|
120
|
+
optional :row_change, :bytes, 2
|
121
|
+
optional :condition, :message, 3, "Condition"
|
122
|
+
optional :return_content, :message, 4, "ReturnContent"
|
123
|
+
end
|
124
|
+
add_message "UpdateRowResponse" do
|
125
|
+
optional :consumed, :message, 1, "ConsumedCapacity"
|
126
|
+
optional :row, :bytes, 2
|
127
|
+
end
|
128
|
+
add_message "PutRowRequest" do
|
129
|
+
optional :table_name, :string, 1
|
130
|
+
optional :row, :bytes, 2
|
131
|
+
optional :condition, :message, 3, "Condition"
|
132
|
+
optional :return_content, :message, 4, "ReturnContent"
|
133
|
+
end
|
134
|
+
add_message "PutRowResponse" do
|
135
|
+
optional :consumed, :message, 1, "ConsumedCapacity"
|
136
|
+
optional :row, :bytes, 2
|
137
|
+
end
|
138
|
+
add_message "DeleteRowRequest" do
|
139
|
+
optional :table_name, :string, 1
|
140
|
+
optional :primary_key, :bytes, 2
|
141
|
+
optional :condition, :message, 3, "Condition"
|
142
|
+
optional :return_content, :message, 4, "ReturnContent"
|
143
|
+
end
|
144
|
+
add_message "DeleteRowResponse" do
|
145
|
+
optional :consumed, :message, 1, "ConsumedCapacity"
|
146
|
+
optional :row, :bytes, 2
|
147
|
+
end
|
148
|
+
add_message "TableInBatchGetRowRequest" do
|
149
|
+
optional :table_name, :string, 1
|
150
|
+
repeated :primary_key, :bytes, 2
|
151
|
+
repeated :token, :bytes, 3
|
152
|
+
repeated :columns_to_get, :string, 4
|
153
|
+
optional :time_range, :message, 5, "TimeRange"
|
154
|
+
optional :max_versions, :int32, 6
|
155
|
+
optional :filter, :bytes, 8
|
156
|
+
optional :start_column, :string, 9
|
157
|
+
optional :end_column, :string, 10
|
158
|
+
end
|
159
|
+
add_message "BatchGetRowRequest" do
|
160
|
+
repeated :tables, :message, 1, "TableInBatchGetRowRequest"
|
161
|
+
end
|
162
|
+
add_message "RowInBatchGetRowResponse" do
|
163
|
+
optional :is_ok, :bool, 1
|
164
|
+
optional :error, :message, 2, "Error"
|
165
|
+
optional :consumed, :message, 3, "ConsumedCapacity"
|
166
|
+
optional :row, :bytes, 4
|
167
|
+
optional :next_token, :bytes, 5
|
168
|
+
end
|
169
|
+
add_message "TableInBatchGetRowResponse" do
|
170
|
+
optional :table_name, :string, 1
|
171
|
+
repeated :rows, :message, 2, "RowInBatchGetRowResponse"
|
172
|
+
end
|
173
|
+
add_message "BatchGetRowResponse" do
|
174
|
+
repeated :tables, :message, 1, "TableInBatchGetRowResponse"
|
175
|
+
end
|
176
|
+
add_message "RowInBatchWriteRowRequest" do
|
177
|
+
optional :type, :enum, 1, "OperationType"
|
178
|
+
optional :row_change, :bytes, 2
|
179
|
+
optional :condition, :message, 3, "Condition"
|
180
|
+
optional :return_content, :message, 4, "ReturnContent"
|
181
|
+
end
|
182
|
+
add_message "TableInBatchWriteRowRequest" do
|
183
|
+
optional :table_name, :string, 1
|
184
|
+
repeated :rows, :message, 2, "RowInBatchWriteRowRequest"
|
185
|
+
end
|
186
|
+
add_message "BatchWriteRowRequest" do
|
187
|
+
repeated :tables, :message, 1, "TableInBatchWriteRowRequest"
|
188
|
+
end
|
189
|
+
add_message "RowInBatchWriteRowResponse" do
|
190
|
+
optional :is_ok, :bool, 1
|
191
|
+
optional :error, :message, 2, "Error"
|
192
|
+
optional :consumed, :message, 3, "ConsumedCapacity"
|
193
|
+
optional :row, :bytes, 4
|
194
|
+
end
|
195
|
+
add_message "TableInBatchWriteRowResponse" do
|
196
|
+
optional :table_name, :string, 1
|
197
|
+
repeated :rows, :message, 2, "RowInBatchWriteRowResponse"
|
198
|
+
end
|
199
|
+
add_message "BatchWriteRowResponse" do
|
200
|
+
repeated :tables, :message, 1, "TableInBatchWriteRowResponse"
|
201
|
+
end
|
202
|
+
add_message "GetRangeRequest" do
|
203
|
+
optional :table_name, :string, 1
|
204
|
+
optional :direction, :enum, 2, "Direction"
|
205
|
+
repeated :columns_to_get, :string, 3
|
206
|
+
optional :time_range, :message, 4, "TimeRange"
|
207
|
+
optional :max_versions, :int32, 5
|
208
|
+
optional :limit, :int32, 6
|
209
|
+
optional :inclusive_start_primary_key, :bytes, 7
|
210
|
+
optional :exclusive_end_primary_key, :bytes, 8
|
211
|
+
optional :filter, :bytes, 10
|
212
|
+
optional :start_column, :string, 11
|
213
|
+
optional :end_column, :string, 12
|
214
|
+
optional :token, :bytes, 13
|
215
|
+
end
|
216
|
+
add_message "GetRangeResponse" do
|
217
|
+
optional :consumed, :message, 1, "ConsumedCapacity"
|
218
|
+
optional :rows, :bytes, 2
|
219
|
+
optional :next_start_primary_key, :bytes, 3
|
220
|
+
optional :next_token, :bytes, 4
|
221
|
+
end
|
222
|
+
add_enum "PrimaryKeyType" do
|
223
|
+
value :BOOLEAN, 0
|
224
|
+
value :INTEGER, 1
|
225
|
+
value :STRING, 2
|
226
|
+
value :BINARY, 3
|
227
|
+
end
|
228
|
+
add_enum "PrimaryKeyOption" do
|
229
|
+
value :DEFAULT, 0
|
230
|
+
value :AUTO_INCREMENT, 1
|
231
|
+
end
|
232
|
+
add_enum "RowExistenceExpectation" do
|
233
|
+
value :DEFAULT, 0
|
234
|
+
value :EXPECT_EXIST, 1
|
235
|
+
value :EXPECT_NOT_EXIST, 2
|
236
|
+
value :IGNORE, 3
|
237
|
+
end
|
238
|
+
add_enum "ReturnType" do
|
239
|
+
value :RT_NONE, 0
|
240
|
+
value :RT_PK, 1
|
241
|
+
end
|
242
|
+
add_enum "OperationType" do
|
243
|
+
value :POST, 0
|
244
|
+
value :PUT, 1
|
245
|
+
value :UPDATE, 2
|
246
|
+
value :DELETE, 3
|
247
|
+
end
|
248
|
+
add_enum "Direction" do
|
249
|
+
value :DEFAULT, 0
|
250
|
+
value :BACKWARD, 1
|
251
|
+
value :FORWARD, 2
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
Error = Google::Protobuf::DescriptorPool.generated_pool.lookup("Error").msgclass
|
256
|
+
PrimaryKeySchema = Google::Protobuf::DescriptorPool.generated_pool.lookup("PrimaryKeySchema").msgclass
|
257
|
+
PartitionRange = Google::Protobuf::DescriptorPool.generated_pool.lookup("PartitionRange").msgclass
|
258
|
+
TableOptions = Google::Protobuf::DescriptorPool.generated_pool.lookup("TableOptions").msgclass
|
259
|
+
TableMeta = Google::Protobuf::DescriptorPool.generated_pool.lookup("TableMeta").msgclass
|
260
|
+
Condition = Google::Protobuf::DescriptorPool.generated_pool.lookup("Condition").msgclass
|
261
|
+
CapacityUnit = Google::Protobuf::DescriptorPool.generated_pool.lookup("CapacityUnit").msgclass
|
262
|
+
ReservedThroughputDetails = Google::Protobuf::DescriptorPool.generated_pool.lookup("ReservedThroughputDetails").msgclass
|
263
|
+
ReservedThroughput = Google::Protobuf::DescriptorPool.generated_pool.lookup("ReservedThroughput").msgclass
|
264
|
+
ConsumedCapacity = Google::Protobuf::DescriptorPool.generated_pool.lookup("ConsumedCapacity").msgclass
|
265
|
+
CreateTableRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("CreateTableRequest").msgclass
|
266
|
+
CreateTableResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("CreateTableResponse").msgclass
|
267
|
+
UpdateTableRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("UpdateTableRequest").msgclass
|
268
|
+
UpdateTableResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("UpdateTableResponse").msgclass
|
269
|
+
DescribeTableRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("DescribeTableRequest").msgclass
|
270
|
+
DescribeTableResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("DescribeTableResponse").msgclass
|
271
|
+
ListTableRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("ListTableRequest").msgclass
|
272
|
+
ListTableResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("ListTableResponse").msgclass
|
273
|
+
DeleteTableRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("DeleteTableRequest").msgclass
|
274
|
+
DeleteTableResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("DeleteTableResponse").msgclass
|
275
|
+
LoadTableRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("LoadTableRequest").msgclass
|
276
|
+
LoadTableResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("LoadTableResponse").msgclass
|
277
|
+
UnloadTableRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("UnloadTableRequest").msgclass
|
278
|
+
UnloadTableResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("UnloadTableResponse").msgclass
|
279
|
+
TimeRange = Google::Protobuf::DescriptorPool.generated_pool.lookup("TimeRange").msgclass
|
280
|
+
ReturnContent = Google::Protobuf::DescriptorPool.generated_pool.lookup("ReturnContent").msgclass
|
281
|
+
GetRowRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("GetRowRequest").msgclass
|
282
|
+
GetRowResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("GetRowResponse").msgclass
|
283
|
+
UpdateRowRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("UpdateRowRequest").msgclass
|
284
|
+
UpdateRowResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("UpdateRowResponse").msgclass
|
285
|
+
PutRowRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("PutRowRequest").msgclass
|
286
|
+
PutRowResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("PutRowResponse").msgclass
|
287
|
+
DeleteRowRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("DeleteRowRequest").msgclass
|
288
|
+
DeleteRowResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("DeleteRowResponse").msgclass
|
289
|
+
TableInBatchGetRowRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("TableInBatchGetRowRequest").msgclass
|
290
|
+
BatchGetRowRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("BatchGetRowRequest").msgclass
|
291
|
+
RowInBatchGetRowResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("RowInBatchGetRowResponse").msgclass
|
292
|
+
TableInBatchGetRowResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("TableInBatchGetRowResponse").msgclass
|
293
|
+
BatchGetRowResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("BatchGetRowResponse").msgclass
|
294
|
+
RowInBatchWriteRowRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("RowInBatchWriteRowRequest").msgclass
|
295
|
+
TableInBatchWriteRowRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("TableInBatchWriteRowRequest").msgclass
|
296
|
+
BatchWriteRowRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("BatchWriteRowRequest").msgclass
|
297
|
+
RowInBatchWriteRowResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("RowInBatchWriteRowResponse").msgclass
|
298
|
+
TableInBatchWriteRowResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("TableInBatchWriteRowResponse").msgclass
|
299
|
+
BatchWriteRowResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("BatchWriteRowResponse").msgclass
|
300
|
+
GetRangeRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("GetRangeRequest").msgclass
|
301
|
+
GetRangeResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("GetRangeResponse").msgclass
|
302
|
+
PrimaryKeyType = Google::Protobuf::DescriptorPool.generated_pool.lookup("PrimaryKeyType").enummodule
|
303
|
+
PrimaryKeyOption = Google::Protobuf::DescriptorPool.generated_pool.lookup("PrimaryKeyOption").enummodule
|
304
|
+
RowExistenceExpectation = Google::Protobuf::DescriptorPool.generated_pool.lookup("RowExistenceExpectation").enummodule
|
305
|
+
ReturnType = Google::Protobuf::DescriptorPool.generated_pool.lookup("ReturnType").enummodule
|
306
|
+
OperationType = Google::Protobuf::DescriptorPool.generated_pool.lookup("OperationType").enummodule
|
307
|
+
Direction = Google::Protobuf::DescriptorPool.generated_pool.lookup("Direction").enummodule
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'openssl'
|
3
|
+
require 'base64'
|
4
|
+
require 'tablestore/error'
|
5
|
+
require 'tablestore/ots'
|
6
|
+
require 'tablestore/metadata'
|
7
|
+
|
8
|
+
class TableStore
|
9
|
+
DEFAULT_ENCODING = 'utf8'
|
10
|
+
DEFAULT_SOCKET_TIMEOUT = 50
|
11
|
+
DEFAULT_MAX_CONNECTION = 50
|
12
|
+
DEFAULT_LOGGER_NAME = 'tablestore-client'
|
13
|
+
|
14
|
+
|
15
|
+
def initialize(end_point, access_key_id, access_key_secret, instance_name, **kwargs)
|
16
|
+
# 初始化OTSClient实例。
|
17
|
+
# end_point是OTS服务的地址(例如 'http://instance.cn-hangzhou.ots.aliyun.com'),必须以'http://'或'https://'开头。
|
18
|
+
# access_key_id是访问OTS服务的accessid,通过官方网站申请或通过管理员获取。
|
19
|
+
# access_key_secret是访问OTS服务的accesskey,通过官方网站申请或通过管理员获取。
|
20
|
+
# instance_name是要访问的实例名,通过官方网站控制台创建或通过管理员获取。
|
21
|
+
# sts_token是访问OTS服务的STS token,从STS服务获取,具有有效期,过期后需要重新获取。
|
22
|
+
# encoding请求参数的字符串编码类型,默认是utf8。
|
23
|
+
# socket_timeout是连接池中每个连接的Socket超时,单位为秒,可以为int或float。默认值为50。
|
24
|
+
# max_connection是连接池的最大连接数。默认为50,
|
25
|
+
# logger_name用来在请求中打DEBUG日志,或者在出错时打ERROR日志。
|
26
|
+
# retry_policy定义了重试策略,默认的重试策略为 DefaultRetryPolicy。你可以继承 RetryPolicy 来实现自己的重试策略,请参考 DefaultRetryPolicy 的代码。
|
27
|
+
|
28
|
+
#self.validate_parameter(end_point, access_key_id, access_key_secret, instance_name)
|
29
|
+
#sts_token = kwargs.get('sts_token')
|
30
|
+
|
31
|
+
#示例:创建一个OTSClient实例
|
32
|
+
# from tablestore.client import OTSClient
|
33
|
+
# client = OTSClient('your_instance_endpoint', 'your_user_id', 'your_user_key', 'your_instance_name')
|
34
|
+
end
|
35
|
+
|
36
|
+
def _get_range(request)
|
37
|
+
api_name = 'GetRange'
|
38
|
+
body = OTS.new.encode_get_range_request(request)
|
39
|
+
response = post_request(body, api_name)
|
40
|
+
OTS.new.decode_get_range_request(api_name, response.headers, response.body)
|
41
|
+
end
|
42
|
+
|
43
|
+
def _put_row(table_name, row, condition)
|
44
|
+
api_name = 'PutRow'
|
45
|
+
body = OTS.new.encode_put_row(table_name, row, condition)
|
46
|
+
response = post_request(body, api_name)
|
47
|
+
if response.code == 200
|
48
|
+
'write succeed!'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def _get_row(table_name, primary_key, columns_to_get=nil, column_filter=nil, max_version=1)
|
53
|
+
api_name = 'GetRow'
|
54
|
+
body = OTS.new.encode_get_row(table_name, primary_key, columns_to_get, column_filter, max_version)
|
55
|
+
response = post_request(body, api_name)
|
56
|
+
OTS.new.decode_get_row(response.body)
|
57
|
+
end
|
58
|
+
|
59
|
+
def _batch_get_row(request)
|
60
|
+
api_name = 'BatchGetRow'
|
61
|
+
body = OTS.new.make_batch_get_row(request)
|
62
|
+
response = post_request(body, api_name)
|
63
|
+
OTS.new.decode_batch_get_row(response.body)
|
64
|
+
end
|
65
|
+
|
66
|
+
def _batch_write_row(request)
|
67
|
+
api_name = 'BatchWriteRow'
|
68
|
+
body = OTS.new.make_batch_write_row(request)
|
69
|
+
response = post_request(body, api_name)
|
70
|
+
if response.code == 200
|
71
|
+
'write succeed!'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
def post_request(body, api_name)
|
77
|
+
md5 = Base64.encode64(Digest::MD5.new.digest(body)).gsub(/\n/, '')
|
78
|
+
headers = get_headers(md5, api_name)
|
79
|
+
url = BaseUrl+ '/' + api_name
|
80
|
+
RestClient.post(url, body, headers)
|
81
|
+
end
|
82
|
+
|
83
|
+
def get_headers(md5, api_name)
|
84
|
+
headers = {
|
85
|
+
"x-ots-date": Time.now.getutc.strftime('%Y-%m-%dT%H:%M:%S.000Z'),
|
86
|
+
"x-ots-apiversion": '2015-12-31',
|
87
|
+
"x-ots-accesskeyid": UserID,
|
88
|
+
"x-ots-contentmd5": md5,
|
89
|
+
"x-ots-instancename": InstanceName,
|
90
|
+
}
|
91
|
+
signature_string = "/#{api_name}\nPOST\n\n"
|
92
|
+
headers_string = headers.map{|k,v| "#{k.downcase}:#{v.strip}"}.sort.join("\n")
|
93
|
+
signature_string += headers_string + "\n"
|
94
|
+
salt1 = OpenSSL::HMAC.digest('sha1', UserSecret, signature_string)
|
95
|
+
signature = Base64.encode64(salt1).gsub(/\n/, '')
|
96
|
+
headers.merge!({'User-Agent': 'aliyun-tablestore-sdk-ruby', 'x-ots-signature': signature})
|
97
|
+
headers
|
98
|
+
end
|
99
|
+
end
|