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
42#define AS_COMMAND_FLAGS_TXN_MONITOR 16
45#define AS_FIELD_NAMESPACE 0
46#define AS_FIELD_SETNAME 1
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
71#define AS_MSG_INFO1_READ (1 << 0)
72#define AS_MSG_INFO1_GET_ALL (1 << 1)
73#define AS_MSG_INFO1_SHORT_QUERY (1 << 2)
74#define AS_MSG_INFO1_BATCH_INDEX (1 << 3)
75#define AS_MSG_INFO1_XDR (1 << 4)
76#define AS_MSG_INFO1_GET_NOBINDATA (1 << 5)
77#define AS_MSG_INFO1_READ_MODE_AP_ALL (1 << 6)
78#define AS_MSG_INFO1_COMPRESS_RESPONSE (1 << 7)
81#define AS_MSG_INFO2_WRITE (1 << 0)
82#define AS_MSG_INFO2_DELETE (1 << 1)
83#define AS_MSG_INFO2_GENERATION (1 << 2)
84#define AS_MSG_INFO2_GENERATION_GT (1 << 3)
85#define AS_MSG_INFO2_DURABLE_DELETE (1 << 4)
86#define AS_MSG_INFO2_CREATE_ONLY (1 << 5)
87#define AS_MSG_INFO2_RELAX_AP_LONG_QUERY (1 << 6)
88#define AS_MSG_INFO2_RESPOND_ALL_OPS (1 << 7)
91#define AS_MSG_INFO3_LAST (1 << 0)
92#define AS_MSG_INFO3_COMMIT_MASTER (1 << 1)
95#define AS_MSG_INFO3_PARTITION_DONE (1 << 2)
96#define AS_MSG_INFO3_UPDATE_ONLY (1 << 3)
97#define AS_MSG_INFO3_CREATE_OR_REPLACE (1 << 4)
98#define AS_MSG_INFO3_REPLACE_ONLY (1 << 5)
99#define AS_MSG_INFO3_SC_READ_TYPE (1 << 6)
100#define AS_MSG_INFO3_SC_READ_RELAX (1 << 7)
115#define AS_MSG_INFO4_TXN_VERIFY_READ (1 << 0)
116#define AS_MSG_INFO4_TXN_ROLL_FORWARD (1 << 1)
117#define AS_MSG_INFO4_TXN_ROLL_BACK (1 << 2)
118#define AS_MSG_INFO4_TXN_ON_LOCKING_ONLY (1 << 4)
121#define AS_HEADER_SIZE 30
122#define AS_FIELD_HEADER_SIZE 5
123#define AS_OPERATION_HEADER_SIZE 8
125#define AS_STACK_BUF_SIZE (1024 * 16)
126#define AS_COMPRESS_THRESHOLD 128
136 return cf_malloc(size);
149#define as_command_buffer_init(_sz) (_sz > AS_STACK_BUF_SIZE) ? (uint8_t*)local_malloc(_sz) : (uint8_t*)alloca(_sz)
155#define as_command_buffer_free(_buf, _sz) if (_sz > AS_STACK_BUF_SIZE) {local_free(_buf);}
175 as_error* err,
struct as_command_s* cmd,
as_node* node, uint8_t* buf,
size_t size
182typedef struct as_command_s {
182typedef struct as_command_s {
…};
210typedef struct as_command_txn_data_s {
210typedef struct as_command_txn_data_s {
…};
221typedef struct as_command_parse_result_data_s {
221typedef struct as_command_parse_result_data_s {
…};
296 size_t s = strlen(name);
322 uint8_t* read_attr, uint8_t* info_attr
325 switch (read_mode_sc) {
367 uint8_t* read_attr, uint8_t* info_attr
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
394 uint16_t n_bins, uint8_t read_attr, uint8_t write_attr, uint8_t info_attr
412static inline uint8_t*
415 *(uint32_t*)p = cf_swap_to_be32(size+1);
425static inline uint8_t*
442static inline uint8_t*
446 *(uint32_t*)p = cf_swap_to_be32(val);
447 return p +
sizeof(uint32_t);
454static inline uint8_t*
458 *(uint32_t*)p = cf_swap_to_le32(val);
459 return p +
sizeof(uint32_t);
466static inline uint8_t*
470 *(uint64_t*)p = cf_swap_to_be64(val);
471 return p +
sizeof(uint64_t);
478static inline uint8_t*
482 *(uint64_t*)p = cf_swap_to_le64(val);
483 return p +
sizeof(uint64_t);
490static inline uint8_t*
494 memcpy(p, buffer->
data, buffer->
size);
495 return p + buffer->
size;
502static inline uint8_t*
514static inline uint8_t*
518 uint64_t v = cf_swap_to_le64(ver);
563 uint64_t len = end - begin;
565 *(uint64_t*)begin = cf_swap_to_be64(
proto);
576 uint64_t len = end - begin;
578 *(uint64_t*)begin = cf_swap_to_be64(
proto);
579 ((as_compressed_proto *)begin)->uncompressed_sz = cf_swap_to_be64(
uncompressed_sz);
601static inline uint32_t
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
745static inline uint64_t
752 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)
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)
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)
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)
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)
static uint8_t * as_command_write_field_uint64_le(uint8_t *p, uint8_t id, uint64_t 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)
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 uint8_t * as_command_write_field_uint32_le(uint8_t *p, uint8_t id, uint32_t val)
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)
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
static uint8_t * as_command_write_field_version(uint8_t *p, uint64_t ver)
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_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)
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)
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
size_t as_command_user_key_size(const as_key *key)
#define AS_FIELD_RECORD_VERSION
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)
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