Commit d7ca4a88 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

refs #5947 rename to vlq

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@52810 c7de825b-a66e-492c-adef-691d508d4ae1
parent 146e7078
......@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include <tokudb_base128.h>
#include <tokudb_vlq.h>
int main(void) {
uint32_t n;
......@@ -11,41 +11,41 @@ int main(void) {
printf("%u\n", 0);
for (uint32_t v = 0; v < (1<<7); v++) {
out_s = tokudb::base128_encode_uint32(v, b, sizeof b);
out_s = tokudb::vlq_encode_uint32(v, b, sizeof b);
assert(out_s == 1);
in_s = tokudb::base128_decode_uint32(&n, b, out_s);
in_s = tokudb::vlq_decode_uint32(&n, b, out_s);
assert(in_s == 1 && n == v);
}
printf("%u\n", 1<<7);
for (uint32_t v = (1<<7); v < (1<<14); v++) {
out_s = tokudb::base128_encode_uint32(v, b, sizeof b);
out_s = tokudb::vlq_encode_uint32(v, b, sizeof b);
assert(out_s == 2);
in_s = tokudb::base128_decode_uint32(&n, b, out_s);
in_s = tokudb::vlq_decode_uint32(&n, b, out_s);
assert(in_s == 2 && n == v);
}
printf("%u\n", 1<<14);
for (uint32_t v = (1<<14); v < (1<<21); v++) {
out_s = tokudb::base128_encode_uint32(v, b, sizeof b);
out_s = tokudb::vlq_encode_uint32(v, b, sizeof b);
assert(out_s == 3);
in_s = tokudb::base128_decode_uint32(&n, b, out_s);
in_s = tokudb::vlq_decode_uint32(&n, b, out_s);
assert(in_s == 3 && n == v);
}
printf("%u\n", 1<<21);
for (uint32_t v = (1<<21); v < (1<<28); v++) {
out_s = tokudb::base128_encode_uint32(v, b, sizeof b);
out_s = tokudb::vlq_encode_uint32(v, b, sizeof b);
assert(out_s == 4);
in_s = tokudb::base128_decode_uint32(&n, b, out_s);
in_s = tokudb::vlq_decode_uint32(&n, b, out_s);
assert(in_s == 4 && n == v);
}
printf("%u\n", 1<<28);
for (uint32_t v = (1<<28); v != 0; v++) {
out_s = tokudb::base128_encode_uint32(v, b, sizeof b);
out_s = tokudb::vlq_encode_uint32(v, b, sizeof b);
assert(out_s == 5);
in_s = tokudb::base128_decode_uint32(&n, b, out_s);
in_s = tokudb::vlq_decode_uint32(&n, b, out_s);
assert(in_s == 5 && n == v);
}
......
#if !defined(_TOKUDB_BUFFER_H)
#define _TOKUDB_BUFFER_H
#include "tokudb_base128.h"
#include "tokudb_vlq.h"
namespace tokudb {
......@@ -35,7 +35,7 @@ class buffer {
void append_uint32(uint32_t n) {
maybe_realloc(5);
size_t s = tokudb::base128_encode_uint32(n, (char *) m_data + m_size, 5);
size_t s = tokudb::vlq_encode_uint32(n, (char *) m_data + m_size, 5);
m_size += s;
}
......@@ -55,7 +55,7 @@ class buffer {
uint32_t consume_uint32() {
uint32_t n;
size_t s = tokudb::base128_decode_uint32(&n, (char *) m_data + m_size, m_limit - m_size);
size_t s = tokudb::vlq_decode_uint32(&n, (char *) m_data + m_size, m_limit - m_size);
m_size += s;
return n;
}
......
#ifndef _TOKUDB_BASE128_H
#define _TOKUDB_BASE128_H
#ifndef _TOKUDB_VLQ_H
#define _TOKUDB_VLQ_H
namespace tokudb {
static size_t base128_encode_uint32(uint32_t n, void *p, size_t s) {
static size_t vlq_encode_uint32(uint32_t n, void *p, size_t s) {
unsigned char *pp = (unsigned char *)p;
size_t i = 0;
while (n >= 128) {
......@@ -14,7 +14,7 @@ namespace tokudb {
return i;
}
static size_t base128_decode_uint32(uint32_t *np, void *p, size_t s) {
static size_t vlq_decode_uint32(uint32_t *np, void *p, size_t s) {
unsigned char *pp = (unsigned char *)p;
uint32_t n = 0;
uint i = 0;
......
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