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