mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 19:11:46 +01:00
addresses #1567
write function to create a row descriptor untested, just verified that it compiles also currently unused git-svn-id: file:///svn/mysql/tokudb-engine/src@10950 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
0944e9198a
commit
a8375cb5c9
2 changed files with 60 additions and 4 deletions
|
@ -1133,7 +1133,7 @@ int tokudb_prefix_cmp_packed_key(DB *file, const DBT *keya, const DBT *keyb) {
|
|||
// outputs a descriptor for key into buf. num_bytes returns number of bytes used in buf
|
||||
// to store the descriptor
|
||||
//
|
||||
int create_key_descriptor(KEY* key, uchar* buf, u_int32_t* num_bytes) {
|
||||
int create_toku_key_descriptor(KEY* key, uchar* buf) {
|
||||
int ret_val = 0;
|
||||
uchar* pos = buf;
|
||||
u_int32_t num_bytes_in_field = 0;
|
||||
|
@ -1217,6 +1217,62 @@ int create_key_descriptor(KEY* key, uchar* buf, u_int32_t* num_bytes) {
|
|||
|
||||
}
|
||||
}
|
||||
*num_bytes = pos - buf;
|
||||
return ret_val;
|
||||
return pos - buf;
|
||||
}
|
||||
|
||||
int create_toku_descriptor(uchar* buf, bool is_first_hpk, KEY* first_key, bool is_second_hpk, KEY* second_key) {
|
||||
uchar* pos = buf + 4;
|
||||
u_int32_t num_bytes = 0;
|
||||
u_int32_t offset = 0;
|
||||
|
||||
if (is_first_hpk) {
|
||||
pos[0] = 1;
|
||||
pos++;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
//
|
||||
// first key is NOT a hidden primary key, so we now pack first_key
|
||||
//
|
||||
pos[0] = 0;
|
||||
pos++;
|
||||
num_bytes = create_toku_key_descriptor(first_key, pos);
|
||||
pos += num_bytes;
|
||||
|
||||
//
|
||||
// if we do not have a second key, we can jump to exit right now
|
||||
// we do not have a second key if it is not a hidden primary key
|
||||
// and if second_key is NULL
|
||||
//
|
||||
if (!is_second_hpk && (second_key == NULL) ) {
|
||||
goto exit;
|
||||
}
|
||||
//
|
||||
// at this point, we have a second key, so we need to write an offset
|
||||
// into the first four bytes
|
||||
//
|
||||
offset = pos - buf;
|
||||
buf[0] = (uchar)(offset & 255);
|
||||
buf[1] = (uchar)((offset >> 8) & 255);
|
||||
buf[2] = (uchar)((offset >> 16) & 255);
|
||||
buf[3] = (uchar)((offset >> 24) & 255);
|
||||
|
||||
//
|
||||
// if we have a second key, and it is an hpk, we need to pack it, and
|
||||
// write in the offset to this position in the first four bytes
|
||||
//
|
||||
if (is_second_hpk) {
|
||||
pos[0] = 1;
|
||||
pos++;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
pos[0] = 0;
|
||||
pos++;
|
||||
num_bytes = create_toku_key_descriptor(second_key, pos);
|
||||
pos += num_bytes;
|
||||
|
||||
|
||||
exit:
|
||||
return pos - buf;
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ int tokudb_cmp_primary_key(DB *file, const DBT *keya, const DBT *keyb);
|
|||
//TODO: QQQ Only do one direction for prefix.
|
||||
int tokudb_prefix_cmp_packed_key(DB *file, const DBT *keya, const DBT *keyb);
|
||||
|
||||
int create_key_descriptor(KEY* key, uchar* buf, u_int32_t* num_bytes);
|
||||
int create_toku_key_descriptor(KEY* key, uchar* buf);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue