fix(util):do some internal refactor.

This commit is contained in:
Haojun Liao 2024-06-20 18:41:16 +08:00
parent 852857eae9
commit b730cfd568
2 changed files with 8 additions and 12 deletions

View File

@ -399,19 +399,15 @@ int32_t tsDecompressTimestampAvx2(const char *const input, const int32_t nelemen
int8_t nbytes1 = flags & INT8MASK(4); // range of nbytes starts from 0 to 7 int8_t nbytes1 = flags & INT8MASK(4); // range of nbytes starts from 0 to 7
int8_t nbytes2 = (flags >> 4) & INT8MASK(4); int8_t nbytes2 = (flags >> 4) & INT8MASK(4);
__m128i data1; __m128i data1 = _mm_setzero_si128();
if (nbytes1 == 0) { if (nbytes1 > 0) {
data1 = _mm_setzero_si128();
} else {
int64_t dd = 0; int64_t dd = 0;
memcpy(&dd, (const void*) (input + ipos), nbytes1); memcpy(&dd, (const void*) (input + ipos), nbytes1);
data1 = _mm_loadu_si64(&dd); data1 = _mm_loadu_si64(&dd);
} }
__m128i data2; __m128i data2 = _mm_setzero_si128();
if (nbytes2 == 0) { if (nbytes2 > 0) {
data2 = _mm_setzero_si128();
} else {
int64_t dd = 0; int64_t dd = 0;
memcpy(&dd, (const void*) (input + ipos + nbytes1), nbytes2); memcpy(&dd, (const void*) (input + ipos + nbytes1), nbytes2);
data2 = _mm_loadu_si64(&dd); data2 = _mm_loadu_si64(&dd);

View File

@ -38,13 +38,13 @@ TEST(utilTest, decompress_ts_test) {
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int64_t tsList[4] = {1286, 1124, 2681, 2823}; tsList[0] = 1286; tsList[1] = 1124; tsList[2]=2681; tsList[3] = 2823;
char* pOutput[4 * sizeof(int64_t)] = {0}; // char* pOutput[4 * sizeof(int64_t)] = {0};
int32_t len = tsCompressTimestamp(tsList, sizeof(tsList), sizeof(tsList) / sizeof(tsList[0]), pOutput, 4, len = tsCompressTimestamp(tsList, sizeof(tsList), sizeof(tsList) / sizeof(tsList[0]), pOutput, 4,
ONE_STAGE_COMP, NULL, 0); ONE_STAGE_COMP, NULL, 0);
char* decompOutput[4 * 8] = {0}; decompOutput[4 * 8] = {0};
tsDecompressTimestamp(pOutput, len, 4, decompOutput, sizeof(int64_t) * 4, ONE_STAGE_COMP, NULL, 0); tsDecompressTimestamp(pOutput, len, 4, decompOutput, sizeof(int64_t) * 4, ONE_STAGE_COMP, NULL, 0);
for (int32_t i = 0; i < 4; ++i) { for (int32_t i = 0; i < 4; ++i) {