All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
as_list_operations.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2022 Aerospike, Inc.
3  *
4  * Portions may be licensed to Aerospike, Inc. under one or more contributor
5  * license agreements.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
8  * use this file except in compliance with the License. You may obtain a copy of
9  * the License at http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14  * License for the specific language governing permissions and limitations under
15  * the License.
16  */
17 #pragma once
18 
19 /**
20  * @defgroup list_operations List Operations
21  * @ingroup client_operations
22  *
23  * List bin operations. Create list operations used by client operate command.
24  *
25  * List operations support negative indexing. If the index is negative, the
26  * resolved index starts backwards from end of list. If an index is out of bounds,
27  * a parameter error will be returned. If a range is partially out of bounds, the
28  * valid part of the range will be returned. Index/Range examples:
29  * <ul>
30  * <li>Index 0: First item in list.</li>
31  * <li>Index 4: Fifth item in list.</li>
32  * <li>Index -1: Last item in list.</li>
33  * <li>Index -3: Third to last item in list.</li>
34  * <li>Index 1 Count 2: Second and third items in list.</li>
35  * <li>Index -3 Count 3: Last three items in list.</li>
36  * <li>Index -5 Count 4: Range between fifth to last item to second to last item inclusive.</li>
37  * </ul>
38  *
39  * Example 1:
40  *
41  * ~~~~~~~~~~{.c}
42  * // list bin = [7,9,5]
43  * // Append 11 to list bin.
44  * as_operations ops;
45  * as_operations_inita(&ops, 1);
46  *
47  * as_integer val;
48  * as_integer_init(&val, 11);
49  * as_operations_list_append(&ops, "bin", NULL, NULL, &val);
50  *
51  * as_record* rec = 0;
52  * as_error err;
53  * aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);
54  * // bin result = [7,9,5,11]
55  * as_operations_destroy(&ops);
56  * as_record_destroy(rec);
57  * ~~~~~~~~~~
58  *
59  * Nested CDT operations are supported by optional context (as_cdt_ctx). Example:
60  *
61  * ~~~~~~~~~~{.c}
62  * // bin = [[7,9,5],[1,2,3],[6,5,4,1]]
63  * // Append 11 to last list.
64  * as_cdt_ctx ctx;
65  * as_cdt_ctx_inita(&ctx, 1);
66  * as_cdt_ctx_add_list_index(&ctx, -1);
67  *
68  * as_operations ops;
69  * as_operations_inita(&ops, 1);
70  *
71  * as_integer val;
72  * as_integer_init(&val, 11);
73  * as_operations_list_append(&ops, "bin", &ctx, NULL, &val);
74  *
75  * as_record* rec = 0;
76  * as_error err;
77  * aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);
78  * // bin result = [[7,9,5],[1,2,3],[6,5,4,1,11]]
79  * as_operations_destroy(&ops);
80  * as_record_destroy(rec);
81  * ~~~~~~~~~~
82  */
83 
85 #include <aerospike/as_cdt_ctx.h>
86 #include <aerospike/as_cdt_order.h>
87 
88 #ifdef __cplusplus
89 extern "C" {
90 #endif
91 
92 /******************************************************************************
93  * TYPES
94  *****************************************************************************/
95 
96 /**
97  * List sort flags.
98  *
99  * @ingroup list_operations
100  */
101 typedef enum as_list_sort_flags_e {
102  /**
103  * Default. Preserve duplicate values when sorting list.
104  */
106 
107  /**
108  * Drop duplicate values when sorting list.
109  */
112 
113 /**
114  * List write bit flags.
115  *
116  * @ingroup list_operations
117  */
118 typedef enum as_list_write_flags_e {
119  /**
120  * Default. Allow duplicate values and insertions at any index.
121  */
123 
124  /**
125  * Only add unique values.
126  */
128 
129  /**
130  * Enforce list boundaries when inserting. Do not allow values to be inserted
131  * at index outside current list boundaries.
132  */
134 
135  /**
136  * Do not raise error if a list item fails due to write flag constraints.
137  */
139 
140  /**
141  * Allow other valid list items to be committed if a list item fails due to
142  * write flag constraints.
143  */
146 
147 /**
148  * List policy directives when creating a list and writing list items.
149  *
150  * @ingroup list_operations
151  */
152 typedef struct as_list_policy_s {
156 
157 /**
158  * List return type. Type of data to return when selecting or removing items from the list.
159  *
160  * @ingroup list_operations
161  */
162 typedef enum as_list_return_type_e {
163  /**
164  * Do not return a result.
165  */
167 
168  /**
169  * Return key index order.
170  */
172 
173  /**
174  * Return reverse key order.
175  */
177 
178  /**
179  * Return value order.
180  */
182 
183  /**
184  * Return reverse value order.
185  */
187 
188  /**
189  * Return count of items selected.
190  */
192 
193  /**
194  * Return value for single key read and value list for range read.
195  */
197 
198  /**
199  * Return true if count > 0.
200  */
202 
203  /**
204  * Invert meaning of list command and return values. For example:
205  *
206  * ~~~~~~~~~~{.c}
207  * as_operations ops;
208  * as_operations_inita(&ops, 1);
209  *
210  * as_operations_add_list_remove_by_index_range(&ops, BIN_NAME, index, count,
211  * AS_LIST_RETURN_VALUE | AS_LIST_RETURN_INVERTED);
212  *
213  * as_record* rec = NULL;
214  * as_status status = aerospike_key_operate(as, &err, NULL, &key, &ops, &rec);
215  * as_operations_destroy(&ops);
216  * ~~~~~~~~~~
217  *
218  * With AS_LIST_RETURN_INVERTED enabled, the items outside of the specified index range will be
219  * removed and returned.
220  */
223 
224 /**
225  * @private
226  * List operation codes.
227  */
228 typedef enum {
263 
264 /******************************************************************************
265  * FUNCTIONS
266  *****************************************************************************/
267 
268 /**
269  * Initialize list attributes to default unordered list with standard overwrite semantics.
270  *
271  * @ingroup list_operations
272  */
273 static inline void
275 {
276  policy->order = AS_LIST_UNORDERED;
277  policy->flags = AS_LIST_WRITE_DEFAULT;
278 }
279 
280 /**
281  * Set list attributes to specified list order and write flag semantics.
282  *
283  * @ingroup list_operations
284  */
285 static inline void
287 {
288  policy->order = order;
289  policy->flags = flags;
290 }
291 
292 /**
293  * Create list create operation.
294  * Server creates list at given context level. The context is allowed to be beyond list
295  * boundaries only if pad is set to true. In that case, nil list entries will be inserted to
296  * satisfy the context position.
297  *
298  * @ingroup list_operations
299  */
300 AS_EXTERN bool
302  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_order order, bool pad
303  );
304 
305 /**
306  * Create set list order operation.
307  * Server sets list order. Server returns null.
308  *
309  * @ingroup list_operations
310  */
311 AS_EXTERN bool
313  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_order order
314  );
315 
316 /**
317  * Create list sort operation.
318  * Server sorts list according to flags.
319  * Server does not return a result by default.
320  *
321  * @ingroup list_operations
322  */
323 AS_EXTERN bool
325  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_sort_flags flags
326  );
327 
328 /**
329  * Create list append operation with policy.
330  * Server appends value to list bin.
331  * Server returns list size.
332  *
333  * This function takes ownership and frees heap memory associated with val parameter.
334  * @ingroup list_operations
335  */
336 AS_EXTERN bool
338  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_policy* policy,
339  as_val* val
340  );
341 
342 /**
343  * Create list append items operation with policy.
344  * Server appends each input list item to end of list bin.
345  * Server returns list size.
346  *
347  * This function takes ownership and frees heap memory associated with list parameter.
348  * @ingroup list_operations
349  */
350 AS_EXTERN bool
352  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_policy* policy,
353  as_list* list
354  );
355 
356 /**
357  * Create default list insert operation with policy.
358  * Server inserts value to specified index of list bin.
359  * Server returns list size.
360  *
361  * This function takes ownership and frees heap memory associated with val parameter.
362  * @ingroup list_operations
363  */
364 AS_EXTERN bool
366  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_policy* policy,
367  int64_t index, as_val* val
368  );
369 
370 /**
371  * Create default list insert items operation with policy.
372  * Server inserts each input list item starting at specified index of list bin.
373  * Server returns list size.
374  *
375  * This function takes ownership and frees heap memory associated with list parameter.
376  * @ingroup list_operations
377  */
378 AS_EXTERN bool
380  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_policy* policy,
381  int64_t index, as_list* list
382  );
383 
384 /**
385  * Create list increment operation with policy.
386  * Server increments value at index by incr and returns final result.
387  * Valid only for numbers.
388  *
389  * This function takes ownership and frees heap memory associated with incr parameter.
390  * @ingroup list_operations
391  */
392 AS_EXTERN bool
394  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_policy* policy,
395  int64_t index, as_val* incr
396  );
397 
398 /**
399  * Create list set operation with policy.
400  * Server sets item value at specified index in list bin.
401  * Server does not return a result by default.
402  *
403  * This function takes ownership and frees heap memory associated with val parameter.
404  * @ingroup list_operations
405  */
406 AS_EXTERN bool
408  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_policy* policy,
409  int64_t index, as_val* val
410  );
411 
412 /**
413  * Create list pop operation.
414  * Server returns item at specified index and removes item from list bin.
415  *
416  * @ingroup list_operations
417  */
418 AS_EXTERN bool
419 as_operations_list_pop(as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index);
420 
421 /**
422  * Create list pop range operation.
423  * Server returns "count" items starting at specified index and removes items from list bin.
424  *
425  * @ingroup list_operations
426  */
427 AS_EXTERN bool
428 as_operations_list_pop_range(as_operations* ops, const char* name, as_cdt_ctx* ctx,
429  int64_t index, uint64_t count
430  );
431 
432 /**
433  * Create list pop range operation.
434  * Server returns items starting at specified index to the end of list and removes those items
435  * from list bin.
436  *
437  * @ingroup list_operations
438  */
439 AS_EXTERN bool
441  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index
442  );
443 
444 /**
445  * Create list remove operation.
446  * Server removes item at specified index from list bin.
447  * Server returns number of items removed.
448  *
449  * @ingroup list_operations
450  */
451 AS_EXTERN bool
453  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index
454  );
455 
456 /**
457  * Create list remove range operation.
458  * Server removes "count" items starting at specified index from list bin.
459  * Server returns number of items removed.
460  *
461  * @ingroup list_operations
462  */
463 AS_EXTERN bool
465  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index, uint64_t count
466  );
467 
468 /**
469  * Create list remove range operation.
470  * Server removes items starting at specified index to the end of list.
471  * Server returns number of items removed.
472  *
473  * @ingroup list_operations
474  */
475 AS_EXTERN bool
477  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index
478  );
479 
480 /**
481  * Create list remove operation.
482  * Server removes list items identified by value and returns removed data specified by return_type.
483  *
484  * This function takes ownership and frees heap memory associated with value parameter.
485  * @ingroup list_operations
486  */
487 AS_EXTERN bool
489  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_val* value,
490  as_list_return_type return_type
491  );
492 
493 /**
494  * Create list remove operation.
495  * Server removes list items identified by values and returns removed data specified by return_type.
496  *
497  * This function takes ownership and frees heap memory associated with values parameter.
498  * @ingroup list_operations
499  */
500 AS_EXTERN bool
502  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list* values,
503  as_list_return_type return_type
504  );
505 
506 /**
507  * Create list remove operation.
508  * Server removes list items identified by value range (begin inclusive, end exclusive).
509  * If begin is null, the range is less than end.
510  * If end is null, the range is greater than equal to begin.
511  *
512  * Server returns removed data specified by return_type.
513  *
514  * This function takes ownership and frees heap memory associated with begin/end parameters.
515  * @ingroup list_operations
516  */
517 AS_EXTERN bool
519  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_val* begin, as_val* end,
520  as_list_return_type return_type
521  );
522 
523 /**
524  * Create list remove by value relative to rank range operation.
525  * Server removes list items nearest to value and greater by relative rank.
526  * Server returns removed data specified by return_type.
527  *
528  * Examples for ordered list [0,4,5,9,11,15]:
529  * <ul>
530  * <li>(value,rank) = [removed items]</li>
531  * <li>(5,0) = [5,9,11,15]</li>
532  * <li>(5,1) = [9,11,15]</li>
533  * <li>(5,-1) = [4,5,9,11,15]</li>
534  * <li>(3,0) = [4,5,9,11,15]</li>
535  * <li>(3,3) = [11,15]</li>
536  * <li>(3,-3) = [0,4,5,9,11,15]</li>
537  * </ul>
538  *
539  * This function takes ownership and frees heap memory associated with value parameter.
540  * @ingroup list_operations
541  */
542 AS_EXTERN bool
544  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_val* value, int64_t rank,
545  as_list_return_type return_type
546  );
547 
548 /**
549  * Create list remove by value relative to rank range operation.
550  * Server removes list items nearest to value and greater by relative rank with a count limit.
551  * Server returns removed data specified by return_type.
552  *
553  * Examples for ordered list [0,4,5,9,11,15]:
554  * <ul>
555  * <li>(value,rank,count) = [removed items]</li>
556  * <li>(5,0,2) = [5,9]</li>
557  * <li>(5,1,1) = [9]</li>
558  * <li>(5,-1,2) = [4,5]</li>
559  * <li>(3,0,1) = [4]</li>
560  * <li>(3,3,7) = [11,15]</li>
561  * <li>(3,-3,2) = []</li>
562  * </ul>
563  *
564  * This function takes ownership and frees heap memory associated with value parameter.
565  * @ingroup list_operations
566  */
567 AS_EXTERN bool
569  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_val* value, int64_t rank,
570  uint64_t count, as_list_return_type return_type
571  );
572 
573 /**
574  * Create list remove operation.
575  * Server removes list item identified by index and returns removed data specified by return_type.
576  *
577  * @ingroup list_operations
578  */
579 AS_EXTERN bool
581  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index,
582  as_list_return_type return_type
583  );
584 
585 /**
586  * Create list remove operation.
587  * Server removes list items starting at specified index to the end of list and returns removed
588  * data specified by return_type.
589  *
590  * @ingroup list_operations
591  */
592 AS_EXTERN bool
594  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index,
595  as_list_return_type return_type
596  );
597 
598 /**
599  * Create list remove operation.
600  * Server removes `count` list items starting at specified index and returns removed data specified
601  * by return_type.
602  *
603  * @ingroup list_operations
604  */
605 AS_EXTERN bool
607  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index, uint64_t count,
608  as_list_return_type return_type
609  );
610 
611 /**
612  * Create list remove operation.
613  * Server removes list item identified by rank and returns removed data specified by return_type.
614  *
615  * @ingroup list_operations
616  */
617 AS_EXTERN bool
619  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t rank,
620  as_list_return_type return_type
621  );
622 
623 /**
624  * Create list remove operation.
625  * Server removes list items starting at specified rank to the last ranked item and returns removed
626  * data specified by return_type.
627  *
628  * @ingroup list_operations
629  */
630 AS_EXTERN bool
632  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t rank,
633  as_list_return_type return_type
634  );
635 
636 /**
637  * Create list remove operation.
638  * Server removes `count` list items starting at specified rank and returns removed data specified
639  * by return_type.
640  *
641  * @ingroup list_operations
642  */
643 AS_EXTERN bool
645  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t rank, uint64_t count,
646  as_list_return_type return_type
647  );
648 
649 /**
650  * Create list trim operation.
651  * Server removes items in list bin that do not fall into range specified by index
652  * and count range. If the range is out of bounds, then all items will be removed.
653  * Server returns list size after trim.
654  *
655  * @ingroup list_operations
656  */
657 AS_EXTERN bool
659  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index, uint64_t count
660  );
661 
662 /**
663  * Create list clear operation.
664  * Server removes all items in list bin.
665  * Server does not return a result by default.
666  *
667  * @ingroup list_operations
668  */
669 AS_EXTERN bool
670 as_operations_list_clear(as_operations* ops, const char* name, as_cdt_ctx* ctx);
671 
672 //-----------------------------------------------------------------------------
673 // Read operations
674 
675 /**
676  * Create list size operation.
677  * Server returns size of list.
678  *
679  * @ingroup list_operations
680  */
681 AS_EXTERN bool
682 as_operations_list_size(as_operations* ops, const char* name, as_cdt_ctx* ctx);
683 
684 /**
685  * Create list get operation.
686  * Server returns item at specified index in list bin.
687  *
688  * @ingroup list_operations
689  */
690 AS_EXTERN bool
691 as_operations_list_get(as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index);
692 
693 /**
694  * Create list get range operation.
695  * Server returns "count" items starting at specified index in list bin.
696  *
697  * @ingroup list_operations
698  */
699 AS_EXTERN bool
701  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index, uint64_t count
702  );
703 
704 /**
705  * Create list get range operation.
706  * Server returns items starting at index to the end of list.
707  *
708  * @ingroup list_operations
709  */
710 AS_EXTERN bool
712  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index
713  );
714 
715 /**
716  * Create list get by value operation.
717  * Server selects list items identified by value and returns selected data specified by return_type.
718  *
719  * This function takes ownership and frees heap memory associated with value parameter.
720  * @ingroup list_operations
721  */
722 AS_EXTERN bool
724  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_val* value,
725  as_list_return_type return_type
726  );
727 
728 /**
729  * Create list get by value range operation.
730  * Server selects list items identified by value range (begin inclusive, end exclusive).
731  * If begin is null, the range is less than end.
732  * If end is null, the range is greater than equal to begin.
733  *
734  * Server returns selected data specified by return_type.
735  *
736  * This function takes ownership and frees heap memory associated with begin/end parameters.
737  * @ingroup list_operations
738  */
739 AS_EXTERN bool
741  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_val* begin, as_val* end,
742  as_list_return_type return_type
743  );
744 
745 /**
746  * Create list get by value list operation.
747  * Server selects list items identified by values and returns selected data specified by return_type.
748  *
749  * This function takes ownership and frees heap memory associated with values parameter.
750  * @ingroup list_operations
751  */
752 AS_EXTERN bool
754  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list* values,
755  as_list_return_type return_type
756  );
757 
758 /**
759  * Create list get by value relative to rank range operation.
760  * Server selects list items nearest to value and greater by relative rank.
761  * Server returns selected data specified by return_type.
762  *
763  * Examples for ordered list [0,4,5,9,11,15]:
764  * <ul>
765  * <li>(value,rank) = [selected items]</li>
766  * <li>(5,0) = [5,9,11,15]</li>
767  * <li>(5,1) = [9,11,15]</li>
768  * <li>(5,-1) = [4,5,9,11,15]</li>
769  * <li>(3,0) = [4,5,9,11,15]</li>
770  * <li>(3,3) = [11,15]</li>
771  * <li>(3,-3) = [0,4,5,9,11,15]</li>
772  * </ul>
773  *
774  * This function takes ownership and frees heap memory associated with value parameter.
775  * @ingroup list_operations
776  */
777 AS_EXTERN bool
779  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_val* value, int64_t rank,
780  as_list_return_type return_type
781  );
782 
783 /**
784  * Create list get by value relative to rank range operation.
785  * Server selects list items nearest to value and greater by relative rank with a count limit.
786  * Server returns selected data specified by return_type.
787  *
788  * Examples for ordered list [0,4,5,9,11,15]:
789  * <ul>
790  * <li>(value,rank,count) = [selected items]</li>
791  * <li>(5,0,2) = [5,9]</li>
792  * <li>(5,1,1) = [9]</li>
793  * <li>(5,-1,2) = [4,5]</li>
794  * <li>(3,0,1) = [4]</li>
795  * <li>(3,3,7) = [11,15]</li>
796  * <li>(3,-3,2) = []</li>
797  * </ul>
798  *
799  * This function takes ownership and frees heap memory associated with value parameter.
800  * @ingroup list_operations
801  */
802 AS_EXTERN bool
804  as_operations* ops, const char* name, as_cdt_ctx* ctx, as_val* value, int64_t rank,
805  uint64_t count, as_list_return_type return_type
806  );
807 
808 /**
809  * Create list get by index operation.
810  * Server selects list item identified by index and returns selected data specified by return_type.
811  *
812  * @ingroup list_operations
813  */
814 AS_EXTERN bool
816  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index,
817  as_list_return_type return_type
818  );
819 
820 /**
821  * Create list get by index range operation.
822  * Server selects list items starting at specified index to the end of list and returns selected
823  * data specified by return_type.
824  *
825  * @ingroup list_operations
826  */
827 AS_EXTERN bool
829  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index,
830  as_list_return_type return_type
831  );
832 
833 /**
834  * Create list get by index range operation.
835  * Server selects `count` list items starting at specified index and returns selected data specified
836  * by return_type.
837  *
838  * @ingroup list_operations
839  */
840 AS_EXTERN bool
842  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index, uint64_t count,
843  as_list_return_type return_type
844  );
845 
846 /**
847  * Create list get by rank operation.
848  * Server selects list item identified by rank and returns selected data specified by return_type.
849  *
850  * @ingroup list_operations
851  */
852 AS_EXTERN bool
854  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t rank,
855  as_list_return_type return_type
856  );
857 
858 /**
859  * Create list get by rank range operation.
860  * Server selects list items starting at specified rank to the last ranked item and returns selected
861  * data specified by return_type.
862  *
863  * @ingroup list_operations
864  */
865 AS_EXTERN bool
867  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t rank,
868  as_list_return_type return_type
869  );
870 
871 /**
872  * Create list get by rank range operation.
873  * Server selects `count` list items starting at specified rank and returns selected data specified by return_type.
874  *
875  * @ingroup list_operations
876  */
877 AS_EXTERN bool
879  as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t rank, uint64_t count,
880  as_list_return_type return_type
881  );
882 
883 /******************************************************************************
884  * LEGACY FUNCTIONS
885  *****************************************************************************/
886 
887 /**
888  * Create set list order operation.
889  * Server sets list order. Server returns null.
890  *
891  * @ingroup list_operations
892  */
893 static inline bool
895 {
896  return as_operations_list_set_order(ops, name, NULL, order);
897 }
898 
899 /**
900  * Create list sort operation.
901  * Server sorts list according to flags.
902  * Server does not return a result by default.
903  *
904  * @return true on success. Otherwise an error occurred.
905  * @ingroup list_operations
906  */
907 static inline bool
909 {
910  return as_operations_list_sort(ops, name, NULL, flags);
911 }
912 
913 /**
914  * Create list append operation.
915  * Server appends value to list bin.
916  * Server returns list size.
917  *
918  * @ingroup list_operations
919  */
920 static inline bool
922 {
923  return as_operations_list_append(ops, name, NULL, NULL, val);
924 }
925 
926 /**
927  * Create list append operation with policy.
928  * Server appends value to list bin.
929  * Server returns list size.
930  *
931  * @ingroup list_operations
932  */
933 static inline bool
935  as_operations* ops, const char* name, as_list_policy* policy, as_val* val
936  )
937 {
938  return as_operations_list_append(ops, name, NULL, policy, val);
939 }
940 
941 /**
942  * Create list append operation.
943  * Server appends integer to list bin.
944  * Server returns list size.
945  *
946  * @ingroup list_operations
947  */
948 static inline bool
949 as_operations_add_list_append_int64(as_operations* ops, const char* name, int64_t value)
950 {
951  as_integer v;
952  as_integer_init(&v, value);
953  return as_operations_list_append(ops, name, NULL, NULL, (as_val*)&v);
954 }
955 
956 /**
957  * Create list append operation.
958  * Server appends double to list bin.
959  * Server returns list size.
960  *
961  * @ingroup list_operations
962  */
963 static inline bool
964 as_operations_add_list_append_double(as_operations* ops, const char* name, double value)
965 {
966  as_double v;
967  as_double_init(&v, value);
968  return as_operations_list_append(ops, name, NULL, NULL, (as_val*)&v);
969 }
970 
971 /**
972  * Create list append operation.
973  * Server appends string to list bin.
974  * Server returns list size.
975  *
976  * If free is true, the value will be freed when the operations are destroyed.
977  *
978  * @ingroup list_operations
979  */
980 static inline bool
982  as_operations* ops, const char* name, const char* value, bool free
983  )
984 {
985  as_string v;
986  as_string_init(&v, (char*)value, free);
987  return as_operations_list_append(ops, name, NULL, NULL, (as_val*)&v);
988 }
989 
990 /**
991  * Create list append operation.
992  * Server appends string to list bin.
993  * Server returns list size.
994  *
995  * The value will not be freed when the operations are destroyed.
996  *
997  * @ingroup list_operations
998  */
999 static inline bool
1000 as_operations_add_list_append_str(as_operations* ops, const char* name, const char* value)
1001 {
1002  return as_operations_add_list_append_strp(ops, name, value, false);
1003 }
1004 
1005 /**
1006  * Create list append operation.
1007  * Server appends blob (byte array) to list bin.
1008  * Server returns list size.
1009  *
1010  * If free is true, the value will be freed when the operations are destroyed.
1011  *
1012  * @ingroup list_operations
1013  */
1014 static inline bool
1016  as_operations* ops, const char* name, const uint8_t* value, uint32_t size, bool free
1017  )
1018 {
1019  as_bytes v;
1020  as_bytes_init_wrap(&v, (uint8_t*)value, size, free);
1021  return as_operations_list_append(ops, name, NULL, NULL, (as_val*)&v);
1022 }
1023 
1024 /**
1025  * Create list append operation.
1026  * Server appends blob (byte array) to list bin.
1027  * Server returns list size.
1028  *
1029  * The value will not be freed when the operations are destroyed.
1030  *
1031  * @ingroup list_operations
1032  */
1033 static inline bool
1035  as_operations* ops, const char* name, const uint8_t* value, uint32_t size
1036  )
1037 {
1038  return as_operations_add_list_append_rawp(ops, name, value, size, false);
1039 }
1040 
1041 /**
1042  * Create list append items operation.
1043  * Server appends each input list item to end of list bin.
1044  * Server returns list size.
1045  *
1046  * @ingroup list_operations
1047  */
1048 static inline bool
1050 {
1051  return as_operations_list_append_items(ops, name, NULL, NULL, list);
1052 }
1053 
1054 /**
1055  * Create list append items operation with policy.
1056  * Server appends each input list item to end of list bin.
1057  * Server returns list size.
1058  *
1059  * @ingroup list_operations
1060  */
1061 static inline bool
1063  as_operations* ops, const char* name, as_list_policy* policy, as_list* list
1064  )
1065 {
1066  return as_operations_list_append_items(ops, name, NULL, policy, list);
1067 }
1068 
1069 /**
1070  * Create default list insert operation.
1071  * Server inserts value to specified index of list bin.
1072  * Server returns list size.
1073  *
1074  * @ingroup list_operations
1075  */
1076 static inline bool
1078  as_operations* ops, const char* name, int64_t index, as_val* val
1079  )
1080 {
1081  return as_operations_list_insert(ops, name, NULL, NULL, index, val);
1082 }
1083 
1084 /**
1085  * Create default list insert operation with policy.
1086  * Server inserts value to specified index of list bin.
1087  * Server returns list size.
1088  *
1089  * @ingroup list_operations
1090  */
1091 static inline bool
1093  as_operations* ops, const char* name, as_list_policy* policy, int64_t index, as_val* val
1094  )
1095 {
1096  return as_operations_list_insert(ops, name, NULL, policy, index, val);
1097 }
1098 
1099 /**
1100  * Create default list insert operation with policy.
1101  * Server inserts integer to specified index of list bin.
1102  * Server returns list size.
1103  *
1104  * @ingroup list_operations
1105  */
1106 static inline bool
1108  as_operations* ops, const char* name, int64_t index, int64_t value
1109  )
1110 {
1111  as_integer v;
1112  as_integer_init(&v, value);
1113  return as_operations_list_insert(ops, name, NULL, NULL, index, (as_val*)&v);
1114 }
1115 
1116 /**
1117  * Create default list insert operation with policy.
1118  * Server inserts double to specified index of list bin.
1119  * Server returns list size.
1120  *
1121  * @ingroup list_operations
1122  */
1123 static inline bool
1125  as_operations* ops, const char* name, int64_t index, double value
1126  )
1127 {
1128  as_double v;
1129  as_double_init(&v, value);
1130  return as_operations_list_insert(ops, name, NULL, NULL, index, (as_val*)&v);
1131 }
1132 
1133 /**
1134  * Create default list insert operation with policy.
1135  * Server inserts string to specified index of list bin.
1136  * Server returns list size.
1137  *
1138  * If free is true, the value will be freed when the operations are destroyed.
1139  *
1140  * @ingroup list_operations
1141  */
1142 static inline bool
1144  as_operations* ops, const char* name, int64_t index, const char* value, bool free
1145  )
1146 {
1147  as_string v;
1148  as_string_init(&v, (char *)value, free);
1149  return as_operations_list_insert(ops, name, NULL, NULL, index, (as_val*)&v);
1150 }
1151 
1152 /**
1153  * Create default list insert operation with policy.
1154  * Server inserts string to specified index of list bin.
1155  * Server returns list size.
1156  *
1157  * The value will not be freed when the operations are destroyed.
1158  *
1159  * @ingroup list_operations
1160  */
1161 static inline bool
1163  as_operations* ops, const char* name, int64_t index, const char* value
1164  )
1165 {
1166  return as_operations_add_list_insert_strp(ops, name, index, value, false);
1167 }
1168 
1169 /**
1170  * Create default list insert operation with policy.
1171  * Server inserts blob (byte array) to specified index of list bin.
1172  * Server returns list size.
1173  *
1174  * If free is true, the value will be freed when the operations are destroyed.
1175  *
1176  * @ingroup list_operations
1177  */
1178 static inline bool
1180  as_operations* ops, const char* name, int64_t index, const uint8_t* value, uint32_t size,
1181  bool free
1182  )
1183 {
1184  as_bytes v;
1185  as_bytes_init_wrap(&v, (uint8_t *)value, size, free);
1186  return as_operations_list_insert(ops, name, NULL, NULL, index, (as_val*)&v);
1187 }
1188 
1189 /**
1190  * Create default list insert operation with policy.
1191  * Server inserts blob (byte array) to specified index of list bin.
1192  * Server returns list size.
1193  *
1194  * The value will not be freed when the operations are destroyed.
1195  *
1196  * @ingroup list_operations
1197  */
1198 static inline bool
1200  as_operations* ops, const char* name, int64_t index, const uint8_t* value, uint32_t size
1201  )
1202 {
1203  return as_operations_add_list_insert_rawp(ops, name, index, value, size, false);
1204 }
1205 
1206 /**
1207  * Create default list insert items operation.
1208  * Server inserts each input list item starting at specified index of list bin.
1209  * Server returns list size.
1210  *
1211  * @ingroup list_operations
1212  */
1213 static inline bool
1215  as_operations* ops, const char* name, int64_t index, as_list* list
1216  )
1217 {
1218  return as_operations_list_insert_items(ops, name, NULL, NULL, index, list);
1219 }
1220 
1221 /**
1222  * Create default list insert items operation with policy.
1223  * Server inserts each input list item starting at specified index of list bin.
1224  * Server returns list size.
1225  *
1226  * @ingroup list_operations
1227  */
1228 static inline bool
1230  as_operations* ops, const char* name, as_list_policy* policy, int64_t index,
1231  as_list* list
1232  )
1233 {
1234  return as_operations_list_insert_items(ops, name, NULL, policy, index, list);
1235 }
1236 
1237 /**
1238  * Create list increment operation.
1239  * Server increments value at index by incr and returns final result.
1240  * Valid only for numbers.
1241  *
1242  * @ingroup list_operations
1243  */
1244 static inline bool
1246  as_operations* ops, const char* name, int64_t index, as_val* incr
1247  )
1248 {
1249  return as_operations_list_increment(ops, name, NULL, NULL, index, incr);
1250 }
1251 
1252 /**
1253  * Create list increment operation with policy.
1254  * Server increments value at index by incr and returns final result.
1255  * Valid only for numbers.
1256  *
1257  * @ingroup list_operations
1258  */
1259 static inline bool
1261  as_operations* ops, const char* name, as_list_policy* policy, int64_t index, as_val* incr
1262  )
1263 {
1264  return as_operations_list_increment(ops, name, NULL, policy, index, incr);
1265 }
1266 
1267 /**
1268  * Create list set operation.
1269  * Server sets item value at specified index in list bin.
1270  * Server does not return a result by default.
1271  *
1272  * @ingroup list_operations
1273  */
1274 static inline bool
1275 as_operations_add_list_set(as_operations* ops, const char* name, int64_t index, as_val* val)
1276 {
1277  return as_operations_list_set(ops, name, NULL, NULL, index, val);
1278 }
1279 
1280 /**
1281  * Create list set operation with policy.
1282  * Server sets item value at specified index in list bin.
1283  * Server does not return a result by default.
1284  *
1285  * @ingroup list_operations
1286  */
1287 static inline bool
1289  as_operations* ops, const char* name, as_list_policy* policy, int64_t index, as_val* val
1290  )
1291 {
1292  return as_operations_list_set(ops, name, NULL, policy, index, val);
1293 }
1294 
1295 /**
1296  * Create list set operation with policy.
1297  * Server sets integer at specified index in list bin.
1298  * Server does not return a result by default.
1299  *
1300  * @ingroup list_operations
1301  */
1302 static inline bool
1304  as_operations* ops, const char* name, int64_t index, int64_t value
1305  )
1306 {
1307  as_integer v;
1308  as_integer_init(&v, value);
1309  return as_operations_list_set(ops, name, NULL, NULL, index, (as_val*)&v);
1310 }
1311 
1312 /**
1313  * Create list set operation with policy.
1314  * Server sets double at specified index in list bin.
1315  * Server does not return a result by default.
1316  *
1317  * @ingroup list_operations
1318  */
1319 static inline bool
1321  as_operations* ops, const char* name, int64_t index, double value
1322  )
1323 {
1324  as_double v;
1325  as_double_init(&v, value);
1326  return as_operations_list_set(ops, name, NULL, NULL, index, (as_val*)&v);
1327 }
1328 
1329 /**
1330  * Create list set operation with policy.
1331  * Server sets string at specified index in list bin.
1332  * Server does not return a result by default.
1333  *
1334  * If free is true, the value will be freed when the operations are destroyed.
1335  *
1336  * @ingroup list_operations
1337  */
1338 static inline bool
1340  as_operations* ops, const char* name, int64_t index, const char* value, bool free
1341  )
1342 {
1343  as_string v;
1344  as_string_init(&v, (char *)value, free);
1345  return as_operations_list_set(ops, name, NULL, NULL, index, (as_val*)&v);
1346 }
1347 
1348 /**
1349  * Create list set operation with policy.
1350  * Server sets string at specified index in list bin.
1351  * Server does not return a result by default.
1352  *
1353  * The value will not be freed when the operations are destroyed.
1354  *
1355  * @ingroup list_operations
1356  */
1357 static inline bool
1359  as_operations* ops, const char* name, int64_t index, const char* value
1360  )
1361 {
1362  return as_operations_add_list_set_strp(ops, name, index, value, false);
1363 }
1364 
1365 /**
1366  * Create list set operation with policy.
1367  * Server sets blob (byte array) at specified index in list bin.
1368  * Server does not return a result by default.
1369  *
1370  * If free is true, the value will be freed when the operations are destroyed.
1371  *
1372  * @ingroup list_operations
1373  */
1374 static inline bool
1376  as_operations* ops, const char* name, int64_t index, const uint8_t* value, uint32_t size,
1377  bool free
1378  )
1379 {
1380  as_bytes v;
1381  as_bytes_init_wrap(&v, (uint8_t *)value, size, free);
1382  return as_operations_list_set(ops, name, NULL, NULL, index, (as_val*)&v);
1383 }
1384 
1385 /**
1386  * Create list set operation with policy.
1387  * Server sets blob (byte array) at specified index in list bin.
1388  * Server does not return a result by default.
1389  *
1390  * The value will not be freed when the operations are destroyed.
1391  *
1392  * @ingroup list_operations
1393  */
1394 static inline bool
1396  as_operations* ops, const char* name, int64_t index, const uint8_t* value, uint32_t size
1397  )
1398 {
1399  return as_operations_add_list_set_rawp(ops, name, index, value, size, false);
1400 }
1401 
1402 /**
1403  * Create list pop operation.
1404  * Server returns item at specified index and removes item from list bin.
1405  *
1406  * @ingroup list_operations
1407  */
1408 static inline bool
1409 as_operations_add_list_pop(as_operations* ops, const char* name, int64_t index)
1410 {
1411  return as_operations_list_pop(ops, name, NULL, index);
1412 }
1413 
1414 /**
1415  * Create list pop range operation.
1416  * Server returns "count" items starting at specified index and removes items from list bin.
1417  *
1418  * @ingroup list_operations
1419  */
1420 static inline bool
1422  as_operations* ops, const char* name, int64_t index, uint64_t count
1423  )
1424 {
1425  return as_operations_list_pop_range(ops, name, NULL, index, count);
1426 }
1427 
1428 /**
1429  * Create list pop range operation.
1430  * Server returns items starting at specified index to the end of list and removes those items
1431  * from list bin.
1432  *
1433  * @ingroup list_operations
1434  */
1435 static inline bool
1436 as_operations_add_list_pop_range_from(as_operations* ops, const char* name, int64_t index)
1437 {
1438  return as_operations_list_pop_range_from(ops, name, NULL, index);
1439 }
1440 
1441 /**
1442  * Create list remove operation.
1443  * Server removes item at specified index from list bin.
1444  * Server returns number of items removed.
1445  *
1446  * @ingroup list_operations
1447  */
1448 static inline bool
1449 as_operations_add_list_remove(as_operations* ops, const char* name, int64_t index)
1450 {
1451  return as_operations_list_remove(ops, name, NULL, index);
1452 }
1453 
1454 /**
1455  * Create list remove range operation.
1456  * Server removes "count" items starting at specified index from list bin.
1457  * Server returns number of items removed.
1458  *
1459  * @ingroup list_operations
1460  */
1461 static inline bool
1463  as_operations* ops, const char* name, int64_t index, uint64_t count
1464  )
1465 {
1466  return as_operations_list_remove_range(ops, name, NULL, index, count);
1467 }
1468 
1469 /**
1470  * Create list remove range operation.
1471  * Server removes items starting at specified index to the end of list.
1472  * Server returns number of items removed.
1473  *
1474  * @ingroup list_operations
1475  */
1476 static inline bool
1477 as_operations_add_list_remove_range_from(as_operations* ops, const char* name, int64_t index)
1478 {
1479  return as_operations_list_remove_range_from(ops, name, NULL, index);
1480 }
1481 
1482 /**
1483  * Create list remove operation.
1484  * Server removes list items identified by value and returns removed data specified by return_type.
1485  *
1486  * @ingroup list_operations
1487  */
1488 static inline bool
1490  as_operations* ops, const char* name, as_val* value, as_list_return_type return_type
1491  )
1492 {
1493  return as_operations_list_remove_by_value(ops, name, NULL, value, return_type);
1494 }
1495 
1496 /**
1497  * Create list remove operation.
1498  * Server removes list items identified by values and returns removed data specified by return_type.
1499  *
1500  * @ingroup list_operations
1501  */
1502 static inline bool
1504  as_operations* ops, const char* name, as_list* values, as_list_return_type return_type
1505  )
1506 {
1507  return as_operations_list_remove_by_value_list(ops, name, NULL, values, return_type);
1508 }
1509 
1510 /**
1511  * Create list remove operation.
1512  * Server removes list items identified by value range (begin inclusive, end exclusive).
1513  * If begin is null, the range is less than end.
1514  * If end is null, the range is greater than equal to begin.
1515  *
1516  * Server returns removed data specified by return_type.
1517  *
1518  * @ingroup list_operations
1519  */
1520 static inline bool
1522  as_operations* ops, const char* name, as_val* begin, as_val* end,
1523  as_list_return_type return_type
1524  )
1525 {
1526  return as_operations_list_remove_by_value_range(ops, name, NULL, begin, end, return_type);
1527 }
1528 
1529 /**
1530  * Create list remove by value relative to rank range operation.
1531  * Server removes list items nearest to value and greater by relative rank.
1532  * Server returns removed data specified by return_type.
1533  *
1534  * Examples for ordered list [0,4,5,9,11,15]:
1535  * <ul>
1536  * <li>(value,rank) = [removed items]</li>
1537  * <li>(5,0) = [5,9,11,15]</li>
1538  * <li>(5,1) = [9,11,15]</li>
1539  * <li>(5,-1) = [4,5,9,11,15]</li>
1540  * <li>(3,0) = [4,5,9,11,15]</li>
1541  * <li>(3,3) = [11,15]</li>
1542  * <li>(3,-3) = [0,4,5,9,11,15]</li>
1543  * </ul>
1544  *
1545  * @ingroup list_operations
1546  */
1547 static inline bool
1549  as_operations* ops, const char* name, as_val* value, int64_t rank,
1550  as_list_return_type return_type
1551  )
1552 {
1553  return as_operations_list_remove_by_value_rel_rank_range_to_end(ops, name, NULL, value, rank,
1554  return_type);
1555 }
1556 
1557 /**
1558  * Create list remove by value relative to rank range operation.
1559  * Server removes list items nearest to value and greater by relative rank with a count limit.
1560  * Server returns removed data specified by return_type.
1561  *
1562  * Examples for ordered list [0,4,5,9,11,15]:
1563  * <ul>
1564  * <li>(value,rank,count) = [removed items]</li>
1565  * <li>(5,0,2) = [5,9]</li>
1566  * <li>(5,1,1) = [9]</li>
1567  * <li>(5,-1,2) = [4,5]</li>
1568  * <li>(3,0,1) = [4]</li>
1569  * <li>(3,3,7) = [11,15]</li>
1570  * <li>(3,-3,2) = []</li>
1571  * </ul>
1572  *
1573  * @ingroup list_operations
1574  */
1575 static inline bool
1577  as_operations* ops, const char* name, as_val* value, int64_t rank, uint64_t count,
1578  as_list_return_type return_type
1579  )
1580 {
1581  return as_operations_list_remove_by_value_rel_rank_range(ops, name, NULL, value, rank, count,
1582  return_type);
1583 }
1584 
1585 /**
1586  * Create list remove operation.
1587  * Server removes list item identified by index and returns removed data specified by return_type.
1588  *
1589  * @ingroup list_operations
1590  */
1591 static inline bool
1593  as_operations* ops, const char* name, int64_t index, as_list_return_type return_type
1594  )
1595 {
1596  return as_operations_list_remove_by_index(ops, name, NULL, index, return_type);
1597 }
1598 
1599 /**
1600  * Create list remove operation.
1601  * Server removes list items starting at specified index to the end of list and returns removed
1602  * data specified by return_type.
1603  *
1604  * @ingroup list_operations
1605  */
1606 static inline bool
1608  as_operations* ops, const char* name, int64_t index, as_list_return_type return_type
1609  )
1610 {
1611  return as_operations_list_remove_by_index_range_to_end(ops, name, NULL, index, return_type);
1612 }
1613 
1614 /**
1615  * Create list remove operation.
1616  * Server removes `count` list items starting at specified index and returns removed data specified by return_type.
1617  *
1618  * @ingroup list_operations
1619  */
1620 static inline bool
1622  as_operations* ops, const char* name, int64_t index, uint64_t count,
1623  as_list_return_type return_type
1624  )
1625 {
1626  return as_operations_list_remove_by_index_range(ops, name, NULL, index, count, return_type);
1627 }
1628 
1629 /**
1630  * Create list remove operation.
1631  * Server removes list item identified by rank and returns removed data specified by return_type.
1632  *
1633  * @ingroup list_operations
1634  */
1635 static inline bool
1637  as_operations* ops, const char* name, int64_t rank, as_list_return_type return_type
1638  )
1639 {
1640  return as_operations_list_remove_by_rank(ops, name, NULL, rank, return_type);
1641 }
1642 
1643 /**
1644  * Create list remove operation.
1645  * Server removes list items starting at specified rank to the last ranked item and returns removed
1646  * data specified by return_type.
1647  *
1648  * @ingroup list_operations
1649  */
1650 static inline bool
1652  as_operations* ops, const char* name, int64_t rank, as_list_return_type return_type
1653  )
1654 {
1655  return as_operations_list_remove_by_rank_range_to_end(ops, name, NULL, rank, return_type);
1656 }
1657 
1658 /**
1659  * Create list remove operation.
1660  * Server removes `count` list items starting at specified rank and returns removed data specified by return_type.
1661  *
1662  * @ingroup list_operations
1663  */
1664 static inline bool
1666  as_operations* ops, const char* name, int64_t rank, uint64_t count,
1667  as_list_return_type return_type
1668  )
1669 {
1670  return as_operations_list_remove_by_rank_range(ops, name, NULL, rank, count, return_type);
1671 }
1672 
1673 /**
1674  * Create list trim operation.
1675  * Server removes items in list bin that do not fall into range specified by index
1676  * and count range. If the range is out of bounds, then all items will be removed.
1677  * Server returns list size after trim.
1678  *
1679  * @ingroup list_operations
1680  */
1681 static inline bool
1683  as_operations* ops, const char* name, int64_t index, uint64_t count
1684  )
1685 {
1686  return as_operations_list_trim(ops, name, NULL, index, count);
1687 }
1688 
1689 /**
1690  * Create list clear operation.
1691  * Server removes all items in list bin.
1692  * Server does not return a result by default.
1693  *
1694  * @ingroup list_operations
1695  */
1696 static inline bool
1698 {
1699  return as_operations_list_clear(ops, name, NULL);
1700 }
1701 
1702 //-----------------------------------------------------------------------------
1703 // Read operations
1704 
1705 /**
1706  * Create list size operation.
1707  * Server returns size of list.
1708  *
1709  * @ingroup list_operations
1710  */
1711 static inline bool
1713 {
1714  return as_operations_list_size(ops, name, NULL);
1715 }
1716 
1717 /**
1718  * Create list get operation.
1719  * Server returns item at specified index in list bin.
1720  *
1721  * @ingroup list_operations
1722  */
1723 static inline bool
1724 as_operations_add_list_get(as_operations* ops, const char* name, int64_t index)
1725 {
1726  return as_operations_list_get(ops, name, NULL, index);
1727 }
1728 
1729 /**
1730  * Create list get range operation.
1731  * Server returns "count" items starting at specified index in list bin.
1732  *
1733  * @ingroup list_operations
1734  */
1735 static inline bool
1737  as_operations* ops, const char* name, int64_t index, uint64_t count
1738  )
1739 {
1740  return as_operations_list_get_range(ops, name, NULL, index, count);
1741 }
1742 
1743 /**
1744  * Create list get range operation.
1745  * Server returns items starting at index to the end of list.
1746  *
1747  * @ingroup list_operations
1748  */
1749 static inline bool
1750 as_operations_add_list_get_range_from(as_operations* ops, const char* name, int64_t index)
1751 {
1752  return as_operations_list_get_range_from(ops, name, NULL, index);
1753 }
1754 
1755 /**
1756  * Create list get by value operation.
1757  * Server selects list items identified by value and returns selected data specified by return_type.
1758  *
1759  * @ingroup list_operations
1760  */
1761 static inline bool
1763  as_operations* ops, const char* name, as_val* value, as_list_return_type return_type
1764  )
1765 {
1766  return as_operations_list_get_by_value(ops, name, NULL, value, return_type);
1767 }
1768 
1769 /**
1770  * Create list get by value range operation.
1771  * Server selects list items identified by value range (begin inclusive, end exclusive).
1772  * If begin is null, the range is less than end.
1773  * If end is null, the range is greater than equal to begin.
1774  *
1775  * Server returns selected data specified by return_type.
1776  *
1777  * @ingroup list_operations
1778  */
1779 static inline bool
1781  as_operations* ops, const char* name, as_val* begin, as_val* end,
1782  as_list_return_type return_type
1783  )
1784 {
1785  return as_operations_list_get_by_value_range(ops, name, NULL, begin, end, return_type);
1786 }
1787 
1788 /**
1789  * Create list get by value list operation.
1790  * Server selects list items identified by values and returns selected data specified by return_type.
1791  *
1792  * @ingroup list_operations
1793  */
1794 static inline bool
1796  as_operations* ops, const char* name, as_list* values, as_list_return_type return_type
1797  )
1798 {
1799  return as_operations_list_get_by_value_list(ops, name, NULL, values, return_type);
1800 }
1801 
1802 /**
1803  * Create list get by value relative to rank range operation.
1804  * Server selects list items nearest to value and greater by relative rank.
1805  * Server returns selected data specified by return_type.
1806  *
1807  * Examples for ordered list [0,4,5,9,11,15]:
1808  * <ul>
1809  * <li>(value,rank) = [selected items]</li>
1810  * <li>(5,0) = [5,9,11,15]</li>
1811  * <li>(5,1) = [9,11,15]</li>
1812  * <li>(5,-1) = [4,5,9,11,15]</li>
1813  * <li>(3,0) = [4,5,9,11,15]</li>
1814  * <li>(3,3) = [11,15]</li>
1815  * <li>(3,-3) = [0,4,5,9,11,15]</li>
1816  * </ul>
1817  *
1818  * @ingroup list_operations
1819  */
1820 static inline bool
1822  as_operations* ops, const char* name, as_val* value, int64_t rank,
1823  as_list_return_type return_type
1824  )
1825 {
1826  return as_operations_list_get_by_value_rel_rank_range_to_end(ops, name, NULL, value, rank,
1827  return_type);
1828 }
1829 
1830 /**
1831  * Create list get by value relative to rank range operation.
1832  * Server selects list items nearest to value and greater by relative rank with a count limit.
1833  * Server returns selected data specified by return_type.
1834  *
1835  * Examples for ordered list [0,4,5,9,11,15]:
1836  * <ul>
1837  * <li>(value,rank,count) = [selected items]</li>
1838  * <li>(5,0,2) = [5,9]</li>
1839  * <li>(5,1,1) = [9]</li>
1840  * <li>(5,-1,2) = [4,5]</li>
1841  * <li>(3,0,1) = [4]</li>
1842  * <li>(3,3,7) = [11,15]</li>
1843  * <li>(3,-3,2) = []</li>
1844  * </ul>
1845  *
1846  * @ingroup list_operations
1847  */
1848 static inline bool
1850  as_operations* ops, const char* name, as_val* value, int64_t rank, uint64_t count,
1851  as_list_return_type return_type
1852  )
1853 {
1854  return as_operations_list_get_by_value_rel_rank_range(ops, name, NULL, value, rank, count,
1855  return_type);
1856 }
1857 
1858 /**
1859  * Create list get by index operation.
1860  * Server selects list item identified by index and returns selected data specified by return_type.
1861  *
1862  * @ingroup list_operations
1863  */
1864 static inline bool
1866  as_operations* ops, const char* name, int64_t index, as_list_return_type return_type
1867  )
1868 {
1869  return as_operations_list_get_by_index(ops, name, NULL, index, return_type);
1870 }
1871 
1872 /**
1873  * Create list get by index range operation.
1874  * Server selects list items starting at specified index to the end of list and returns selected
1875  * data specified by return_type.
1876  *
1877  * @ingroup list_operations
1878  */
1879 static inline bool
1881  as_operations* ops, const char* name, int64_t index, as_list_return_type return_type
1882  )
1883 {
1884  return as_operations_list_get_by_index_range_to_end(ops, name, NULL, index, return_type);
1885 }
1886 
1887 /**
1888  * Create list get by index range operation.
1889  * Server selects `count` list items starting at specified index and returns selected data specified
1890  * by return_type.
1891  *
1892  * @ingroup list_operations
1893  */
1894 static inline bool
1896  as_operations* ops, const char* name, int64_t index, uint64_t count,
1897  as_list_return_type return_type
1898  )
1899 {
1900  return as_operations_list_get_by_index_range(ops, name, NULL, index, count, return_type);
1901 }
1902 
1903 /**
1904  * Create list get by rank operation.
1905  * Server selects list item identified by rank and returns selected data specified by return_type.
1906  *
1907  * @ingroup list_operations
1908  */
1909 static inline bool
1911  as_operations* ops, const char* name, int64_t rank, as_list_return_type return_type
1912  )
1913 {
1914  return as_operations_list_get_by_rank(ops, name, NULL, rank, return_type);
1915 }
1916 
1917 /**
1918  * Create list get by rank range operation.
1919  * Server selects list items starting at specified rank to the last ranked item and returns selected
1920  * data specified by return_type.
1921  *
1922  * @ingroup list_operations
1923  */
1924 static inline bool
1926  as_operations* ops, const char* name, int64_t rank, as_list_return_type return_type
1927  )
1928 {
1929  return as_operations_list_get_by_rank_range_to_end(ops, name, NULL, rank, return_type);
1930 }
1931 
1932 /**
1933  * Create list get by rank range operation.
1934  * Server selects `count` list items starting at specified rank and returns selected data specified
1935  * by return_type.
1936  *
1937  * @ingroup list_operations
1938  */
1939 static inline bool
1941  as_operations* ops, const char* name, int64_t rank, uint64_t count,
1942  as_list_return_type return_type
1943  )
1944 {
1945  return as_operations_list_get_by_rank_range(ops, name, NULL, rank, count, return_type);
1946 }
1947 
1948 #ifdef __cplusplus
1949 } // end extern "C"
1950 #endif
static bool as_operations_add_list_get_by_value(as_operations *ops, const char *name, as_val *value, as_list_return_type return_type)
as_list_order order
static bool as_operations_add_list_set_int64(as_operations *ops, const char *name, int64_t index, int64_t value)
AS_EXTERN bool as_operations_list_insert(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_list_policy *policy, int64_t index, as_val *val)
static bool as_operations_add_list_insert_int64(as_operations *ops, const char *name, int64_t index, int64_t value)
AS_EXTERN bool as_operations_list_get_by_value_range(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_val *begin, as_val *end, as_list_return_type return_type)
static bool as_operations_add_list_append_items_with_policy(as_operations *ops, const char *name, as_list_policy *policy, as_list *list)
AS_EXTERN bool as_operations_list_remove_by_rank(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t rank, as_list_return_type return_type)
AS_EXTERN bool as_operations_list_trim(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index, uint64_t count)
as_list_order
Definition: as_cdt_order.h:34
static bool as_operations_add_list_clear(as_operations *ops, const char *name)
static bool as_operations_add_list_insert_raw(as_operations *ops, const char *name, int64_t index, const uint8_t *value, uint32_t size)
AS_EXTERN bool as_operations_list_increment(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_list_policy *policy, int64_t index, as_val *incr)
static bool as_operations_add_list_set_rawp(as_operations *ops, const char *name, int64_t index, const uint8_t *value, uint32_t size, bool free)
AS_EXTERN bool as_operations_list_append(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_list_policy *policy, as_val *val)
static bool as_operations_add_list_get_by_value_rel_rank_range_to_end(as_operations *ops, const char *name, as_val *value, int64_t rank, as_list_return_type return_type)
static bool as_operations_add_list_trim(as_operations *ops, const char *name, int64_t index, uint64_t count)
AS_EXTERN bool as_operations_list_get_by_rank(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t rank, as_list_return_type return_type)
static bool as_operations_add_list_get_by_rank_range_to_end(as_operations *ops, const char *name, int64_t rank, as_list_return_type return_type)
static bool as_operations_add_list_set_strp(as_operations *ops, const char *name, int64_t index, const char *value, bool free)
static bool as_operations_add_list_remove_by_value_rel_rank_range(as_operations *ops, const char *name, as_val *value, int64_t rank, uint64_t count, as_list_return_type return_type)
AS_EXTERN bool as_operations_list_get_by_index_range(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index, uint64_t count, as_list_return_type return_type)
static bool as_operations_add_list_remove_by_value_list(as_operations *ops, const char *name, as_list *values, as_list_return_type return_type)
as_list_return_type
static bool as_operations_add_list_insert_items_with_policy(as_operations *ops, const char *name, as_list_policy *policy, int64_t index, as_list *list)
AS_EXTERN bool as_operations_list_clear(as_operations *ops, const char *name, as_cdt_ctx *ctx)
AS_EXTERN bool as_operations_list_remove_by_index_range(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index, uint64_t count, as_list_return_type return_type)
static bool as_operations_add_list_append_items(as_operations *ops, const char *name, as_list *list)
static bool as_operations_add_list_insert_rawp(as_operations *ops, const char *name, int64_t index, const uint8_t *value, uint32_t size, bool free)
static bool as_operations_add_list_append_raw(as_operations *ops, const char *name, const uint8_t *value, uint32_t size)
static void as_list_policy_init(as_list_policy *policy)
static bool as_operations_add_list_get_by_value_range(as_operations *ops, const char *name, as_val *begin, as_val *end, as_list_return_type return_type)
static bool as_operations_add_list_get_range_from(as_operations *ops, const char *name, int64_t index)
AS_EXTERN bool as_operations_list_get_by_index_range_to_end(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index, as_list_return_type return_type)
static bool as_operations_add_list_remove(as_operations *ops, const char *name, int64_t index)
Definition: as_val.h:61
AS_EXTERN bool as_operations_list_get_by_value_rel_rank_range(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_val *value, int64_t rank, uint64_t count, as_list_return_type return_type)
static bool as_operations_add_list_set_raw(as_operations *ops, const char *name, int64_t index, const uint8_t *value, uint32_t size)
AS_EXTERN bool as_operations_list_remove_range_from(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index)
AS_EXTERN bool as_operations_list_append_items(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_list_policy *policy, as_list *list)
static bool as_operations_add_list_remove_by_value_range(as_operations *ops, const char *name, as_val *begin, as_val *end, as_list_return_type return_type)
AS_EXTERN bool as_operations_list_remove_by_value_rel_rank_range(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_val *value, int64_t rank, uint64_t count, as_list_return_type return_type)
static bool as_operations_add_list_remove_by_rank(as_operations *ops, const char *name, int64_t rank, as_list_return_type return_type)
static bool as_operations_add_list_append_int64(as_operations *ops, const char *name, int64_t value)
static bool as_operations_add_list_insert_items(as_operations *ops, const char *name, int64_t index, as_list *list)
AS_EXTERN bool as_operations_list_set(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_list_policy *policy, int64_t index, as_val *val)
static bool as_operations_add_list_remove_by_rank_range_to_end(as_operations *ops, const char *name, int64_t rank, as_list_return_type return_type)
#define AS_EXTERN
Definition: as_std.h:25
static bool as_operations_add_list_get_by_index(as_operations *ops, const char *name, int64_t index, as_list_return_type return_type)
AS_EXTERN bool as_operations_list_get_by_rank_range(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t rank, uint64_t count, as_list_return_type return_type)
static bool as_operations_add_list_get_by_index_range_to_end(as_operations *ops, const char *name, int64_t index, as_list_return_type return_type)
static bool as_operations_add_list_append_rawp(as_operations *ops, const char *name, const uint8_t *value, uint32_t size, bool free)
static bool as_operations_add_list_remove_range(as_operations *ops, const char *name, int64_t index, uint64_t count)
static bool as_operations_add_list_get_range(as_operations *ops, const char *name, int64_t index, uint64_t count)
static bool as_operations_add_list_get_by_value_rel_rank_range(as_operations *ops, const char *name, as_val *value, int64_t rank, uint64_t count, as_list_return_type return_type)
static bool as_operations_add_list_insert_strp(as_operations *ops, const char *name, int64_t index, const char *value, bool free)
static bool as_operations_add_list_remove_by_value(as_operations *ops, const char *name, as_val *value, as_list_return_type return_type)
static bool as_operations_add_list_append_strp(as_operations *ops, const char *name, const char *value, bool free)
static bool as_operations_add_list_sort(as_operations *ops, const char *name, as_list_sort_flags flags)
static bool as_operations_add_list_append_double(as_operations *ops, const char *name, double value)
AS_EXTERN bool as_operations_list_get_by_index(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index, as_list_return_type return_type)
static bool as_operations_add_list_insert_with_policy(as_operations *ops, const char *name, as_list_policy *policy, int64_t index, as_val *val)
AS_EXTERN bool as_operations_list_remove_by_value_list(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_list *values, as_list_return_type return_type)
static bool as_operations_add_list_set_double(as_operations *ops, const char *name, int64_t index, double value)
static bool as_operations_add_list_set_with_policy(as_operations *ops, const char *name, as_list_policy *policy, int64_t index, as_val *val)
AS_EXTERN bool as_operations_list_insert_items(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_list_policy *policy, int64_t index, as_list *list)
AS_EXTERN bool as_operations_list_remove_by_index_range_to_end(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index, as_list_return_type return_type)
AS_EXTERN bool as_operations_list_remove_by_rank_range(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t rank, uint64_t count, as_list_return_type return_type)
static bool as_operations_add_list_set(as_operations *ops, const char *name, int64_t index, as_val *val)
static bool as_operations_add_list_pop_range_from(as_operations *ops, const char *name, int64_t index)
AS_EXTERN bool as_operations_list_pop(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index)
static bool as_operations_add_list_remove_by_rank_range(as_operations *ops, const char *name, int64_t rank, uint64_t count, as_list_return_type return_type)
static bool as_operations_add_list_set_str(as_operations *ops, const char *name, int64_t index, const char *value)
AS_EXTERN bool as_operations_list_get_by_value(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_val *value, as_list_return_type return_type)
static bool as_operations_add_list_remove_range_from(as_operations *ops, const char *name, int64_t index)
static bool as_operations_add_list_get_by_value_list(as_operations *ops, const char *name, as_list *values, as_list_return_type return_type)
AS_EXTERN bool as_operations_list_remove(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index)
static bool as_operations_add_list_increment_with_policy(as_operations *ops, const char *name, as_list_policy *policy, int64_t index, as_val *incr)
AS_EXTERN bool as_operations_list_get_range(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index, uint64_t count)
static bool as_operations_add_list_remove_by_index(as_operations *ops, const char *name, int64_t index, as_list_return_type return_type)
as_list_sort_flags
static bool as_operations_add_list_get(as_operations *ops, const char *name, int64_t index)
AS_EXTERN bool as_operations_list_get_by_value_list(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_list *values, as_list_return_type return_type)
static bool as_operations_add_list_pop_range(as_operations *ops, const char *name, int64_t index, uint64_t count)
AS_EXTERN bool as_operations_list_get_by_value_rel_rank_range_to_end(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_val *value, int64_t rank, as_list_return_type return_type)
AS_EXTERN bool as_operations_list_set_order(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_list_order order)
static bool as_operations_add_list_remove_by_index_range(as_operations *ops, const char *name, int64_t index, uint64_t count, as_list_return_type return_type)
AS_EXTERN as_bytes * as_bytes_init_wrap(as_bytes *bytes, uint8_t *value, uint32_t size, bool free)
static bool as_operations_add_list_remove_by_value_rel_rank_range_to_end(as_operations *ops, const char *name, as_val *value, int64_t rank, as_list_return_type return_type)
AS_EXTERN bool as_operations_list_size(as_operations *ops, const char *name, as_cdt_ctx *ctx)
static bool as_operations_add_list_append_with_policy(as_operations *ops, const char *name, as_list_policy *policy, as_val *val)
AS_EXTERN bool as_operations_list_remove_by_value_rel_rank_range_to_end(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_val *value, int64_t rank, as_list_return_type return_type)
static bool as_operations_add_list_get_by_index_range(as_operations *ops, const char *name, int64_t index, uint64_t count, as_list_return_type return_type)
static bool as_operations_add_list_get_by_rank_range(as_operations *ops, const char *name, int64_t rank, uint64_t count, as_list_return_type return_type)
AS_EXTERN bool as_operations_list_sort(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_list_sort_flags flags)
as_list_write_flags
AS_EXTERN bool as_operations_list_get(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index)
AS_EXTERN as_integer * as_integer_init(as_integer *integer, int64_t value)
AS_EXTERN bool as_operations_list_pop_range(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index, uint64_t count)
AS_EXTERN bool as_operations_list_get_by_rank_range_to_end(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t rank, as_list_return_type return_type)
static bool as_operations_add_list_set_order(as_operations *ops, const char *name, as_list_order order)
AS_EXTERN bool as_operations_list_remove_by_value(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_val *value, as_list_return_type return_type)
AS_EXTERN as_double * as_double_init(as_double *value_ptr, double value)
static bool as_operations_add_list_append_str(as_operations *ops, const char *name, const char *value)
static bool as_operations_add_list_size(as_operations *ops, const char *name)
AS_EXTERN bool as_operations_list_remove_by_value_range(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_val *begin, as_val *end, as_list_return_type return_type)
static bool as_operations_add_list_increment(as_operations *ops, const char *name, int64_t index, as_val *incr)
static bool as_operations_add_list_insert_double(as_operations *ops, const char *name, int64_t index, double value)
as_list_write_flags flags
static bool as_operations_add_list_insert_str(as_operations *ops, const char *name, int64_t index, const char *value)
static bool as_operations_add_list_insert(as_operations *ops, const char *name, int64_t index, as_val *val)
AS_EXTERN bool as_operations_list_get_range_from(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index)
AS_EXTERN as_string * as_string_init(as_string *string, char *value, bool free)
static bool as_operations_add_list_pop(as_operations *ops, const char *name, int64_t index)
static bool as_operations_add_list_remove_by_index_range_to_end(as_operations *ops, const char *name, int64_t index, as_list_return_type return_type)
AS_EXTERN bool as_operations_list_create(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_list_order order, bool pad)
as_cdt_op_list
static bool as_operations_add_list_append(as_operations *ops, const char *name, as_val *val)
AS_EXTERN bool as_operations_list_remove_range(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index, uint64_t count)
AS_EXTERN bool as_operations_list_pop_range_from(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index)
AS_EXTERN bool as_operations_list_remove_by_rank_range_to_end(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t rank, as_list_return_type return_type)
AS_EXTERN bool as_operations_list_remove_by_index(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index, as_list_return_type return_type)
static bool as_operations_add_list_get_by_rank(as_operations *ops, const char *name, int64_t rank, as_list_return_type return_type)
static void as_list_policy_set(as_list_policy *policy, as_list_order order, as_list_write_flags flags)