提交 79227057 编写于 作者: H Haojun Liao

enh(tsdb): opt decompress int perf

上级 2cbbc889
......@@ -273,6 +273,7 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha
char bit = bit_per_integer[(int32_t)selector]; // bit = 3
int32_t elems = selector_to_elems[(int32_t)selector];
#if 0
for (int32_t i = 0; i < elems; i++) {
uint64_t zigzag_value;
......@@ -309,6 +310,91 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha
count++;
if (count == nelements) break;
}
#endif
int32_t v = 0;
uint64_t zigzag_value;
switch (type) {
case TSDB_DATA_TYPE_BIGINT: {
for (int32_t i = 0; i < elems; i++) {
if (selector == 0 || selector == 1) {
zigzag_value = 0;
} else {
zigzag_value = ((w >> (4 + v)) & INT64MASK(bit));
}
int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value);
int64_t curr_value = diff + prev_value;
prev_value = curr_value;
*((int64_t *)output + _pos) = (int64_t)curr_value;
_pos++;
v += bit;
if ((++count) == nelements) break;
}
} break;
case TSDB_DATA_TYPE_INT: {
for (int32_t i = 0; i < elems; i++) {
if (selector == 0 || selector == 1) {
zigzag_value = 0;
} else {
zigzag_value = ((w >> (4 + v)) & INT64MASK(bit));
}
int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value);
int64_t curr_value = diff + prev_value;
prev_value = curr_value;
*((int32_t *)output + _pos) = (int32_t)curr_value;
_pos++;
v += bit;
if ((++count) == nelements) break;
}
} break;
case TSDB_DATA_TYPE_SMALLINT: {
for (int32_t i = 0; i < elems; i++) {
if (selector == 0 || selector == 1) {
zigzag_value = 0;
} else {
zigzag_value = ((w >> (4 + v)) & INT64MASK(bit));
}
int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value);
int64_t curr_value = diff + prev_value;
prev_value = curr_value;
*((int16_t *)output + _pos) = (int16_t)curr_value;
_pos++;
v += bit;
if ((++count) == nelements) break;
}
} break;
case TSDB_DATA_TYPE_TINYINT: {
for (int32_t i = 0; i < elems; i++) {
if (selector == 0 || selector == 1) {
zigzag_value = 0;
} else {
zigzag_value = ((w >> (4 + v)) & INT64MASK(bit));
}
int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value);
int64_t curr_value = diff + prev_value;
prev_value = curr_value;
*((int8_t *)output + _pos) = (int8_t)curr_value;
_pos++;
v += bit;
if ((++count) == nelements) break;
}
} break;
}
ip += LONG_BYTES;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册