All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Macros | Typedefs | Functions
as_command.h File Reference
#include <aerospike/as_bin.h>
#include <aerospike/as_buffer.h>
#include <aerospike/as_cluster.h>
#include <aerospike/as_key.h>
#include <aerospike/as_operations.h>
#include <aerospike/as_proto.h>
#include <aerospike/as_record.h>
#include <citrusleaf/cf_byte_order.h>
#include <citrusleaf/cf_digest.h>
+ Include dependency graph for as_command.h:

Go to the source code of this file.

Data Structures

struct  as_command_node
 
struct  as_command_parse_result_data
 

Macros

#define as_command_free(_buf, _sz)   if (_sz > AS_STACK_BUF_SIZE) {local_free(_buf);}
 
#define as_command_init(_sz)   (_sz > AS_STACK_BUF_SIZE) ? (uint8_t*)local_malloc(_sz) : (uint8_t*)alloca(_sz)
 
#define AS_COMPRESSED_MESSAGE_TYPE   4L
 
#define AS_FIELD_BATCH_INDEX   41
 
#define AS_FIELD_BATCH_INDEX_WITH_SET   42
 
#define AS_FIELD_DIGEST   4
 
#define AS_FIELD_DIGEST_ARRAY   6
 
#define AS_FIELD_HEADER_SIZE   5
 
#define AS_FIELD_INDEX_FILTER   23
 
#define AS_FIELD_INDEX_LIMIT   24
 
#define AS_FIELD_INDEX_ORDER   25
 
#define AS_FIELD_INDEX_RANGE   22
 
#define AS_FIELD_INDEX_TYPE   26
 
#define AS_FIELD_KEY   2
 
#define AS_FIELD_NAMESPACE   0
 
#define AS_FIELD_PREDEXP   43
 
#define AS_FIELD_QUERY_BINS   40
 
#define AS_FIELD_SCAN_OPTIONS   8
 
#define AS_FIELD_SETNAME   1
 
#define AS_FIELD_TASK_ID   7
 
#define AS_FIELD_UDF_ARGLIST   32
 
#define AS_FIELD_UDF_FUNCTION   31
 
#define AS_FIELD_UDF_OP   33
 
#define AS_FIELD_UDF_PACKAGE_NAME   30
 
#define AS_HEADER_SIZE   30
 
#define AS_INFO_MESSAGE_TYPE   1L
 
#define AS_INFO_MESSAGE_VERSION   2L
 
#define AS_MESSAGE_TYPE   3L
 
#define AS_MESSAGE_VERSION   2L
 
#define AS_MSG_INFO1_BATCH_INDEX   (1 << 3)
 
#define AS_MSG_INFO1_CONSISTENCY_ALL   (1 << 6)
 
#define AS_MSG_INFO1_GET_ALL   (1 << 1)
 
#define AS_MSG_INFO1_GET_NOBINDATA   (1 << 5)
 
#define AS_MSG_INFO1_READ   (1 << 0)
 
#define AS_MSG_INFO1_XDR   (1 << 4)
 
#define AS_MSG_INFO2_CREATE_ONLY   (1 << 5)
 
#define AS_MSG_INFO2_DELETE   (1 << 1)
 
#define AS_MSG_INFO2_DURABLE_DELETE   (1 << 4)
 
#define AS_MSG_INFO2_GENERATION   (1 << 2)
 
#define AS_MSG_INFO2_GENERATION_GT   (1 << 3)
 
#define AS_MSG_INFO2_RESPOND_ALL_OPS   (1 << 7)
 
#define AS_MSG_INFO2_WRITE   (1 << 0)
 
#define AS_MSG_INFO3_COMMIT_MASTER   (1 << 1)
 
#define AS_MSG_INFO3_CREATE_OR_REPLACE   (1 << 4)
 
#define AS_MSG_INFO3_LAST   (1 << 0)
 
#define AS_MSG_INFO3_REPLACE_ONLY   (1 << 5)
 
#define AS_MSG_INFO3_UPDATE_ONLY   (1 << 3)
 
#define AS_OPERATION_HEADER_SIZE   8
 
#define AS_STACK_BUF_SIZE   (1024 * 16)
 

Typedefs

typedef as_status(* as_parse_results_fn )(as_error *err, as_socket *sock, uint64_t deadline_ms, void *user_data)
 

Functions

static as_status as_command_bin_name_size (as_error *err, const char *name, size_t *size)
 
static size_t as_command_bin_size (const as_bin *bin, as_buffer *buffer)
 
as_status as_command_compress (as_error *err, uint8_t *cmd, size_t cmd_sz, uint8_t *compressed_cmd, size_t *compressed_size)
 
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)
 
as_status as_command_execute (as_cluster *cluster, as_error *err, as_command_node *cn, uint8_t *command, size_t command_len, uint32_t timeout_ms, bool timeout_per_try, uint32_t max_retries, uint32_t sleep_between_retries_ms, as_parse_results_fn parse_results_fn, void *parse_results_data)
 
static size_t as_command_field_size (size_t size)
 
uint8_t * as_command_ignore_bins (uint8_t *p, uint32_t n_bins)
 
uint8_t * as_command_ignore_fields (uint8_t *p, uint32_t n_fields)
 
size_t as_command_key_size (as_policy_key policy, const as_key *key, uint16_t *n_fields)
 
as_status as_command_parse_bins (uint8_t **pp, as_error *err, as_record *rec, uint32_t n_bins, bool deserialize)
 
as_status as_command_parse_header (as_error *err, as_socket *sock, uint64_t deadline_ms, void *user_data)
 
uint8_t * as_command_parse_key (uint8_t *p, uint32_t n_fields, as_key *key)
 
as_status as_command_parse_result (as_error *err, as_socket *sock, uint64_t deadline_ms, void *user_data)
 
as_status as_command_parse_success_failure (as_error *err, as_socket *sock, uint64_t deadline_ms, void *user_data)
 
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_udf_failure (uint8_t *p, as_error *err, as_msg *msg, as_status status)
 
static size_t as_command_string_field_size (const char *value)
 
static size_t as_command_string_operation_size (const char *value)
 
size_t as_command_value_size (as_val *val, as_buffer *buffer)
 
uint8_t * as_command_write_bin (uint8_t *begin, uint8_t operation_type, const as_bin *bin, as_buffer *buffer)
 
static uint8_t * as_command_write_bin_name (uint8_t *cmd, const char *name)
 
static size_t as_command_write_end (uint8_t *begin, uint8_t *end)
 
static uint8_t * as_command_write_field_buffer (uint8_t *p, uint8_t id, as_buffer *buffer)
 
static uint8_t * as_command_write_field_digest (uint8_t *p, const as_digest *val)
 
static uint8_t * as_command_write_field_header (uint8_t *p, uint8_t id, uint32_t size)
 
static uint8_t * as_command_write_field_string (uint8_t *begin, uint8_t id, const char *val)
 
static uint8_t * as_command_write_field_uint64 (uint8_t *p, uint8_t id, uint64_t val)
 
uint8_t * as_command_write_header (uint8_t *cmd, uint8_t read_attr, uint8_t write_attr, as_policy_commit_level commit_level, as_policy_consistency_level consistency, as_policy_exists exists, as_policy_gen gen_policy, uint32_t gen, uint32_t ttl, uint32_t timeout_ms, uint16_t n_fields, uint16_t n_bins, bool durable_delete)
 
static uint8_t * as_command_write_header_read (uint8_t *cmd, uint8_t read_attr, as_policy_consistency_level consistency, uint32_t timeout_ms, uint16_t n_fields, uint16_t n_bins)
 
uint8_t * as_command_write_key (uint8_t *p, as_policy_key policy, const as_key *key)
 
static void local_free (void *memory)
 
static void * local_malloc (size_t size)
 

Macro Definition Documentation

#define as_command_free (   _buf,
  _sz 
)    if (_sz > AS_STACK_BUF_SIZE) {local_free(_buf);}

Free command buffer.

Definition at line 133 of file as_command.h.

#define as_command_init (   _sz)    (_sz > AS_STACK_BUF_SIZE) ? (uint8_t*)local_malloc(_sz) : (uint8_t*)alloca(_sz)

Allocate command buffer on stack or heap depending on given size.

Definition at line 127 of file as_command.h.

#define AS_COMPRESSED_MESSAGE_TYPE   4L

Definition at line 92 of file as_command.h.

#define AS_FIELD_BATCH_INDEX   41

Definition at line 55 of file as_command.h.

#define AS_FIELD_BATCH_INDEX_WITH_SET   42

Definition at line 56 of file as_command.h.

#define AS_FIELD_DIGEST   4

Definition at line 41 of file as_command.h.

#define AS_FIELD_DIGEST_ARRAY   6

Definition at line 42 of file as_command.h.

#define AS_FIELD_HEADER_SIZE   5

Definition at line 100 of file as_command.h.

#define AS_FIELD_INDEX_FILTER   23

Definition at line 46 of file as_command.h.

#define AS_FIELD_INDEX_LIMIT   24

Definition at line 47 of file as_command.h.

#define AS_FIELD_INDEX_ORDER   25

Definition at line 48 of file as_command.h.

#define AS_FIELD_INDEX_RANGE   22

Definition at line 45 of file as_command.h.

#define AS_FIELD_INDEX_TYPE   26

Definition at line 49 of file as_command.h.

#define AS_FIELD_KEY   2

Definition at line 40 of file as_command.h.

#define AS_FIELD_NAMESPACE   0

Definition at line 38 of file as_command.h.

#define AS_FIELD_PREDEXP   43

Definition at line 57 of file as_command.h.

#define AS_FIELD_QUERY_BINS   40

Definition at line 54 of file as_command.h.

#define AS_FIELD_SCAN_OPTIONS   8

Definition at line 44 of file as_command.h.

#define AS_FIELD_SETNAME   1

Definition at line 39 of file as_command.h.

#define AS_FIELD_TASK_ID   7

Definition at line 43 of file as_command.h.

#define AS_FIELD_UDF_ARGLIST   32

Definition at line 52 of file as_command.h.

#define AS_FIELD_UDF_FUNCTION   31

Definition at line 51 of file as_command.h.

#define AS_FIELD_UDF_OP   33

Definition at line 53 of file as_command.h.

#define AS_FIELD_UDF_PACKAGE_NAME   30

Definition at line 50 of file as_command.h.

#define AS_HEADER_SIZE   30

Definition at line 99 of file as_command.h.

#define AS_INFO_MESSAGE_TYPE   1L

Definition at line 96 of file as_command.h.

#define AS_INFO_MESSAGE_VERSION   2L

Definition at line 95 of file as_command.h.

#define AS_MESSAGE_TYPE   3L

Definition at line 91 of file as_command.h.

#define AS_MESSAGE_VERSION   2L

Definition at line 90 of file as_command.h.

#define AS_MSG_INFO1_BATCH_INDEX   (1 << 3)

Definition at line 63 of file as_command.h.

#define AS_MSG_INFO1_CONSISTENCY_ALL   (1 << 6)

Definition at line 66 of file as_command.h.

#define AS_MSG_INFO1_GET_ALL   (1 << 1)

Definition at line 61 of file as_command.h.

#define AS_MSG_INFO1_GET_NOBINDATA   (1 << 5)

Definition at line 65 of file as_command.h.

#define AS_MSG_INFO1_READ   (1 << 0)

Definition at line 60 of file as_command.h.

#define AS_MSG_INFO1_XDR   (1 << 4)

Definition at line 64 of file as_command.h.

#define AS_MSG_INFO2_CREATE_ONLY   (1 << 5)

Definition at line 75 of file as_command.h.

#define AS_MSG_INFO2_DELETE   (1 << 1)

Definition at line 71 of file as_command.h.

#define AS_MSG_INFO2_DURABLE_DELETE   (1 << 4)

Definition at line 74 of file as_command.h.

#define AS_MSG_INFO2_GENERATION   (1 << 2)

Definition at line 72 of file as_command.h.

#define AS_MSG_INFO2_GENERATION_GT   (1 << 3)

Definition at line 73 of file as_command.h.

#define AS_MSG_INFO2_RESPOND_ALL_OPS   (1 << 7)

Definition at line 77 of file as_command.h.

#define AS_MSG_INFO2_WRITE   (1 << 0)

Definition at line 70 of file as_command.h.

#define AS_MSG_INFO3_COMMIT_MASTER   (1 << 1)

Definition at line 81 of file as_command.h.

#define AS_MSG_INFO3_CREATE_OR_REPLACE   (1 << 4)

Definition at line 84 of file as_command.h.

#define AS_MSG_INFO3_LAST   (1 << 0)

Definition at line 80 of file as_command.h.

#define AS_MSG_INFO3_REPLACE_ONLY   (1 << 5)

Definition at line 85 of file as_command.h.

#define AS_MSG_INFO3_UPDATE_ONLY   (1 << 3)

Definition at line 83 of file as_command.h.

#define AS_OPERATION_HEADER_SIZE   8

Definition at line 101 of file as_command.h.

#define AS_STACK_BUF_SIZE   (1024 * 16)

Definition at line 103 of file as_command.h.

Typedef Documentation

typedef as_status(* as_parse_results_fn)(as_error *err, as_socket *sock, uint64_t deadline_ms, void *user_data)

Parse results callback used in as_command_execute().

Definition at line 163 of file as_command.h.

Function Documentation

static as_status as_command_bin_name_size ( as_error err,
const char *  name,
size_t *  size 
)
inlinestaticprivate

Calculate size of bin name. Return error is bin name greater than 14 characters.

Definition at line 218 of file as_command.h.

References AEROSPIKE_ERR_PARAM, AEROSPIKE_OK, AS_BIN_NAME_MAX_LEN, as_error_update, and AS_OPERATION_HEADER_SIZE.

static size_t as_command_bin_size ( const as_bin bin,
as_buffer *  buffer 
)
inlinestaticprivate

Calculate size of bin name and value combined.

Definition at line 208 of file as_command.h.

References as_command_value_size(), as_bin::name, and as_bin::valuep.

as_status as_command_compress ( as_error err,
uint8_t *  cmd,
size_t  cmd_sz,
uint8_t *  compressed_cmd,
size_t *  compressed_size 
)
private

Compress command buffer.

size_t as_command_compress_max_size ( size_t  cmd_sz)
private

Calculate max size the compressed command buffer.

static size_t as_command_compress_write_end ( uint8_t *  begin,
uint8_t *  end,
uint64_t  uncompressed_sz 
)
inlinestaticprivate

Finish writing compressed command.

Definition at line 391 of file as_command.h.

References AS_COMPRESSED_MESSAGE_TYPE, AS_MESSAGE_VERSION, proto, and uncompressed_sz.

as_status as_command_execute ( as_cluster cluster,
as_error err,
as_command_node cn,
uint8_t *  command,
size_t  command_len,
uint32_t  timeout_ms,
bool  timeout_per_try,
uint32_t  max_retries,
uint32_t  sleep_between_retries_ms,
as_parse_results_fn  parse_results_fn,
void *  parse_results_data 
)
private

Send command to the server.

static size_t as_command_field_size ( size_t  size)
inlinestaticprivate

Calculate size of field structure given field value size.

Definition at line 191 of file as_command.h.

References AS_FIELD_HEADER_SIZE.

uint8_t* as_command_ignore_bins ( uint8_t *  p,
uint32_t  n_bins 
)
private

Skip over bins in returned data.

uint8_t* as_command_ignore_fields ( uint8_t *  p,
uint32_t  n_fields 
)
private

Skip over fields section in returned data.

size_t as_command_key_size ( as_policy_key  policy,
const as_key key,
uint16_t *  n_fields 
)
private

Calculate size of command header plus key fields.

as_status as_command_parse_bins ( uint8_t **  pp,
as_error err,
as_record rec,
uint32_t  n_bins,
bool  deserialize 
)
private

Parse bins received from the server.

as_status as_command_parse_header ( as_error err,
as_socket sock,
uint64_t  deadline_ms,
void *  user_data 
)
private

Parse header of server response.

uint8_t* as_command_parse_key ( uint8_t *  p,
uint32_t  n_fields,
as_key key 
)
private

Parse key fields received from server. Used for reads.

as_status as_command_parse_result ( as_error err,
as_socket sock,
uint64_t  deadline_ms,
void *  user_data 
)
private

Parse server record. Used for reads.

as_status as_command_parse_success_failure ( as_error err,
as_socket sock,
uint64_t  deadline_ms,
void *  user_data 
)
private

Parse server success or failure result.

as_status as_command_parse_success_failure_bins ( uint8_t **  pp,
as_error err,
as_msg *  msg,
as_val **  value 
)
private

Parse server success or failure bins.

as_status as_command_parse_udf_failure ( uint8_t *  p,
as_error err,
as_msg *  msg,
as_status  status 
)
private

Parse user defined function error.

static size_t as_command_string_field_size ( const char *  value)
inlinestaticprivate

Calculate size of string field.

Definition at line 181 of file as_command.h.

References AS_FIELD_HEADER_SIZE.

static size_t as_command_string_operation_size ( const char *  value)
inlinestaticprivate

Calculate size of string operation.

Definition at line 234 of file as_command.h.

References AS_OPERATION_HEADER_SIZE.

size_t as_command_value_size ( as_val val,
as_buffer *  buffer 
)
private

Calculate size of as_val field.

uint8_t* as_command_write_bin ( uint8_t *  begin,
uint8_t  operation_type,
const as_bin bin,
as_buffer *  buffer 
)
private

Write bin.

static uint8_t* as_command_write_bin_name ( uint8_t *  cmd,
const char *  name 
)
inlinestaticprivate

Write bin header and bin name.

Definition at line 348 of file as_command.h.

References AS_OPERATION_HEADER_SIZE, and AS_OPERATOR_READ.

static size_t as_command_write_end ( uint8_t *  begin,
uint8_t *  end 
)
inlinestaticprivate

Finish writing command.

Definition at line 378 of file as_command.h.

References AS_MESSAGE_TYPE, AS_MESSAGE_VERSION, and proto.

static uint8_t* as_command_write_field_buffer ( uint8_t *  p,
uint8_t  id,
as_buffer *  buffer 
)
inlinestaticprivate

Write as_buffer field.

Definition at line 317 of file as_command.h.

References as_command_write_field_header().

static uint8_t* as_command_write_field_digest ( uint8_t *  p,
const as_digest val 
)
inlinestaticprivate

Write digest field.

Definition at line 329 of file as_command.h.

References as_command_write_field_header(), AS_DIGEST_VALUE_SIZE, AS_FIELD_DIGEST, and as_digest::value.

static uint8_t* as_command_write_field_header ( uint8_t *  p,
uint8_t  id,
uint32_t  size 
)
inlinestaticprivate

Write field header.

Definition at line 275 of file as_command.h.

static uint8_t* as_command_write_field_string ( uint8_t *  begin,
uint8_t  id,
const char *  val 
)
inlinestaticprivate

Write string field.

Definition at line 288 of file as_command.h.

References as_command_write_field_header(), and AS_FIELD_HEADER_SIZE.

static uint8_t* as_command_write_field_uint64 ( uint8_t *  p,
uint8_t  id,
uint64_t  val 
)
inlinestaticprivate

Write uint64_t field.

Definition at line 305 of file as_command.h.

References as_command_write_field_header().

uint8_t* as_command_write_header ( uint8_t *  cmd,
uint8_t  read_attr,
uint8_t  write_attr,
as_policy_commit_level  commit_level,
as_policy_consistency_level  consistency,
as_policy_exists  exists,
as_policy_gen  gen_policy,
uint32_t  gen,
uint32_t  ttl,
uint32_t  timeout_ms,
uint16_t  n_fields,
uint16_t  n_bins,
bool  durable_delete 
)
private

Write command header for all commands.

static uint8_t* as_command_write_header_read ( uint8_t *  cmd,
uint8_t  read_attr,
as_policy_consistency_level  consistency,
uint32_t  timeout_ms,
uint16_t  n_fields,
uint16_t  n_bins 
)
inlinestaticprivate

Write command header for read commands only.

Definition at line 254 of file as_command.h.

References AS_HEADER_SIZE, AS_MSG_INFO1_CONSISTENCY_ALL, and AS_POLICY_CONSISTENCY_LEVEL_ALL.

uint8_t* as_command_write_key ( uint8_t *  p,
as_policy_key  policy,
const as_key key 
)
private

Write key structure.

static void local_free ( void *  memory)
inlinestatic

Definition at line 118 of file as_command.h.

static void* local_malloc ( size_t  size)
inlinestaticprivate

Macros use these stand-ins for cf_malloc() / cf_free(), so that instrumentation properly substitutes them.

Definition at line 112 of file as_command.h.