27#include <citrusleaf/cf_byte_order.h>
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
44#define AS_FIELD_NAMESPACE 0
45#define AS_FIELD_SETNAME 1
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
67#define AS_MSG_INFO1_READ (1 << 0)
68#define AS_MSG_INFO1_GET_ALL (1 << 1)
69#define AS_MSG_INFO1_SHORT_QUERY (1 << 2)
70#define AS_MSG_INFO1_BATCH_INDEX (1 << 3)
71#define AS_MSG_INFO1_XDR (1 << 4)
72#define AS_MSG_INFO1_GET_NOBINDATA (1 << 5)
73#define AS_MSG_INFO1_READ_MODE_AP_ALL (1 << 6)
74#define AS_MSG_INFO1_COMPRESS_RESPONSE (1 << 7)
77#define AS_MSG_INFO2_WRITE (1 << 0)
78#define AS_MSG_INFO2_DELETE (1 << 1)
79#define AS_MSG_INFO2_GENERATION (1 << 2)
80#define AS_MSG_INFO2_GENERATION_GT (1 << 3)
81#define AS_MSG_INFO2_DURABLE_DELETE (1 << 4)
82#define AS_MSG_INFO2_CREATE_ONLY (1 << 5)
83#define AS_MSG_INFO2_RELAX_AP_LONG_QUERY (1 << 6)
84#define AS_MSG_INFO2_RESPOND_ALL_OPS (1 << 7)
87#define AS_MSG_INFO3_LAST (1 << 0)
88#define AS_MSG_INFO3_COMMIT_MASTER (1 << 1)
91#define AS_MSG_INFO3_PARTITION_DONE (1 << 2)
92#define AS_MSG_INFO3_UPDATE_ONLY (1 << 3)
93#define AS_MSG_INFO3_CREATE_OR_REPLACE (1 << 4)
94#define AS_MSG_INFO3_REPLACE_ONLY (1 << 5)
95#define AS_MSG_INFO3_SC_READ_TYPE (1 << 6)
96#define AS_MSG_INFO3_SC_READ_RELAX (1 << 7)
111#define AS_HEADER_SIZE 30
112#define AS_FIELD_HEADER_SIZE 5
113#define AS_OPERATION_HEADER_SIZE 8
115#define AS_STACK_BUF_SIZE (1024 * 16)
116#define AS_COMPRESS_THRESHOLD 128
126 return cf_malloc(size);
139#define as_command_buffer_init(_sz) (_sz > AS_STACK_BUF_SIZE) ? (uint8_t*)local_malloc(_sz) : (uint8_t*)alloca(_sz)
145#define as_command_buffer_free(_buf, _sz) if (_sz > AS_STACK_BUF_SIZE) {local_free(_buf);}
164 as_error* err,
struct as_command_s* cmd,
as_node* node, uint8_t* buf,
size_t size
171typedef struct as_command_s {
200typedef struct as_command_parse_result_data_s {
272 size_t s = strlen(name);
298 uint8_t* read_attr, uint8_t* info_attr
301 switch (read_mode_sc) {
343 uint8_t* read_attr, uint8_t* info_attr
358 uint16_t
n_fields, uint16_t n_bins,
bool durable_delete, uint8_t read_attr, uint8_t write_attr,
370 uint16_t n_bins, uint8_t read_attr, uint8_t write_attr, uint8_t info_attr
388static inline uint8_t*
391 *(uint32_t*)p = cf_swap_to_be32(size+1);
401static inline uint8_t*
418static inline uint8_t*
422 *(uint32_t*)p = cf_swap_to_be32(val);
423 return p +
sizeof(uint32_t);
430static inline uint8_t*
434 *(uint64_t*)p = cf_swap_to_be64(val);
435 return p +
sizeof(uint64_t);
442static inline uint8_t*
446 memcpy(p, buffer->
data, buffer->
size);
447 return p + buffer->
size;
454static inline uint8_t*
499 uint64_t len = end - begin;
501 *(uint64_t*)begin = cf_swap_to_be64(
proto);
512 uint64_t len = end - begin;
514 *(uint64_t*)begin = cf_swap_to_be64(
proto);
515 ((as_compressed_proto *)begin)->uncompressed_sz = cf_swap_to_be64(
uncompressed_sz);
537static inline uint32_t
655static inline uint64_t
662 if (*task_id_ptr == 0) {
#define AS_BIN_NAME_MAX_LEN
as_status(* as_parse_results_fn)(as_error *err, struct as_command_s *cmd, as_node *node, uint8_t *buf, size_t size)
size_t as_command_compress_max_size(size_t cmd_sz)
static size_t as_command_field_size(size_t size)
static as_status as_command_bin_name_size(as_error *err, const char *name, size_t *size)
as_status as_command_parse_udf_failure(uint8_t *p, as_error *err, as_msg *msg, as_status status)
static size_t as_command_write_end(uint8_t *begin, uint8_t *end)
size_t(* as_write_fn)(void *udata, uint8_t *buf)
as_status as_command_bin_size(const as_bin *bin, as_queue *buffers, size_t *size, as_error *err)
static uint8_t * as_command_write_field_string(uint8_t *begin, uint8_t id, const char *val)
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)
#define AS_OPERATION_HEADER_SIZE
static uint32_t as_command_server_timeout(const as_policy_base *policy)
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)
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)
size_t as_command_key_size(as_policy_key policy, const as_key *key, uint16_t *n_fields)
static uint8_t * as_command_write_field_uint32(uint8_t *p, uint8_t id, uint32_t val)
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)
static uint8_t * as_command_write_field_header(uint8_t *p, uint8_t id, uint32_t size)
static uint64_t as_task_id_resolve(uint64_t *task_id_ptr)
static size_t as_command_string_operation_size(const char *value)
static void as_command_start_timer(as_command *cmd)
static void as_buffers_destroy(as_queue *buffers)
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)
static void as_command_set_attr_compress(bool compress, uint8_t *read_attr)
static size_t as_command_compress_write_end(uint8_t *begin, uint8_t *end, uint64_t uncompressed_sz)
uint8_t * as_command_write_user_key(uint8_t *begin, const as_key *key)
static void local_free(void *memory)
as_status as_command_execute(as_command *cmd, as_error *err)
static void * local_malloc(size_t size)
#define AS_MSG_INFO1_COMPRESS_RESPONSE
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)
#define AS_FIELD_HEADER_SIZE
uint8_t as_replica_index_any(void)
#define AS_MSG_INFO1_READ_MODE_AP_ALL
#define AS_MSG_INFO3_SC_READ_TYPE
uint8_t * as_command_write_bin(uint8_t *begin, as_operator operation_type, const as_bin *bin, as_queue *buffers)
static uint8_t as_replica_index_init_read(as_policy_replica replica)
static uint8_t * as_command_write_field_uint64(uint8_t *p, uint8_t id, uint64_t val)
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_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
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)
size_t as_command_user_key_size(const as_key *key)
uint8_t * as_command_write_key(uint8_t *p, as_policy_key policy, const as_key *key)
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
#define AS_COMPRESSED_MESSAGE_TYPE
static bool as_queue_pop(as_queue *queue, void *ptr)
AS_EXTERN void as_queue_destroy(as_queue *queue)
static uint64_t as_random_get_uint64(void)
@ AS_POLICY_READ_MODE_SC_ALLOW_REPLICA
@ AS_POLICY_READ_MODE_SC_SESSION
@ AS_POLICY_READ_MODE_SC_ALLOW_UNAVAILABLE
@ AS_POLICY_READ_MODE_SC_LINEARIZE
@ AS_POLICY_REPLICA_MASTER
@ AS_POLICY_REPLICA_SEQUENCE
@ AS_POLICY_READ_MODE_AP_ALL
const as_policy_base * policy
as_latency_type latency_type
as_parse_results_fn parse_results_fn
as_policy_replica replica