All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
aerospike_key.h
Go to the documentation of this file.
1/*
2 * Copyright 2008-2024 Aerospike, Inc.
3 *
4 * Portions may be licensed to Aerospike, Inc. under one or more contributor
5 * license agreements.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
8 * use this file except in compliance with the License. You may obtain a copy of
9 * the License at http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17#pragma once
18
19/**
20 * @defgroup key_operations Key Operations
21 * @ingroup client_operations
22 *
23 * Aerospike provides a key based API to access and modify data into the
24 * cluster.
25 *
26 * The Key API is a collection of APIs that use as_key as for looking up
27 * records for accessing and modifying in the cluster.
28 *
29 */
30
31#include <aerospike/aerospike.h>
33#include <aerospike/as_error.h>
34#include <aerospike/as_key.h>
35#include <aerospike/as_list.h>
37#include <aerospike/as_policy.h>
38#include <aerospike/as_record.h>
39#include <aerospike/as_status.h>
40#include <aerospike/as_val.h>
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46//---------------------------------
47// Functions
48//---------------------------------
49
50/**
51 * Look up a record by key and return all bins.
52 *
53 * ~~~~~~~~~~{.c}
54 * as_key key;
55 * as_key_init(&key, "ns", "set", "key");
56 *
57 * as_record* rec = NULL;
58 * if (aerospike_key_get(&as, &err, NULL, &key, &rec) != AEROSPIKE_OK) {
59 * printf("error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
60 * }
61 * else {
62 * as_record_destroy(rec);
63 * }
64 * ~~~~~~~~~~
65 *
66 * @param as The aerospike instance to use for this operation.
67 * @param err The as_error to be populated if an error occurs.
68 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
69 * @param key The key of the record.
70 * @param rec The record to be populated with the data from request. If the record pointer is
71 * preset to NULL, the record will be created and initialized. If the record pointer
72 * is not NULL, the record is assumed to be valid and will be reused. Either way,
73 * the record must be preset.
74 *
75 * @return AEROSPIKE_OK if successful. Otherwise an error.
76 *
77 * @ingroup key_operations
78 */
81 aerospike* as, as_error* err, const as_policy_read* policy, const as_key* key, as_record** rec
82 );
83
84/**
85 * Asynchronously look up a record by key and return all bins.
86 *
87 * ~~~~~~~~~~{.c}
88 * void my_listener(as_error* err, as_record* record, void* udata, as_event_loop* event_loop)
89 * {
90 * if (err) {
91 * printf("Command failed: %d %s\n", err->code, err->message);
92 * return;
93 * }
94 * // Process record bins
95 * // Only call as_record_destroy(record) when command is successful (err == NULL) and
96 * // "as_policy_read.async_heap_rec" is true. Otherwise, the calling function will destroy the
97 * // record when the listener completes.
98 * }
99 *
100 * as_key key;
101 * as_key_init(&key, "ns", "set", "key");
102 *
103 * as_status status = aerospike_key_get_async(&as, &err, NULL, &key, my_listener, NULL, NULL, NULL);
104 * ~~~~~~~~~~
105 *
106 * @param as The aerospike instance to use for this operation.
107 * @param err The as_error to be populated if an error occurs.
108 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
109 * @param key The key of the record.
110 * @param listener User function to be called with command results.
111 * @param udata User data to be forwarded to user callback.
112 * @param event_loop Event loop assigned to run this command. If NULL, an event loop will be chosen by round-robin.
113 * @param pipe_listener Enables command pipelining, if not NULL. The given callback is invoked after the current command
114 * has been sent to the server. This allows for issuing the next command even before receiving a
115 * result for the current command.
116 *
117 * @return AEROSPIKE_OK if async command successfully queued. Otherwise an error.
118 *
119 * @ingroup key_operations
120 */
123 aerospike* as, as_error* err, const as_policy_read* policy, const as_key* key,
124 as_async_record_listener listener, void* udata, as_event_loop* event_loop,
125 as_pipe_listener pipe_listener
126 );
127
128/**
129 * Read a record's bins given the NULL terminated bins array argument.
130 *
131 * ~~~~~~~~~~{.c}
132 * char* select[] = {"bin1", "bin2", "bin3", NULL};
133 *
134 * as_key key;
135 * as_key_init(&key, "ns", "set", "key");
136 *
137 * as_record* rec = NULL;
138 * if (aerospike_key_select(&as, &err, NULL, &key, select, &rec) != AEROSPIKE_OK) {
139 * printf("error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
140 * }
141 * else {
142 * as_record_destroy(rec);
143 * }
144 * ~~~~~~~~~~
145 *
146 * @param as The aerospike instance to use for this operation.
147 * @param err The as_error to be populated if an error occurs.
148 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
149 * @param key The key of the record.
150 * @param bins The bins to select. A NULL terminated array of NULL terminated strings.
151 * @param rec The record to be populated with the data from request. If the record pointer is
152 * preset to NULL, the record will be created and initialized. If the record pointer
153 * is not NULL, the record is assumed to be valid and will be reused. Either way,
154 * the record must be preset.
155 *
156 * @return AEROSPIKE_OK if successful. Otherwise an error.
157 *
158 * @ingroup key_operations
159 */
162 aerospike* as, as_error* err, const as_policy_read* policy, const as_key* key,
163 const char* bins[], as_record** rec
164 );
165
166/**
167 * Asynchronously read a record's bins given the NULL terminated bins array argument.
168 *
169 * ~~~~~~~~~~{.c}
170 * void my_listener(as_error* err, as_record* record, void* udata, as_event_loop* event_loop)
171 * {
172 * if (err) {
173 * printf("Command failed: %d %s\n", err->code, err->message);
174 * return;
175 * }
176 * // Process record bins
177 * // Only call as_record_destroy(record) when command is successful (err == NULL) and
178 * // "as_policy_read.async_heap_rec" is true. Otherwise, the calling function will destroy the
179 * // record when the listener completes.
180 * }
181 *
182 * char* select[] = {"bin1", "bin2", "bin3", NULL};
183 *
184 * as_key key;
185 * as_key_init(&key, "ns", "set", "key");
186 *
187 * as_status status = aerospike_key_select_async(&as, &err, NULL, &key, select, my_listener, NULL, NULL, NULL);
188 * ~~~~~~~~~~
189 *
190 * @param as The aerospike instance to use for this operation.
191 * @param err The as_error to be populated if an error occurs.
192 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
193 * @param key The key of the record.
194 * @param bins The bins to select. A NULL terminated array of NULL terminated strings.
195 * @param listener User function to be called with command results.
196 * @param udata User data to be forwarded to user callback.
197 * @param event_loop Event loop assigned to run this command. If NULL, an event loop will be chosen by round-robin.
198 * @param pipe_listener Enables command pipelining, if not NULL. The given callback is invoked after the current command
199 * has been sent to the server. This allows for issuing the next command even before receiving a
200 * result for the current command.
201 *
202 * @return AEROSPIKE_OK if async command successfully queued. Otherwise an error.
203 *
204 * @ingroup key_operations
205 */
208 aerospike* as, as_error* err, const as_policy_read* policy, const as_key* key, const char* bins[],
209 as_async_record_listener listener, void* udata, as_event_loop* event_loop, as_pipe_listener pipe_listener
210 );
211
212/**
213 * Read a record's bins given the bins array argument and the n_bins count.
214 *
215 * ~~~~~~~~~~{.c}
216 * char* select[] = {"bin1", "bin2", "bin3"};
217 *
218 * as_key key;
219 * as_key_init(&key, "ns", "set", "key");
220 *
221 * as_record* rec = NULL;
222 * if (aerospike_key_select_bins(&as, &err, NULL, &key, select, 3, &rec) != AEROSPIKE_OK) {
223 * printf("error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
224 * }
225 * else {
226 * as_record_destroy(rec);
227 * }
228 * ~~~~~~~~~~
229 *
230 * @param as The aerospike instance to use for this operation.
231 * @param err The as_error to be populated if an error occurs.
232 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
233 * @param key The key of the record.
234 * @param bins The array of bins to select. The array does not need a final NULL entry.
235 * @param n_bins The count of bins to select.
236 * @param rec The record to be populated with the data from request. If the record pointer is
237 * preset to NULL, the record will be created and initialized. If the record pointer
238 * is not NULL, the record is assumed to be valid and will be reused. Either way,
239 * the record must be preset.
240 *
241 * @return AEROSPIKE_OK if successful. Otherwise an error.
242 *
243 * @ingroup key_operations
244 */
247 aerospike* as, as_error* err, const as_policy_read* policy, const as_key* key,
248 const char* bins[], uint32_t n_bins, as_record** rec
249 );
250
251/**
252 * Asynchronously read a record's bins given the bins array argument and the n_bins count.
253 *
254 * ~~~~~~~~~~{.c}
255 * void my_listener(as_error* err, as_record* record, void* udata, as_event_loop* event_loop)
256 * {
257 * if (err) {
258 * printf("Command failed: %d %s\n", err->code, err->message);
259 * return;
260 * }
261 * // Process record bins
262 * // Only call as_record_destroy(record) when command is successful (err == NULL) and
263 * // "as_policy_read.async_heap_rec" is true. Otherwise, the calling function will destroy the
264 * // record when the listener completes.
265 * }
266 *
267 * char* select[] = {"bin1", "bin2", "bin3"};
268 *
269 * as_key key;
270 * as_key_init(&key, "ns", "set", "key");
271 *
272 * as_status status = aerospike_key_select_bins_async(&as, &err, NULL, &key, select, 3, my_listener, NULL, NULL, NULL);
273 * ~~~~~~~~~~
274 *
275 * @param as The aerospike instance to use for this operation.
276 * @param err The as_error to be populated if an error occurs.
277 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
278 * @param key The key of the record.
279 * @param bins The bins to select. A NULL terminated array of NULL terminated strings.
280 * @param n_bins The count of bins to select.
281 * @param listener User function to be called with command results.
282 * @param udata User data to be forwarded to user callback.
283 * @param event_loop Event loop assigned to run this command. If NULL, an event loop will be chosen by round-robin.
284 * @param pipe_listener Enables command pipelining, if not NULL. The given callback is invoked after the current command
285 * has been sent to the server. This allows for issuing the next command even before receiving a
286 * result for the current command.
287 *
288 * @return AEROSPIKE_OK if async command successfully queued. Otherwise an error.
289 *
290 * @ingroup key_operations
291 */
294 aerospike* as, as_error* err, const as_policy_read* policy, const as_key* key, const char* bins[],
295 uint32_t n_bins, as_async_record_listener listener, void* udata, as_event_loop* event_loop,
296 as_pipe_listener pipe_listener
297 );
298
299/**
300 * Check if a record exists in the cluster via its key. The record's metadata
301 * will be populated if the record exists.
302 *
303 * ~~~~~~~~~~{.c}
304 * as_key key;
305 * as_key_init(&key, "ns", "set", "key");
306 *
307 * as_record* rec = NULL;
308 * if (aerospike_key_exists(&as, &err, NULL, &key, &rec) != AEROSPIKE_OK) {
309 * printf("error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
310 * }
311 * else {
312 * if (rec) {
313 * printf("Record exists.");
314 * as_record_destroy(rec);
315 * }
316 * else {
317 * printf("Record doesn't exist.");
318 * }
319 * }
320 * ~~~~~~~~~~
321 *
322 * @param as The aerospike instance to use for this operation.
323 * @param err The as_error to be populated if an error occurs.
324 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
325 * @param key The key of the record.
326 * @param rec The metadata will be populated if the record exists. If the record pointer is
327 * preset to NULL, the record will be created and initialized. If the record pointer
328 * is not NULL, the record is assumed to be valid and will be reused. Either way,
329 * the record must be preset.
330 *
331 * @return AEROSPIKE_OK if successful. AEROSPIKE_ERR_RECORD_NOT_FOUND if not found. Otherwise an error.
332 *
333 * @ingroup key_operations
334 */
337 aerospike* as, as_error* err, const as_policy_read* policy, const as_key* key, as_record** rec
338 );
339
340/**
341 * Asynchronously check if a record exists in the cluster via its key. The record's metadata
342 * will be populated if the record exists.
343 *
344 * ~~~~~~~~~~{.c}
345 * void my_listener(as_error* err, as_record* record, void* udata, as_event_loop* event_loop)
346 * {
347 * if (err) {
348 * printf("Command failed: %d %s\n", err->code, err->message);
349 * return;
350 * }
351 * if (record) {
352 * printf("Record exists.");
353 * // Only call as_record_destroy(record) when the record exists, the command is successful
354 * // (err == NULL) and "as_policy_read.async_heap_rec" is true. Otherwise, the calling
355 * // function will destroy the record when the listener completes.
356 * }
357 * else {
358 * printf("Record doesn't exist.");
359 * }
360 * }
361 *
362 * as_key key;
363 * as_key_init(&key, "ns", "set", "key");
364 *
365 * as_status status = aerospike_key_exists_async(&as, &err, NULL, &key, my_listener, NULL, NULL, NULL);
366 * ~~~~~~~~~~
367 *
368 * @param as The aerospike instance to use for this operation.
369 * @param err The as_error to be populated if an error occurs.
370 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
371 * @param key The key of the record.
372 * @param listener User function to be called with command results.
373 * @param udata User data to be forwarded to user callback.
374 * @param event_loop Event loop assigned to run this command. If NULL, an event loop will be chosen by round-robin.
375 * @param pipe_listener Enables command pipelining, if not NULL. The given callback is invoked after the current command
376 * has been sent to the server. This allows for issuing the next command even before receiving a
377 * result for the current command.
378 *
379 * @return AEROSPIKE_OK if async command successfully queued. Otherwise an error.
380 *
381 * @ingroup key_operations
382 */
385 aerospike* as, as_error* err, const as_policy_read* policy, const as_key* key,
386 as_async_record_listener listener, void* udata, as_event_loop* event_loop,
387 as_pipe_listener pipe_listener
388 );
389
390/**
391 * Store a record in the cluster.
392 *
393 * ~~~~~~~~~~{.c}
394 * as_key key;
395 * as_key_init(&key, "ns", "set", "key");
396 *
397 * as_record rec;
398 * as_record_init(&rec, 2);
399 * as_record_set_str(&rec, "bin1", "abc");
400 * as_record_set_int64(&rec, "bin2", 123);
401 *
402 * if (aerospike_key_put(&as, &err, NULL, &key, &rec) != AEROSPIKE_OK) {
403 * printf("error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
404 * }
405 * as_record_destroy(&rec);
406 * ~~~~~~~~~~
407 *
408 * @param as The aerospike instance to use for this operation.
409 * @param err The as_error to be populated if an error occurs.
410 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
411 * @param key The key of the record.
412 * @param rec The record containing the data to be written.
413 *
414 * @return AEROSPIKE_OK if successful. Otherwise an error.
415 *
416 * @ingroup key_operations
417 */
420 aerospike* as, as_error* err, const as_policy_write* policy, const as_key* key, as_record* rec
421 );
422
423/**
424 * Asynchronously store a record in the cluster.
425 *
426 * ~~~~~~~~~~{.c}
427 * void my_listener(as_error* err, void* udata, as_event_loop* event_loop)
428 * {
429 * if (err) {
430 * printf("Command failed: %d %s\n", err->code, err->message);
431 * return;
432 * }
433 * printf("Command succeeded\n");
434 * }
435 *
436 * as_key key;
437 * as_key_init(&key, "ns", "set", "key");
438 *
439 * as_record rec;
440 * as_record_init(&rec, 2);
441 * as_record_set_str(&rec, "bin1", "abc");
442 * as_record_set_int64(&rec, "bin2", 123);
443 *
444 * as_status status = aerospike_key_put_async(&as, &err, NULL, &key, &rec, my_listener, NULL, NULL, NULL);
445 * as_record_destroy(&rec);
446 * ~~~~~~~~~~
447 *
448 * @param as The aerospike instance to use for this operation.
449 * @param err The as_error to be populated if an error occurs.
450 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
451 * @param key The key of the record.
452 * @param rec The record containing the data to be written.
453 * @param listener User function to be called with command results.
454 * @param udata User data to be forwarded to user callback.
455 * @param event_loop Event loop assigned to run this command. If NULL, an event loop will be chosen by round-robin.
456 * @param pipe_listener Enables command pipelining, if not NULL. The given callback is invoked after the current command
457 * has been sent to the server. This allows for issuing the next command even before receiving a
458 * result for the current command.
459 *
460 * @return AEROSPIKE_OK if async command successfully queued. Otherwise an error.
461 *
462 * @ingroup key_operations
463 */
466 aerospike* as, as_error* err, const as_policy_write* policy, const as_key* key, as_record* rec,
467 as_async_write_listener listener, void* udata, as_event_loop* event_loop, as_pipe_listener pipe_listener
468 );
469
470/**
471 * Remove a record from the cluster.
472 *
473 * ~~~~~~~~~~{.c}
474 * as_key key;
475 * as_key_init(&key, "ns", "set", "key");
476 *
477 * if (aerospike_key_remove(&as, &err, NULL, &key) != AEROSPIKE_OK) {
478 * printf("error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
479 * }
480 * ~~~~~~~~~~
481 *
482 * @param as The aerospike instance to use for this operation.
483 * @param err The as_error to be populated if an error occurs.
484 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
485 * @param key The key of the record.
486 *
487 * @return AEROSPIKE_OK if successful and AEROSPIKE_ERR_RECORD_NOT_FOUND if the record was not found. Otherwise an error.
488 *
489 * @ingroup key_operations
490 */
493 aerospike* as, as_error* err, const as_policy_remove* policy, const as_key* key
494 );
495
496/**
497 * Asynchronously remove a record from the cluster.
498 *
499 * ~~~~~~~~~~{.c}
500 * void my_listener(as_error* err, void* udata, as_event_loop* event_loop)
501 * {
502 * if (err) {
503 * printf("Command failed: %d %s\n", err->code, err->message);
504 * return;
505 * }
506 * printf("Command succeeded\n");
507 * }
508 *
509 * as_key key;
510 * as_key_init(&key, "ns", "set", "key");
511 *
512 * as_status status = aerospike_key_remove(&as, &err, NULL, &key, my_listener, NULL, NULL, NULL);
513 * ~~~~~~~~~~
514 *
515 * @param as The aerospike instance to use for this operation.
516 * @param err The as_error to be populated if an error occurs.
517 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
518 * @param key The key of the record.
519 * @param listener User function to be called with command results.
520 * @param udata User data to be forwarded to user callback.
521 * @param event_loop Event loop assigned to run this command. If NULL, an event loop will be chosen by round-robin.
522 * @param pipe_listener Enables command pipelining, if not NULL. The given callback is invoked after the current command
523 * has been sent to the server. This allows for issuing the next command even before receiving a
524 * result for the current command.
525 *
526 * @return AEROSPIKE_OK if async command successfully queued. Otherwise an error.
527 *
528 * @ingroup key_operations
529 */
532 aerospike* as, as_error* err, const as_policy_remove* policy, const as_key* key,
533 as_async_write_listener listener, void* udata, as_event_loop* event_loop,
534 as_pipe_listener pipe_listener
535 );
536
537/**
538 * Lookup a record by key, then perform specified operations.
539 *
540 * ~~~~~~~~~~{.c}
541 * as_key key;
542 * as_key_init(&key, "ns", "set", "key");
543 *
544 * as_operations ops;
545 * as_operations_inita(&ops,3);
546 * as_operations_add_incr(&ops, "bin1", 456);
547 * as_operations_add_append_str(&ops, "bin2", "def");
548 * as_operations_add_read(&ops, "bin1")
549 *
550 * as_record* rec = NULL;
551 *
552 * if (aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec) != AEROSPIKE_OK) {
553 * printf("error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
554 * }
555 * else {
556 * as_record_destroy(rec);
557 * }
558 * as_operations_destroy(&ops);
559 * ~~~~~~~~~~
560 *
561 * @param as The aerospike instance to use for this operation.
562 * @param err The as_error to be populated if an error occurs.
563 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
564 * @param key The key of the record.
565 * @param ops The operations to perform on the record.
566 * @param rec The record to be populated with the data from AS_OPERATOR_READ operations.
567 *
568 * @return AEROSPIKE_OK if successful. Otherwise an error.
569 *
570 * @ingroup key_operations
571 */
574 aerospike* as, as_error* err, const as_policy_operate* policy, const as_key* key,
575 const as_operations* ops, as_record** rec
576 );
577
578/**
579 * Asynchronously lookup a record by key, then perform specified operations.
580 *
581 * ~~~~~~~~~~{.c}
582 * void my_listener(as_error* err, as_record* record, void* udata, as_event_loop* event_loop)
583 * {
584 * if (err) {
585 * printf("Command failed: %d %s\n", err->code, err->message);
586 * return;
587 * }
588 * // Process record bins
589 * // Only call as_record_destroy(record) when command is successful (err == NULL) and
590 * // "as_policy_operate.async_heap_rec" is true. Otherwise, the calling function will destroy
591 * // the record when the listener completes.
592 * }
593 *
594 * as_key key;
595 * as_key_init(&key, "ns", "set", "key");
596 *
597 * as_operations ops;
598 * as_operations_inita(&ops,3);
599 * as_operations_add_incr(&ops, "bin1", 456);
600 * as_operations_add_append_str(&ops, "bin2", "def");
601 * as_operations_add_read(&ops, "bin1")
602 *
603 * as_status status = aerospike_key_operate(&as, &err, NULL, &key, &ops, my_listener, NULL, NULL, NULL);
604 * as_operations_destroy(&ops);
605 * ~~~~~~~~~~
606 *
607 * @param as The aerospike instance to use for this operation.
608 * @param err The as_error to be populated if an error occurs.
609 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
610 * @param key The key of the record.
611 * @param ops The operations to perform on the record.
612 * @param listener User function to be called with command results.
613 * @param udata User data to be forwarded to user callback.
614 * @param event_loop Event loop assigned to run this command. If NULL, an event loop will be chosen by round-robin.
615 * @param pipe_listener Enables command pipelining, if not NULL. The given callback is invoked after the current command
616 * has been sent to the server. This allows for issuing the next command even before receiving a
617 * result for the current command.
618 *
619 * @return AEROSPIKE_OK if async command successfully queued. Otherwise an error.
620 *
621 * @ingroup key_operations
622 */
625 aerospike* as, as_error* err, const as_policy_operate* policy, const as_key* key, const as_operations* ops,
626 as_async_record_listener listener, void* udata, as_event_loop* event_loop, as_pipe_listener pipe_listener
627 );
628
629/**
630 * Lookup a record by key, then apply the UDF.
631 *
632 * ~~~~~~~~~~{.c}
633 * as_key key;
634 * as_key_init(&key, "ns", "set", "key");
635 *
636 * as_arraylist args;
637 * as_arraylist_inita(&args, 2);
638 * as_arraylist_append_int64(&args, 1);
639 * as_arraylist_append_int64(&args, 2);
640 *
641 * as_val * res = NULL;
642 *
643 * if (aerospike_key_apply(&as, &err, NULL, &key, "math", "add", &args, &res) != AEROSPIKE_OK) {
644 * printf("error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
645 * }
646 * else {
647 * as_val_destroy(res);
648 * }
649 *
650 * as_arraylist_destroy(&args);
651 * ~~~~~~~~~~
652 *
653 *
654 * @param as The aerospike instance to use for this operation.
655 * @param err The as_error to be populated if an error occurs.
656 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
657 * @param key The key of the record.
658 * @param module The module containing the function to execute.
659 * @param function The function to execute.
660 * @param arglist The arguments for the function.
661 * @param result The return value from the function.
662 *
663 * @return AEROSPIKE_OK if successful. Otherwise an error.
664 *
665 * @ingroup key_operations
666 */
669 aerospike* as, as_error* err, const as_policy_apply* policy, const as_key* key,
670 const char* module, const char* function, as_list* arglist, as_val** result
671 );
672
673/**
674 * Asynchronously lookup a record by key, then apply the UDF.
675 *
676 * ~~~~~~~~~~{.c}
677 * void my_listener(as_error* err, as_val* val, void* udata, as_event_loop* event_loop)
678 * {
679 * if (err) {
680 * printf("Command failed: %d %s\n", err->code, err->message);
681 * return;
682 * }
683 * // Process value. The calling function will call as_val_destroy().
684 * // If the value needs to be preserved, bump up the reference count using as_val_reserve()
685 * // and call as_val_destroy() when done with the value.
686 * }
687 *
688 * as_key key;
689 * as_key_init(&key, "ns", "set", "key");
690 *
691 * as_arraylist args;
692 * as_arraylist_inita(&args, 2);
693 * as_arraylist_append_int64(&args, 1);
694 * as_arraylist_append_int64(&args, 2);
695 *
696 * as_status status = aerospike_key_apply(&as, &err, NULL, &key, "math", "add", &args, my_listener, NULL, NULL, NULL);
697 * as_arraylist_destroy(&args);
698 * ~~~~~~~~~~
699 *
700 * @param as The aerospike instance to use for this operation.
701 * @param err The as_error to be populated if an error occurs.
702 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
703 * @param key The key of the record.
704 * @param module The module containing the function to execute.
705 * @param function The function to execute.
706 * @param arglist The arguments for the function.
707 * @param listener User function to be called with command results.
708 * @param udata User data to be forwarded to user callback.
709 * @param event_loop Event loop assigned to run this command. If NULL, an event loop will be chosen by round-robin.
710 * @param pipe_listener Enables command pipelining, if not NULL. The given callback is invoked after the current command
711 * has been sent to the server. This allows for issuing the next command even before receiving a
712 * result for the current command.
713 *
714 * @return AEROSPIKE_OK if async command successfully queued. Otherwise an error.
715 *
716 * @ingroup key_operations
717 */
720 aerospike* as, as_error* err, const as_policy_apply* policy, const as_key* key,
721 const char* module, const char* function, as_list* arglist,
722 as_async_value_listener listener, void* udata, as_event_loop* event_loop,
723 as_pipe_listener pipe_listener
724 );
725
726/**
727 * @cond SKIP_DOXYGEN
728 * doxygen skips this section till endcond
729 */
731aerospike_key_put_async_ex(
732 aerospike* as, as_error* err, const as_policy_write* policy, const as_key* key, as_record* rec,
733 as_async_write_listener listener, void* udata, as_event_loop* event_loop, as_pipe_listener pipe_listener,
734 size_t* length, size_t* comp_length
735 );
736
738aerospike_key_remove_async_ex(
739 aerospike* as, as_error* err, const as_policy_remove* policy, const as_key* key,
740 as_async_write_listener listener, void* udata, as_event_loop* event_loop,
741 as_pipe_listener pipe_listener, size_t* length
742 );
743/**
744 * @endcond
745 */
746
747#ifdef __cplusplus
748} // end extern "C"
749#endif
void(* as_pipe_listener)(void *udata, as_event_loop *event_loop)
Definition as_listener.h:72
void(* as_async_value_listener)(as_error *err, as_val *val, void *udata, as_event_loop *event_loop)
Definition as_listener.h:61
void(* as_async_write_listener)(as_error *err, void *udata, as_event_loop *event_loop)
Definition as_listener.h:36
void(* as_async_record_listener)(as_error *err, as_record *record, void *udata, as_event_loop *event_loop)
Definition as_listener.h:48
as_status
Definition as_status.h:30
#define AS_EXTERN
Definition as_std.h:25
AS_EXTERN as_status aerospike_key_operate(aerospike *as, as_error *err, const as_policy_operate *policy, const as_key *key, const as_operations *ops, as_record **rec)
AS_EXTERN as_status aerospike_key_select(aerospike *as, as_error *err, const as_policy_read *policy, const as_key *key, const char *bins[], as_record **rec)
AS_EXTERN as_status aerospike_key_put_async(aerospike *as, as_error *err, const as_policy_write *policy, const as_key *key, as_record *rec, as_async_write_listener listener, void *udata, as_event_loop *event_loop, as_pipe_listener pipe_listener)
AS_EXTERN as_status aerospike_key_get(aerospike *as, as_error *err, const as_policy_read *policy, const as_key *key, as_record **rec)
as_status aerospike_key_select_bins_async(aerospike *as, as_error *err, const as_policy_read *policy, const as_key *key, const char *bins[], uint32_t n_bins, as_async_record_listener listener, void *udata, as_event_loop *event_loop, as_pipe_listener pipe_listener)
AS_EXTERN as_status aerospike_key_remove(aerospike *as, as_error *err, const as_policy_remove *policy, const as_key *key)
AS_EXTERN as_status aerospike_key_apply(aerospike *as, as_error *err, const as_policy_apply *policy, const as_key *key, const char *module, const char *function, as_list *arglist, as_val **result)
as_status aerospike_key_select_bins(aerospike *as, as_error *err, const as_policy_read *policy, const as_key *key, const char *bins[], uint32_t n_bins, as_record **rec)
AS_EXTERN as_status aerospike_key_apply_async(aerospike *as, as_error *err, const as_policy_apply *policy, const as_key *key, const char *module, const char *function, as_list *arglist, as_async_value_listener listener, void *udata, as_event_loop *event_loop, as_pipe_listener pipe_listener)
AS_EXTERN as_status aerospike_key_put(aerospike *as, as_error *err, const as_policy_write *policy, const as_key *key, as_record *rec)
AS_EXTERN as_status aerospike_key_exists_async(aerospike *as, as_error *err, const as_policy_read *policy, const as_key *key, as_async_record_listener listener, void *udata, as_event_loop *event_loop, as_pipe_listener pipe_listener)
AS_EXTERN as_status aerospike_key_select_async(aerospike *as, as_error *err, const as_policy_read *policy, const as_key *key, const char *bins[], as_async_record_listener listener, void *udata, as_event_loop *event_loop, as_pipe_listener pipe_listener)
AS_EXTERN as_status aerospike_key_get_async(aerospike *as, as_error *err, const as_policy_read *policy, const as_key *key, as_async_record_listener listener, void *udata, as_event_loop *event_loop, as_pipe_listener pipe_listener)
AS_EXTERN as_status aerospike_key_remove_async(aerospike *as, as_error *err, const as_policy_remove *policy, const as_key *key, as_async_write_listener listener, void *udata, as_event_loop *event_loop, as_pipe_listener pipe_listener)
AS_EXTERN as_status aerospike_key_operate_async(aerospike *as, as_error *err, const as_policy_operate *policy, const as_key *key, const as_operations *ops, as_async_record_listener listener, void *udata, as_event_loop *event_loop, as_pipe_listener pipe_listener)
AS_EXTERN as_status aerospike_key_exists(aerospike *as, as_error *err, const as_policy_read *policy, const as_key *key, as_record **rec)