All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
as_command.h
Go to the documentation of this file.
1/*
2 * Copyright 2008-2025 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#include <aerospike/as_bin.h>
20#include <aerospike/as_buffer.h>
22#include <aerospike/as_key.h>
24#include <aerospike/as_proto.h>
25#include <aerospike/as_random.h>
26#include <aerospike/as_record.h>
27#include <citrusleaf/cf_byte_order.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33//---------------------------------
34// Macros
35//---------------------------------
36
37// Command Flags
38#define AS_COMMAND_FLAGS_READ 1
39#define AS_COMMAND_FLAGS_BATCH 2
40#define AS_COMMAND_FLAGS_LINEARIZE 4
41#define AS_COMMAND_FLAGS_SPLIT_RETRY 8
42#define AS_COMMAND_FLAGS_TXN_MONITOR 16
43
44// Field IDs
45#define AS_FIELD_NAMESPACE 0
46#define AS_FIELD_SETNAME 1
47#define AS_FIELD_KEY 2
48#define AS_FIELD_RECORD_VERSION 3
49#define AS_FIELD_DIGEST 4
50#define AS_FIELD_TXN_ID 5
51#define AS_FIELD_TXN_DEADLINE 6
52#define AS_FIELD_TASK_ID 7
53#define AS_FIELD_SOCKET_TIMEOUT 9
54#define AS_FIELD_RPS 10
55#define AS_FIELD_PID_ARRAY 11
56#define AS_FIELD_DIGEST_ARRAY 12
57#define AS_FIELD_MAX_RECORDS 13
58#define AS_FIELD_BVAL_ARRAY 15
59#define AS_FIELD_INDEX_RANGE 22
60#define AS_FIELD_INDEX_CONTEXT 23
61#define AS_FIELD_INDEX_TYPE 26
62#define AS_FIELD_UDF_PACKAGE_NAME 30
63#define AS_FIELD_UDF_FUNCTION 31
64#define AS_FIELD_UDF_ARGLIST 32
65#define AS_FIELD_UDF_OP 33
66#define AS_FIELD_QUERY_BINS 40
67#define AS_FIELD_BATCH_INDEX 41
68#define AS_FIELD_FILTER 43
69
70// Message info1 bits
71#define AS_MSG_INFO1_READ (1 << 0) // contains a read operation
72#define AS_MSG_INFO1_GET_ALL (1 << 1) // get all bins, period
73#define AS_MSG_INFO1_SHORT_QUERY (1 << 2) // short query
74#define AS_MSG_INFO1_BATCH_INDEX (1 << 3) // batch
75#define AS_MSG_INFO1_XDR (1 << 4) // operation is being performed by XDR
76#define AS_MSG_INFO1_GET_NOBINDATA (1 << 5) // do not get information about bins and its data
77#define AS_MSG_INFO1_READ_MODE_AP_ALL (1 << 6) // read mode all for AP namespaces.
78#define AS_MSG_INFO1_COMPRESS_RESPONSE (1 << 7) // tell server to compress it's response.
79
80// Message info2 bits
81#define AS_MSG_INFO2_WRITE (1 << 0) // contains a write semantic
82#define AS_MSG_INFO2_DELETE (1 << 1) // delete record
83#define AS_MSG_INFO2_GENERATION (1 << 2) // pay attention to the generation
84#define AS_MSG_INFO2_GENERATION_GT (1 << 3) // apply write if new generation >= old, good for restore
85#define AS_MSG_INFO2_DURABLE_DELETE (1 << 4) // command resulting in record deletion leaves tombstone (Enterprise only).
86#define AS_MSG_INFO2_CREATE_ONLY (1 << 5) // write record only if it doesn't exist
87#define AS_MSG_INFO2_RELAX_AP_LONG_QUERY (1 << 6) // treat as long query, but relax read consistency.
88#define AS_MSG_INFO2_RESPOND_ALL_OPS (1 << 7) // return a result for every operation.
89
90// Message info3 bits
91#define AS_MSG_INFO3_LAST (1 << 0) // this is the last of a multi-part message
92#define AS_MSG_INFO3_COMMIT_MASTER (1 << 1) // write commit level - bit 0
93// On send: Do not return partition done in scan/query.
94// On receive: Specified partition is done in scan/query.
95#define AS_MSG_INFO3_PARTITION_DONE (1 << 2)
96#define AS_MSG_INFO3_UPDATE_ONLY (1 << 3) // update existing record only, do not create new record
97#define AS_MSG_INFO3_CREATE_OR_REPLACE (1 << 4) // completely replace existing record, or create new record
98#define AS_MSG_INFO3_REPLACE_ONLY (1 << 5) // completely replace existing record, do not create new record
99#define AS_MSG_INFO3_SC_READ_TYPE (1 << 6) // see below
100#define AS_MSG_INFO3_SC_READ_RELAX (1 << 7) // see below
101// Interpret SC_READ bits in info3.
102//
103// RELAX TYPE
104// strict
105// ------
106// 0 0 sequential (default)
107// 0 1 linearize
108//
109// relaxed
110// -------
111// 1 0 allow prole
112// 1 1 allow unavailable
113
114// Transaction
115#define AS_MSG_INFO4_TXN_VERIFY_READ (1 << 0) // Send transaction version to the server to be verified.
116#define AS_MSG_INFO4_TXN_ROLL_FORWARD (1 << 1) // Roll forward transaction.
117#define AS_MSG_INFO4_TXN_ROLL_BACK (1 << 2) // Roll back transaction.
118#define AS_MSG_INFO4_TXN_ON_LOCKING_ONLY (1 << 4) // Must be able to lock record in transaction.
119
120// Misc
121#define AS_HEADER_SIZE 30
122#define AS_FIELD_HEADER_SIZE 5
123#define AS_OPERATION_HEADER_SIZE 8
124
125#define AS_STACK_BUF_SIZE (1024 * 16)
126#define AS_COMPRESS_THRESHOLD 128
127
128/**
129 * @private
130 * Macros use these stand-ins for cf_malloc() / cf_free(), so that
131 * instrumentation properly substitutes them.
132 */
133static inline void*
134local_malloc(size_t size)
135{
136 return cf_malloc(size);
137}
138
139static inline void
140local_free(void* memory)
141{
142 cf_free(memory);
143}
144
145/**
146 * @private
147 * Allocate command buffer on stack or heap depending on given size.
148 */
149#define as_command_buffer_init(_sz) (_sz > AS_STACK_BUF_SIZE) ? (uint8_t*)local_malloc(_sz) : (uint8_t*)alloca(_sz)
150
151/**
152 * @private
153 * Free command buffer.
154 */
155#define as_command_buffer_free(_buf, _sz) if (_sz > AS_STACK_BUF_SIZE) {local_free(_buf);}
156
157//---------------------------------
158// Types
159//---------------------------------
160
161/**
162 * @private
163 * Write buffer callback used in as_command_send().
164 */
165typedef size_t (*as_write_fn) (void* udata, uint8_t* buf);
166
167struct as_command_s;
168struct as_txn;
169
170/**
171 * @private
172 * Parse results callback used in as_command_execute().
173 */
175 as_error* err, struct as_command_s* cmd, as_node* node, uint8_t* buf, size_t size
176 );
177
178/**
179 * @private
180 * Synchronous command data.
181 */
206
207/**
208 * @private
209 */
210typedef struct as_command_txn_data_s {
211 uint64_t version;
213 uint16_t n_fields;
216
217/**
218 * @private
219 * Data used in as_command_parse_result().
220 */
221typedef struct as_command_parse_result_data_s {
225
226//---------------------------------
227// Functions
228//---------------------------------
229
230/**
231 * @private
232 * Destroy buffers when error occurs before bins have been written.
233 */
234static inline void
236{
237 as_buffer b;
238
239 while (as_queue_pop(buffers, &b)) {
240 cf_free(b.data);
241 }
242 as_queue_destroy(buffers);
243}
244
245/**
246 * @private
247 * Calculate size of user key.
248 */
249size_t
251
252/**
253 * @private
254 * Calculate size of command header plus key fields.
255 */
256size_t
258 const as_policy_base* policy, as_policy_key pol_key, const as_key* key, bool send_deadline,
260 );
261
262/**
263 * @private
264 * Calculate size of string field.
265 */
266static inline size_t
268{
269 return strlen(value) + AS_FIELD_HEADER_SIZE;
270}
271
272/**
273 * @private
274 * Calculate size of field structure given field value size.
275 */
276static inline size_t
278{
279 return size + AS_FIELD_HEADER_SIZE;
280}
281
282/**
283 * @private
284 * Increment size by bin size.
285 */
287as_command_bin_size(const as_bin* bin, as_queue* buffers, size_t* size, as_error* err);
288
289/**
290 * @private
291 * Calculate size of bin name. Return error is bin name greater than AS_BIN_NAME_MAX_LEN characters.
292 */
293static inline as_status
294as_command_bin_name_size(as_error* err, const char* name, size_t* size)
295{
296 size_t s = strlen(name);
297
298 if (s > AS_BIN_NAME_MAX_LEN) {
299 return as_error_update(err, AEROSPIKE_ERR_PARAM, "Bin name too long: %s", name);
300 }
301 (*size) += s + AS_OPERATION_HEADER_SIZE;
302 return AEROSPIKE_OK;
303}
304
305/**
306 * @private
307 * Calculate size of string operation.
308 */
309static inline size_t
311{
312 return strlen(value) + AS_OPERATION_HEADER_SIZE;
313}
314
315/**
316 * @private
317 * Set read attributes for read header commands.
318 */
319static inline void
321 as_policy_read_mode_ap read_mode_ap, as_policy_read_mode_sc read_mode_sc,
322 uint8_t* read_attr, uint8_t* info_attr
323 )
324{
325 switch (read_mode_sc) {
326 default:
328 break;
329
331 *info_attr |= AS_MSG_INFO3_SC_READ_TYPE;
332 break;
333
335 *info_attr |= AS_MSG_INFO3_SC_READ_RELAX;
336 break;
337
340 break;
341 }
342
343 if (read_mode_ap == AS_POLICY_READ_MODE_AP_ALL) {
344 *read_attr |= AS_MSG_INFO1_READ_MODE_AP_ALL;
345 }
346}
347
348/**
349 * @private
350 * Set compress attributes when compress is true.
351 */
352static inline void
353as_command_set_attr_compress(bool compress, uint8_t* read_attr)
354{
355 if (compress) {
356 *read_attr |= AS_MSG_INFO1_COMPRESS_RESPONSE;
357 }
358}
359
360/**
361 * @private
362 * Set read attributes for read commands.
363 */
364static inline void
366 as_policy_read_mode_ap read_mode_ap, as_policy_read_mode_sc read_mode_sc, bool compress,
367 uint8_t* read_attr, uint8_t* info_attr
368 )
369{
370 as_command_set_attr_read_header(read_mode_ap, read_mode_sc, read_attr, info_attr);
371 as_command_set_attr_compress(compress, read_attr);
372}
373
374/**
375 * @private
376 * Write command header for write commands.
377 */
378uint8_t*
380 uint8_t* cmd, const as_policy_base* policy, as_policy_commit_level commit_level,
381 as_policy_exists exists, as_policy_gen gen_policy, uint32_t gen, uint32_t ttl,
382 uint16_t n_fields, uint16_t n_bins, bool durable_delete, bool on_locking_only,
383 uint8_t read_attr, uint8_t write_attr, uint8_t info_attr
384 );
385
386/**
387 * @private
388 * Write command header for read commands.
389 */
390uint8_t*
392 uint8_t* cmd, const as_policy_base* policy, as_policy_read_mode_ap read_mode_ap,
393 as_policy_read_mode_sc read_mode_sc, int read_ttl, uint32_t timeout, uint16_t n_fields,
394 uint16_t n_bins, uint8_t read_attr, uint8_t write_attr, uint8_t info_attr
395 );
396
397/**
398 * @private
399 * Write command header for read header commands.
400 */
401uint8_t*
403 uint8_t* cmd, const as_policy_base* policy, as_policy_read_mode_ap read_mode_ap,
404 as_policy_read_mode_sc read_mode_sc, int read_ttl, uint16_t n_fields, uint16_t n_bins,
405 uint8_t read_attr
406 );
407
408/**
409 * @private
410 * Write field header.
411 */
412static inline uint8_t*
413as_command_write_field_header(uint8_t* p, uint8_t id, uint32_t size)
414{
415 *(uint32_t*)p = cf_swap_to_be32(size+1);
416 p += 4;
417 *p++ = id;
418 return p;
419}
420
421/**
422 * @private
423 * Write string field.
424 */
425static inline uint8_t*
426as_command_write_field_string(uint8_t* begin, uint8_t id, const char* val)
427{
428 uint8_t* p = begin + AS_FIELD_HEADER_SIZE;
429
430 // Copy string, but do not transfer null byte.
431 while (*val) {
432 *p++ = *val++;
433 }
434 as_command_write_field_header(begin, id, (uint32_t)(p - begin - AS_FIELD_HEADER_SIZE));
435 return p;
436}
437
438/**
439 * @private
440 * Write uint32_t field.
441 */
442static inline uint8_t*
443as_command_write_field_uint32(uint8_t* p, uint8_t id, uint32_t val)
444{
445 p = as_command_write_field_header(p, id, sizeof(uint32_t));
446 *(uint32_t*)p = cf_swap_to_be32(val);
447 return p + sizeof(uint32_t);
448}
449
450/**
451 * @private
452 * Write uint32_t field in little endian format.
453 */
454static inline uint8_t*
455as_command_write_field_uint32_le(uint8_t* p, uint8_t id, uint32_t val)
456{
457 p = as_command_write_field_header(p, id, sizeof(uint32_t));
458 *(uint32_t*)p = cf_swap_to_le32(val);
459 return p + sizeof(uint32_t);
460}
461
462/**
463 * @private
464 * Write uint64_t field.
465 */
466static inline uint8_t*
467as_command_write_field_uint64(uint8_t* p, uint8_t id, uint64_t val)
468{
469 p = as_command_write_field_header(p, id, sizeof(uint64_t));
470 *(uint64_t*)p = cf_swap_to_be64(val);
471 return p + sizeof(uint64_t);
472}
473
474/**
475 * @private
476 * Write uint64_t field in little endian format.
477 */
478static inline uint8_t*
479as_command_write_field_uint64_le(uint8_t* p, uint8_t id, uint64_t val)
480{
481 p = as_command_write_field_header(p, id, sizeof(uint64_t));
482 *(uint64_t*)p = cf_swap_to_le64(val);
483 return p + sizeof(uint64_t);
484}
485
486/**
487 * @private
488 * Write as_buffer field.
489 */
490static inline uint8_t*
491as_command_write_field_buffer(uint8_t* p, uint8_t id, as_buffer* buffer)
492{
493 p = as_command_write_field_header(p, id, buffer->size);
494 memcpy(p, buffer->data, buffer->size);
495 return p + buffer->size;
496}
497
498/**
499 * @private
500 * Write digest field.
501 */
502static inline uint8_t*
509
510/**
511 * @private
512 * Write 7 byte record version field.
513 */
514static inline uint8_t*
515as_command_write_field_version(uint8_t* p, uint64_t ver)
516{
518 uint64_t v = cf_swap_to_le64(ver);
519 memcpy(p, &v, 7);
520 return p + 7;
521}
522
523/**
524 * @private
525 * Write user key.
526 */
527uint8_t*
528as_command_write_user_key(uint8_t* begin, const as_key* key);
529
530/**
531 * @private
532 * Write key structure.
533 */
534uint8_t*
536 uint8_t* p, const as_policy_base* policy, as_policy_key pol_key, const as_key* key,
538 );
539
540/**
541 * @private
542 * Write bin header and bin name.
543 */
544uint8_t*
545as_command_write_bin_name(uint8_t* cmd, const char* name);
546
547/**
548 * @private
549 * Write bin.
550 */
551uint8_t*
553 uint8_t* begin, as_operator operation_type, const as_bin* bin, as_queue* buffers
554 );
555
556/**
557 * @private
558 * Finish writing command.
559 */
560static inline size_t
561as_command_write_end(uint8_t* begin, uint8_t* end)
562{
563 uint64_t len = end - begin;
564 uint64_t proto = (len - 8) | ((uint64_t)AS_PROTO_VERSION << 56) | ((uint64_t)AS_MESSAGE_TYPE << 48);
565 *(uint64_t*)begin = cf_swap_to_be64(proto);
566 return len;
567}
568
569/**
570 * @private
571 * Finish writing compressed command.
572 */
573static inline size_t
574as_command_compress_write_end(uint8_t* begin, uint8_t* end, uint64_t uncompressed_sz)
575{
576 uint64_t len = end - begin;
577 uint64_t proto = (len - 8) | ((uint64_t)AS_PROTO_VERSION << 56) | ((uint64_t)AS_COMPRESSED_MESSAGE_TYPE << 48);
578 *(uint64_t*)begin = cf_swap_to_be64(proto);
579 ((as_compressed_proto *)begin)->uncompressed_sz = cf_swap_to_be64(uncompressed_sz);
580 return len;
581}
582
583/**
584 * @private
585 * Calculate max size the compressed command buffer.
586 */
587size_t
589
590/**
591 * @private
592 * Compress command buffer.
593 */
595as_command_compress(as_error* err, uint8_t* cmd, size_t cmd_sz, uint8_t* compressed_cmd, size_t* compressed_size);
596
597/**
598 * @private
599 * Return timeout to be sent to server for single record commands.
600 */
601static inline uint32_t
603{
604 return (policy->socket_timeout < policy->total_timeout && policy->socket_timeout != 0)?
605 policy->socket_timeout : policy->total_timeout;
606}
607
608/**
609 * @private
610 * Start command timer.
611 */
612static inline void
614{
615 const as_policy_base* policy = cmd->policy;
616
617 cmd->max_retries = policy->max_retries;
618 cmd->iteration = 0;
619 cmd->sent = 0;
620
621 if (policy->total_timeout > 0) {
622 cmd->socket_timeout = (policy->socket_timeout == 0 ||
623 policy->socket_timeout > policy->total_timeout)?
624 policy->total_timeout : policy->socket_timeout;
625
626 cmd->total_timeout = policy->total_timeout;
627 cmd->deadline_ms = cf_getms() + policy->total_timeout;
628 }
629 else {
630 cmd->socket_timeout = policy->socket_timeout;
631 cmd->total_timeout = policy->total_timeout;
632 cmd->deadline_ms = 0;
633 }
634}
635
636/**
637 * @private
638 * Write buffer and send command to the server.
639 */
642 as_command* cmd, as_error* err, uint32_t comp_threshold, as_write_fn write_fn, void* udata
643 );
644
645/**
646 * @private
647 * Send command to the server.
648 */
651
652/**
653 * @private
654 * Parse header of server response.
655 */
657as_command_parse_header(as_error* err, as_command* cmd, as_node* node, uint8_t* buf, size_t size);
658
659/**
660 * @private
661 * Skip over fields section in returned data.
662 */
663uint8_t*
664as_command_ignore_fields(uint8_t* p, uint32_t n_fields);
665
666/**
667 * @private
668 * Parse record fields given digest/set.
669 */
672 uint8_t** pp, as_error* err, as_msg* msg, struct as_txn* txn, const uint8_t* digest,
673 const char* set, bool is_write
674 );
675
676/**
677 * @private
678 * Parse record fields given key.
679 */
680static inline as_status
682 uint8_t** pp, as_error* err, as_msg* msg, struct as_txn* txn, const as_key* key, bool is_write
683 )
684{
685 if (! txn) {
686 *pp = as_command_ignore_fields(*pp, msg->n_fields);
687 return AEROSPIKE_OK;
688 }
689 return as_command_parse_fields_txn(pp, err, msg, txn, key->digest.value, key->set, is_write);
690}
691
692/**
693 * @private
694 * Parse server record. Used for reads.
695 */
697as_command_parse_result(as_error* err, as_command* cmd, as_node* node, uint8_t* buf, size_t size);
698
699/**
700 * @private
701 * Parse server success or failure result.
702 */
704as_command_parse_success_failure(as_error* err, as_command* cmd, as_node* node, uint8_t* buf, size_t size);
705
706/**
707 * @private
708 * Parse server success or failure bins.
709 */
711as_command_parse_success_failure_bins(uint8_t** pp, as_error* err, as_msg* msg, as_val** value);
712
713/**
714 * @private
715 * Parse bins received from the server.
716 */
718as_command_parse_bins(uint8_t** pp, as_error* err, as_record* rec, uint32_t n_bins, bool deserialize);
719
720/**
721 * @private
722 * Parse user defined function error.
723 */
725as_command_parse_udf_failure(uint8_t* p, as_error* err, as_msg* msg, as_status status);
726
727/**
728 * @private
729 * Skip over bins in returned data.
730 */
731uint8_t*
732as_command_ignore_bins(uint8_t* p, uint32_t n_bins);
733
734/**
735 * @private
736 * Parse key fields received from server. Used for reads.
737 */
738uint8_t*
739as_command_parse_key(uint8_t* p, uint32_t n_fields, as_key* key, uint64_t* bval);
740
741/**
742 * @private
743 * Return random task id if not specified.
744 */
745static inline uint64_t
746as_task_id_resolve(uint64_t* task_id_ptr)
747{
748 if (! task_id_ptr) {
749 return as_random_get_uint64();
750 }
751
752 if (*task_id_ptr == 0) {
753 *task_id_ptr = as_random_get_uint64();
754 }
755 return *task_id_ptr;
756}
757
758/**
759 * @private
760 * Return command's starting replica index for AS_POLICY_REPLICA_ANY.
761 */
762uint8_t
764
765/**
766 * @private
767 * Return starting replica index for read commands.
768 */
769static inline uint8_t
774
775/**
776 * @private
777 * Convert replica target for write commands.
778 */
779static inline as_policy_replica
781{
782 // Writes should always go to master node on first attempt.
783 // Allow prole on retry when possible.
784 return (replica == AS_POLICY_REPLICA_MASTER)? replica : AS_POLICY_REPLICA_SEQUENCE;
785}
786
787/**
788 * @private
789 * Parse response with deadline field when adding keys to the transaction monitor record.
790 */
792as_command_parse_deadline(as_error* err, as_command* cmd, as_node* node, uint8_t* buf, size_t size);
793
794/**
795 * @private
796 * Parse deadline field.
797 */
799as_command_parse_fields_deadline(uint8_t** pp, as_error* err, as_msg* msg, struct as_txn* txn);
800
801#ifdef __cplusplus
802} // end extern "C"
803#endif
#define AS_BIN_NAME_MAX_LEN
Definition as_bin.h:44
as_status(* as_parse_results_fn)(as_error *err, struct as_command_s *cmd, as_node *node, uint8_t *buf, size_t size)
Definition as_command.h:174
size_t as_command_compress_max_size(size_t cmd_sz)
static size_t as_command_field_size(size_t size)
Definition as_command.h:277
static as_status as_command_bin_name_size(as_error *err, const char *name, size_t *size)
Definition as_command.h:294
as_status as_command_parse_udf_failure(uint8_t *p, as_error *err, as_msg *msg, as_status status)
as_status as_command_parse_deadline(as_error *err, as_command *cmd, as_node *node, uint8_t *buf, size_t size)
static size_t as_command_write_end(uint8_t *begin, uint8_t *end)
Definition as_command.h:561
size_t(* as_write_fn)(void *udata, uint8_t *buf)
Definition as_command.h:165
as_status as_command_bin_size(const as_bin *bin, as_queue *buffers, size_t *size, as_error *err)
as_status as_command_parse_fields_deadline(uint8_t **pp, as_error *err, as_msg *msg, struct as_txn *txn)
static uint8_t * as_command_write_field_string(uint8_t *begin, uint8_t id, const char *val)
Definition as_command.h:426
uint8_t * as_command_write_bin_name(uint8_t *cmd, const char *name)
static uint8_t * as_command_write_field_digest(uint8_t *p, const as_digest *val)
Definition as_command.h:503
static uint8_t * as_command_write_field_uint64_le(uint8_t *p, uint8_t id, uint64_t val)
Definition as_command.h:479
#define AS_OPERATION_HEADER_SIZE
Definition as_command.h:123
static uint32_t as_command_server_timeout(const as_policy_base *policy)
Definition as_command.h:602
static void as_command_set_attr_read(as_policy_read_mode_ap read_mode_ap, as_policy_read_mode_sc read_mode_sc, bool compress, uint8_t *read_attr, uint8_t *info_attr)
Definition as_command.h:365
uint8_t * as_command_write_header_read(uint8_t *cmd, const as_policy_base *policy, as_policy_read_mode_ap read_mode_ap, as_policy_read_mode_sc read_mode_sc, int read_ttl, uint32_t timeout, uint16_t n_fields, uint16_t n_bins, uint8_t read_attr, uint8_t write_attr, uint8_t info_attr)
as_status as_command_send(as_command *cmd, as_error *err, uint32_t comp_threshold, as_write_fn write_fn, void *udata)
static as_policy_replica as_command_write_replica(as_policy_replica replica)
Definition as_command.h:780
static uint8_t * as_command_write_field_uint32(uint8_t *p, uint8_t id, uint32_t val)
Definition as_command.h:443
uint8_t * as_command_ignore_fields(uint8_t *p, uint32_t n_fields)
static uint8_t * as_command_write_field_buffer(uint8_t *p, uint8_t id, as_buffer *buffer)
Definition as_command.h:491
static uint8_t * as_command_write_field_header(uint8_t *p, uint8_t id, uint32_t size)
Definition as_command.h:413
static uint64_t as_task_id_resolve(uint64_t *task_id_ptr)
Definition as_command.h:746
static size_t as_command_string_operation_size(const char *value)
Definition as_command.h:310
static void as_command_start_timer(as_command *cmd)
Definition as_command.h:613
static void as_buffers_destroy(as_queue *buffers)
Definition as_command.h:235
static uint8_t * as_command_write_field_uint32_le(uint8_t *p, uint8_t id, uint32_t val)
Definition as_command.h:455
size_t as_command_key_size(const as_policy_base *policy, as_policy_key pol_key, const as_key *key, bool send_deadline, as_command_txn_data *tdata)
static void as_command_set_attr_read_header(as_policy_read_mode_ap read_mode_ap, as_policy_read_mode_sc read_mode_sc, uint8_t *read_attr, uint8_t *info_attr)
Definition as_command.h:320
static void as_command_set_attr_compress(bool compress, uint8_t *read_attr)
Definition as_command.h:353
static size_t as_command_compress_write_end(uint8_t *begin, uint8_t *end, uint64_t uncompressed_sz)
Definition as_command.h:574
uint8_t * as_command_write_user_key(uint8_t *begin, const as_key *key)
static void local_free(void *memory)
Definition as_command.h:140
as_status as_command_execute(as_command *cmd, as_error *err)
static void * local_malloc(size_t size)
Definition as_command.h:134
#define AS_MSG_INFO1_COMPRESS_RESPONSE
Definition as_command.h:78
static uint8_t * as_command_write_field_version(uint8_t *p, uint64_t ver)
Definition as_command.h:515
as_status as_command_parse_header(as_error *err, as_command *cmd, as_node *node, uint8_t *buf, size_t size)
as_status as_command_parse_success_failure(as_error *err, as_command *cmd, as_node *node, uint8_t *buf, size_t size)
uint8_t * as_command_write_header_read_header(uint8_t *cmd, const as_policy_base *policy, as_policy_read_mode_ap read_mode_ap, as_policy_read_mode_sc read_mode_sc, int read_ttl, uint16_t n_fields, uint16_t n_bins, uint8_t read_attr)
static size_t as_command_string_field_size(const char *value)
Definition as_command.h:267
#define AS_FIELD_HEADER_SIZE
Definition as_command.h:122
#define AS_FIELD_DIGEST
Definition as_command.h:49
uint8_t as_replica_index_any(void)
#define AS_MSG_INFO1_READ_MODE_AP_ALL
Definition as_command.h:77
#define AS_MSG_INFO3_SC_READ_TYPE
Definition as_command.h:99
uint8_t * as_command_write_key(uint8_t *p, const as_policy_base *policy, as_policy_key pol_key, const as_key *key, as_command_txn_data *tdata)
uint8_t * as_command_write_bin(uint8_t *begin, as_operator operation_type, const as_bin *bin, as_queue *buffers)
as_status as_command_parse_fields_txn(uint8_t **pp, as_error *err, as_msg *msg, struct as_txn *txn, const uint8_t *digest, const char *set, bool is_write)
static uint8_t as_replica_index_init_read(as_policy_replica replica)
Definition as_command.h:770
static uint8_t * as_command_write_field_uint64(uint8_t *p, uint8_t id, uint64_t val)
Definition as_command.h:467
as_status as_command_compress(as_error *err, uint8_t *cmd, size_t cmd_sz, uint8_t *compressed_cmd, size_t *compressed_size)
uint8_t * as_command_write_header_write(uint8_t *cmd, const as_policy_base *policy, as_policy_commit_level commit_level, as_policy_exists exists, as_policy_gen gen_policy, uint32_t gen, uint32_t ttl, uint16_t n_fields, uint16_t n_bins, bool durable_delete, bool on_locking_only, uint8_t read_attr, uint8_t write_attr, uint8_t info_attr)
as_status as_command_parse_result(as_error *err, as_command *cmd, as_node *node, uint8_t *buf, size_t size)
uint8_t * as_command_parse_key(uint8_t *p, uint32_t n_fields, as_key *key, uint64_t *bval)
as_status as_command_parse_bins(uint8_t **pp, as_error *err, as_record *rec, uint32_t n_bins, bool deserialize)
#define AS_MSG_INFO3_SC_READ_RELAX
Definition as_command.h:100
size_t as_command_user_key_size(const as_key *key)
#define AS_FIELD_RECORD_VERSION
Definition as_command.h:48
static as_status as_command_parse_fields(uint8_t **pp, as_error *err, as_msg *msg, struct as_txn *txn, const as_key *key, bool is_write)
Definition as_command.h:681
uint8_t * as_command_ignore_bins(uint8_t *p, uint32_t n_bins)
as_status as_command_parse_success_failure_bins(uint8_t **pp, as_error *err, as_msg *msg, as_val **value)
#define AS_DIGEST_VALUE_SIZE
Definition as_key.h:36
uint8_t as_latency_type
Definition as_latency.h:29
as_operator
uint16_t n_fields
Definition as_proto.h:9
#define AS_COMPRESSED_MESSAGE_TYPE
Definition as_proto.h:39
uint64_t uncompressed_sz
Definition as_proto.h:1
#define AS_PROTO_VERSION
Definition as_proto.h:33
as_proto proto
Definition as_proto.h:0
#define AS_MESSAGE_TYPE
Definition as_proto.h:38
static bool as_queue_pop(as_queue *queue, void *ptr)
Definition as_queue.h:165
AS_EXTERN void as_queue_destroy(as_queue *queue)
static uint64_t as_random_get_uint64(void)
Definition as_random.h:84
as_status
Definition as_status.h:30
@ AEROSPIKE_OK
Definition as_status.h:143
@ AEROSPIKE_ERR_PARAM
Definition as_status.h:124
as_policy_commit_level
Definition as_policy.h:371
as_policy_gen
Definition as_policy.h:173
as_policy_read_mode_sc
Definition as_policy.h:334
as_policy_exists
Definition as_policy.h:237
as_policy_key
Definition as_policy.h:201
as_policy_replica
Definition as_policy.h:273
as_policy_read_mode_ap
Definition as_policy.h:313
@ AS_POLICY_READ_MODE_SC_ALLOW_REPLICA
Definition as_policy.h:352
@ AS_POLICY_READ_MODE_SC_SESSION
Definition as_policy.h:340
@ AS_POLICY_READ_MODE_SC_ALLOW_UNAVAILABLE
Definition as_policy.h:358
@ AS_POLICY_READ_MODE_SC_LINEARIZE
Definition as_policy.h:346
@ AS_POLICY_REPLICA_ANY
Definition as_policy.h:284
@ AS_POLICY_REPLICA_MASTER
Definition as_policy.h:278
@ AS_POLICY_REPLICA_SEQUENCE
Definition as_policy.h:292
@ AS_POLICY_READ_MODE_AP_ALL
Definition as_policy.h:323
uint8_t * data
Definition as_buffer.h:48
uint32_t size
Definition as_buffer.h:43
uint32_t deadline_offset
Definition as_command.h:212
const as_policy_base * policy
Definition as_command.h:184
const as_key * key
Definition as_command.h:186
size_t buf_size
Definition as_command.h:191
uint64_t deadline_ms
Definition as_command.h:194
uint32_t partition_id
Definition as_command.h:192
uint32_t max_retries
Definition as_command.h:197
as_latency_type latency_type
Definition as_command.h:204
uint32_t socket_timeout
Definition as_command.h:195
uint8_t replica_size
Definition as_command.h:201
void * udata
Definition as_command.h:189
uint8_t replica_index
Definition as_command.h:202
as_node * node
Definition as_command.h:185
uint32_t iteration
Definition as_command.h:198
uint8_t flags
Definition as_command.h:200
as_parse_results_fn parse_results_fn
Definition as_command.h:188
uint32_t total_timeout
Definition as_command.h:196
uint8_t replica_index_sc
Definition as_command.h:203
as_cluster * cluster
Definition as_command.h:183
uint8_t * buf
Definition as_command.h:190
as_policy_replica replica
Definition as_command.h:193
void * partition
Definition as_command.h:187
uint32_t sent
Definition as_command.h:199
as_digest_value value
Definition as_key.h:82
as_digest digest
Definition as_key.h:213
as_set set
Definition as_key.h:196
uint32_t socket_timeout
Definition as_policy.h:449
uint32_t total_timeout
Definition as_policy.h:464
uint32_t max_retries
Definition as_policy.h:486