Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
include
citrusleaf
cl_query.h
Go to the documentation of this file.
1
/******************************************************************************
2
* Copyright 2008-2013 by Aerospike.
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to
6
* deal in the Software without restriction, including without limitation the
7
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8
* sell copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20
* IN THE SOFTWARE.
21
*****************************************************************************/
22
#pragma once
23
24
#include <
citrusleaf/cl_types.h
>
25
#include <
citrusleaf/cl_sindex.h
>
26
27
#include <aerospike/as_rec.h>
28
#include <aerospike/as_map.h>
29
#include <aerospike/as_list.h>
30
#include <aerospike/as_result.h>
31
#include <aerospike/as_stream.h>
32
33
/******************************************************************************
34
* TYPES
35
*******************************************************************************/
36
37
typedef
enum
cl_query_op
{
CL_EQ
,
CL_LT
,
CL_GT
,
CL_LE
,
CL_GE
,
CL_RANGE
}
cl_query_op
;
38
typedef
enum
cl_query_orderby_op
{
CL_ORDERBY_ASC
,
CL_ORDERBY_DESC
}
cl_query_orderby_op
;
39
40
// These are the types of UDF calls that go over the wire from the client to
41
// the server.
42
typedef
enum
cl_query_udf_type_s {
43
AS_UDF_CALLTYPE_NONE
,
// Regular UDF call, no query involved.
44
AS_UDF_CALLTYPE_RECORD
,
45
AS_UDF_CALLTYPE_STREAM
46
}
cl_query_udf_type
;
47
48
49
typedef
struct
cl_query_udf_s {
50
cl_query_udf_type
type
;
51
char
*
filename
;
52
char
*
function
;
53
as_list
*
arglist
;
54
}
cl_query_udf
;
55
56
typedef
struct
cl_query
{
57
char
*
ns
;
58
char
*
indexname
;
59
char
*
setname
;
60
cf_vector *
binnames
;
// Select
61
cf_vector *
ranges
;
// Where
62
cf_vector *
filters
;
63
cf_vector *
orderbys
;
64
cl_query_udf
udf
;
65
void
*
res_streamq
;
66
int
limit
;
67
uint64_t
job_id
;
68
}
cl_query
;
69
70
typedef
struct
cl_query_response_record_t {
71
char
*
ns
;
72
cf_digest
keyd
;
73
char
*
set
;
74
uint32_t
generation
;
75
uint32_t
record_ttl
;
76
cl_bin
*
bins
;
77
int
n_bins
;
78
as_map
*
values
;
79
bool
ismalloc
;
80
bool
free_bins
;
81
}
cl_query_response_rec
;
82
83
typedef
bool (*
cl_query_cb
) (
as_val
* val,
void
* udata);
84
85
86
/******************************************************************************
87
* FUNCTIONS
88
******************************************************************************/
89
#define cl_integer_equals(val) CL_EQ, CL_INT, val
90
#define cl_integer_range(start, end) CL_RANGE, CL_INT, start, end
91
#define cl_string_equals(val) CL_EQ, CL_STR, val
92
93
94
/**
95
* Allocates and initializes a new cl_query
96
*/
97
cl_query
*
cl_query_new
(
const
char
*
ns
,
const
char
* setname);
98
99
/**
100
* Initializes an cl_query
101
*/
102
cl_query
*
cl_query_init
(
cl_query
* query,
const
char
*
ns
,
const
char
* setname);
103
104
/**
105
* Destroy and free an cl_query
106
*/
107
void
cl_query_destroy
(
cl_query
* query);
108
109
/**
110
* Query Builders
111
*/
112
113
int
cl_query_select
(
cl_query
* query,
const
char
* binname);
114
int
cl_query_where
(
cl_query
* query,
const
char
* binname,
cl_query_op
, ...);
115
int
cl_query_where_function
(
cl_query
* query,
const
char
* finame,
cl_query_op
, ...);
116
int
cl_query_filter
(
cl_query
* query,
const
char
* binname,
cl_query_op
op
, ...);
117
int
cl_query_orderby
(
cl_query
* query,
const
char
* binname,
cl_query_orderby_op
order);
118
cl_rv
cl_query_aggregate
(
cl_query
* query,
const
char
* filename,
const
char
*
function
,
as_list
* arglist);
119
cl_rv
cl_query_foreach
(
cl_query
* query,
const
char
* filename,
const
char
*
function
,
as_list
* arglist);
120
int
cl_query_limit
(
cl_query
* query, uint64_t limit);
121
122
123
cl_rv
citrusleaf_query_foreach
(cl_cluster * cluster,
const
cl_query
* query,
void
* udata,
bool
(*
foreach
)(
as_val
*,
void
*));
124
125
126
/*
127
* Init and destroy for client query environment. Should be called for once per cluster
128
* instance before performing citrusleaf query
129
*/
130
int
cl_cluster_query_init
(cl_cluster* asc);
131
void
cl_cluster_query_shutdown
(cl_cluster* asc);