All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
as_query.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2016 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 #pragma GCC diagnostic ignored "-Waddress"
19 
21 #include <aerospike/as_bin.h>
22 #include <aerospike/as_key.h>
23 #include <aerospike/as_list.h>
24 #include <aerospike/as_udf.h>
25 
26 #include <stdarg.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /******************************************************************************
33  * MACROS
34  *****************************************************************************/
35 
36 /**
37  * Macro for setting setting the STRING_EQUAL predicate.
38  *
39  * ~~~~~~~~~~{.c}
40  * as_query_where(query, "bin1", as_string_equals("abc"));
41  * ~~~~~~~~~~
42  *
43  * @relates as_query
44  */
45 #define as_string_equals(__val) AS_PREDICATE_EQUAL, AS_INDEX_TYPE_DEFAULT, AS_INDEX_STRING, __val
46 
47 /**
48  * Macro for setting setting the INTEGER_EQUAL predicate.
49  *
50  * ~~~~~~~~~~{.c}
51  * as_query_where(query, "bin1", as_integer_equals(123));
52  * ~~~~~~~~~~
53  *
54  * @relates as_query
55  */
56 #define as_integer_equals(__val) AS_PREDICATE_EQUAL, AS_INDEX_TYPE_DEFAULT, AS_INDEX_NUMERIC, (int64_t)__val
57 
58 /**
59  * Macro for setting setting the INTEGER_RANGE predicate.
60  *
61  * ~~~~~~~~~~{.c}
62  * as_query_where(query, "bin1", as_integer_range(1,100));
63  * ~~~~~~~~~~
64  *
65  * @relates as_query
66  * @ingroup query_object
67  */
68 #define as_integer_range(__min, __max) AS_PREDICATE_RANGE, AS_INDEX_TYPE_DEFAULT, AS_INDEX_NUMERIC, (int64_t)__min, (int64_t)__max
69 
70 /**
71  * Macro for setting setting the RANGE predicate.
72  *
73  * ~~~~~~~~~~{.c}
74  * as_query_where(query, "bin1", as_range(LIST,NUMERIC,1,100));
75  * ~~~~~~~~~~
76  *
77  * @relates as_query
78  * @ingroup query_object
79  */
80 #define as_range(indextype, datatype, __min, __max) AS_PREDICATE_RANGE, AS_INDEX_TYPE_ ##indextype, AS_INDEX_ ##datatype, __min, __max
81 
82 /**
83  * Macro for setting setting the CONTAINS predicate.
84  *
85  * ~~~~~~~~~~{.c}
86  * as_query_where(query, "bin1", as_contains(LIST,STRING,"val"));
87  * ~~~~~~~~~~
88  *
89  * @relates as_query
90  * @ingroup query_object
91  */
92 #define as_contains(indextype, datatype, __val) AS_PREDICATE_EQUAL, AS_INDEX_TYPE_ ##indextype, AS_INDEX_ ##datatype, __val
93 
94 /**
95  * Macro for setting setting the EQUALS predicate.
96  *
97  * ~~~~~~~~~~{.c}
98  * as_query_where(query, "bin1", as_equals(NUMERIC,5));
99  * ~~~~~~~~~~
100  *
101  * @relates as_query
102  * @ingroup query_object
103  */
104 #define as_equals(datatype, __val) AS_PREDICATE_EQUAL, AS_INDEX_TYPE_DEFAULT, AS_INDEX_ ##datatype, __val
105 
106 #define as_geo_within(__val) AS_PREDICATE_RANGE, AS_INDEX_TYPE_DEFAULT, AS_INDEX_GEO2DSPHERE, __val
107 
108 #define as_geo_contains(__val) AS_PREDICATE_RANGE, AS_INDEX_TYPE_DEFAULT, AS_INDEX_GEO2DSPHERE, __val
109 
110 
111 /******************************************************************************
112  * TYPES
113  *****************************************************************************/
114 
115 /**
116  * Union of supported predicates
117  */
118 typedef union as_predicate_value_u {
119 
120  /**
121  * String Value
122  */
123  char * string;
124 
125  /**
126  * Integer Value
127  */
128  int64_t integer;
129 
130  /**
131  * Integer Range Value
132  */
133  struct {
134 
135  /**
136  * Minimum value
137  */
138  int64_t min;
139 
140  /**
141  * Maximum value
142  */
143  int64_t max;
144 
145  } integer_range;
146 
148 
149 /**
150  * The types of predicates supported.
151  */
152 typedef enum as_predicate_type_e {
153 
154  /**
155  * String Equality Predicate.
156  * Requires as_predicate_value.string to be set.
157  */
159 
162 
163 /**
164  * Defines a predicate, including the bin, type of predicate and the value
165  * for the predicate.
166  */
167 typedef struct as_predicate_s {
168 
169  /**
170  * Bin to apply the predicate to
171  */
173 
174  /**
175  * The predicate type, dictates which values to use from the union
176  */
178 
179  /**
180  * The value for the predicate.
181  */
183 
184  /*
185  * The type of data user wants to query
186  */
187 
189 
190  /*
191  * The type of index predicate is on
192  */
194 } as_predicate;
195 
196 /**
197  * Enumerations defining the direction of an ordering.
198  */
199 typedef enum as_order_e {
200 
201  /**
202  * Ascending order
203  */
205 
206  /**
207  * bin should be in ascending order
208  */
210 
211 } as_order;
212 
213 
214 /**
215  * Defines the direction a bin should be ordered by.
216  */
217 typedef struct as_ordering_s {
218 
219  /**
220  * Name of the bin to sort by
221  */
223 
224  /**
225  * Direction of the sort
226  */
228 
229 } as_ordering;
230 
231 /**
232  * Sequence of bins which should be selected during a query.
233  *
234  * Entries can either be initialized on the stack or on the heap.
235  *
236  * Initialization should be performed via a query object, using:
237  * - as_query_select_init()
238  * - as_query_select_inita()
239  */
240 typedef struct as_query_bins_s {
241 
242  /**
243  * @private
244  * If true, then as_query_destroy() will free this instance.
245  */
246  bool _free;
247 
248  /**
249  * Number of entries allocated
250  */
251  uint16_t capacity;
252 
253  /**
254  * Number of entries used
255  */
256  uint16_t size;
257 
258  /**
259  * Sequence of entries
260  */
262 
263 } as_query_bins;
264 
265 /**
266  * Sequence of predicates to be applied to a query.
267  *
268  * Entries can either be initialized on the stack or on the heap.
269  *
270  * Initialization should be performed via a query object, using:
271  * - as_query_where_init()
272  * - as_query_where_inita()
273  */
274 typedef struct as_query_predicates_s {
275 
276  /**
277  * @private
278  * If true, then as_query_destroy() will free this instance.
279  */
280  bool _free;
281 
282  /**
283  * Number of entries allocated
284  */
285  uint16_t capacity;
286 
287  /**
288  * Number of entries used
289  */
290  uint16_t size;
291 
292  /**
293  * Sequence of entries
294  */
296 
298 
299 /**
300  * Sequence of ordering to be applied to a query results.
301  *
302  * Entries can either be initialized on the stack or on the heap.
303  *
304  * Initialization should be performed via a query object, using:
305  * - as_query_orderby_init()
306  * - as_query_orderby_inita()
307  */
308 typedef struct as_query_sort_s {
309 
310  /**
311  * @private
312  * If true, then as_query_destroy() will free this instance.
313  */
314  bool _free;
315 
316  /**
317  * Number of entries allocated
318  */
319  uint16_t capacity;
320 
321  /**
322  * Number of entries used
323  */
324  uint16_t size;
325 
326  /**
327  * Sequence of entries
328  */
330 
332 
333 
334 /**
335  * The as_query object is used define a query to be executed in the datasbase.
336  *
337  * ## Initialization
338  *
339  * Before using an as_query, it must be initialized via either:
340  * - as_query_init()
341  * - as_query_new()
342  *
343  * as_query_init() should be used on a stack allocated as_query. It will
344  * initialize the as_query with the given namespace and set. On success,
345  * it will return a pointer to the initialized as_query. Otherwise, NULL
346  * is returned.
347  *
348  * ~~~~~~~~~~{.c}
349  * as_query query;
350  * as_query_init(&query, "namespace", "set");
351  * ~~~~~~~~~~
352  *
353  * as_query_new() should be used to allocate and initialize a heap allocated
354  * as_query. It will allocate the as_query, then initialized it with the
355  * given namespace and set. On success, it will return a pointer to the
356  * initialized as_query. Otherwise, NULL is returned.
357  *
358  * ~~~~~~~~~~{.c}
359  * as_query * query = as_query_new("namespace", "set");
360  * ~~~~~~~~~~
361  *
362  * ## Destruction
363  *
364  * When you are finished with the as_query, you can destroy it and associated
365  * resources:
366  *
367  * ~~~~~~~~~~{.c}
368  * as_query_destroy(query);
369  * ~~~~~~~~~~
370  *
371  * ## Usage
372  *
373  * The following explains how to use an as_query to build a query.
374  *
375  * ### Selecting Bins
376  *
377  * as_query_select() is used to specify the bins to be selected by the query.
378  *
379  * ~~~~~~~~~~{.c}
380  * as_query_select(query, "bin1");
381  * as_query_select(query, "bin2");
382  * ~~~~~~~~~~
383  *
384  * Before adding bins to select, the select structure must be initialized via
385  * either:
386  * - as_query_select_inita() - Initializes the structure on the stack.
387  * - as_query_select_init() - Initializes the structure on the heap.
388  *
389  * Both functions are given the number of bins to be selected.
390  *
391  * A complete example using as_query_select_inita()
392  *
393  * ~~~~~~~~~~{.c}
394  * as_query_select_inita(query, 2);
395  * as_query_select(query, "bin1");
396  * as_query_select(query, "bin2");
397  * ~~~~~~~~~~
398  *
399  *
400  * ### Predicates on Bins
401  *
402  * as_query_where() is used to specify predicates to be added to the the query.
403  *
404  * **Note:** Currently, a single where predicate is supported. To do more advanced filtering,
405  * you will want to use a UDF to process the result set on the server.
406  *
407  * ~~~~~~~~~~{.c}
408  * as_query_where(query, "bin1", as_string_equals("abc"));
409  * ~~~~~~~~~~
410  *
411  * The predicates that you can apply to a bin include:
412  * - as_string_equals() - Test for string equality.
413  * - as_integer_equals() - Test for integer equality.
414  * - as_integer_range() - Test for integer within a range.
415  *
416  * Before adding predicates, the where structure must be initialized. To
417  * initialize the where structure, you can choose to use one of the following:
418  * - as_query_where_inita() - Initializes the structure on the stack.
419  * - as_query_where_init() - Initializes the structure on the heap.
420  *
421  * Both functions are given the number of predicates to be added.
422  *
423  * A complete example using as_query_where_inita():
424  *
425  * ~~~~~~~~~~{.c}
426  * as_query_where_inita(query, 1);
427  * as_query_where(query, "bin1", as_string_equals("abc"));
428  * ~~~~~~~~~~
429  *
430  *
431  * ### Sorting Results
432  *
433  * as_query_orderby() is used to specify ordering of results of a query.
434  *
435  * ~~~~~~~~~~{.c}
436  * as_query_orderby(query, "bin1", AS_ORDER_ASCENDING);
437  * ~~~~~~~~~~
438  *
439  * The sort order can be:
440  * - `AS_ORDER_ASCENDING`
441  * - `AS_ORDER_DESCENDING`
442  *
443  * Before adding ordering, the orderby structure must be initialized via
444  * either:
445  * - as_query_orderby_inita() - Initializes the structure on the stack.
446  * - as_query_orderby_init() - Initializes the structure on the heap.
447  *
448  * Both functions are given the number of orderings to be added.
449  *
450  * A complete example using as_query_orderby_inita():
451  *
452  * ~~~~~~~~~~{.c}
453  * as_query_orderby_inita(query, 2);
454  * as_query_orderby(query, "bin1", AS_ORDER_ASCENDING);
455  * as_query_orderby(query, "bin2", AS_ORDER_ASCENDING);
456  * ~~~~~~~~~~
457  *
458  * ### Applying a UDF to Query Results
459  *
460  * A UDF can be applied to the results of a query.
461  *
462  * To define the UDF for the query, use as_query_apply().
463  *
464  * ~~~~~~~~~~{.c}
465  * as_query_apply(query, "udf_module", "udf_function", arglist);
466  * ~~~~~~~~~~
467  *
468  * @ingroup client_objects
469  */
470 typedef struct as_query_s {
471 
472  /**
473  * @private
474  * If true, then as_query_destroy() will free this instance.
475  */
476  bool _free;
477 
478  /**
479  * Namespace to be queried.
480  *
481  * Should be initialized via either:
482  * - as_query_init() - To initialize a stack allocated query.
483  * - as_query_new() - To heap allocate and initialize a query.
484  */
486 
487  /**
488  * Set to be queried.
489  *
490  * Should be initialized via either:
491  * - as_query_init() - To initialize a stack allocated query.
492  * - as_query_new() - To heap allocate and initialize a query.
493  */
495 
496  /**
497  * Name of bins to select.
498  *
499  * Use either of the following function to initialize:
500  * - as_query_select_init() - To initialize on the heap.
501  * - as_query_select_inita() - To initialize on the stack.
502  *
503  * Use as_query_select() to populate.
504  */
506 
507  /**
508  * Predicates for filtering.
509  *
510  * Use either of the following function to initialize:
511  * - as_query_where_init() - To initialize on the heap.
512  * - as_query_where_inita() - To initialize on the stack.
513  *
514  * Use as_query_where() to populate.
515  */
517 
518  /**
519  * Bins to order by.
520  *
521  * Use either of the following function to initialize:
522  * - as_query_orderby_init() - To initialize on the heap.
523  * - as_query_orderby_inita() - To initialize on the stack.
524  *
525  * Use as_query_orderby() to populate.
526  */
528 
529  /**
530  * UDF to apply to results of the query
531  *
532  * Should be set via `as_query_apply()`.
533  */
535 
536 } as_query;
537 
538 /******************************************************************************
539  * INSTANCE FUNCTIONS
540  *****************************************************************************/
541 
542 /**
543  * Initialize a stack allocated as_query.
544  *
545  * ~~~~~~~~~~{.c}
546  * as_query query;
547  * as_query_init(&query, "test", "demo");
548  * ~~~~~~~~~~
549  *
550  * @param query The query to initialize.
551  * @param ns The namespace to query.
552  * @param set The set to query.
553  *
554  * @return On success, the initialized query. Otherwise NULL.
555  *
556  * @relates as_query
557  */
558 as_query * as_query_init(as_query * query, const as_namespace ns, const as_set set);
559 
560 /**
561  * Create and initialize a new heap allocated as_query.
562  *
563  * ~~~~~~~~~~{.c}
564  * as_query * query = as_query_new("test", "demo");
565  * ~~~~~~~~~~
566  *
567  * @param ns The namespace to query.
568  * @param set The set to query.
569  *
570  * @return On success, the new query. Otherwise NULL.
571  *
572  * @relates as_query
573  * @ingroup query_object
574  */
575 as_query * as_query_new(const as_namespace ns, const as_set set);
576 
577 /**
578  * Destroy the query and associated resources.
579  *
580  * ~~~~~~~~~~{.c}
581  * as_query_destroy(scan);
582  * ~~~~~~~~~~
583  *
584  * @param query The query to destroy.
585  *
586  * @relates as_query
587  */
588 void as_query_destroy(as_query * query);
589 
590 /******************************************************************************
591  * SELECT FUNCTIONS
592  *****************************************************************************/
593 
594 /**
595  * Initializes `as_query.select` with a capacity of `n` using `alloca`
596  *
597  * For heap allocation, use `as_query_select_init()`.
598  *
599  * ~~~~~~~~~~{.c}
600  * as_query_select_inita(&query, 2);
601  * as_query_select(&query, "bin1");
602  * as_query_select(&query, "bin2");
603  * ~~~~~~~~~~
604  *
605  * @param __query The query to initialize.
606  * @param __n The number of bins to allocate.
607  *
608  * @relates as_query
609  * @ingroup query_object
610  */
611 #define as_query_select_inita(__query, __n) \
612  do { \
613  if ( (__query) != NULL && (__query)->select.entries == NULL ) {\
614  (__query)->select.entries = (as_bin_name *) alloca(__n * sizeof(as_bin_name));\
615  if ( (__query)->select.entries ) { \
616  (__query)->select._free = false;\
617  (__query)->select.capacity = __n;\
618  (__query)->select.size = 0;\
619  }\
620  } \
621  } while(0)
622 
623 /**
624  * Initializes `as_query.select` with a capacity of `n` using `malloc()`.
625  *
626  * For stack allocation, use `as_query_select_inita()`.
627  *
628  * ~~~~~~~~~~{.c}
629  * as_query_select_init(&query, 2);
630  * as_query_select(&query, "bin1");
631  * as_query_select(&query, "bin2");
632  * ~~~~~~~~~~
633  *
634  * @param query The query to initialize.
635  * @param n The number of bins to allocate.
636  *
637  * @return On success, the initialized. Otherwise an error occurred.
638  *
639  * @relates as_query
640  * @ingroup query_object
641  */
642 bool as_query_select_init(as_query * query, uint16_t n);
643 
644 /**
645  * Select bins to be projected from matching records.
646  *
647  * You have to ensure as_query.select has sufficient capacity, prior to
648  * adding a bin. If capacity is sufficient then false is returned.
649  *
650  * ~~~~~~~~~~{.c}
651  * as_query_select_init(&query, 2);
652  * as_query_select(&query, "bin1");
653  * as_query_select(&query, "bin2");
654  * ~~~~~~~~~~
655  *
656  * @param query The query to modify.
657  * @param bin The name of the bin to select.
658  *
659  * @return On success, true. Otherwise an error occurred.
660  *
661  * @relates as_query
662  * @ingroup query_object
663  */
664 bool as_query_select(as_query * query, const char * bin);
665 
666 /******************************************************************************
667  * WHERE FUNCTIONS
668  *****************************************************************************/
669 
670 /**
671  * Initializes `as_query.where` with a capacity of `n` using `alloca()`.
672  *
673  * For heap allocation, use `as_query_where_init()`.
674  *
675  * ~~~~~~~~~~{.c}
676  * as_query_where_inita(&query, 3);
677  * as_query_where(&query, "bin1", as_string_equals("abc"));
678  * as_query_where(&query, "bin2", as_integer_equals(123));
679  * as_query_where(&query, "bin3", as_integer_range(0,123));
680  * ~~~~~~~~~~
681  *
682  * @param __query The query to initialize.
683  * @param __n The number of as_predicate to allocate.
684  *
685  * @return On success, true. Otherwise an error occurred.
686  *
687  * @relates as_query
688  */
689 #define as_query_where_inita(__query, __n) \
690  do { \
691  if ( (__query) != NULL && (__query)->where.entries == NULL ) {\
692  (__query)->where.entries = (as_predicate *) alloca(__n * sizeof(as_predicate));\
693  if ( (__query)->where.entries ) { \
694  (__query)->where._free = false;\
695  (__query)->where.capacity = __n;\
696  (__query)->where.size = 0;\
697  }\
698  } \
699  } while(0)
700 
701 /**
702  * Initializes `as_query.where` with a capacity of `n` using `malloc()`.
703  *
704  * For stack allocation, use `as_query_where_inita()`.
705  *
706  * ~~~~~~~~~~{.c}
707  * as_query_where_init(&query, 3);
708  * as_query_where(&query, "bin1", as_string_equals("abc"));
709  * as_query_where(&query, "bin1", as_integer_equals(123));
710  * as_query_where(&query, "bin1", as_integer_range(0,123));
711  * ~~~~~~~~~~
712  *
713  * @param query The query to initialize.
714  * @param n The number of as_predicate to allocate.
715  *
716  * @return On success, true. Otherwise an error occurred.
717  *
718  * @relates as_query
719  */
720 bool as_query_where_init(as_query * query, uint16_t n);
721 
722 /**
723  * Add a predicate to the query.
724  *
725  * You have to ensure as_query.where has sufficient capacity, prior to
726  * adding a predicate. If capacity is insufficient then false is returned.
727  *
728  * String predicates are not owned by as_query. If the string is allocated
729  * on the heap, the caller is responsible for freeing the string after the query
730  * has been executed. as_query_destroy() will not free this string predicate.
731  *
732  * ~~~~~~~~~~{.c}
733  * as_query_where_init(&query, 3);
734  * as_query_where(&query, "bin1", as_string_equals("abc"));
735  * as_query_where(&query, "bin1", as_integer_equals(123));
736  * as_query_where(&query, "bin1", as_integer_range(0,123));
737  * ~~~~~~~~~~
738  *
739  * @param query The query add the predicate to.
740  * @param bin The name of the bin the predicate will apply to.
741  * @param type The type of predicate.
742  * @param itype The type of index.
743  * @param dtype The underlying data type that the index is based on.
744  * @param ... The values for the predicate.
745  *
746  * @return On success, true. Otherwise an error occurred.
747  *
748  * @relates as_query
749  */
750 bool as_query_where(as_query * query, const char * bin, as_predicate_type type, as_index_type itype, as_index_datatype dtype, ... );
751 
752 /******************************************************************************
753  * ORDERBY FUNCTIONS
754  *****************************************************************************/
755 
756 /**
757  * Initializes `as_query.where` with a capacity of `n` using `alloca()`.
758  *
759  * For heap allocation, use `as_query_where_init()`.
760  *
761  * ~~~~~~~~~~{.c}
762  * as_query_orderby_inita(&query, 1);
763  * as_query_orderby(&query, "bin1", AS_ORDER_ASCENDING);
764  * ~~~~~~~~~~
765  *
766  * @param __query The query to initialize.
767  * @param __n The number of as_orders to allocate.
768  *
769  * @return On success, true. Otherwise an error occurred.
770  *
771  * @relates as_query
772  */
773 #define as_query_orderby_inita(__query, __n) \
774  do { \
775  if ( (__query) != NULL && (__query)->orderby.entries == NULL ) {\
776  (__query)->orderby.entries = (as_ordering *) alloca(__n * sizeof(as_ordering));\
777  if ( (__query)->orderby.entries ) { \
778  (__query)->orderby._free = false;\
779  (__query)->orderby.capacity = __n;\
780  (__query)->orderby.size = 0;\
781  }\
782  } \
783  } while(0)
784 
785 /**
786  * Initializes `as_query.orderby` with a capacity of `n` using `malloc()`.
787  *
788  * For stack allocation, use `as_query_orderby_inita()`.
789  *
790  * ~~~~~~~~~~{.c}
791  * as_query_orderby_init(&query, 1);
792  * as_query_orderby(&query, "bin1", AS_ORDER_ASCENDING);
793  * ~~~~~~~~~~
794  *
795  * @param query The query to initialize.
796  * @param n The number of as_orders to allocate.
797  *
798  * @return On success, true. Otherwise an error occurred.
799  *
800  * @relates as_query
801  */
802 bool as_query_orderby_init(as_query * query, uint16_t n);
803 
804 /**
805  * Add a bin to sort by to the query.
806  *
807  * You have to ensure as_query.orderby has sufficient capacity, prior to
808  * adding an ordering. If capacity is insufficient then false is returned.
809  *
810  * ~~~~~~~~~~{.c}
811  * as_query_orderby_init(&query, 1);
812  * as_query_orderby(&query, "bin1", AS_ORDER_ASCENDING);
813  * ~~~~~~~~~~
814  *
815  * @param query The query to modify.
816  * @param bin The name of the bin to sort by.
817  * @param order The sort order: `AS_ORDER_ASCENDING` or `AS_ORDER_DESCENDING`.
818  *
819  * @return On success, true. Otherwise an error occurred.
820  *
821  * @relates as_query
822  */
823 bool as_query_orderby(as_query * query, const char * bin, as_order order);
824 
825 /******************************************************************************
826  * QUERY MODIFIER FUNCTIONS
827  *****************************************************************************/
828 
829 /**
830  * Apply a function to the results of the query.
831  *
832  * ~~~~~~~~~~{.c}
833  * as_query_apply(&query, "my_module", "my_function", NULL);
834  * ~~~~~~~~~~
835  *
836  * @param query The query to apply the function to.
837  * @param module The module containing the function to invoke.
838  * @param function The function in the module to invoke.
839  * @param arglist The arguments to use when calling the function.
840  *
841  * @return On success, true. Otherwise an error occurred.
842  *
843  * @relates as_query
844  */
845 bool as_query_apply(as_query * query, const char * module, const char * function, const as_list * arglist);
846 
847 #ifdef __cplusplus
848 } // end extern "C"
849 #endif
bool as_query_where(as_query *query, const char *bin, as_predicate_type type, as_index_type itype, as_index_datatype dtype,...)
uint8_t type
Definition: as_proto.h:893
as_namespace ns
Definition: as_scan.h:359
as_query * as_query_init(as_query *query, const as_namespace ns, const as_set set)
as_predicate_type type
Definition: as_query.h:177
as_query * as_query_new(const as_namespace ns, const as_set set)
as_index_datatype dtype
Definition: as_query.h:188
as_index_type itype
Definition: as_query.h:193
bool as_query_orderby(as_query *query, const char *bin, as_order order)
bool as_query_select(as_query *query, const char *bin)
as_udf_call apply
Definition: as_query.h:534
bool as_query_where_init(as_query *query, uint16_t n)
char as_namespace[AS_NAMESPACE_MAX_SIZE]
Definition: as_key.h:66
void as_query_destroy(as_query *query)
uint16_t capacity
Definition: as_query.h:319
as_predicate * entries
Definition: as_query.h:295
uint16_t size
Definition: as_query.h:256
as_bin_name bin
Definition: as_query.h:222
as_order order
Definition: as_query.h:227
as_query_bins select
Definition: as_query.h:505
as_bin_name bin
Definition: as_query.h:172
uint16_t capacity
Definition: as_query.h:285
as_namespace ns
Definition: as_query.h:485
bool as_query_select_init(as_query *query, uint16_t n)
bool as_query_orderby_init(as_query *query, uint16_t n)
as_bin_name * entries
Definition: as_query.h:261
as_index_type
as_order
Definition: as_query.h:199
as_index_datatype
uint16_t size
Definition: as_query.h:324
as_set set
Definition: as_query.h:494
bool _free
Definition: as_query.h:476
uint16_t capacity
Definition: as_query.h:251
char as_bin_name[AS_BIN_NAME_MAX_SIZE]
Definition: as_bin.h:52
bool as_query_apply(as_query *query, const char *module, const char *function, const as_list *arglist)
as_predicate_value value
Definition: as_query.h:182
as_query_predicates where
Definition: as_query.h:516
as_predicate_type
Definition: as_query.h:152
char as_set[AS_SET_MAX_SIZE]
Definition: as_key.h:73
as_query_ordering orderby
Definition: as_query.h:527
as_ordering * entries
Definition: as_query.h:329