33 const char end_row_chars[3] = { (char)0xff, (
char)0xff, 0 };
34 const char end_root_row_chars[7] = {
'0',
'/',
'0',
':', (char)0xff, (
char)0xff, 0 };
37 write_key(uint8_t *buf, uint8_t control, uint8_t flag,
const char *row, uint32_t row_len,
38 uint8_t column_family_code,
const char *column_qualifier, uint32_t column_qualifier_len) {
41 strcpy((
char *)ptr, row);
43 *ptr++ = column_family_code;
44 if (column_qualifier) {
45 strcpy((
char *)ptr, column_qualifier);
46 ptr += column_qualifier_len + 1;
56 uint32_t row_len, uint8_t column_family_code,
const char *column_qualifier,
57 uint32_t column_qualifier_len, int64_t timestamp, int64_t revision,
58 bool time_order_asc) {
59 size_t len = 1 + row_len + 4 + column_qualifier_len;
67 if (timestamp == revision)
81 dst_buf.
grow(dst_buf.
fill() + len + 6);
83 dst_buf.
ptr += write_key(dst_buf.
ptr, control, flag, row, row_len,
84 column_family_code, column_qualifier, column_qualifier_len);
93 assert(dst_buf.
fill() <= dst_buf.
size);
121 uint8_t column_family_code,
const char *column_qualifier,
122 int64_t timestamp, int64_t revision,
bool time_order_asc) {
130 column_qualifier && *column_qualifier ? strlen(column_qualifier) : 0,
137 uint8_t control = Key::HAVE_REVISION
141 size_t row_len = strlen(row);
142 size_t len = 13 + row_len;
144 dst_buf.
grow(dst_buf.
fill() + len + 6);
146 dst_buf.
ptr += write_key(dst_buf.
ptr, control, 0, row, row_len, 0, 0, 0);
148 assert(dst_buf.
fill() <= dst_buf.
size);
160 const uint8_t* ptr = serial.
ptr;
163 length = len + (ptr - serial.ptr);
165 const uint8_t *end_ptr = ptr + len;
168 row = (
const char *)ptr;
170 while (ptr < end_ptr && *ptr != 0)
173 row_len = ptr - (uint8_t *)row;
174 assert(strlen(row) == row_len);
177 if (ptr >= end_ptr) {
178 cerr <<
"row decode overrun" << endl;
182 column_family_code = *ptr++;
183 column_qualifier = (
const char *)ptr;
185 while (ptr < end_ptr && *ptr != 0)
188 column_qualifier_len = ptr - (uint8_t *)column_qualifier;
189 assert(strlen(column_qualifier) == column_qualifier_len);
192 if (ptr >= end_ptr) {
193 cerr <<
"qualifier decode overrun" << endl;
201 timestamp = decode_ts64((
const uint8_t **)&ptr,
202 (control&TS_CHRONOLOGICAL) == 0);
204 revision = timestamp;
205 assert(ptr == end_ptr);
217 revision = decode_ts64((
const uint8_t **)&ptr,
218 (control&TS_CHRONOLOGICAL) == 0);
222 assert(ptr == end_ptr);
231 if (key.
control & Key::HAVE_REVISION) {
235 if (key.
control & Key::HAVE_TIMESTAMP) {
236 os << ((got) ?
"|TS" :
"TS");
240 os << ((got) ?
"|AUTO" :
"AUTO");
244 os << ((got) ?
"|SHARED" :
"SHARED");
247 os <<
") row='" << key.
row <<
"' ";
260 os <<
" DELETE_COLUMN_FAMILY";
262 os <<
" DELETE_CELL";
264 os <<
" DELETE_CELL_VERSION";
268 os << key.
flag <<
"(unrecognized flag)";
static const uint32_t FLAG_DELETE_ROW
static const uint32_t FLAG_INSERT
static const uint8_t HAVE_REVISION
static const uint32_t FLAG_DELETE_CELL
uint8_t * ptr
Pointer to the end of the used part of the buffer.
A dynamic, resizable and reference counted memory buffer.
static const uint32_t FLAG_DELETE_COLUMN_FAMILY
#define HT_EXPECT(_e_, _code_)
void grow(size_t new_size, bool nocopy=false)
Grows the buffer and copies the data unless nocopy is true.
Key()
Constructor (for implicit construction).
uint32_t size
The size of the allocated memory buffer (base)
Compatibility Macros for C/C++.
static const uint8_t HAVE_TIMESTAMP
std::ostream & operator<<(std::ostream &os, const crontab_entry &entry)
Helper function to write crontab_entry to an ostream.
bool load(const SerializedKey &key)
Parses the opaque key and loads the components into the member variables.
static const int64_t TIMESTAMP_NULL
static const uint8_t TS_CHRONOLOGICAL
const uint8_t * ptr
The pointer to the serialized data.
void encode_vi32(uint8_t **bufp, uint32_t val)
Encode a integer (up to 32-bit) in variable length encoding.
static const uint8_t AUTO_TIMESTAMP
void create_key_and_append(DynamicBuffer &dst_buf, const Key &key, bool time_order_asc)
Provides access to internal components of opaque key.
uint32_t column_qualifier_len
size_t fill() const
Returns the size of the used portion.
static void encode_ts64(uint8_t **bufp, int64_t val, bool ascending=true)
static const char * END_ROOT_ROW
uint8_t column_family_code
static const int64_t AUTO_ASSIGN
const char * column_qualifier
static const char * END_ROW_MARKER
static const uint32_t FLAG_DELETE_CELL_VERSION
uint32_t decode_vi32(const uint8_t **bufp, size_t *remainp)
Decode a variable length encoded integer up to 32-bit.
size_t remaining() const
Returns the size of the unused portion.
static const uint8_t REV_IS_TS