Commit 146e7078 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

refs #5947 replace update base128 code with ft vlq code

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@52787 c7de825b-a66e-492c-adef-691d508d4ae1
parent 1e82276b
...@@ -681,7 +681,8 @@ int ha_tokudb::send_update_message(List<Item> &update_fields, List<Item> &update ...@@ -681,7 +681,8 @@ int ha_tokudb::send_update_message(List<Item> &update_fields, List<Item> &update
// construct the update message // construct the update message
tokudb::buffer update_message; tokudb::buffer update_message;
update_message.append_uint32(UPDATE_OP_UPDATE_2); uint8_t op = UPDATE_OP_UPDATE_2;
update_message.append(&op, sizeof op);
uint32_t num_updates = update_fields.elements; uint32_t num_updates = update_fields.elements;
uint num_varchars = 0, num_blobs = 0; uint num_varchars = 0, num_blobs = 0;
...@@ -834,7 +835,8 @@ int ha_tokudb::send_upsert_message(THD *thd, List<Item> &update_fields, List<Ite ...@@ -834,7 +835,8 @@ int ha_tokudb::send_upsert_message(THD *thd, List<Item> &update_fields, List<Ite
tokudb::buffer update_message; tokudb::buffer update_message;
// append the operation // append the operation
update_message.append_uint32(UPDATE_OP_UPSERT_2); uint8_t op = UPDATE_OP_UPSERT_2;
update_message.append(&op, sizeof op);
// append the row // append the row
update_message.append_uint32(row.size); update_message.append_uint32(row.size);
......
...@@ -1529,8 +1529,9 @@ static int tokudb_update_2_fun( ...@@ -1529,8 +1529,9 @@ static int tokudb_update_2_fun(
{ {
tokudb::buffer extra_val(extra->data, 0, extra->size); tokudb::buffer extra_val(extra->data, 0, extra->size);
uint32_t operation = extra_val.consume_uint32(); uint8_t op;
assert(operation == UPDATE_OP_UPDATE_2); extra_val.consume(&op, sizeof op);
assert(op == UPDATE_OP_UPDATE_2);
if (old_val_dbt != NULL) { if (old_val_dbt != NULL) {
tokudb::buffer old_val(old_val_dbt->data, old_val_dbt->size, old_val_dbt->size); tokudb::buffer old_val(old_val_dbt->data, old_val_dbt->size, old_val_dbt->size);
...@@ -1567,8 +1568,9 @@ static int tokudb_upsert_2_fun( ...@@ -1567,8 +1568,9 @@ static int tokudb_upsert_2_fun(
{ {
tokudb::buffer extra_val(extra->data, 0, extra->size); tokudb::buffer extra_val(extra->data, 0, extra->size);
uint32_t operation = extra_val.consume_uint32(); uint8_t op;
assert(operation == UPDATE_OP_UPSERT_2); extra_val.consume(&op, sizeof op);
assert(op == UPDATE_OP_UPSERT_2);
uint32_t insert_length = extra_val.consume_uint32(); uint32_t insert_length = extra_val.consume_uint32();
assert(insert_length < extra_val.limit()); assert(insert_length < extra_val.limit());
...@@ -1645,6 +1647,7 @@ int tokudb_update_fun( ...@@ -1645,6 +1647,7 @@ int tokudb_update_fun(
error = tokudb_upsert_2_fun(db, key, old_val, extra, set_val, set_extra); error = tokudb_upsert_2_fun(db, key, old_val, extra, set_val, set_extra);
break; break;
default: default:
assert(0);
error = EINVAL; error = EINVAL;
break; break;
} }
......
...@@ -5,16 +5,12 @@ namespace tokudb { ...@@ -5,16 +5,12 @@ namespace tokudb {
static size_t base128_encode_uint32(uint32_t n, void *p, size_t s) { static size_t base128_encode_uint32(uint32_t n, void *p, size_t s) {
unsigned char *pp = (unsigned char *)p; unsigned char *pp = (unsigned char *)p;
uint i = 0; size_t i = 0;
while (i < s) { while (n >= 128) {
uint32_t m = n & 127; pp[i++] = n%128;
n >>= 7; n = n/128;
if (n != 0)
m |= 128;
pp[i++] = m;
if (n == 0)
break;
} }
pp[i++] = 128+n;
return i; return i;
} }
...@@ -23,10 +19,10 @@ namespace tokudb { ...@@ -23,10 +19,10 @@ namespace tokudb {
uint32_t n = 0; uint32_t n = 0;
uint i = 0; uint i = 0;
while (i < s) { while (i < s) {
uint m = pp[i]; unsigned char m = pp[i];
n |= (m & 127) << 7*i; n |= (m & 127) << 7*i;
i++; i++;
if ((m & 128) == 0) if ((m & 128) != 0)
break; break;
} }
*np = n; *np = n;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment