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  // Record key sent with transaction did not match key stored on server.
133 
134  // ???
136 
137  // UDF RANGE 100-110
139 
140  // Secondary Index Query Codes 200 - 230
148 
153 } cl_rv;
154 
155 typedef enum cl_rvclient_e {
158 } cl_rvclient;
159 
160 
161 typedef enum cl_operator_type_e {
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];
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;
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;
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 {
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