Loading...
Searching...
No Matches
as_list_operations.h
Go to the documentation of this file.
1/*
2 * Copyright 2008-2024 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
87
88#ifdef __cplusplus
89extern "C" {
90#endif
91
92/******************************************************************************
93 * TYPES
94 *****************************************************************************/
95
96/**
97 * List sort flags.
98 *
99 * @ingroup list_operations
100 */
101typedef 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 */
118typedef 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 */
152typedef 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 */
162typedef 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 */
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 */
273static inline void
279
280/**
281 * Set list attributes to specified list order and write flag semantics.
282 *
283 * @ingroup list_operations
284 */
285static 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 */
300AS_EXTERN bool
302 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_order order, bool pad
303 );
304
305/**
306 * Create list create operation.
307 * Server creates list at given context level.
308 *
309 * @param ops Target operations list.
310 * @param name Bin name.
311 * @param ctx Optional path to nested list. If not defined, the top-level list is used.
312 * @param order List order.
313 * @param pad If true, the context is allowed to be beyond list boundaries. In that case, nil
314 * list entries will be inserted to satisfy the context position.
315 * @param persist_index If true, persist list index. A list index improves lookup performance,
316 * but requires more storage. A list index can be created for a top-level
317 * ordered list only. Nested and unordered list indexes are not supported.
318 *
319 * @ingroup map_operations
320 */
321AS_EXTERN bool
323 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_order order, bool pad, bool persist_index
324 );
325
326/**
327 * Create set list order operation.
328 * Server sets list order. Server returns null.
329 *
330 * @ingroup list_operations
331 */
332AS_EXTERN bool
334 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_order order
335 );
336
337/**
338 * Create list sort operation.
339 * Server sorts list according to flags.
340 * Server does not return a result by default.
341 *
342 * @ingroup list_operations
343 */
344AS_EXTERN bool
346 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_sort_flags flags
347 );
348
349/**
350 * Create list append operation with policy.
351 * Server appends value to list bin.
352 * Server returns list size.
353 *
354 * This function takes ownership and frees heap memory associated with val parameter.
355 * @ingroup list_operations
356 */
357AS_EXTERN bool
359 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_policy* policy,
360 as_val* val
361 );
362
363/**
364 * Create list append items operation with policy.
365 * Server appends each input list item to end of list bin.
366 * Server returns list size.
367 *
368 * This function takes ownership and frees heap memory associated with list parameter.
369 * @ingroup list_operations
370 */
371AS_EXTERN bool
373 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_policy* policy,
374 as_list* list
375 );
376
377/**
378 * Create default list insert operation with policy.
379 * Server inserts value to specified index of list bin.
380 * Server returns list size.
381 *
382 * This function takes ownership and frees heap memory associated with val parameter.
383 * @ingroup list_operations
384 */
385AS_EXTERN bool
387 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_policy* policy,
388 int64_t index, as_val* val
389 );
390
391/**
392 * Create default list insert items operation with policy.
393 * Server inserts each input list item starting at specified index of list bin.
394 * Server returns list size.
395 *
396 * This function takes ownership and frees heap memory associated with list parameter.
397 * @ingroup list_operations
398 */
399AS_EXTERN bool
401 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_policy* policy,
402 int64_t index, as_list* list
403 );
404
405/**
406 * Create list increment operation with policy.
407 * Server increments value at index by incr and returns final result.
408 * Valid only for numbers.
409 *
410 * This function takes ownership and frees heap memory associated with incr parameter.
411 * @ingroup list_operations
412 */
413AS_EXTERN bool
415 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_policy* policy,
416 int64_t index, as_val* incr
417 );
418
419/**
420 * Create list set operation with policy.
421 * Server sets item value at specified index in list bin.
422 * Server does not return a result by default.
423 *
424 * This function takes ownership and frees heap memory associated with val parameter.
425 * @ingroup list_operations
426 */
427AS_EXTERN bool
429 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list_policy* policy,
430 int64_t index, as_val* val
431 );
432
433/**
434 * Create list pop operation.
435 * Server returns item at specified index and removes item from list bin.
436 *
437 * @ingroup list_operations
438 */
439AS_EXTERN bool
440as_operations_list_pop(as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index);
441
442/**
443 * Create list pop range operation.
444 * Server returns "count" items starting at specified index and removes items from list bin.
445 *
446 * @ingroup list_operations
447 */
448AS_EXTERN bool
450 int64_t index, uint64_t count
451 );
452
453/**
454 * Create list pop range operation.
455 * Server returns items starting at specified index to the end of list and removes those items
456 * from list bin.
457 *
458 * @ingroup list_operations
459 */
460AS_EXTERN bool
462 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index
463 );
464
465/**
466 * Create list remove operation.
467 * Server removes item at specified index from list bin.
468 * Server returns number of items removed.
469 *
470 * @ingroup list_operations
471 */
472AS_EXTERN bool
474 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index
475 );
476
477/**
478 * Create list remove range operation.
479 * Server removes "count" items starting at specified index from list bin.
480 * Server returns number of items removed.
481 *
482 * @ingroup list_operations
483 */
484AS_EXTERN bool
486 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index, uint64_t count
487 );
488
489/**
490 * Create list remove range operation.
491 * Server removes items starting at specified index to the end of list.
492 * Server returns number of items removed.
493 *
494 * @ingroup list_operations
495 */
496AS_EXTERN bool
498 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index
499 );
500
501/**
502 * Create list remove operation.
503 * Server removes list items identified by value and returns removed data specified by return_type.
504 *
505 * This function takes ownership and frees heap memory associated with value parameter.
506 * @ingroup list_operations
507 */
508AS_EXTERN bool
510 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_val* value,
511 as_list_return_type return_type
512 );
513
514/**
515 * Create list remove operation.
516 * Server removes list items identified by values and returns removed data specified by return_type.
517 *
518 * This function takes ownership and frees heap memory associated with values parameter.
519 * @ingroup list_operations
520 */
521AS_EXTERN bool
523 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list* values,
524 as_list_return_type return_type
525 );
526
527/**
528 * Create list remove operation.
529 * Server removes list items identified by value range (begin inclusive, end exclusive).
530 * If begin is null, the range is less than end.
531 * If end is null, the range is greater than equal to begin.
532 *
533 * Server returns removed data specified by return_type.
534 *
535 * This function takes ownership and frees heap memory associated with begin/end parameters.
536 * @ingroup list_operations
537 */
538AS_EXTERN bool
540 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_val* begin, as_val* end,
541 as_list_return_type return_type
542 );
543
544/**
545 * Create list remove by value relative to rank range operation.
546 * Server removes list items nearest to value and greater by relative rank.
547 * Server returns removed data specified by return_type.
548 *
549 * Examples for ordered list [0,4,5,9,11,15]:
550 * <ul>
551 * <li>(value,rank) = [removed items]</li>
552 * <li>(5,0) = [5,9,11,15]</li>
553 * <li>(5,1) = [9,11,15]</li>
554 * <li>(5,-1) = [4,5,9,11,15]</li>
555 * <li>(3,0) = [4,5,9,11,15]</li>
556 * <li>(3,3) = [11,15]</li>
557 * <li>(3,-3) = [0,4,5,9,11,15]</li>
558 * </ul>
559 *
560 * This function takes ownership and frees heap memory associated with value parameter.
561 * @ingroup list_operations
562 */
563AS_EXTERN bool
565 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_val* value, int64_t rank,
566 as_list_return_type return_type
567 );
568
569/**
570 * Create list remove by value relative to rank range operation.
571 * Server removes list items nearest to value and greater by relative rank with a count limit.
572 * Server returns removed data specified by return_type.
573 *
574 * Examples for ordered list [0,4,5,9,11,15]:
575 * <ul>
576 * <li>(value,rank,count) = [removed items]</li>
577 * <li>(5,0,2) = [5,9]</li>
578 * <li>(5,1,1) = [9]</li>
579 * <li>(5,-1,2) = [4,5]</li>
580 * <li>(3,0,1) = [4]</li>
581 * <li>(3,3,7) = [11,15]</li>
582 * <li>(3,-3,2) = []</li>
583 * </ul>
584 *
585 * This function takes ownership and frees heap memory associated with value parameter.
586 * @ingroup list_operations
587 */
588AS_EXTERN bool
590 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_val* value, int64_t rank,
591 uint64_t count, as_list_return_type return_type
592 );
593
594/**
595 * Create list remove operation.
596 * Server removes list item identified by index and returns removed data specified by return_type.
597 *
598 * @ingroup list_operations
599 */
600AS_EXTERN bool
602 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index,
603 as_list_return_type return_type
604 );
605
606/**
607 * Create list remove operation.
608 * Server removes list items starting at specified index to the end of list and returns removed
609 * data specified by return_type.
610 *
611 * @ingroup list_operations
612 */
613AS_EXTERN bool
615 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index,
616 as_list_return_type return_type
617 );
618
619/**
620 * Create list remove operation.
621 * Server removes `count` list items starting at specified index and returns removed data specified
622 * by return_type.
623 *
624 * @ingroup list_operations
625 */
626AS_EXTERN bool
628 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index, uint64_t count,
629 as_list_return_type return_type
630 );
631
632/**
633 * Create list remove operation.
634 * Server removes list item identified by rank and returns removed data specified by return_type.
635 *
636 * @ingroup list_operations
637 */
638AS_EXTERN bool
640 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t rank,
641 as_list_return_type return_type
642 );
643
644/**
645 * Create list remove operation.
646 * Server removes list items starting at specified rank to the last ranked item and returns removed
647 * data specified by return_type.
648 *
649 * @ingroup list_operations
650 */
651AS_EXTERN bool
653 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t rank,
654 as_list_return_type return_type
655 );
656
657/**
658 * Create list remove operation.
659 * Server removes `count` list items starting at specified rank and returns removed data specified
660 * by return_type.
661 *
662 * @ingroup list_operations
663 */
664AS_EXTERN bool
666 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t rank, uint64_t count,
667 as_list_return_type return_type
668 );
669
670/**
671 * Create list trim operation.
672 * Server removes items in list bin that do not fall into range specified by index
673 * and count range. If the range is out of bounds, then all items will be removed.
674 * Server returns list size after trim.
675 *
676 * @ingroup list_operations
677 */
678AS_EXTERN bool
680 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index, uint64_t count
681 );
682
683/**
684 * Create list clear operation.
685 * Server removes all items in list bin.
686 * Server does not return a result by default.
687 *
688 * @ingroup list_operations
689 */
690AS_EXTERN bool
692
693//-----------------------------------------------------------------------------
694// Read operations
695
696/**
697 * Create list size operation.
698 * Server returns size of list.
699 *
700 * @ingroup list_operations
701 */
702AS_EXTERN bool
704
705/**
706 * Create list get operation.
707 * Server returns item at specified index in list bin.
708 *
709 * @ingroup list_operations
710 */
711AS_EXTERN bool
712as_operations_list_get(as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index);
713
714/**
715 * Create list get range operation.
716 * Server returns "count" items starting at specified index in list bin.
717 *
718 * @ingroup list_operations
719 */
720AS_EXTERN bool
722 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index, uint64_t count
723 );
724
725/**
726 * Create list get range operation.
727 * Server returns items starting at index to the end of list.
728 *
729 * @ingroup list_operations
730 */
731AS_EXTERN bool
733 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index
734 );
735
736/**
737 * Create list get by value operation.
738 * Server selects list items identified by value and returns selected data specified by return_type.
739 *
740 * This function takes ownership and frees heap memory associated with value parameter.
741 * @ingroup list_operations
742 */
743AS_EXTERN bool
745 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_val* value,
746 as_list_return_type return_type
747 );
748
749/**
750 * Create list get by value range operation.
751 * Server selects list items identified by value range (begin inclusive, end exclusive).
752 * If begin is null, the range is less than end.
753 * If end is null, the range is greater than equal to begin.
754 *
755 * Server returns selected data specified by return_type.
756 *
757 * This function takes ownership and frees heap memory associated with begin/end parameters.
758 * @ingroup list_operations
759 */
760AS_EXTERN bool
762 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_val* begin, as_val* end,
763 as_list_return_type return_type
764 );
765
766/**
767 * Create list get by value list operation.
768 * Server selects list items identified by values and returns selected data specified by return_type.
769 *
770 * This function takes ownership and frees heap memory associated with values parameter.
771 * @ingroup list_operations
772 */
773AS_EXTERN bool
775 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_list* values,
776 as_list_return_type return_type
777 );
778
779/**
780 * Create list get by value relative to rank range operation.
781 * Server selects list items nearest to value and greater by relative rank.
782 * Server returns selected data specified by return_type.
783 *
784 * Examples for ordered list [0,4,5,9,11,15]:
785 * <ul>
786 * <li>(value,rank) = [selected items]</li>
787 * <li>(5,0) = [5,9,11,15]</li>
788 * <li>(5,1) = [9,11,15]</li>
789 * <li>(5,-1) = [4,5,9,11,15]</li>
790 * <li>(3,0) = [4,5,9,11,15]</li>
791 * <li>(3,3) = [11,15]</li>
792 * <li>(3,-3) = [0,4,5,9,11,15]</li>
793 * </ul>
794 *
795 * This function takes ownership and frees heap memory associated with value parameter.
796 * @ingroup list_operations
797 */
798AS_EXTERN bool
800 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_val* value, int64_t rank,
801 as_list_return_type return_type
802 );
803
804/**
805 * Create list get by value relative to rank range operation.
806 * Server selects list items nearest to value and greater by relative rank with a count limit.
807 * Server returns selected data specified by return_type.
808 *
809 * Examples for ordered list [0,4,5,9,11,15]:
810 * <ul>
811 * <li>(value,rank,count) = [selected items]</li>
812 * <li>(5,0,2) = [5,9]</li>
813 * <li>(5,1,1) = [9]</li>
814 * <li>(5,-1,2) = [4,5]</li>
815 * <li>(3,0,1) = [4]</li>
816 * <li>(3,3,7) = [11,15]</li>
817 * <li>(3,-3,2) = []</li>
818 * </ul>
819 *
820 * This function takes ownership and frees heap memory associated with value parameter.
821 * @ingroup list_operations
822 */
823AS_EXTERN bool
825 as_operations* ops, const char* name, as_cdt_ctx* ctx, as_val* value, int64_t rank,
826 uint64_t count, as_list_return_type return_type
827 );
828
829/**
830 * Create list get by index operation.
831 * Server selects list item identified by index and returns selected data specified by return_type.
832 *
833 * @ingroup list_operations
834 */
835AS_EXTERN bool
837 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index,
838 as_list_return_type return_type
839 );
840
841/**
842 * Create list get by index range operation.
843 * Server selects list items starting at specified index to the end of list and returns selected
844 * data specified by return_type.
845 *
846 * @ingroup list_operations
847 */
848AS_EXTERN bool
850 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index,
851 as_list_return_type return_type
852 );
853
854/**
855 * Create list get by index range operation.
856 * Server selects `count` list items starting at specified index and returns selected data specified
857 * by return_type.
858 *
859 * @ingroup list_operations
860 */
861AS_EXTERN bool
863 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t index, uint64_t count,
864 as_list_return_type return_type
865 );
866
867/**
868 * Create list get by rank operation.
869 * Server selects list item identified by rank and returns selected data specified by return_type.
870 *
871 * @ingroup list_operations
872 */
873AS_EXTERN bool
875 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t rank,
876 as_list_return_type return_type
877 );
878
879/**
880 * Create list get by rank range operation.
881 * Server selects list items starting at specified rank to the last ranked item and returns selected
882 * data specified by return_type.
883 *
884 * @ingroup list_operations
885 */
886AS_EXTERN bool
888 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t rank,
889 as_list_return_type return_type
890 );
891
892/**
893 * Create list get by rank range operation.
894 * Server selects `count` list items starting at specified rank and returns selected data specified by return_type.
895 *
896 * @ingroup list_operations
897 */
898AS_EXTERN bool
900 as_operations* ops, const char* name, as_cdt_ctx* ctx, int64_t rank, uint64_t count,
901 as_list_return_type return_type
902 );
903
904/******************************************************************************
905 * LEGACY FUNCTIONS
906 *****************************************************************************/
907
908/**
909 * Create set list order operation.
910 * Server sets list order. Server returns null.
911 *
912 * @ingroup list_operations
913 */
914static inline bool
916{
917 return as_operations_list_set_order(ops, name, NULL, order);
918}
919
920/**
921 * Create list sort operation.
922 * Server sorts list according to flags.
923 * Server does not return a result by default.
924 *
925 * @return true on success. Otherwise an error occurred.
926 * @ingroup list_operations
927 */
928static inline bool
930{
931 return as_operations_list_sort(ops, name, NULL, flags);
932}
933
934/**
935 * Create list append operation.
936 * Server appends value to list bin.
937 * Server returns list size.
938 *
939 * @ingroup list_operations
940 */
941static inline bool
943{
944 return as_operations_list_append(ops, name, NULL, NULL, val);
945}
946
947/**
948 * Create list append operation with policy.
949 * Server appends value to list bin.
950 * Server returns list size.
951 *
952 * @ingroup list_operations
953 */
954static inline bool
956 as_operations* ops, const char* name, as_list_policy* policy, as_val* val
957 )
958{
959 return as_operations_list_append(ops, name, NULL, policy, val);
960}
961
962/**
963 * Create list append operation.
964 * Server appends integer to list bin.
965 * Server returns list size.
966 *
967 * @ingroup list_operations
968 */
969static inline bool
970as_operations_add_list_append_int64(as_operations* ops, const char* name, int64_t value)
971{
972 as_integer v;
973 as_integer_init(&v, value);
974 return as_operations_list_append(ops, name, NULL, NULL, (as_val*)&v);
975}
976
977/**
978 * Create list append operation.
979 * Server appends double to list bin.
980 * Server returns list size.
981 *
982 * @ingroup list_operations
983 */
984static inline bool
985as_operations_add_list_append_double(as_operations* ops, const char* name, double value)
986{
987 as_double v;
988 as_double_init(&v, value);
989 return as_operations_list_append(ops, name, NULL, NULL, (as_val*)&v);
990}
991
992/**
993 * Create list append operation.
994 * Server appends string to list bin.
995 * Server returns list size.
996 *
997 * If free is true, the value will be freed when the operations are destroyed.
998 *
999 * @ingroup list_operations
1000 */
1001static inline bool
1003 as_operations* ops, const char* name, const char* value, bool free
1004 )
1005{
1006 as_string v;
1007 as_string_init(&v, (char*)value, free);
1008 return as_operations_list_append(ops, name, NULL, NULL, (as_val*)&v);
1009}
1010
1011/**
1012 * Create list append operation.
1013 * Server appends string to list bin.
1014 * Server returns list size.
1015 *
1016 * The value will not be freed when the operations are destroyed.
1017 *
1018 * @ingroup list_operations
1019 */
1020static inline bool
1021as_operations_add_list_append_str(as_operations* ops, const char* name, const char* value)
1022{
1023 return as_operations_add_list_append_strp(ops, name, value, false);
1024}
1025
1026/**
1027 * Create list append operation.
1028 * Server appends blob (byte array) to list bin.
1029 * Server returns list size.
1030 *
1031 * If free is true, the value will be freed when the operations are destroyed.
1032 *
1033 * @ingroup list_operations
1034 */
1035static inline bool
1037 as_operations* ops, const char* name, const uint8_t* value, uint32_t size, bool free
1038 )
1039{
1040 as_bytes v;
1041 as_bytes_init_wrap(&v, (uint8_t*)value, size, free);
1042 return as_operations_list_append(ops, name, NULL, NULL, (as_val*)&v);
1043}
1044
1045/**
1046 * Create list append operation.
1047 * Server appends blob (byte array) to list bin.
1048 * Server returns list size.
1049 *
1050 * The value will not be freed when the operations are destroyed.
1051 *
1052 * @ingroup list_operations
1053 */
1054static inline bool
1056 as_operations* ops, const char* name, const uint8_t* value, uint32_t size
1057 )
1058{
1059 return as_operations_add_list_append_rawp(ops, name, value, size, false);
1060}
1061
1062/**
1063 * Create list append items operation.
1064 * Server appends each input list item to end of list bin.
1065 * Server returns list size.
1066 *
1067 * @ingroup list_operations
1068 */
1069static inline bool
1071{
1072 return as_operations_list_append_items(ops, name, NULL, NULL, list);
1073}
1074
1075/**
1076 * Create list append items operation with policy.
1077 * Server appends each input list item to end of list bin.
1078 * Server returns list size.
1079 *
1080 * @ingroup list_operations
1081 */
1082static inline bool
1084 as_operations* ops, const char* name, as_list_policy* policy, as_list* list
1085 )
1086{
1087 return as_operations_list_append_items(ops, name, NULL, policy, list);
1088}
1089
1090/**
1091 * Create default list insert operation.
1092 * Server inserts value to specified index of list bin.
1093 * Server returns list size.
1094 *
1095 * @ingroup list_operations
1096 */
1097static inline bool
1099 as_operations* ops, const char* name, int64_t index, as_val* val
1100 )
1101{
1102 return as_operations_list_insert(ops, name, NULL, NULL, index, val);
1103}
1104
1105/**
1106 * Create default list insert operation with policy.
1107 * Server inserts value to specified index of list bin.
1108 * Server returns list size.
1109 *
1110 * @ingroup list_operations
1111 */
1112static inline bool
1114 as_operations* ops, const char* name, as_list_policy* policy, int64_t index, as_val* val
1115 )
1116{
1117 return as_operations_list_insert(ops, name, NULL, policy, index, val);
1118}
1119
1120/**
1121 * Create default list insert operation with policy.
1122 * Server inserts integer to specified index of list bin.
1123 * Server returns list size.
1124 *
1125 * @ingroup list_operations
1126 */
1127static inline bool
1129 as_operations* ops, const char* name, int64_t index, int64_t value
1130 )
1131{
1132 as_integer v;
1133 as_integer_init(&v, value);
1134 return as_operations_list_insert(ops, name, NULL, NULL, index, (as_val*)&v);
1135}
1136
1137/**
1138 * Create default list insert operation with policy.
1139 * Server inserts double to specified index of list bin.
1140 * Server returns list size.
1141 *
1142 * @ingroup list_operations
1143 */
1144static inline bool
1146 as_operations* ops, const char* name, int64_t index, double value
1147 )
1148{
1149 as_double v;
1150 as_double_init(&v, value);
1151 return as_operations_list_insert(ops, name, NULL, NULL, index, (as_val*)&v);
1152}
1153
1154/**
1155 * Create default list insert operation with policy.
1156 * Server inserts string to specified index of list bin.
1157 * Server returns list size.
1158 *
1159 * If free is true, the value will be freed when the operations are destroyed.
1160 *
1161 * @ingroup list_operations
1162 */
1163static inline bool
1165 as_operations* ops, const char* name, int64_t index, const char* value, bool free
1166 )
1167{
1168 as_string v;
1169 as_string_init(&v, (char *)value, free);
1170 return as_operations_list_insert(ops, name, NULL, NULL, index, (as_val*)&v);
1171}
1172
1173/**
1174 * Create default list insert operation with policy.
1175 * Server inserts string to specified index of list bin.
1176 * Server returns list size.
1177 *
1178 * The value will not be freed when the operations are destroyed.
1179 *
1180 * @ingroup list_operations
1181 */
1182static inline bool
1184 as_operations* ops, const char* name, int64_t index, const char* value
1185 )
1186{
1187 return as_operations_add_list_insert_strp(ops, name, index, value, false);
1188}
1189
1190/**
1191 * Create default list insert operation with policy.
1192 * Server inserts blob (byte array) to specified index of list bin.
1193 * Server returns list size.
1194 *
1195 * If free is true, the value will be freed when the operations are destroyed.
1196 *
1197 * @ingroup list_operations
1198 */
1199static inline bool
1201 as_operations* ops, const char* name, int64_t index, const uint8_t* value, uint32_t size,
1202 bool free
1203 )
1204{
1205 as_bytes v;
1206 as_bytes_init_wrap(&v, (uint8_t *)value, size, free);
1207 return as_operations_list_insert(ops, name, NULL, NULL, index, (as_val*)&v);
1208}
1209
1210/**
1211 * Create default list insert operation with policy.
1212 * Server inserts blob (byte array) to specified index of list bin.
1213 * Server returns list size.
1214 *
1215 * The value will not be freed when the operations are destroyed.
1216 *
1217 * @ingroup list_operations
1218 */
1219static inline bool
1221 as_operations* ops, const char* name, int64_t index, const uint8_t* value, uint32_t size
1222 )
1223{
1224 return as_operations_add_list_insert_rawp(ops, name, index, value, size, false);
1225}
1226
1227/**
1228 * Create default list insert items operation.
1229 * Server inserts each input list item starting at specified index of list bin.
1230 * Server returns list size.
1231 *
1232 * @ingroup list_operations
1233 */
1234static inline bool
1236 as_operations* ops, const char* name, int64_t index, as_list* list
1237 )
1238{
1239 return as_operations_list_insert_items(ops, name, NULL, NULL, index, list);
1240}
1241
1242/**
1243 * Create default list insert items operation with policy.
1244 * Server inserts each input list item starting at specified index of list bin.
1245 * Server returns list size.
1246 *
1247 * @ingroup list_operations
1248 */
1249static inline bool
1251 as_operations* ops, const char* name, as_list_policy* policy, int64_t index,
1252 as_list* list
1253 )
1254{
1255 return as_operations_list_insert_items(ops, name, NULL, policy, index, list);
1256}
1257
1258/**
1259 * Create list increment operation.
1260 * Server increments value at index by incr and returns final result.
1261 * Valid only for numbers.
1262 *
1263 * @ingroup list_operations
1264 */
1265static inline bool
1267 as_operations* ops, const char* name, int64_t index, as_val* incr
1268 )
1269{
1270 return as_operations_list_increment(ops, name, NULL, NULL, index, incr);
1271}
1272
1273/**
1274 * Create list increment operation with policy.
1275 * Server increments value at index by incr and returns final result.
1276 * Valid only for numbers.
1277 *
1278 * @ingroup list_operations
1279 */
1280static inline bool
1282 as_operations* ops, const char* name, as_list_policy* policy, int64_t index, as_val* incr
1283 )
1284{
1285 return as_operations_list_increment(ops, name, NULL, policy, index, incr);
1286}
1287
1288/**
1289 * Create list set operation.
1290 * Server sets item value at specified index in list bin.
1291 * Server does not return a result by default.
1292 *
1293 * @ingroup list_operations
1294 */
1295static inline bool
1296as_operations_add_list_set(as_operations* ops, const char* name, int64_t index, as_val* val)
1297{
1298 return as_operations_list_set(ops, name, NULL, NULL, index, val);
1299}
1300
1301/**
1302 * Create list set operation with policy.
1303 * Server sets item value at specified index in list bin.
1304 * Server does not return a result by default.
1305 *
1306 * @ingroup list_operations
1307 */
1308static inline bool
1310 as_operations* ops, const char* name, as_list_policy* policy, int64_t index, as_val* val
1311 )
1312{
1313 return as_operations_list_set(ops, name, NULL, policy, index, val);
1314}
1315
1316/**
1317 * Create list set operation with policy.
1318 * Server sets integer at specified index in list bin.
1319 * Server does not return a result by default.
1320 *
1321 * @ingroup list_operations
1322 */
1323static inline bool
1325 as_operations* ops, const char* name, int64_t index, int64_t value
1326 )
1327{
1328 as_integer v;
1329 as_integer_init(&v, value);
1330 return as_operations_list_set(ops, name, NULL, NULL, index, (as_val*)&v);
1331}
1332
1333/**
1334 * Create list set operation with policy.
1335 * Server sets double at specified index in list bin.
1336 * Server does not return a result by default.
1337 *
1338 * @ingroup list_operations
1339 */
1340static inline bool
1342 as_operations* ops, const char* name, int64_t index, double value
1343 )
1344{
1345 as_double v;
1346 as_double_init(&v, value);
1347 return as_operations_list_set(ops, name, NULL, NULL, index, (as_val*)&v);
1348}
1349
1350/**
1351 * Create list set operation with policy.
1352 * Server sets string at specified index in list bin.
1353 * Server does not return a result by default.
1354 *
1355 * If free is true, the value will be freed when the operations are destroyed.
1356 *
1357 * @ingroup list_operations
1358 */
1359static inline bool
1361 as_operations* ops, const char* name, int64_t index, const char* value, bool free
1362 )
1363{
1364 as_string v;
1365 as_string_init(&v, (char *)value, free);
1366 return as_operations_list_set(ops, name, NULL, NULL, index, (as_val*)&v);
1367}
1368
1369/**
1370 * Create list set operation with policy.
1371 * Server sets string at specified index in list bin.
1372 * Server does not return a result by default.
1373 *
1374 * The value will not be freed when the operations are destroyed.
1375 *
1376 * @ingroup list_operations
1377 */
1378static inline bool
1380 as_operations* ops, const char* name, int64_t index, const char* value
1381 )
1382{
1383 return as_operations_add_list_set_strp(ops, name, index, value, false);
1384}
1385
1386/**
1387 * Create list set operation with policy.
1388 * Server sets blob (byte array) at specified index in list bin.
1389 * Server does not return a result by default.
1390 *
1391 * If free is true, the value will be freed when the operations are destroyed.
1392 *
1393 * @ingroup list_operations
1394 */
1395static inline bool
1397 as_operations* ops, const char* name, int64_t index, const uint8_t* value, uint32_t size,
1398 bool free
1399 )
1400{
1401 as_bytes v;
1402 as_bytes_init_wrap(&v, (uint8_t *)value, size, free);
1403 return as_operations_list_set(ops, name, NULL, NULL, index, (as_val*)&v);
1404}
1405
1406/**
1407 * Create list set operation with policy.
1408 * Server sets blob (byte array) at specified index in list bin.
1409 * Server does not return a result by default.
1410 *
1411 * The value will not be freed when the operations are destroyed.
1412 *
1413 * @ingroup list_operations
1414 */
1415static inline bool
1417 as_operations* ops, const char* name, int64_t index, const uint8_t* value, uint32_t size
1418 )
1419{
1420 return as_operations_add_list_set_rawp(ops, name, index, value, size, false);
1421}
1422
1423/**
1424 * Create list pop operation.
1425 * Server returns item at specified index and removes item from list bin.
1426 *
1427 * @ingroup list_operations
1428 */
1429static inline bool
1430as_operations_add_list_pop(as_operations* ops, const char* name, int64_t index)
1431{
1432 return as_operations_list_pop(ops, name, NULL, index);
1433}
1434
1435/**
1436 * Create list pop range operation.
1437 * Server returns "count" items starting at specified index and removes items from list bin.
1438 *
1439 * @ingroup list_operations
1440 */
1441static inline bool
1443 as_operations* ops, const char* name, int64_t index, uint64_t count
1444 )
1445{
1446 return as_operations_list_pop_range(ops, name, NULL, index, count);
1447}
1448
1449/**
1450 * Create list pop range operation.
1451 * Server returns items starting at specified index to the end of list and removes those items
1452 * from list bin.
1453 *
1454 * @ingroup list_operations
1455 */
1456static inline bool
1457as_operations_add_list_pop_range_from(as_operations* ops, const char* name, int64_t index)
1458{
1459 return as_operations_list_pop_range_from(ops, name, NULL, index);
1460}
1461
1462/**
1463 * Create list remove operation.
1464 * Server removes item at specified index from list bin.
1465 * Server returns number of items removed.
1466 *
1467 * @ingroup list_operations
1468 */
1469static inline bool
1470as_operations_add_list_remove(as_operations* ops, const char* name, int64_t index)
1471{
1472 return as_operations_list_remove(ops, name, NULL, index);
1473}
1474
1475/**
1476 * Create list remove range operation.
1477 * Server removes "count" items starting at specified index from list bin.
1478 * Server returns number of items removed.
1479 *
1480 * @ingroup list_operations
1481 */
1482static inline bool
1484 as_operations* ops, const char* name, int64_t index, uint64_t count
1485 )
1486{
1487 return as_operations_list_remove_range(ops, name, NULL, index, count);
1488}
1489
1490/**
1491 * Create list remove range operation.
1492 * Server removes items starting at specified index to the end of list.
1493 * Server returns number of items removed.
1494 *
1495 * @ingroup list_operations
1496 */
1497static inline bool
1498as_operations_add_list_remove_range_from(as_operations* ops, const char* name, int64_t index)
1499{
1500 return as_operations_list_remove_range_from(ops, name, NULL, index);
1501}
1502
1503/**
1504 * Create list remove operation.
1505 * Server removes list items identified by value and returns removed data specified by return_type.
1506 *
1507 * @ingroup list_operations
1508 */
1509static inline bool
1511 as_operations* ops, const char* name, as_val* value, as_list_return_type return_type
1512 )
1513{
1514 return as_operations_list_remove_by_value(ops, name, NULL, value, return_type);
1515}
1516
1517/**
1518 * Create list remove operation.
1519 * Server removes list items identified by values and returns removed data specified by return_type.
1520 *
1521 * @ingroup list_operations
1522 */
1523static inline bool
1525 as_operations* ops, const char* name, as_list* values, as_list_return_type return_type
1526 )
1527{
1528 return as_operations_list_remove_by_value_list(ops, name, NULL, values, return_type);
1529}
1530
1531/**
1532 * Create list remove operation.
1533 * Server removes list items identified by value range (begin inclusive, end exclusive).
1534 * If begin is null, the range is less than end.
1535 * If end is null, the range is greater than equal to begin.
1536 *
1537 * Server returns removed data specified by return_type.
1538 *
1539 * @ingroup list_operations
1540 */
1541static inline bool
1543 as_operations* ops, const char* name, as_val* begin, as_val* end,
1544 as_list_return_type return_type
1545 )
1546{
1547 return as_operations_list_remove_by_value_range(ops, name, NULL, begin, end, return_type);
1548}
1549
1550/**
1551 * Create list remove by value relative to rank range operation.
1552 * Server removes list items nearest to value and greater by relative rank.
1553 * Server returns removed data specified by return_type.
1554 *
1555 * Examples for ordered list [0,4,5,9,11,15]:
1556 * <ul>
1557 * <li>(value,rank) = [removed items]</li>
1558 * <li>(5,0) = [5,9,11,15]</li>
1559 * <li>(5,1) = [9,11,15]</li>
1560 * <li>(5,-1) = [4,5,9,11,15]</li>
1561 * <li>(3,0) = [4,5,9,11,15]</li>
1562 * <li>(3,3) = [11,15]</li>
1563 * <li>(3,-3) = [0,4,5,9,11,15]</li>
1564 * </ul>
1565 *
1566 * @ingroup list_operations
1567 */
1568static inline bool
1570 as_operations* ops, const char* name, as_val* value, int64_t rank,
1571 as_list_return_type return_type
1572 )
1573{
1574 return as_operations_list_remove_by_value_rel_rank_range_to_end(ops, name, NULL, value, rank,
1575 return_type);
1576}
1577
1578/**
1579 * Create list remove by value relative to rank range operation.
1580 * Server removes list items nearest to value and greater by relative rank with a count limit.
1581 * Server returns removed data specified by return_type.
1582 *
1583 * Examples for ordered list [0,4,5,9,11,15]:
1584 * <ul>
1585 * <li>(value,rank,count) = [removed items]</li>
1586 * <li>(5,0,2) = [5,9]</li>
1587 * <li>(5,1,1) = [9]</li>
1588 * <li>(5,-1,2) = [4,5]</li>
1589 * <li>(3,0,1) = [4]</li>
1590 * <li>(3,3,7) = [11,15]</li>
1591 * <li>(3,-3,2) = []</li>
1592 * </ul>
1593 *
1594 * @ingroup list_operations
1595 */
1596static inline bool
1598 as_operations* ops, const char* name, as_val* value, int64_t rank, uint64_t count,
1599 as_list_return_type return_type
1600 )
1601{
1602 return as_operations_list_remove_by_value_rel_rank_range(ops, name, NULL, value, rank, count,
1603 return_type);
1604}
1605
1606/**
1607 * Create list remove operation.
1608 * Server removes list item identified by index and returns removed data specified by return_type.
1609 *
1610 * @ingroup list_operations
1611 */
1612static inline bool
1614 as_operations* ops, const char* name, int64_t index, as_list_return_type return_type
1615 )
1616{
1617 return as_operations_list_remove_by_index(ops, name, NULL, index, return_type);
1618}
1619
1620/**
1621 * Create list remove operation.
1622 * Server removes list items starting at specified index to the end of list and returns removed
1623 * data specified by return_type.
1624 *
1625 * @ingroup list_operations
1626 */
1627static inline bool
1629 as_operations* ops, const char* name, int64_t index, as_list_return_type return_type
1630 )
1631{
1632 return as_operations_list_remove_by_index_range_to_end(ops, name, NULL, index, return_type);
1633}
1634
1635/**
1636 * Create list remove operation.
1637 * Server removes `count` list items starting at specified index and returns removed data specified by return_type.
1638 *
1639 * @ingroup list_operations
1640 */
1641static inline bool
1643 as_operations* ops, const char* name, int64_t index, uint64_t count,
1644 as_list_return_type return_type
1645 )
1646{
1647 return as_operations_list_remove_by_index_range(ops, name, NULL, index, count, return_type);
1648}
1649
1650/**
1651 * Create list remove operation.
1652 * Server removes list item identified by rank and returns removed data specified by return_type.
1653 *
1654 * @ingroup list_operations
1655 */
1656static inline bool
1658 as_operations* ops, const char* name, int64_t rank, as_list_return_type return_type
1659 )
1660{
1661 return as_operations_list_remove_by_rank(ops, name, NULL, rank, return_type);
1662}
1663
1664/**
1665 * Create list remove operation.
1666 * Server removes list items starting at specified rank to the last ranked item and returns removed
1667 * data specified by return_type.
1668 *
1669 * @ingroup list_operations
1670 */
1671static inline bool
1673 as_operations* ops, const char* name, int64_t rank, as_list_return_type return_type
1674 )
1675{
1676 return as_operations_list_remove_by_rank_range_to_end(ops, name, NULL, rank, return_type);
1677}
1678
1679/**
1680 * Create list remove operation.
1681 * Server removes `count` list items starting at specified rank and returns removed data specified by return_type.
1682 *
1683 * @ingroup list_operations
1684 */
1685static inline bool
1687 as_operations* ops, const char* name, int64_t rank, uint64_t count,
1688 as_list_return_type return_type
1689 )
1690{
1691 return as_operations_list_remove_by_rank_range(ops, name, NULL, rank, count, return_type);
1692}
1693
1694/**
1695 * Create list trim operation.
1696 * Server removes items in list bin that do not fall into range specified by index
1697 * and count range. If the range is out of bounds, then all items will be removed.
1698 * Server returns list size after trim.
1699 *
1700 * @ingroup list_operations
1701 */
1702static inline bool
1704 as_operations* ops, const char* name, int64_t index, uint64_t count
1705 )
1706{
1707 return as_operations_list_trim(ops, name, NULL, index, count);
1708}
1709
1710/**
1711 * Create list clear operation.
1712 * Server removes all items in list bin.
1713 * Server does not return a result by default.
1714 *
1715 * @ingroup list_operations
1716 */
1717static inline bool
1719{
1720 return as_operations_list_clear(ops, name, NULL);
1721}
1722
1723//-----------------------------------------------------------------------------
1724// Read operations
1725
1726/**
1727 * Create list size operation.
1728 * Server returns size of list.
1729 *
1730 * @ingroup list_operations
1731 */
1732static inline bool
1734{
1735 return as_operations_list_size(ops, name, NULL);
1736}
1737
1738/**
1739 * Create list get operation.
1740 * Server returns item at specified index in list bin.
1741 *
1742 * @ingroup list_operations
1743 */
1744static inline bool
1745as_operations_add_list_get(as_operations* ops, const char* name, int64_t index)
1746{
1747 return as_operations_list_get(ops, name, NULL, index);
1748}
1749
1750/**
1751 * Create list get range operation.
1752 * Server returns "count" items starting at specified index in list bin.
1753 *
1754 * @ingroup list_operations
1755 */
1756static inline bool
1758 as_operations* ops, const char* name, int64_t index, uint64_t count
1759 )
1760{
1761 return as_operations_list_get_range(ops, name, NULL, index, count);
1762}
1763
1764/**
1765 * Create list get range operation.
1766 * Server returns items starting at index to the end of list.
1767 *
1768 * @ingroup list_operations
1769 */
1770static inline bool
1771as_operations_add_list_get_range_from(as_operations* ops, const char* name, int64_t index)
1772{
1773 return as_operations_list_get_range_from(ops, name, NULL, index);
1774}
1775
1776/**
1777 * Create list get by value operation.
1778 * Server selects list items identified by value and returns selected data specified by return_type.
1779 *
1780 * @ingroup list_operations
1781 */
1782static inline bool
1784 as_operations* ops, const char* name, as_val* value, as_list_return_type return_type
1785 )
1786{
1787 return as_operations_list_get_by_value(ops, name, NULL, value, return_type);
1788}
1789
1790/**
1791 * Create list get by value range operation.
1792 * Server selects list items identified by value range (begin inclusive, end exclusive).
1793 * If begin is null, the range is less than end.
1794 * If end is null, the range is greater than equal to begin.
1795 *
1796 * Server returns selected data specified by return_type.
1797 *
1798 * @ingroup list_operations
1799 */
1800static inline bool
1802 as_operations* ops, const char* name, as_val* begin, as_val* end,
1803 as_list_return_type return_type
1804 )
1805{
1806 return as_operations_list_get_by_value_range(ops, name, NULL, begin, end, return_type);
1807}
1808
1809/**
1810 * Create list get by value list operation.
1811 * Server selects list items identified by values and returns selected data specified by return_type.
1812 *
1813 * @ingroup list_operations
1814 */
1815static inline bool
1817 as_operations* ops, const char* name, as_list* values, as_list_return_type return_type
1818 )
1819{
1820 return as_operations_list_get_by_value_list(ops, name, NULL, values, return_type);
1821}
1822
1823/**
1824 * Create list get by value relative to rank range operation.
1825 * Server selects list items nearest to value and greater by relative rank.
1826 * Server returns selected data specified by return_type.
1827 *
1828 * Examples for ordered list [0,4,5,9,11,15]:
1829 * <ul>
1830 * <li>(value,rank) = [selected items]</li>
1831 * <li>(5,0) = [5,9,11,15]</li>
1832 * <li>(5,1) = [9,11,15]</li>
1833 * <li>(5,-1) = [4,5,9,11,15]</li>
1834 * <li>(3,0) = [4,5,9,11,15]</li>
1835 * <li>(3,3) = [11,15]</li>
1836 * <li>(3,-3) = [0,4,5,9,11,15]</li>
1837 * </ul>
1838 *
1839 * @ingroup list_operations
1840 */
1841static inline bool
1843 as_operations* ops, const char* name, as_val* value, int64_t rank,
1844 as_list_return_type return_type
1845 )
1846{
1847 return as_operations_list_get_by_value_rel_rank_range_to_end(ops, name, NULL, value, rank,
1848 return_type);
1849}
1850
1851/**
1852 * Create list get by value relative to rank range operation.
1853 * Server selects list items nearest to value and greater by relative rank with a count limit.
1854 * Server returns selected data specified by return_type.
1855 *
1856 * Examples for ordered list [0,4,5,9,11,15]:
1857 * <ul>
1858 * <li>(value,rank,count) = [selected items]</li>
1859 * <li>(5,0,2) = [5,9]</li>
1860 * <li>(5,1,1) = [9]</li>
1861 * <li>(5,-1,2) = [4,5]</li>
1862 * <li>(3,0,1) = [4]</li>
1863 * <li>(3,3,7) = [11,15]</li>
1864 * <li>(3,-3,2) = []</li>
1865 * </ul>
1866 *
1867 * @ingroup list_operations
1868 */
1869static inline bool
1871 as_operations* ops, const char* name, as_val* value, int64_t rank, uint64_t count,
1872 as_list_return_type return_type
1873 )
1874{
1875 return as_operations_list_get_by_value_rel_rank_range(ops, name, NULL, value, rank, count,
1876 return_type);
1877}
1878
1879/**
1880 * Create list get by index operation.
1881 * Server selects list item identified by index and returns selected data specified by return_type.
1882 *
1883 * @ingroup list_operations
1884 */
1885static inline bool
1887 as_operations* ops, const char* name, int64_t index, as_list_return_type return_type
1888 )
1889{
1890 return as_operations_list_get_by_index(ops, name, NULL, index, return_type);
1891}
1892
1893/**
1894 * Create list get by index range operation.
1895 * Server selects list items starting at specified index to the end of list and returns selected
1896 * data specified by return_type.
1897 *
1898 * @ingroup list_operations
1899 */
1900static inline bool
1902 as_operations* ops, const char* name, int64_t index, as_list_return_type return_type
1903 )
1904{
1905 return as_operations_list_get_by_index_range_to_end(ops, name, NULL, index, return_type);
1906}
1907
1908/**
1909 * Create list get by index range operation.
1910 * Server selects `count` list items starting at specified index and returns selected data specified
1911 * by return_type.
1912 *
1913 * @ingroup list_operations
1914 */
1915static inline bool
1917 as_operations* ops, const char* name, int64_t index, uint64_t count,
1918 as_list_return_type return_type
1919 )
1920{
1921 return as_operations_list_get_by_index_range(ops, name, NULL, index, count, return_type);
1922}
1923
1924/**
1925 * Create list get by rank operation.
1926 * Server selects list item identified by rank and returns selected data specified by return_type.
1927 *
1928 * @ingroup list_operations
1929 */
1930static inline bool
1932 as_operations* ops, const char* name, int64_t rank, as_list_return_type return_type
1933 )
1934{
1935 return as_operations_list_get_by_rank(ops, name, NULL, rank, return_type);
1936}
1937
1938/**
1939 * Create list get by rank range operation.
1940 * Server selects list items starting at specified rank to the last ranked item and returns selected
1941 * data specified by return_type.
1942 *
1943 * @ingroup list_operations
1944 */
1945static inline bool
1947 as_operations* ops, const char* name, int64_t rank, as_list_return_type return_type
1948 )
1949{
1950 return as_operations_list_get_by_rank_range_to_end(ops, name, NULL, rank, return_type);
1951}
1952
1953/**
1954 * Create list get by rank range operation.
1955 * Server selects `count` list items starting at specified rank and returns selected data specified
1956 * by return_type.
1957 *
1958 * @ingroup list_operations
1959 */
1960static inline bool
1962 as_operations* ops, const char* name, int64_t rank, uint64_t count,
1963 as_list_return_type return_type
1964 )
1965{
1966 return as_operations_list_get_by_rank_range(ops, name, NULL, rank, count, return_type);
1967}
1968
1969#ifdef __cplusplus
1970} // end extern "C"
1971#endif
AS_EXTERN as_bytes * as_bytes_init_wrap(as_bytes *bytes, uint8_t *value, uint32_t size, bool free)
AS_EXTERN as_double * as_double_init(as_double *value_ptr, double value)
AS_EXTERN as_integer * as_integer_init(as_integer *integer, int64_t value)
@ AS_CDT_OP_LIST_INCREMENT
@ AS_CDT_OP_LIST_GET_BY_INDEX_RANGE
@ AS_CDT_OP_LIST_REMOVE_ALL_BY_VALUE
@ AS_CDT_OP_LIST_GET_BY_RANK
@ AS_CDT_OP_LIST_GET_RANGE
@ AS_CDT_OP_LIST_REMOVE_BY_RANK_RANGE
@ AS_CDT_OP_LIST_REMOVE_BY_VALUE_INTERVAL
@ AS_CDT_OP_LIST_GET
@ AS_CDT_OP_LIST_REMOVE_BY_RANK
@ AS_CDT_OP_LIST_APPEND
@ AS_CDT_OP_LIST_POP_RANGE
@ AS_CDT_OP_LIST_SET
@ AS_CDT_OP_LIST_REMOVE_RANGE
@ AS_CDT_OP_LIST_CLEAR
@ AS_CDT_OP_LIST_GET_BY_INDEX
@ AS_CDT_OP_LIST_REMOVE_BY_VALUE_REL_RANK_RANGE
@ AS_CDT_OP_LIST_SIZE
@ AS_CDT_OP_LIST_POP
@ AS_CDT_OP_LIST_REMOVE_BY_VALUE_LIST
@ AS_CDT_OP_LIST_GET_ALL_BY_VALUE
@ AS_CDT_OP_LIST_SET_TYPE
@ AS_CDT_OP_LIST_SORT
@ AS_CDT_OP_LIST_REMOVE_BY_INDEX_RANGE
@ AS_CDT_OP_LIST_APPEND_ITEMS
@ AS_CDT_OP_LIST_GET_BY_VALUE_REL_RANK_RANGE
@ AS_CDT_OP_LIST_REMOVE_BY_INDEX
@ AS_CDT_OP_LIST_GET_BY_RANK_RANGE
@ AS_CDT_OP_LIST_GET_BY_VALUE_LIST
@ AS_CDT_OP_LIST_INSERT
@ AS_CDT_OP_LIST_REMOVE
@ AS_CDT_OP_LIST_INSERT_ITEMS
@ AS_CDT_OP_LIST_TRIM
@ AS_CDT_OP_LIST_GET_BY_VALUE_INTERVAL
#define AS_EXTERN
Definition as_std.h:25
AS_EXTERN as_string * as_string_init(as_string *string, char *value, bool free)
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_trim(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index, uint64_t count)
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_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_append_int64(as_operations *ops, const char *name, int64_t value)
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)
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)
static bool as_operations_add_list_get_by_value(as_operations *ops, const char *name, as_val *value, 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_set_double(as_operations *ops, const char *name, int64_t index, double value)
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_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_append_str(as_operations *ops, const char *name, const char *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_pop(as_operations *ops, const char *name, int64_t index)
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_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_get_range(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index, uint64_t count)
static bool as_operations_add_list_pop_range(as_operations *ops, const char *name, int64_t index, uint64_t count)
static bool as_operations_add_list_increment(as_operations *ops, const char *name, int64_t index, as_val *incr)
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_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_size(as_operations *ops, const char *name)
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_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_insert_raw(as_operations *ops, const char *name, int64_t index, const uint8_t *value, uint32_t size)
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_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_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_items(as_operations *ops, const char *name, as_list *list)
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)
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_list_order
AS_EXTERN bool as_operations_list_pop_range_from(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index)
static bool as_operations_add_list_get_by_rank(as_operations *ops, const char *name, int64_t rank, 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_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)
static bool as_operations_add_list_get_range_from(as_operations *ops, const char *name, 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_size(as_operations *ops, const char *name, as_cdt_ctx *ctx)
static bool as_operations_add_list_insert_int64(as_operations *ops, const char *name, int64_t index, int64_t value)
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_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_remove_range(as_operations *ops, const char *name, int64_t index, uint64_t count)
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_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_remove_by_index_range(as_operations *ops, const char *name, int64_t index, uint64_t count, 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)
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)
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)
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_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_get_by_index_range(as_operations *ops, const char *name, int64_t index, uint64_t count, as_list_return_type return_type)
static void as_list_policy_init(as_list_policy *policy)
static bool as_operations_add_list_append_double(as_operations *ops, const char *name, double value)
static bool as_operations_add_list_insert_double(as_operations *ops, const char *name, int64_t index, double value)
static bool as_operations_add_list_remove_range_from(as_operations *ops, const char *name, int64_t index)
static bool as_operations_add_list_remove_by_rank(as_operations *ops, const char *name, int64_t rank, 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_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_by_index(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index, as_list_return_type return_type)
as_list_write_flags
static bool as_operations_add_list_clear(as_operations *ops, const char *name)
AS_EXTERN bool as_operations_list_get_range_from(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index)
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)
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)
as_list_return_type
static bool as_operations_add_list_append(as_operations *ops, const char *name, as_val *val)
static bool as_operations_add_list_remove_by_index(as_operations *ops, const char *name, 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_insert_items(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_list_policy *policy, int64_t index, as_list *list)
static bool as_operations_add_list_sort(as_operations *ops, const char *name, as_list_sort_flags flags)
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_sort(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_list_sort_flags flags)
static bool as_operations_add_list_remove_by_value(as_operations *ops, const char *name, as_val *value, as_list_return_type return_type)
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_rank_range(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t rank, uint64_t count, as_list_return_type return_type)
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)
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_get(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)
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_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_append_strp(as_operations *ops, const char *name, const char *value, bool free)
static bool as_operations_add_list_insert_str(as_operations *ops, const char *name, int64_t index, const char *value)
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)
static bool as_operations_add_list_append_raw(as_operations *ops, const char *name, const uint8_t *value, uint32_t size)
as_list_sort_flags
AS_EXTERN bool as_operations_list_remove_range(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index, uint64_t count)
static bool as_operations_add_list_insert_items(as_operations *ops, const char *name, int64_t index, 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_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_trim(as_operations *ops, const char *name, int64_t index, uint64_t count)
static bool as_operations_add_list_set_order(as_operations *ops, const char *name, as_list_order order)
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)
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)
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_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_set_order(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_list_order order)
static bool as_operations_add_list_pop_range_from(as_operations *ops, const char *name, int64_t index)
AS_EXTERN bool as_operations_list_get(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index)
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_remove_by_value(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_val *value, as_list_return_type return_type)
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)
AS_EXTERN bool as_operations_list_pop(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index)
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_remove(as_operations *ops, const char *name, int64_t index)
static bool as_operations_add_list_insert(as_operations *ops, const char *name, int64_t index, as_val *val)
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_append_with_policy(as_operations *ops, const char *name, as_list_policy *policy, as_val *val)
static bool as_operations_add_list_set_int64(as_operations *ops, const char *name, int64_t index, int64_t value)
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_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_remove(as_operations *ops, const char *name, as_cdt_ctx *ctx, int64_t index)
@ AS_LIST_UNORDERED
@ AS_LIST_WRITE_NO_FAIL
@ AS_LIST_WRITE_DEFAULT
@ AS_LIST_WRITE_INSERT_BOUNDED
@ AS_LIST_WRITE_ADD_UNIQUE
@ AS_LIST_WRITE_PARTIAL
@ AS_LIST_RETURN_EXISTS
@ AS_LIST_RETURN_REVERSE_INDEX
@ AS_LIST_RETURN_VALUE
@ AS_LIST_RETURN_NONE
@ AS_LIST_RETURN_REVERSE_RANK
@ AS_LIST_RETURN_RANK
@ AS_LIST_RETURN_COUNT
@ AS_LIST_RETURN_INDEX
@ AS_LIST_RETURN_INVERTED
@ AS_LIST_SORT_DROP_DUPLICATES
@ AS_LIST_SORT_DEFAULT
AS_EXTERN bool as_operations_list_create_all(as_operations *ops, const char *name, as_cdt_ctx *ctx, as_list_order order, bool pad, bool persist_index)
as_list_order order
as_list_write_flags flags