Merge lp:~zorba-coders/zorba/couchbase_module-bug-1188063 into lp:zorba/couchbase-module
- couchbase_module-bug-1188063
- Merge into couchbase-module
Proposed by
Matthias Brantner
Status: | Needs review | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~zorba-coders/zorba/couchbase_module-bug-1188063 | ||||
Merge into: | lp:zorba/couchbase-module | ||||
Diff against target: |
546 lines (+127/-153) 2 files modified
src/couchbase.xq (+126/-152) src/couchbase.xq.src/couchbase.h (+1/-1) |
||||
To merge this branch: | bzr merge lp:~zorba-coders/zorba/couchbase_module-bug-1188063 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Hillery | Needs Fixing | ||
Matthias Brantner | Approve | ||
Review via email: mp+182781@code.launchpad.net |
Commit message
renamed to zorba.io and adapted documentation
Description of the change
To post a comment you must log in.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue result for https:/
Stage "TestZorbaUbuntu" failed.
20 tests failed (8409 total tests run).
Check test results at http://
Revision history for this message
Chris Hillery (ceejatec) wrote : | # |
This needs JSON validation too, correct?
Revision history for this message
Chris Hillery (ceejatec) wrote : | # |
Per Matthias, validation is done in C++, so we can defer adding a JSON schema for now.
Revision history for this message
Chris Hillery (ceejatec) wrote : | # |
Need to update error codes. Don't want to use CB0001 codes anymore.
review:
Needs Fixing
Unmerged revisions
- 48. By Matthias Brantner
-
renamed and improved documentation
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/couchbase.xq' |
2 | --- src/couchbase.xq 2013-08-09 09:37:05 +0000 |
3 | +++ src/couchbase.xq 2013-08-28 23:18:04 +0000 |
4 | @@ -1,7 +1,7 @@ |
5 | -xquery version "3.0"; |
6 | +jsoniq version "1.0"; |
7 | |
8 | (: |
9 | - : Copyright 2012 The FLWOR Foundation. |
10 | + : Copyright 2013 The FLWOR Foundation. |
11 | : |
12 | : Licensed under the Apache License, Version 2.0 (the "License"); |
13 | : you may not use this file except in compliance with the License. |
14 | @@ -19,9 +19,9 @@ |
15 | (:~ |
16 | : This module provides minimal functionality to interact with the |
17 | : Couchbase NoSQL database. |
18 | - : |
19 | + : <p/> |
20 | : The module is built using the libcouchbase C client library and |
21 | - : exposes most of its functionality in XQuery with JSONiq extensions. |
22 | + : exposes most of its functionality. |
23 | : Beyond just allowing for basic key-value store operations (e.g. |
24 | : put-/get-text or put-/get-binary, this module also allows to work |
25 | : with Couchbase views in order to allow for complex JSON query |
26 | @@ -31,9 +31,8 @@ |
27 | : @project DB Drivers/Couchbase |
28 | : |
29 | :) |
30 | -module namespace cb = "http://www.zorba-xquery.com/modules/couchbase"; |
31 | +module namespace cb = "http://zorba.io/modules/couchbase"; |
32 | |
33 | -declare namespace jn = "http://jsoniq.org/functions"; |
34 | declare namespace an = "http://zorba.io/annotations"; |
35 | |
36 | declare namespace ver = "http://zorba.io/options/versioning"; |
37 | @@ -55,11 +54,11 @@ |
38 | :) |
39 | |
40 | declare %an:sequential function cb:connect( |
41 | - $host as xs:string, |
42 | - $username as xs:string?, |
43 | - $password as xs:string?, |
44 | - $bucket as xs:string) |
45 | - as xs:anyURI |
46 | + $host as string, |
47 | + $username as string?, |
48 | + $password as string?, |
49 | + $bucket as string) |
50 | + as anyURI |
51 | { |
52 | cb:connect({"host" : $host, |
53 | "username" : $username, |
54 | @@ -71,13 +70,8 @@ |
55 | : Connect to the Couchbase server and return an opaque identifier |
56 | : representing the established connection. |
57 | : |
58 | - : @param $options a JSONiq object that contains the host, bucket, |
59 | - : and user information. |
60 | - : |
61 | - : @option "host" endpoint of the Couchbase server (mandatory) |
62 | - : @option "username" username used for the connection (optional) |
63 | - : @option "password" password used for the connection (optional) |
64 | - : @option "bucket" name of an existing bucket (mandatory) |
65 | + : @param $options an object that contains the host (mandatory), |
66 | + : bucket (mandatory), username, and password. |
67 | : |
68 | : @error cb:LCB0001 if the connection to the given host/bucket |
69 | : could not be established. |
70 | @@ -85,22 +79,12 @@ |
71 | : @error cb:CB0007 if a given option is not supported. |
72 | : |
73 | : @return an identifier for the established connection. |
74 | - : |
75 | - : Example: |
76 | - : <code> |
77 | - : { |
78 | - : "host": "localhost:8091", |
79 | - : "username" : null, |
80 | - : "password" : null, |
81 | - : "bucket" : "default" |
82 | - : } |
83 | - : </code> |
84 | :) |
85 | -declare %an:sequential function cb:connect($options as object()) |
86 | - as xs:anyURI external; |
87 | +declare %an:sequential function cb:connect($options as object) |
88 | + as anyURI external; |
89 | |
90 | (:~ |
91 | - : Return the values of the given keys (type xs:string) as string. |
92 | + : Return the values of the given keys as string. |
93 | : |
94 | : @param $db connection reference |
95 | : @param $key the requested keys |
96 | @@ -108,43 +92,39 @@ |
97 | : @error cb:LCB0002 if any error occurs in the communication with |
98 | : the server. |
99 | : |
100 | - : @return A sequence of string Items corresponding to the key |
101 | + : @return A sequence of strings. |
102 | :) |
103 | |
104 | declare %an:sequential function cb:get-text( |
105 | - $db as xs:anyURI, |
106 | - $key as xs:string*) |
107 | -as xs:string* external; |
108 | + $db as anyURI, |
109 | + $key as string*) |
110 | +as string* external; |
111 | |
112 | (:~ |
113 | - : Return the values of the given keys (type xs:string) as string. |
114 | + : Return the values of the given keys as string. |
115 | : |
116 | : @param $db connection reference |
117 | : @param $key the requested keys |
118 | - : @param $options JSONiq object with additional options |
119 | + : @param $options an object specifying the expiration-time (integer) |
120 | + : or encoding (string; default is UTF-8). |
121 | : |
122 | - : @option "expiration-time" xs:integer value for refreshing the expiration |
123 | - : time in seconds. |
124 | - : @option "encoding" string with the name of the encoding of the returned |
125 | - : string (if not UTF-8). |
126 | - : |
127 | : @error cb:LCB0002 if any error occurs in the communication with |
128 | : the server. |
129 | : @error cb:CB0006 if the given encoding is not supported. |
130 | : @error cb:CB0007 if any of the options is not supported. |
131 | - : @error cb:CB0009 if the given expiration time is not an xs:integer. |
132 | + : @error cb:CB0009 if the given expiration time is not an integer. |
133 | : |
134 | : @return a sequence of strings for the given keys. |
135 | :) |
136 | |
137 | declare %an:sequential function cb:get-text( |
138 | - $db as xs:anyURI, |
139 | - $key as xs:string*, |
140 | - $options as object()) |
141 | -as xs:string* external; |
142 | + $db as anyURI, |
143 | + $key as string*, |
144 | + $options as object) |
145 | +as string* external; |
146 | |
147 | (:~ |
148 | - : Return the values of the given keys (type xs:string) as base64Binary. |
149 | + : Return the values of the given keys as base64Binary. |
150 | : |
151 | : @param $db connection reference |
152 | : @param $key the requested keys |
153 | @@ -152,91 +132,90 @@ |
154 | : @error cb:LCB0002 if any error occurs in the communication with |
155 | : the server. |
156 | : |
157 | - : @return a sequence of xs:base64Binary items for the given keys. |
158 | + : @return a sequence of base64Binary items for the given keys. |
159 | :) |
160 | declare %an:sequential function cb:get-binary( |
161 | - $db as xs:anyURI, |
162 | - $key as xs:string*) |
163 | -as xs:base64Binary* external; |
164 | + $db as anyURI, |
165 | + $key as string*) |
166 | +as base64Binary* external; |
167 | |
168 | (:~ |
169 | - : Return the values of the given keys (type xs:string) as base64Binary. |
170 | + : Return the values of the given keys as base64Binary. |
171 | : |
172 | : @param $db connection reference |
173 | : @param $key the requested keys |
174 | - : @param $options JSONiq object with additional options |
175 | + : @param $options an object with specyfing the expiration-time (integer). |
176 | : |
177 | - : @option "expiration-time" xs:integer value for refreshing the expiration |
178 | - : time in seconds. |
179 | - : |
180 | : @error cb:LCB0002 if any error occurs in the communication with |
181 | : the server. |
182 | : @error cb:CB0007 if any of the options is not supported. |
183 | - : @error cb:CB0009 if the given expiration time is not an xs:integer. |
184 | + : @error cb:CB0009 if the given expiration time is not an integer. |
185 | : |
186 | - : @return a sequence of xs:base64Binary items for the given keys. |
187 | + : @return a sequence of base64Binary items for the given keys. |
188 | :) |
189 | declare %an:sequential function cb:get-binary( |
190 | - $db as xs:anyURI, |
191 | - $key as xs:string*, |
192 | - $options as object()) |
193 | -as xs:base64Binary* external; |
194 | + $db as anyURI, |
195 | + $key as string*, |
196 | + $options as object) |
197 | +as base64Binary* external; |
198 | |
199 | (:~ |
200 | - : Remove the values matching the given keys (xs:string) from the server. |
201 | + : Remove the values matching the given keys. |
202 | : |
203 | : @param $db connection reference |
204 | : @param $key the keys of the values that should be removed. |
205 | : |
206 | : @error cb:LCB0002 if any error occurs in the communication with |
207 | : the server. |
208 | + : |
209 | : @return a empty sequence. |
210 | :) |
211 | -declare %an:sequential function cb:remove($db as xs:anyURI, $key as xs:string*) |
212 | - as empty-sequence() external; |
213 | +declare %an:sequential function cb:remove($db as anyURI, $key as string*) |
214 | + as () external; |
215 | |
216 | (:~ |
217 | : Store the given key-value bindings. |
218 | - : |
219 | + : <p/> |
220 | : The values are stored with the UTF-8 encoding and a default |
221 | : expiration time of 60 seconds. |
222 | : |
223 | : @param $db connection reference |
224 | : @param $key the keys to store |
225 | - : @param $value the values (as xs:string) to be stored. |
226 | + : @param $value the values to be stored. |
227 | : |
228 | : @error cb:LCB0002 if any error occurs in the communication with |
229 | : the server. |
230 | : @error cb:CB0005 if the number of keys doesn't match the number |
231 | : of values. |
232 | + : |
233 | : @return a empty sequence. |
234 | :) |
235 | declare %an:sequential function cb:put-text( |
236 | - $db as xs:anyURI, |
237 | - $key as xs:string*, |
238 | - $value as xs:string*) |
239 | -as empty-sequence() |
240 | + $db as anyURI, |
241 | + $key as string*, |
242 | + $value as string*) |
243 | + as () |
244 | { |
245 | cb:put-text($db, $key, $value, { "expiration-time" : 60, "encoding" : "UTF-8" }) |
246 | }; |
247 | |
248 | (:~ |
249 | : Store the given key-value bindings. |
250 | + : <p/> |
251 | + : Available options: |
252 | + : <ul> |
253 | + : <li>"expiration-time" integer value that represent the : expiration time in seconds.</li> |
254 | + : <li>"operation" type of operation, possible values are : "add", "replace", "set", "append" and "prepend".</li> |
255 | + : <li>"encoding" the encoding that should be used for the : value (default is UTF-8).</li> |
256 | + : <li>"wait" variable for setting if a wait for persistancy in |
257 | + : the storing key is needed, possible values are "persist" and "false".</li> |
258 | + : </ul> |
259 | : |
260 | : @param $db connection reference |
261 | : @param $key the keys to store |
262 | - : @param $value the values (as xs:string) to be stored. |
263 | - : @param $options JSONiq object with additional options |
264 | + : @param $value the values (as string) to be stored. |
265 | + : @param $options an object with additional options |
266 | : |
267 | - : @option "expiration-time" integer value that represent the |
268 | - : expiration time in seconds. |
269 | - : @option "operation" type of operation, possible values are |
270 | - : "add", "replace", "set", "append" and "prepend". |
271 | - : @option "encoding" the encoding that should be used for the |
272 | - : value (default is UTF-8). |
273 | - : @option "wait" variable for setting if a wait for persistancy in |
274 | - : the storing key is needed, possible values are "persist" |
275 | - : and "false". |
276 | : |
277 | : @error cb:LCB0002 if any error occurs in the communication with |
278 | : the server. |
279 | @@ -244,24 +223,24 @@ |
280 | : of values. |
281 | : @error cb:CB0006 if the given encoding is not supported. |
282 | : @error cb:CB0007 if any of the options is not supported. |
283 | - : @error cb:CB0009 if the given expiration time is not an xs:integer. |
284 | + : @error cb:CB0009 if the given expiration time is not an integer. |
285 | : @error cb:CB0011 if the stored Variable was not stored |
286 | : |
287 | : @return a empty sequence. |
288 | :) |
289 | declare %an:sequential function cb:put-text( |
290 | - $db as xs:anyURI, |
291 | - $key as xs:string*, |
292 | - $value as xs:string*, |
293 | - $options as object()) |
294 | - as empty-sequence() external; |
295 | + $db as anyURI, |
296 | + $key as string*, |
297 | + $value as string*, |
298 | + $options as object) |
299 | + as () external; |
300 | |
301 | (:~ |
302 | : Store the given key-value bindings. |
303 | : |
304 | : @param $db connection reference |
305 | : @param $key the keys to store |
306 | - : @param $value the values (as xs:base64binary) to be stored. |
307 | + : @param $value the values (as base64binary) to be stored. |
308 | : |
309 | : @error cb:LCB0002 if any error occurs in the communication with |
310 | : the server. |
311 | @@ -271,10 +250,10 @@ |
312 | : @return a empty sequence. |
313 | :) |
314 | declare %an:sequential function cb:put-binary( |
315 | - $db as xs:anyURI, |
316 | - $key as xs:string*, |
317 | - $value as xs:base64Binary*) |
318 | -as empty-sequence() |
319 | + $db as anyURI, |
320 | + $key as string*, |
321 | + $value as base64Binary*) |
322 | + as () |
323 | { |
324 | cb:put-binary($db, $key, $value, { "expiration-time" : 60 }) |
325 | }; |
326 | @@ -284,8 +263,8 @@ |
327 | : |
328 | : @param $db connection reference |
329 | : @param $key the keys to store |
330 | - : @param $value the values (as xs:base64binary) to be stored. |
331 | - : @param $options JSONiq object with additional options |
332 | + : @param $value the values (as base64binary) to be stored. |
333 | + : @param $options an object with additional options |
334 | |
335 | : @option "expiration-time" integer value that represent the |
336 | : expiration time in seconds. |
337 | @@ -300,17 +279,17 @@ |
338 | : @error cb:CB0005 if the number of keys doesn't match the number |
339 | : of values. |
340 | : @error cb:CB0007 if any of the options is not supported. |
341 | - : @error cb:CB0009 if the given expiration time is not an xs:integer. |
342 | + : @error cb:CB0009 if the given expiration time is not an integer. |
343 | : @error cb:CB0011 if the stored Variable was not stored |
344 | : |
345 | : @return a empty sequence. |
346 | :) |
347 | declare %an:sequential function cb:put-binary( |
348 | - $db as xs:anyURI, |
349 | - $key as xs:string*, |
350 | - $value as xs:base64Binary*, |
351 | - $options as object()) |
352 | -as empty-sequence() external; |
353 | + $db as anyURI, |
354 | + $key as string*, |
355 | + $value as base64Binary*, |
356 | + $options as object) |
357 | + as () external; |
358 | |
359 | |
360 | (:~ |
361 | @@ -323,8 +302,8 @@ |
362 | : |
363 | : @return a empty sequence. |
364 | :) |
365 | -declare %an:sequential function cb:flush($db as xs:anyURI) |
366 | -as empty-sequence() external; |
367 | +declare %an:sequential function cb:flush($db as anyURI) |
368 | +as () external; |
369 | |
370 | (:~ |
371 | : Refresh the expiration time of the given keys. |
372 | @@ -339,10 +318,10 @@ |
373 | : @return a empty sequence. |
374 | :) |
375 | declare %an:sequential function cb:touch( |
376 | - $db as xs:anyURI, |
377 | - $key as xs:string*, |
378 | - $exp-time as xs:integer) |
379 | -as empty-sequence() external; |
380 | + $db as anyURI, |
381 | + $key as string*, |
382 | + $exp-time as integer) |
383 | + as () external; |
384 | |
385 | (:~ |
386 | : Retrieve the content of existing views. |
387 | @@ -356,14 +335,14 @@ |
388 | : |
389 | : @return a sequence of strings (as JSON) containing information of the views. |
390 | :) |
391 | -declare %an:sequential function cb:view($db as xs:anyURI, $path as xs:string*) |
392 | - as object()* |
393 | +declare %an:sequential function cb:view($db as anyURI, $path as string*) |
394 | + as object* |
395 | { |
396 | jn:parse-json(cb:view-text($db, $path)) |
397 | }; |
398 | |
399 | -declare %private %an:sequential function cb:view-text($db as xs:anyURI, $path as xs:string*) |
400 | - as xs:string* external; |
401 | +declare %private %an:sequential function cb:view-text($db as anyURI, $path as string*) |
402 | + as string* external; |
403 | |
404 | |
405 | (:~ |
406 | @@ -372,7 +351,7 @@ |
407 | : @param $db connection reference |
408 | : @param $path contains the string of a view path |
409 | : (e.g. "_design/test/_view/vies"). |
410 | - : @param $options JSONiq object with additional options |
411 | + : @param $options an object with additional options |
412 | : |
413 | : @option Json object whith options for the querying the view. available options: |
414 | : "encoding" string with the name of the encoding of the returned |
415 | @@ -394,24 +373,23 @@ |
416 | : @return a sequence of strings (as JSON) containing information of the views. |
417 | :) |
418 | declare %an:sequential function cb:view( |
419 | - $db as xs:anyURI, |
420 | - $path as xs:string*, |
421 | - $options as object()) |
422 | -as object()* |
423 | + $db as anyURI, |
424 | + $path as string*, |
425 | + $options as object) |
426 | + as object* |
427 | { |
428 | jn:parse-json(cb:view-text($db, $path, $options)) |
429 | }; |
430 | |
431 | declare %private %an:sequential function cb:view-text( |
432 | - $db as xs:anyURI, |
433 | - $path as xs:string*, |
434 | - $options as object()) |
435 | -as xs:string* external; |
436 | - |
437 | + $db as anyURI, |
438 | + $path as string*, |
439 | + $options as object) |
440 | + as string* external; |
441 | |
442 | (:~ |
443 | : Create a document/view. |
444 | - |
445 | + : <p/> |
446 | : If the document already exists, it is replaced. A document can hold several |
447 | : views that must be specified in the same call of cb:create-view. |
448 | : |
449 | @@ -426,34 +404,31 @@ |
450 | : created. |
451 | :) |
452 | declare %an:sequential function cb:create-view( |
453 | - $db as xs:anyURI, |
454 | - $doc-name as xs:string, |
455 | - $view-names as xs:string*) |
456 | -as xs:string* external; |
457 | + $db as anyURI, |
458 | + $doc-name as string, |
459 | + $view-names as string*) |
460 | + as string* external; |
461 | |
462 | (:~ |
463 | : Create a document/view. |
464 | - |
465 | - : If the document already exists, it is replaced. A document can hold several |
466 | + : <p/> |
467 | + : If the document already exists, it is replaced. A document can have several |
468 | : views that must be specified in the same call of cb:create-view. |
469 | + : <p/> |
470 | + : The following options can be specified: |
471 | + : <ul> |
472 | + : <li>"key": name of the key displayed in the resulting object.</li> |
473 | + : <li>"values" a string or array of strings containing the values |
474 | + : that should be contained in the resulting object.</li> |
475 | + : <li>"function" the javascript map function of the view. If present, |
476 | + : the "key" and "values" options are ignored.</li> |
477 | + : </ul> |
478 | : |
479 | : @param $db connection reference |
480 | : @param $doc-name name of the document to create. |
481 | : @param $view-names names of the views to create in the document. |
482 | : @param $options options describing how to create the view. |
483 | : |
484 | - : @option "key" value must be a string containing the name of the value |
485 | - : in the json object stored in couchbase that is wanted to be |
486 | - : displayed as the value of "key" in the resulting json. |
487 | - : @option "values" value must be a string or an array of strings containing |
488 | - : the name of the value in the json object stored in couchbase that |
489 | - : is wanted to be displayed as the value of "value" in the resulting |
490 | - : json. |
491 | - : @option "function" string with a javascript function describing the |
492 | - : map function of the view. cb:create-view won't throw an error |
493 | - : if the javascript function is not compilable or functional. If |
494 | - : this option is set the "key" and "values" options are ignored. |
495 | - : |
496 | : @error cb:LCB0002 if any error occurs in the communication with |
497 | : the server. |
498 | : @error cb:CB0005 if the number of options doesn't match the number of |
499 | @@ -465,18 +440,17 @@ |
500 | : created. |
501 | :) |
502 | declare %an:sequential function cb:create-view( |
503 | - $db as xs:anyURI, |
504 | - $doc-name as xs:string, |
505 | - $view-names as xs:string*, |
506 | - $options as object()*) |
507 | -as xs:string* external; |
508 | - |
509 | + $db as anyURI, |
510 | + $doc-name as string, |
511 | + $view-names as string*, |
512 | + $options as object*) |
513 | + as string* external; |
514 | |
515 | (:~ |
516 | : Delete a document/view. |
517 | - |
518 | + : <p/> |
519 | : If the document doesn't exists, function does nothing. All the views hold in the |
520 | - : Document are deleted, this function can't delete single views. |
521 | + : document are deleted, this function can't delete single views. |
522 | : |
523 | : @param $db connection reference |
524 | : @param $doc-name name of the document to create. |
525 | @@ -487,6 +461,6 @@ |
526 | : @return empty sequence. |
527 | :) |
528 | declare %an:sequential function cb:delete-view( |
529 | - $db as xs:anyURI, |
530 | - $doc as xs:string*) |
531 | -as xs:string* external; |
532 | + $db as anyURI, |
533 | + $doc as string*) |
534 | + as string* external; |
535 | |
536 | === modified file 'src/couchbase.xq.src/couchbase.h' |
537 | --- src/couchbase.xq.src/couchbase.h 2013-01-21 22:42:49 +0000 |
538 | +++ src/couchbase.xq.src/couchbase.h 2013-08-28 23:18:04 +0000 |
539 | @@ -24,7 +24,7 @@ |
540 | #include <zorba/function.h> |
541 | #include <zorba/dynamic_context.h> |
542 | |
543 | -#define COUCHBASE_MODULE_NAMESPACE "http://www.zorba-xquery.com/modules/couchbase" |
544 | +#define COUCHBASE_MODULE_NAMESPACE "http://zorba.io/modules/couchbase" |
545 | |
546 | namespace zorba { namespace couchbase { |
547 |
Validation queue starting for the following merge proposals: /code.launchpad .net/~zorba- coders/ zorba/couchbase _module- bug-1188063/ +merge/ 182781
https:/
Progress dashboard at http:// jenkins. lambda. nu/view/ ValidationQueue