lwtarantool 0.0.2

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.
Files changed (107) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +84 -0
  3. data/ext/lwtarantool/conn.c +314 -0
  4. data/ext/lwtarantool/depend +23 -0
  5. data/ext/lwtarantool/errors.c +24 -0
  6. data/ext/lwtarantool/extconf.rb +8 -0
  7. data/ext/lwtarantool/lwtarantool.c +12 -0
  8. data/ext/lwtarantool/lwtarantool.h +38 -0
  9. data/ext/lwtarantool/request.c +124 -0
  10. data/ext/lwtarantool/vendor/msgpuck/CMakeLists.txt +73 -0
  11. data/ext/lwtarantool/vendor/msgpuck/hints.c +674 -0
  12. data/ext/lwtarantool/vendor/msgpuck/msgpuck.c +375 -0
  13. data/ext/lwtarantool/vendor/msgpuck/msgpuck.h +2195 -0
  14. data/ext/lwtarantool/vendor/msgpuck/test/CMakeLists.txt +25 -0
  15. data/ext/lwtarantool/vendor/msgpuck/test/msgpuck.c +1126 -0
  16. data/ext/lwtarantool/vendor/msgpuck/test/test.c +105 -0
  17. data/ext/lwtarantool/vendor/msgpuck/test/test.h +123 -0
  18. data/ext/lwtarantool/vendor/tarantool-c/CMakeLists.txt +89 -0
  19. data/ext/lwtarantool/vendor/tarantool-c/cmake/FindMsgPuck.cmake +18 -0
  20. data/ext/lwtarantool/vendor/tarantool-c/cmake/FindSphinx.cmake +10 -0
  21. data/ext/lwtarantool/vendor/tarantool-c/doc/CMakeLists.txt +15 -0
  22. data/ext/lwtarantool/vendor/tarantool-c/doc/source/example.c +340 -0
  23. data/ext/lwtarantool/vendor/tarantool-c/include/CMakeLists.txt +6 -0
  24. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tarantool.h +67 -0
  25. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_auth.h +72 -0
  26. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_buf.h +88 -0
  27. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_call.h +83 -0
  28. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_delete.h +52 -0
  29. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_execute.h +24 -0
  30. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_insert.h +62 -0
  31. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_io.h +67 -0
  32. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_iob.h +62 -0
  33. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_iter.h +301 -0
  34. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_mem.h +102 -0
  35. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_net.h +242 -0
  36. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_object.h +248 -0
  37. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_opt.h +138 -0
  38. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_ping.h +49 -0
  39. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_proto.h +295 -0
  40. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_reply.h +204 -0
  41. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_request.h +377 -0
  42. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_schema.h +165 -0
  43. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_select.h +59 -0
  44. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_stream.h +79 -0
  45. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_update.h +226 -0
  46. data/ext/lwtarantool/vendor/tarantool-c/include/tp.h +1998 -0
  47. data/ext/lwtarantool/vendor/tarantool-c/test/CMakeLists.txt +36 -0
  48. data/ext/lwtarantool/vendor/tarantool-c/test/common.c +233 -0
  49. data/ext/lwtarantool/vendor/tarantool-c/test/common.h +28 -0
  50. data/ext/lwtarantool/vendor/tarantool-c/test/plain_test.c +152 -0
  51. data/ext/lwtarantool/vendor/tarantool-c/test/tarantool_call.c +57 -0
  52. data/ext/lwtarantool/vendor/tarantool-c/test/tarantool_disconnect.c +31 -0
  53. data/ext/lwtarantool/vendor/tarantool-c/test/tarantool_tcp.c +840 -0
  54. data/ext/lwtarantool/vendor/tarantool-c/test/tarantool_unix.c +384 -0
  55. data/ext/lwtarantool/vendor/tarantool-c/test/test.c +72 -0
  56. data/ext/lwtarantool/vendor/tarantool-c/test/test.h +94 -0
  57. data/ext/lwtarantool/vendor/tarantool-c/test/tnt_assoc.c +6 -0
  58. data/ext/lwtarantool/vendor/tarantool-c/test/tnt_assoc.h +67 -0
  59. data/ext/lwtarantool/vendor/tarantool-c/third_party/PMurHash.c +317 -0
  60. data/ext/lwtarantool/vendor/tarantool-c/third_party/PMurHash.h +68 -0
  61. data/ext/lwtarantool/vendor/tarantool-c/third_party/base64.c +300 -0
  62. data/ext/lwtarantool/vendor/tarantool-c/third_party/base64.h +91 -0
  63. data/ext/lwtarantool/vendor/tarantool-c/third_party/mhash.h +589 -0
  64. data/ext/lwtarantool/vendor/tarantool-c/third_party/sha1.c +219 -0
  65. data/ext/lwtarantool/vendor/tarantool-c/third_party/sha1.h +24 -0
  66. data/ext/lwtarantool/vendor/tarantool-c/third_party/uri.c +6528 -0
  67. data/ext/lwtarantool/vendor/tarantool-c/third_party/uri.h +81 -0
  68. data/ext/lwtarantool/vendor/tarantool-c/tnt/CMakeLists.txt +83 -0
  69. data/ext/lwtarantool/vendor/tarantool-c/tnt/pmatomic.h +494 -0
  70. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_assoc.c +9 -0
  71. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_assoc.h +172 -0
  72. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_auth.c +118 -0
  73. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_buf.c +171 -0
  74. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_call.c +79 -0
  75. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_delete.c +52 -0
  76. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_execute.c +60 -0
  77. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_insert.c +60 -0
  78. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_io.c +520 -0
  79. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_iob.c +75 -0
  80. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_iter.c +293 -0
  81. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_mem.c +82 -0
  82. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_net.c +336 -0
  83. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_object.c +476 -0
  84. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_opt.c +117 -0
  85. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_ping.c +38 -0
  86. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_proto_internal.h +43 -0
  87. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_reply.c +300 -0
  88. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_request.c +336 -0
  89. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_schema.c +334 -0
  90. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_select.c +58 -0
  91. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_stream.c +71 -0
  92. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_update.c +247 -0
  93. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/CMakeLists.txt +69 -0
  94. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_dir.c +173 -0
  95. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_dir.h +58 -0
  96. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_log.c +329 -0
  97. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_log.h +119 -0
  98. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_rpl.c +189 -0
  99. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_rpl.h +47 -0
  100. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_snapshot.c +163 -0
  101. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_snapshot.h +50 -0
  102. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_xlog.c +163 -0
  103. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_xlog.h +50 -0
  104. data/lib/lwtarantool/connection.rb +84 -0
  105. data/lib/lwtarantool/request.rb +58 -0
  106. data/lib/lwtarantool.rb +23 -0
  107. metadata +164 -0
@@ -0,0 +1,377 @@
1
+ #ifndef TNT_REQUEST_H_INCLUDED
2
+ #define TNT_REQUEST_H_INCLUDED
3
+
4
+ /*
5
+ * Redistribution and use in source and binary forms, with or
6
+ * without modification, are permitted provided that the following
7
+ * conditions are met:
8
+ *
9
+ * 1. Redistributions of source code must retain the above
10
+ * copyright notice, this list of conditions and the
11
+ * following disclaimer.
12
+ *
13
+ * 2. Redistributions in binary form must reproduce the above
14
+ * copyright notice, this list of conditions and the following
15
+ * disclaimer in the documentation and/or other materials
16
+ * provided with the distribution.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22
+ * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
26
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
29
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
+ * SUCH DAMAGE.
31
+ */
32
+
33
+ /**
34
+ * \file tnt_request.h
35
+ * \brief Request creation using connection schema
36
+ */
37
+
38
+ #include <tarantool/tnt_proto.h>
39
+
40
+ struct tnt_request {
41
+ struct {
42
+ uint64_t sync; /*!< Request sync id. Generated when encoded */
43
+ enum tnt_request_t type; /*!< Request type */
44
+ } hdr; /*!< fields for header */
45
+ uint32_t space_id; /*!< Space number */
46
+ uint32_t index_id; /*!< Index number */
47
+ uint32_t offset; /*!< Offset for select */
48
+ uint32_t limit; /*!< Limit for select */
49
+ enum tnt_iterator_t iterator; /*!< Iterator for select */
50
+ /* Search key, proc name or eval expression */
51
+ const char *key; /*!< Pointer for
52
+ * key for select/update/delete,
53
+ * procedure for call,
54
+ * expression for eval,
55
+ * operations for upsert
56
+ */
57
+ const char *key_end;
58
+ struct tnt_stream *key_object; /*!< Pointer for key object
59
+ * if allocated inside requests
60
+ * functions
61
+ */
62
+ const char *tuple; /*!< Pointer for
63
+ * tuple for insert/replace,
64
+ * ops for update
65
+ * default tuple for upsert,
66
+ * args for eval/call
67
+ */
68
+ const char *tuple_end;
69
+ struct tnt_stream *tuple_object; /*!< Pointer for tuple object
70
+ * if allocated inside requests
71
+ * functions
72
+ */
73
+ int index_base; /*!< field offset for UPDATE */
74
+ int alloc; /*!< allocation mark */
75
+ };
76
+
77
+ /**
78
+ * \brief Allocate and initialize request object
79
+ *
80
+ * if request pointer is NULL, then new request will be created
81
+ *
82
+ * \param req pointer to request
83
+ * \param stream pointer to stream for schema (may be NULL)
84
+ *
85
+ * \returns pointer to request object
86
+ * \retval NULL memory allocation failure
87
+ */
88
+ struct tnt_request *
89
+ tnt_request_init(struct tnt_request *req);
90
+ /**
91
+ * \brief Free request object
92
+ *
93
+ * \param req request object
94
+ */
95
+ void
96
+ tnt_request_free(struct tnt_request *req);
97
+
98
+ /**
99
+ * \brief Set request space from number
100
+ *
101
+ * \param req request object
102
+ * \param space space number
103
+ *
104
+ * \retval 0 ok
105
+ * \sa tnt_request_set_space
106
+ */
107
+ int
108
+ tnt_request_set_space(struct tnt_request *req, uint32_t space);
109
+
110
+ /**
111
+ * \brief Set request index from number
112
+ *
113
+ * \param req request object
114
+ * \param index index number
115
+ *
116
+ * \retval 0 ok
117
+ * \sa tnt_request_set_index
118
+ */
119
+ int
120
+ tnt_request_set_index(struct tnt_request *req, uint32_t index);
121
+
122
+ /**
123
+ * \brief Set offset for select
124
+ *
125
+ * \param req request pointer
126
+ * \param offset offset to set
127
+ *
128
+ * \retval 0 ok
129
+ */
130
+ int
131
+ tnt_request_set_offset(struct tnt_request *req, uint32_t offset);
132
+
133
+ /**
134
+ * \brief Set limit for select
135
+ *
136
+ * \param req request pointer
137
+ * \param limit limit to set
138
+ *
139
+ * \retval 0 ok
140
+ */
141
+ int
142
+ tnt_request_set_limit(struct tnt_request *req, uint32_t limit);
143
+
144
+ /**
145
+ * \brief Set iterator for select
146
+ *
147
+ * \param req request pointer
148
+ * \param iter iter to set
149
+ *
150
+ * \retval 0 ok
151
+ */
152
+ int
153
+ tnt_request_set_iterator(struct tnt_request *req, enum tnt_iterator_t iter);
154
+
155
+ /**
156
+ * \brief Set index base for update/upsert operation
157
+ *
158
+ * \param req request pointer
159
+ * \param index_base field offset to set
160
+ *
161
+ * \retval 0 ok
162
+ */
163
+ int
164
+ tnt_request_set_index_base(struct tnt_request *req, uint32_t index_base);
165
+
166
+ /**
167
+ * \brief Set key from predefined object
168
+ *
169
+ * \param req request pointer
170
+ * \param s tnt_object pointer
171
+ *
172
+ * \retval 0 ok
173
+ */
174
+ int
175
+ tnt_request_set_key(struct tnt_request *req, struct tnt_stream *s);
176
+
177
+ /**
178
+ * \brief Set key from print-like function
179
+ *
180
+ * \param req request pointer
181
+ * \param fmt format string
182
+ * \param ... arguments for format string
183
+ *
184
+ * \retval 0 ok
185
+ * \retval -1 oom/format error
186
+ * \sa tnt_object_format
187
+ */
188
+ int
189
+ tnt_request_set_key_format(struct tnt_request *req, const char *fmt, ...);
190
+
191
+ /**
192
+ * \brief Set function from string
193
+ *
194
+ * \param req request pointer
195
+ * \param func function string
196
+ * \param flen function string length
197
+ *
198
+ * \retval 0 ok
199
+ */
200
+ int
201
+ tnt_request_set_func(struct tnt_request *req, const char *func, uint32_t flen);
202
+
203
+ /**
204
+ * \brief Set function from NULL-terminated string
205
+ *
206
+ * \param req request pointer
207
+ * \param func function string
208
+ *
209
+ * \retval 0 ok
210
+ */
211
+ int
212
+ tnt_request_set_funcz(struct tnt_request *req, const char *func);
213
+
214
+ /**
215
+ * \brief Set expression from string
216
+ *
217
+ * \param req request pointer
218
+ * \param expr expression string
219
+ * \param elen expression string length
220
+ *
221
+ * \retval 0 ok
222
+ * \retval -1 error
223
+ */
224
+ int
225
+ tnt_request_set_expr(struct tnt_request *req, const char *expr, uint32_t elen);
226
+
227
+ /**
228
+ * \brief Set expression from NULL-terminated string
229
+ *
230
+ * \param req request pointer
231
+ * \param expr expression string
232
+ *
233
+ * \retval 0 ok
234
+ * \retval -1 error
235
+ */
236
+ int
237
+ tnt_request_set_exprz(struct tnt_request *req, const char *expr);
238
+
239
+ /**
240
+ * \brief Set tuple from predefined object
241
+ *
242
+ * \param req request pointer
243
+ * \param s tnt_object pointer
244
+ *
245
+ * \retval 0 ok
246
+ */
247
+ int
248
+ tnt_request_set_tuple(struct tnt_request *req, struct tnt_stream *s);
249
+
250
+ /**
251
+ * \brief Set tuple from print-like function
252
+ *
253
+ * \param req request pointer
254
+ * \param fmt format string
255
+ * \param ... arguments for format string
256
+ *
257
+ * \retval 0 ok
258
+ * \retval -1 oom/format error
259
+ * \sa tnt_object_format
260
+ */
261
+ int
262
+ tnt_request_set_tuple_format(struct tnt_request *req, const char *fmt, ...);
263
+
264
+ /**
265
+ * \brief Set operations from predefined object
266
+ *
267
+ * \param req request pointer
268
+ * \param s tnt_object pointer
269
+ *
270
+ * \retval 0 ok
271
+ */
272
+ int
273
+ tnt_request_set_ops(struct tnt_request *req, struct tnt_stream *s);
274
+
275
+ /**
276
+ * \brief Encode request to stream object
277
+ *
278
+ * \param s stream pointer
279
+ * \param req request pointer
280
+ *
281
+ * \retval >0 ok, sync is returned
282
+ * \retval -1 out of memory
283
+ */
284
+ int64_t
285
+ tnt_request_compile(struct tnt_stream *s, struct tnt_request *req);
286
+
287
+ /**
288
+ * \brief Encode request to stream object.
289
+ *
290
+ * \param[in] s stream pointer
291
+ * \param[in] req request pointer
292
+ * \param[out] sync pointer to compiled request
293
+ *
294
+ * \retval 0 ok
295
+ * \retval -1 out of memory
296
+ */
297
+ int
298
+ tnt_request_writeout(struct tnt_stream *s, struct tnt_request *req,
299
+ uint64_t *sync);
300
+ /**
301
+ * \brief create select request object
302
+ * \sa tnt_request_init
303
+ */
304
+ struct tnt_request *
305
+ tnt_request_select(struct tnt_request *req);
306
+
307
+ /**
308
+ * \brief create insert request object
309
+ * \sa tnt_request_init
310
+ */
311
+ struct tnt_request *
312
+ tnt_request_insert(struct tnt_request *req);
313
+
314
+ /**
315
+ * \brief create replace request object
316
+ * \sa tnt_request_init
317
+ */
318
+ struct tnt_request *
319
+ tnt_request_replace(struct tnt_request *req);
320
+
321
+ /**
322
+ * \brief create update request object
323
+ * \sa tnt_request_init
324
+ */
325
+ struct tnt_request *
326
+ tnt_request_update(struct tnt_request *req);
327
+
328
+ /**
329
+ * \brief create delete request object
330
+ * \sa tnt_request_init
331
+ */
332
+ struct tnt_request *
333
+ tnt_request_delete(struct tnt_request *req);
334
+
335
+ /**
336
+ * \brief create call request object
337
+ * \sa tnt_request_init
338
+ */
339
+ struct tnt_request *
340
+ tnt_request_call(struct tnt_request *req);
341
+
342
+ /**
343
+ * \brief create call request object
344
+ * \sa tnt_request_init
345
+ */
346
+ struct tnt_request *
347
+ tnt_request_call_16(struct tnt_request *req);
348
+
349
+ /**
350
+ * \brief create auth request object
351
+ * \sa tnt_request_init
352
+ */
353
+ struct tnt_request *
354
+ tnt_request_auth(struct tnt_request *req);
355
+
356
+ /**
357
+ * \brief create eval request object
358
+ * \sa tnt_request_init
359
+ */
360
+ struct tnt_request *
361
+ tnt_request_eval(struct tnt_request *req);
362
+
363
+ /**
364
+ * \brief create upsert request object
365
+ * \sa tnt_request_init
366
+ */
367
+ struct tnt_request *
368
+ tnt_request_upsert(struct tnt_request *req);
369
+
370
+ /**
371
+ * \brief create ping request object
372
+ * \sa tnt_request_init
373
+ */
374
+ struct tnt_request *
375
+ tnt_request_ping(struct tnt_request *req);
376
+
377
+ #endif /* TNT_REQUEST_H_INCLUDED */
@@ -0,0 +1,165 @@
1
+ #ifndef TNT_SCHEMA_H_INCLUDED
2
+ #define TNT_SCHEMA_H_INCLUDED
3
+
4
+ /*
5
+ * Redistribution and use in source and binary forms, with or
6
+ * without modification, are permitted provided that the following
7
+ * conditions are met:
8
+ *
9
+ * 1. Redistributions of source code must retain the above
10
+ * copyright notice, this list of conditions and the
11
+ * following disclaimer.
12
+ *
13
+ * 2. Redistributions in binary form must reproduce the above
14
+ * copyright notice, this list of conditions and the following
15
+ * disclaimer in the documentation and/or other materials
16
+ * provided with the distribution.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22
+ * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
26
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
29
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
+ * SUCH DAMAGE.
31
+ */
32
+
33
+
34
+ /**
35
+ * \internal
36
+ * \file tnt_schema.h
37
+ * \brief Tarantool schema
38
+ */
39
+
40
+ struct mh_assoc_t;
41
+
42
+ /**
43
+ * \internal
44
+ * \brief index value information
45
+ */
46
+ struct tnt_schema_ival {
47
+ const char *name;
48
+ uint32_t name_len;
49
+ uint32_t number;
50
+ };
51
+
52
+ /**
53
+ * \internal
54
+ * \brief space value information
55
+ */
56
+ struct tnt_schema_sval {
57
+ char *name;
58
+ uint32_t name_len;
59
+ uint32_t number;
60
+ struct mh_assoc_t *index;
61
+ };
62
+
63
+ /**
64
+ * \brief Schema of tarantool instance
65
+ */
66
+ struct tnt_schema {
67
+ struct mh_assoc_t *space_hash; /*!< hash with spaces */
68
+ int alloc; /*!< allocation mark */
69
+ };
70
+
71
+ /**
72
+ * \brief Add spaces definitions to schema
73
+ *
74
+ * must be used with response's data of select from 280/281 spaces
75
+ * (_space/_vspace)
76
+ *
77
+ * \param sch schema pointer
78
+ * \param data pointer to data
79
+ * \param dlen data size
80
+ *
81
+ * \returns status
82
+ * \retval -1 failed parsing/oom
83
+ * \retval 0 ok
84
+ */
85
+ int
86
+ tnt_schema_add_spaces(struct tnt_schema *sch, struct tnt_reply *r);
87
+
88
+ /**
89
+ * \brief Add indexes definitions to schema
90
+ *
91
+ * must be used with response's data of select from 288/289 indexes
92
+ * (_index/_vindex)
93
+ *
94
+ * \param sch schema pointer
95
+ * \param data pointer to data
96
+ * \param dlen data size
97
+ *
98
+ * \returns status
99
+ * \retval -1 failed parsing/oom
100
+ * \retval 0 ok
101
+ */
102
+ int
103
+ tnt_schema_add_indexes(struct tnt_schema *sch, struct tnt_reply *r);
104
+
105
+ /**
106
+ * \brief Get spaceno by space name
107
+ *
108
+ * \param sch schema pointer
109
+ * \param sstr space name
110
+ * \param sslen space name len
111
+ *
112
+ * \returns space id
113
+ * \retval -1 error, space not found
114
+ */
115
+ int32_t
116
+ tnt_schema_stosid (struct tnt_schema *sch, const char *sstr, uint32_t sslen);
117
+
118
+ /**
119
+ * \brief Get indexno by space no and index name
120
+ *
121
+ * \param sch schema pointer
122
+ * \param sno space no
123
+ * \param istr index name
124
+ * \param islen index name len
125
+ *
126
+ * \returns index id
127
+ * \retval -1 error, index/space not found
128
+ */
129
+ int32_t
130
+ tnt_schema_stoiid (struct tnt_schema *sch, uint32_t sno, const char *istr,
131
+ uint32_t islen);
132
+
133
+ /**
134
+ * \brief Create and init schema object
135
+ *
136
+ * if schema pointer is NULL, then new schema object will be created
137
+ *
138
+ * \param sch schema pointer
139
+ * \returns new schema object
140
+ * \retval NULL oom
141
+ */
142
+ struct tnt_schema *
143
+ tnt_schema_new(struct tnt_schema *sch);
144
+
145
+ /**
146
+ * \brief Reset schema to default state (empty)
147
+ * \param sch schema pointer
148
+ */
149
+ void
150
+ tnt_schema_flush(struct tnt_schema *sch);
151
+
152
+ /**
153
+ * \brief Reset and free schema
154
+ * \param sch schema pointer
155
+ */
156
+ void
157
+ tnt_schema_free(struct tnt_schema *sch);
158
+
159
+ ssize_t
160
+ tnt_get_space(struct tnt_stream *s);
161
+
162
+ ssize_t
163
+ tnt_get_index(struct tnt_stream *s);
164
+
165
+ #endif /* TNT_SCHEMA_H_INCLUDED */
@@ -0,0 +1,59 @@
1
+ #ifndef TNT_SELECT_H_INCLUDED
2
+ #define TNT_SELECT_H_INCLUDED
3
+
4
+ /*
5
+ * Redistribution and use in source and binary forms, with or
6
+ * without modification, are permitted provided that the following
7
+ * conditions are met:
8
+ *
9
+ * 1. Redistributions of source code must retain the above
10
+ * copyright notice, this list of conditions and the
11
+ * following disclaimer.
12
+ *
13
+ * 2. Redistributions in binary form must reproduce the above
14
+ * copyright notice, this list of conditions and the following
15
+ * disclaimer in the documentation and/or other materials
16
+ * provided with the distribution.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22
+ * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
26
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
29
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
+ * SUCH DAMAGE.
31
+ */
32
+
33
+ #include <tarantool/tnt_stream.h>
34
+
35
+ /**
36
+ * \file tnt_select.h
37
+ * \brief Select request
38
+ */
39
+
40
+ /**
41
+ * \brief Construct select request and write it into stream
42
+ *
43
+ * \param s stream object
44
+ * \param space space no
45
+ * \param index index no
46
+ * \param limit limit of tuples to select
47
+ * \param offset offset of tuples to select
48
+ * \param iterator iterator to use for select
49
+ * \param key key for select
50
+ *
51
+ * \returns number of bytes written to stream
52
+ * \retval -1 oom
53
+ */
54
+ ssize_t
55
+ tnt_select(struct tnt_stream *s, uint32_t space, uint32_t index,
56
+ uint32_t limit, uint32_t offset, uint8_t iterator,
57
+ struct tnt_stream *key);
58
+
59
+ #endif /* TNT_SELECT_H_INCLUDED */
@@ -0,0 +1,79 @@
1
+ #ifndef TNT_STREAM_H_INCLUDED
2
+ #define TNT_STREAM_H_INCLUDED
3
+
4
+ /*
5
+ * Redistribution and use in source and binary forms, with or
6
+ * without modification, are permitted provided that the following
7
+ * conditions are met:
8
+ *
9
+ * 1. Redistributions of source code must retain the above
10
+ * copyright notice, this list of conditions and the
11
+ * following disclaimer.
12
+ *
13
+ * 2. Redistributions in binary form must reproduce the above
14
+ * copyright notice, this list of conditions and the following
15
+ * disclaimer in the documentation and/or other materials
16
+ * provided with the distribution.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22
+ * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
26
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
29
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
+ * SUCH DAMAGE.
31
+ */
32
+
33
+ /**
34
+ * \file tnt_stream.h
35
+ * \brief Basic stream object
36
+ */
37
+
38
+ #include <sys/types.h>
39
+ #include <sys/uio.h>
40
+
41
+ #include <tarantool/tnt_reply.h>
42
+ #include <tarantool/tnt_request.h>
43
+
44
+ /**
45
+ * \brief Basic stream object
46
+ * all function pointers are NULL, if operation is not supported
47
+ */
48
+ struct tnt_stream {
49
+ int alloc; /*!< Allocation mark */
50
+ ssize_t (*write)(struct tnt_stream *s, const char *buf, size_t size); /*!< write to buffer function */
51
+ ssize_t (*writev)(struct tnt_stream *s, struct iovec *iov, int count); /*!< writev function */
52
+ ssize_t (*write_request)(struct tnt_stream *s, struct tnt_request *r, uint64_t *sync); /*!< write request function */
53
+
54
+ ssize_t (*read)(struct tnt_stream *s, char *buf, size_t size); /*!< read from buffer function */
55
+ int (*read_reply)(struct tnt_stream *s, struct tnt_reply *r); /*!< read reply from buffer */
56
+
57
+ void (*free)(struct tnt_stream *s); /*!< free custom buffer types (destructor) */
58
+
59
+ void *data; /*!< subclass data */
60
+ uint32_t wrcnt; /*!< count of write operations */
61
+ uint64_t reqid; /*!< request id of current operation */
62
+ };
63
+
64
+ /**
65
+ * \brief Base function for allocating stream. For internal use only.
66
+ */
67
+ struct tnt_stream *tnt_stream_init(struct tnt_stream *s);
68
+ /**
69
+ * \brief Base function for freeing stream. For internal use only.
70
+ */
71
+ void tnt_stream_free(struct tnt_stream *s);
72
+
73
+ /**
74
+ * \brief set reqid number. It's incremented at every request compilation.
75
+ * default is 0
76
+ */
77
+ uint32_t tnt_stream_reqid(struct tnt_stream *s, uint32_t reqid);
78
+
79
+ #endif /* TNT_STREAM_H_INCLUDED */