All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
72  CITRUSLEAF_FAIL_CLIENT = -1, // an out of memory or similar locally
73 
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.
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
90 
91  // @todo ??
93 
94  // cluster errors
97 
98  // collapsible timeout, server timeout is based on client-sent value
99  // for the most part
101 
102  // xdr errors
104 
105  // server (node) not avaialble (??)
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
115 
116  // hot key - essentially the record's transaction proc queue is full
118 
119  // scan was aborted ... but why?
121 
122  // Server does not (yet) support this function
124 
125  // Bin-level replace-only supported on server but not on client.
127 
128  // Storage device(s) can't keep up with the current write load.
130 
131  // ???
133 
134  // UDF RANGE 100-110
136 
137  // Secondary Index Query Codes 200 - 230
145 
150 } cl_rv;
151 
152 typedef enum cl_rvclient_e {
155 } cl_rvclient;
156 
157 
158 typedef enum cl_operator_type_e {
169 } cl_operator;
170 
171 /**
172  * A bin is the bin name, and the value set or gotten
173  */
174 typedef struct cl_bin_s {
175  char bin_name[CL_BINNAME_SIZE];
177 } cl_bin;
178 
179 /**
180  * A record structure containing the most common fileds of a record
181  */
182 typedef struct cl_rec_s {
183  cf_digest digest;
184  uint32_t generation;
185  uint32_t record_voidtime;
187  int n_bins;
188 } cl_rec;
189 
190 /**
191  * Structure used by functions which want to return a bunch of records
192  */
193 typedef struct cl_batchresult_s {
194  pthread_mutex_t lock;
195  int numrecs;
198 
199 /**
200  * An operation is the bin, plus the operator (write, read, add, etc)
201  * This structure is used for the more complex 'operate' call,
202  * which can specify simultaneous operations on multiple bins
203  */
204 typedef struct cl_operation_s {
207 } cl_operation;
208 
209 /**
210  * Structure to map the internal address to the external address
211  */
212 typedef struct cl_addrmap {
213  char * orig;
214  char * alt;
215 } cl_addrmap;
216 
217 /**
218  * Callback function type used by batch and scan
219  */
220 typedef int (*citrusleaf_get_many_cb) (char *ns, cf_digest *keyd, char *set,
221  int result, uint32_t generation, uint32_t ttl, cl_bin *bins,
222  uint16_t n_bins, void *udata);
223 
224 /******************************************************************************
225  * FUNCTIONS
226  ******************************************************************************/
227 
228 void citrusleaf_bins_free(cl_bin * bins, int n_bins);
229 int citrusleaf_copy_bins(cl_bin ** destbins, cl_bin * srcbins, int n_bins);
230