![]() |
The as_query object is used define a query to be executed in the datasbase.
Before using an as_query, it must be initialized via either:
as_query_init() should be used on a stack allocated as_query. It will initialize the as_query with the given namespace and set. On success, it will return a pointer to the initialized as_query. Otherwise, NULL is returned.
as_query_new() should be used to allocate and initialize a heap allocated as_query. It will allocate the as_query, then initialized it with the given namespace and set. On success, it will return a pointer to the initialized as_query. Otherwise, NULL is returned.
When you are finished with the as_query, you can destroy it and associated resources:
The following explains how to use an as_query to build a query.
as_query_select() is used to specify the bins to be selected by the query.
Before adding bins to select, the select structure must be initialized via either:
Both functions are given the number of bins to be selected.
A complete example using as_query_select_inita()
as_query_where() is used to specify predicates to be added to the the query.
Note: Currently, a single where predicate is supported. To do more advanced filtering, you will want to use a UDF to process the result set on the server.
The predicates that you can apply to a bin include:
Before adding predicates, the where structure must be initialized. To initialize the where structure, you can choose to use one of the following:
Both functions are given the number of predicates to be added.
A complete example using as_query_where_inita():
as_query_orderby() is used to specify ordering of results of a query.
The sort order can be:
AS_ORDER_ASCENDING
AS_ORDER_DESCENDING
Before adding ordering, the orderby structure must be initialized via either:
Both functions are given the number of orderings to be added.
A complete example using as_query_orderby_inita():
A UDF can be applied to the results of a query.
To define the UDF for the query, use as_query_apply().
Definition at line 425 of file as_query.h.
#include "as_query.h"
Data Fields | |
as_udf_call | apply |
as_namespace | ns |
as_query_ordering | orderby |
as_query_bins | select |
as_set | set |
as_query_predicates | where |
Private Attributes | |
bool | _free |
Related Functions | |
(Note that these are not member functions.) | |
bool | as_query_apply (as_query *query, const char *module, const char *function, const as_list *arglist) |
void | as_query_destroy (as_query *query) |
as_query * | as_query_init (as_query *query, const as_namespace ns, const as_set set) |
as_query * | as_query_new (const as_namespace ns, const as_set set) |
bool | as_query_orderby (as_query *query, const char *bin, as_order order) |
bool | as_query_orderby_init (as_query *query, uint16_t n) |
#define | as_query_orderby_inita(__query, __n) |
bool | as_query_select (as_query *query, const char *bin) |
bool | as_query_select_init (as_query *query, uint16_t n) |
#define | as_query_select_inita(__query, __n) |
bool | as_query_where (as_query *query, const char *bin, as_predicate_type type,...) |
bool | as_query_where_init (as_query *query, uint16_t n) |
#define | as_query_where_inita(__query, __n) |
#define | integer_equals(__val) AS_PREDICATE_INTEGER_EQUAL, __val |
#define | integer_range(__min, __max) AS_PREDICATE_INTEGER_RANGE, __min, __max |
#define | string_equals(__val) AS_PREDICATE_STRING_EQUAL, __val |
|
related |
Apply a function to the results of the query.
query | The query to apply the function to. |
module | The module containing the function to invoke. |
function | The function in the module to invoke. |
arglist | The arguments to use when calling the function. |
|
related |
Destroy the query and associated resources.
query | The query to destroy. |
|
related |
|
related |
Create and initialize a new heap allocated as_query.
ns | The namespace to query. |
set | The set to query. |
Add a bin to sort by to the query.
You have to ensure as_query.orderby has sufficient capacity, prior to adding an ordering. If capacity is insufficient then false is returned.
query | The query to modify. |
bin | The name of the bin to sort by. |
order | The sort order: AS_ORDER_ASCENDING or AS_ORDER_DESCENDING . |
|
related |
Initializes as_query.orderby
with a capacity of n
using malloc()
.
For stack allocation, use as_query_orderby_inita()
.
query | The query to initialize. |
n | The number of as_orders to allocate. |
|
related |
Initializes as_query.where
with a capacity of n
using alloca()
.
For heap allocation, use as_query_where_init()
.
__query | The query to initialize. |
__n | The number of as_orders to allocate. |
Definition at line 718 of file as_query.h.
|
related |
Select bins to be projected from matching records.
You have to ensure as_query.select has sufficient capacity, prior to adding a bin. If capacity is sufficient then false is returned.
query | The query to modify. |
bin | The name of the bin to select. |
|
related |
Initializes as_query.select
with a capacity of n
using malloc()
.
For stack allocation, use as_query_select_inita()
.
query | The query to initialize. |
n | The number of bins to allocate. |
|
related |
Initializes as_query.select
with a capacity of n
using alloca
For heap allocation, use as_query_select_init()
.
__query | The query to initialize. |
__n | The number of bins to allocate. |
Definition at line 566 of file as_query.h.
|
related |
Add a predicate to the query.
You have to ensure as_query.where has sufficient capacity, prior to adding a predicate. If capacity is insufficient then false is returned.
query | The query add the predicate to. |
bin | The name of the bin the predicate will apply to. |
type | The type of predicate. |
... | The values for the predicate. |
|
related |
Initializes as_query.where
with a capacity of n
using malloc()
.
For stack allocation, use as_query_where_inita()
.
query | The query to initialize. |
n | The number of as_predicate to allocate. |
|
related |
Initializes as_query.where
with a capacity of n
using alloca()
.
For heap allocation, use as_query_where_init()
.
__query | The query to initialize. |
__n | The number of as_predicate to allocate. |
Definition at line 642 of file as_query.h.
|
related |
|
related |
|
related |
|
private |
If true, then as_query_destroy() will free this instance.
Definition at line 431 of file as_query.h.
as_udf_call as_query::apply |
UDF to apply to results of the query
Should be set via as_query_apply()
.
Definition at line 489 of file as_query.h.
as_namespace as_query::ns |
Namespace to be queried.
Should be initialized via either:
Definition at line 440 of file as_query.h.
as_query_ordering as_query::orderby |
Bins to order by.
Use either of the following function to initialize:
Use as_query_orderby() to populate.
Definition at line 482 of file as_query.h.
as_query_bins as_query::select |
Name of bins to select.
Use either of the following function to initialize:
Use as_query_select() to populate.
Definition at line 460 of file as_query.h.
as_set as_query::set |
Set to be queried.
Should be initialized via either:
Definition at line 449 of file as_query.h.
as_query_predicates as_query::where |
Predicates for filtering.
Use either of the following function to initialize:
Use as_query_where() to populate.
Definition at line 471 of file as_query.h.