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

enh(query): opt decomp performance.

上级 b0885ddd
...@@ -275,16 +275,28 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha ...@@ -275,16 +275,28 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha
// Optimize the performance, by remove the constantly switch operation. // Optimize the performance, by remove the constantly switch operation.
int32_t v = 0; int32_t v = 0;
uint64_t zigzag_value; uint64_t zigzag_value = 0;
uint64_t mask = INT64MASK(bit);
switch (type) { switch (type) {
case TSDB_DATA_TYPE_BIGINT: { case TSDB_DATA_TYPE_BIGINT: {
for (int32_t i = 0; i < elems; i++) {
if (selector == 0 || selector == 1) { if (selector == 0 || selector == 1) {
zigzag_value = 0; zigzag_value = 0;
} else {
zigzag_value = ((w >> (4 + v)) & INT64MASK(bit)); for (int32_t i = 0; i < elems; i++) {
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;
} }
} else {
for (int32_t i = 0; i < elems; i++) {
zigzag_value = ((w >> (4 + v)) & mask);
int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value);
int64_t curr_value = diff + prev_value; int64_t curr_value = diff + prev_value;
...@@ -296,14 +308,25 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha ...@@ -296,14 +308,25 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha
v += bit; v += bit;
if ((++count) == nelements) break; if ((++count) == nelements) break;
} }
}
} break; } break;
case TSDB_DATA_TYPE_INT: { case TSDB_DATA_TYPE_INT: {
for (int32_t i = 0; i < elems; i++) {
if (selector == 0 || selector == 1) { if (selector == 0 || selector == 1) {
zigzag_value = 0; zigzag_value = 0;
} else { for (int32_t i = 0; i < elems; i++) {
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;
} }
} else {
for (int32_t i = 0; i < elems; i++) {
zigzag_value = ((w >> (4 + v)) & mask);
int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value);
int64_t curr_value = diff + prev_value; int64_t curr_value = diff + prev_value;
...@@ -315,13 +338,14 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha ...@@ -315,13 +338,14 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha
v += bit; v += bit;
if ((++count) == nelements) break; if ((++count) == nelements) break;
} }
}
} break; } break;
case TSDB_DATA_TYPE_SMALLINT: { case TSDB_DATA_TYPE_SMALLINT: {
for (int32_t i = 0; i < elems; i++) { for (int32_t i = 0; i < elems; i++) {
if (selector == 0 || selector == 1) { if (selector == 0 || selector == 1) {
zigzag_value = 0; zigzag_value = 0;
} else { } else {
zigzag_value = ((w >> (4 + v)) & INT64MASK(bit)); zigzag_value = ((w >> (4 + v)) & mask);
} }
int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value);
...@@ -341,7 +365,7 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha ...@@ -341,7 +365,7 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha
if (selector == 0 || selector == 1) { if (selector == 0 || selector == 1) {
zigzag_value = 0; zigzag_value = 0;
} else { } else {
zigzag_value = ((w >> (4 + v)) & INT64MASK(bit)); zigzag_value = ((w >> (4 + v)) & mask);
} }
int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册