提交 642651c1 编写于 作者: H Haojun Liao

refactor: do some internal refactor.

上级 c7560202
...@@ -283,40 +283,39 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha ...@@ -283,40 +283,39 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha
case TSDB_DATA_TYPE_BIGINT: { case TSDB_DATA_TYPE_BIGINT: {
int64_t* p = (int64_t*) output; int64_t* p = (int64_t*) output;
if (selector == 0 || selector == 1) { int32_t gRemainder = (nelements - _pos);
int32_t gRemainder = nelements - _pos; int32_t num = (gRemainder > elems)? elems:gRemainder;
int32_t num = gRemainder < elems? gRemainder:elems;
int32_t batch = num >> 2; int32_t batch = num >> 2;
int32_t remainder = num & 0x03; int32_t remain = num & 0x03;
if (selector == 0 || selector == 1) {
if (tsAVX2Enable && tsSIMDBuiltins) {
for (int32_t i = 0; i < batch; ++i) { for (int32_t i = 0; i < batch; ++i) {
p[_pos++] = prev_value; __m256i prev = _mm256_set1_epi64x(prev_value);
p[_pos++] = prev_value; _mm256_storeu_si256((__m256i *)&p[_pos], prev);
p[_pos++] = prev_value; _pos += 4;
p[_pos++] = prev_value;
} }
for (int32_t i = 0; i < remainder; ++i) { for (int32_t i = 0; i < remain; ++i) {
p[_pos++] = prev_value; p[_pos++] = prev_value;
} }
count += num;
} else { } else {
int32_t gRemainder = (nelements - _pos); for (int32_t i = 0; i < elems && count < nelements; i++, count++) {
int32_t num = (gRemainder > elems)? elems:gRemainder; p[_pos++] = prev_value;
v += bit;
int32_t batch = num >> 2; }
int32_t remain = num & 0x03; }
#if 1 } else {
if (tsAVX2Enable && tsSIMDBuiltins) {
__m256i base = _mm256_set1_epi64x(w); __m256i base = _mm256_set1_epi64x(w);
__m256i maskVal = _mm256_set1_epi64x(mask); __m256i maskVal = _mm256_set1_epi64x(mask);
__m256i shiftBits = _mm256_set_epi64x(bit * 3 + 4, bit * 2 + 4, bit + 4, 4); __m256i shiftBits = _mm256_set_epi64x(bit * 3 + 4, bit * 2 + 4, bit + 4, 4);
__m256i inc = _mm256_set1_epi64x(bit << 2); __m256i inc = _mm256_set1_epi64x(bit << 2);
for(int32_t i = 0; i < batch; ++i) { for (int32_t i = 0; i < batch; ++i) {
__m256i after = _mm256_srlv_epi64(base, shiftBits); __m256i after = _mm256_srlv_epi64(base, shiftBits);
__m256i zigzagVal= _mm256_and_si256(after, maskVal); __m256i zigzagVal = _mm256_and_si256(after, maskVal);
// ZIGZAG_DECODE(T, v) (((v) >> 1) ^ -((T)((v)&1))) // ZIGZAG_DECODE(T, v) (((v) >> 1) ^ -((T)((v)&1)))
__m256i signmask = _mm256_and_si256(_mm256_set1_epi64x(1), zigzagVal); __m256i signmask = _mm256_and_si256(_mm256_set1_epi64x(1), zigzagVal);
...@@ -364,7 +363,7 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha ...@@ -364,7 +363,7 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha
p[_pos++] = prev_value; p[_pos++] = prev_value;
v += bit; v += bit;
} }
#else } else {
for (int32_t i = 0; i < elems && count < nelements; i++, count++) { for (int32_t i = 0; i < elems && count < nelements; i++, count++) {
zigzag_value = ((w >> v) & mask); zigzag_value = ((w >> v) & mask);
prev_value += ZIGZAG_DECODE(int64_t, zigzag_value); prev_value += ZIGZAG_DECODE(int64_t, zigzag_value);
...@@ -372,7 +371,7 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha ...@@ -372,7 +371,7 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha
p[_pos++] = prev_value; p[_pos++] = prev_value;
v += bit; v += bit;
} }
#endif }
} }
} break; } break;
case TSDB_DATA_TYPE_INT: { case TSDB_DATA_TYPE_INT: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册