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_types.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_object.h
>
25
26
#include <inttypes.h>
27
#include <stdbool.h>
28
#include <netinet/in.h>
29
30
/**
31
* Hack for the sake of XDS. XDS includes the main CF libs.
32
* We do not want to include them again from client API
33
*/
34
#ifndef XDS
35
#include <citrusleaf/cf_atomic.h>
36
// #include <citrusleaf/cf_log.h>
37
#include <citrusleaf/cf_ll.h>
38
#include <citrusleaf/cf_clock.h>
39
#include <citrusleaf/cf_vector.h>
40
#include <citrusleaf/cf_queue.h>
41
#include <citrusleaf/cf_digest.h>
42
#include <citrusleaf/cf_shash.h>
43
#include <citrusleaf/cf_rchash.h>
44
#endif
45
46
/******************************************************************************
47
* CONSTANTS
48
******************************************************************************/
49
50
#define STACK_BUF_SZ (1024 * 16) // provide a safe number for your system - linux tends to have 8M stacks these days
51
#define DEFAULT_PROGRESS_TIMEOUT 50
52
#define NODE_NAME_SIZE 20
53
#define CL_BINNAME_SIZE 15
54
#define CL_MAX_NUM_FUNC_ARGC 10
55
56
/******************************************************************************
57
* TYPES
58
******************************************************************************/
59
60
typedef
struct
cl_conn_s
cl_conn
;
61
62
// These numbers match with proto.h on the server (AS_PROTO_RESULT_FAIL....)
63
64
typedef
enum
cl_rv_e {
65
66
// negative = client
67
// positive = server
68
69
70
CITRUSLEAF_FAIL_ASYNCQ_FULL
= -3,
71
CITRUSLEAF_FAIL_TIMEOUT
= -2,
72
CITRUSLEAF_FAIL_CLIENT
= -1,
// an out of memory or similar locally
73
74
CITRUSLEAF_OK
= 0,
75
CITRUSLEAF_FAIL_UNKNOWN
= 1,
// unknown failure on the server side
76
77
// record not found
78
// currently only used for reads, but with REPLACE ONLY op will be pertinent.
79
CITRUSLEAF_FAIL_NOTFOUND
= 2,
80
81
// can be a read or write error
82
CITRUSLEAF_FAIL_GENERATION
= 3,
// likely a CAS write, and the write failed
83
84
// bad parameter response from server
85
CITRUSLEAF_FAIL_PARAMETER
= 4,
// you passed in bad parameters
86
87
// digest/record exists when attempting to CREATE ONLY
88
// SCOPE: WRITE ONLY
89
CITRUSLEAF_FAIL_KEY_EXISTS
= 5,
90
91
// @todo ??
92
CITRUSLEAF_FAIL_BIN_EXISTS
= 6,
93
94
// cluster errors
95
CITRUSLEAF_FAIL_CLUSTER_KEY_MISMATCH
= 7,
96
CITRUSLEAF_FAIL_PARTITION_OUT_OF_SPACE
= 8,
97
98
// collapsible timeout, server timeout is based on client-sent value
99
// for the most part
100
CITRUSLEAF_FAIL_SERVERSIDE_TIMEOUT
= 9,
101
102
// xdr errors
103
CITRUSLEAF_FAIL_NOXDS
= 10,
104
105
// server (node) not avaialble (??)
106
CITRUSLEAF_FAIL_UNAVAILABLE
= 11,
107
108
// bin operation cannot be performed on bin b/c of its type
109
// SCOPE: WRITE ONLY
110
CITRUSLEAF_FAIL_INCOMPATIBLE_TYPE
= 12,
// specified operation cannot be performed on that data type
111
112
// record is larger than the write block (1MB)
113
// SCOPE: WRITE ONLY
114
CITRUSLEAF_FAIL_RECORD_TOO_BIG
= 13,
115
116
// hot key - essentially the record's transaction proc queue is full
117
CITRUSLEAF_FAIL_KEY_BUSY
= 14,
118
119
// scan was aborted ... but why?
120
CITRUSLEAF_FAIL_SCAN_ABORT
= 15,
121
122
// Server does not (yet) support this function
123
CITRUSLEAF_FAIL_UNSUPPORTED_FEATURE
= 16,
124
125
// Bin-level replace-only supported on server but not on client.
126
CITRUSLEAF_FAIL_BIN_NOT_FOUND
= 17,
127
128
// Storage device(s) can't keep up with the current write load.
129
CITRUSLEAF_FAIL_DEVICE_OVERLOAD
= 18,
130
131
// Record key sent with transaction did not match key stored on server.
132
CITRUSLEAF_FAIL_KEY_MISMATCH
= 19,
133
134
// ???
135
CITRUSLEAF_FAIL_INVALID_DATA
= 99,
136
137
// UDF RANGE 100-110
138
CITRUSLEAF_FAIL_UDF_BAD_RESPONSE
= 100,
139
140
// Secondary Index Query Codes 200 - 230
141
CITRUSLEAF_FAIL_INDEX_FOUND
= 200,
142
CITRUSLEAF_FAIL_INDEX_NOTFOUND
= 201,
143
CITRUSLEAF_FAIL_INDEX_OOM
= 202,
144
CITRUSLEAF_FAIL_INDEX_NOTREADABLE
= 203,
145
CITRUSLEAF_FAIL_INDEX_GENERIC
= 204,
146
CITRUSLEAF_FAIL_INDEX_NAME_MAXLEN
= 205,
147
CITRUSLEAF_FAIL_INDEX_MAXCOUNT
= 206,
148
149
CITRUSLEAF_FAIL_QUERY_ABORTED
= 210,
150
CITRUSLEAF_FAIL_QUERY_QUEUEFULL
= 211,
151
CITRUSLEAF_FAIL_QUERY_TIMEOUT
= 212,
152
CITRUSLEAF_FAIL_QUERY_GENERIC
= 213
153
}
cl_rv
;
154
155
typedef
enum
cl_rvclient_e {
156
CITRUSLEAF_FAIL_DC_DOWN
= 1,
157
CITRUSLEAF_FAIL_DC_UP
= 2
158
}
cl_rvclient
;
159
160
161
typedef
enum
cl_operator_type_e {
162
CL_OP_WRITE
,
// 0
163
CL_OP_READ
,
// 1
164
CL_OP_INCR
,
// 2
165
CL_OP_MC_INCR
,
// 3
166
CL_OP_PREPEND
,
// 4
167
CL_OP_APPEND
,
// 5
168
CL_OP_MC_PREPEND
,
// 6
169
CL_OP_MC_APPEND
,
// 7
170
CL_OP_TOUCH
,
// 8
171
CL_OP_MC_TOUCH
// 9
172
}
cl_operator
;
173
174
/**
175
* A bin is the bin name, and the value set or gotten
176
*/
177
typedef
struct
cl_bin_s {
178
char
bin_name[
CL_BINNAME_SIZE
];
179
cl_object
object
;
180
}
cl_bin
;
181
182
/**
183
* A record structure containing the most common fileds of a record
184
*/
185
typedef
struct
cl_rec_s {
186
cf_digest
digest
;
187
uint32_t
generation
;
188
uint32_t
record_voidtime
;
189
cl_bin
*
bins
;
190
int
n_bins
;
191
}
cl_rec
;
192
193
/**
194
* Structure used by functions which want to return a bunch of records
195
*/
196
typedef
struct
cl_batchresult_s {
197
pthread_mutex_t
lock
;
198
int
numrecs
;
199
cl_rec
*
records
;
200
}
cl_batchresult
;
201
202
/**
203
* An operation is the bin, plus the operator (write, read, add, etc)
204
* This structure is used for the more complex 'operate' call,
205
* which can specify simultaneous operations on multiple bins
206
*/
207
typedef
struct
cl_operation_s {
208
cl_bin
bin
;
209
cl_operator
op
;
210
}
cl_operation
;
211
212
/**
213
* Structure to map the internal address to the external address
214
*/
215
typedef
struct
cl_addrmap
{
216
char
*
orig
;
217
char
*
alt
;
218
}
cl_addrmap
;
219
220
/**
221
* Callback function type used by batch and scan
222
*/
223
typedef
int (*
citrusleaf_get_many_cb
) (
char
*
ns
, cf_digest *keyd,
char
*set,
224
cl_object
*
key
,
int
result, uint32_t
generation
, uint32_t ttl,
225
cl_bin
*bins, uint16_t n_bins,
void
*udata);
226
227
/******************************************************************************
228
* FUNCTIONS
229
******************************************************************************/
230
231
void
citrusleaf_bins_free
(
cl_bin
* bins,
int
n_bins);
232
int
citrusleaf_copy_bins
(
cl_bin
** destbins,
cl_bin
* srcbins,
int
n_bins);
233
CITRUSLEAF_FAIL_KEY_BUSY
Definition:
cl_types.h:117
cl_operation
Definition:
cl_types.h:207
CL_OP_MC_INCR
Definition:
cl_types.h:165
CITRUSLEAF_FAIL_SERVERSIDE_TIMEOUT
Definition:
cl_types.h:100
as_scan::ns
as_namespace ns
Definition:
src/include/aerospike/as_scan.h:334
citrusleaf_get_many_cb
int(* citrusleaf_get_many_cb)(char *ns, cf_digest *keyd, char *set, cl_object *key, int result, uint32_t generation, uint32_t ttl, cl_bin *bins, uint16_t n_bins, void *udata)
Definition:
cl_types.h:223
CITRUSLEAF_FAIL_SCAN_ABORT
Definition:
cl_types.h:120
CITRUSLEAF_FAIL_TIMEOUT
Definition:
cl_types.h:71
CL_OP_APPEND
Definition:
cl_types.h:167
cl_rv
cl_rv
Definition:
cl_types.h:64
cl_rvclient
cl_rvclient
Definition:
cl_types.h:155
generation
uint32_t generation
Definition:
src/include/citrusleaf/cf_proto.h:61
CITRUSLEAF_FAIL_BIN_NOT_FOUND
Definition:
cl_types.h:126
CITRUSLEAF_FAIL_ASYNCQ_FULL
Definition:
cl_types.h:70
cl_bin
Definition:
cl_types.h:177
CL_OP_TOUCH
Definition:
cl_types.h:170
CITRUSLEAF_FAIL_UNSUPPORTED_FEATURE
Definition:
cl_types.h:123
CL_OP_MC_APPEND
Definition:
cl_types.h:169
citrusleaf_copy_bins
int citrusleaf_copy_bins(cl_bin **destbins, cl_bin *srcbins, int n_bins)
CITRUSLEAF_FAIL_INDEX_NOTFOUND
Definition:
cl_types.h:142
CITRUSLEAF_FAIL_BIN_EXISTS
Definition:
cl_types.h:92
cl_rec::record_voidtime
uint32_t record_voidtime
Definition:
cl_types.h:188
CITRUSLEAF_FAIL_PARTITION_OUT_OF_SPACE
Definition:
cl_types.h:96
CITRUSLEAF_FAIL_NOXDS
Definition:
cl_types.h:103
CITRUSLEAF_FAIL_RECORD_TOO_BIG
Definition:
cl_types.h:114
CITRUSLEAF_OK
Definition:
cl_types.h:74
CITRUSLEAF_FAIL_UDF_BAD_RESPONSE
Definition:
cl_types.h:138
CITRUSLEAF_FAIL_KEY_EXISTS
Definition:
cl_types.h:89
cl_batchresult::lock
pthread_mutex_t lock
Definition:
cl_types.h:197
cl_conn
struct cl_conn_s cl_conn
Definition:
cl_types.h:60
CITRUSLEAF_FAIL_QUERY_ABORTED
Definition:
cl_types.h:149
cl_object
Definition:
cl_object.h:61
cl_operation::op
cl_operator op
Definition:
cl_types.h:209
CITRUSLEAF_FAIL_DC_DOWN
Definition:
cl_types.h:156
cl_rec::n_bins
int n_bins
Definition:
cl_types.h:190
CL_OP_MC_PREPEND
Definition:
cl_types.h:168
cl_addrmap::alt
char * alt
Definition:
cl_types.h:217
CITRUSLEAF_FAIL_UNAVAILABLE
Definition:
cl_types.h:106
CITRUSLEAF_FAIL_QUERY_QUEUEFULL
Definition:
cl_types.h:150
CITRUSLEAF_FAIL_NOTFOUND
Definition:
cl_types.h:79
CITRUSLEAF_FAIL_UNKNOWN
Definition:
cl_types.h:75
CITRUSLEAF_FAIL_INVALID_DATA
Definition:
cl_types.h:135
CL_OP_READ
Definition:
cl_types.h:163
CITRUSLEAF_FAIL_CLIENT
Definition:
cl_types.h:72
cl_batchresult::records
cl_rec * records
Definition:
cl_types.h:199
CITRUSLEAF_FAIL_PARAMETER
Definition:
cl_types.h:85
cl_addrmap::orig
char * orig
Definition:
cl_types.h:216
cl_object.h
cl_bin::object
cl_object object
Definition:
cl_types.h:179
cl_rec::generation
uint32_t generation
Definition:
cl_types.h:187
CITRUSLEAF_FAIL_CLUSTER_KEY_MISMATCH
Definition:
cl_types.h:95
CL_OP_MC_TOUCH
Definition:
cl_types.h:171
CITRUSLEAF_FAIL_QUERY_GENERIC
Definition:
cl_types.h:152
citrusleaf_bins_free
void citrusleaf_bins_free(cl_bin *bins, int n_bins)
CITRUSLEAF_FAIL_INDEX_MAXCOUNT
Definition:
cl_types.h:147
CITRUSLEAF_FAIL_KEY_MISMATCH
Definition:
cl_types.h:132
CL_OP_INCR
Definition:
cl_types.h:164
CITRUSLEAF_FAIL_GENERATION
Definition:
cl_types.h:82
CITRUSLEAF_FAIL_INDEX_NAME_MAXLEN
Definition:
cl_types.h:146
CITRUSLEAF_FAIL_DC_UP
Definition:
cl_types.h:157
CL_OP_WRITE
Definition:
cl_types.h:162
CL_OP_PREPEND
Definition:
cl_types.h:166
CITRUSLEAF_FAIL_QUERY_TIMEOUT
Definition:
cl_types.h:151
CITRUSLEAF_FAIL_DEVICE_OVERLOAD
Definition:
cl_types.h:129
cl_operator
cl_operator
Definition:
cl_types.h:161
cl_rec
Definition:
cl_types.h:185
CITRUSLEAF_FAIL_INDEX_OOM
Definition:
cl_types.h:143
cl_rec::bins
cl_bin * bins
Definition:
cl_types.h:189
cl_rec::digest
cf_digest digest
Definition:
cl_types.h:186
cl_operation::bin
cl_bin bin
Definition:
cl_types.h:208
cl_batchresult
Definition:
cl_types.h:196
cl_addrmap
Definition:
cl_types.h:215
cl_batchresult::numrecs
int numrecs
Definition:
cl_types.h:198
CITRUSLEAF_FAIL_INCOMPATIBLE_TYPE
Definition:
cl_types.h:110
CL_BINNAME_SIZE
#define CL_BINNAME_SIZE
Definition:
cl_types.h:53
CITRUSLEAF_FAIL_INDEX_GENERIC
Definition:
cl_types.h:145
CITRUSLEAF_FAIL_INDEX_NOTREADABLE
Definition:
cl_types.h:144
CITRUSLEAF_FAIL_INDEX_FOUND
Definition:
cl_types.h:141
key
uint8_t key[]
Definition:
src/include/citrusleaf/cf_proto.h:56