fix(query): fix bug in tIntToHex and add test case.
This commit is contained in:
parent
fab32ae930
commit
61a7751b57
|
@ -1988,14 +1988,12 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT
|
||||||
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
||||||
|
|
||||||
pTaskInfo->schemaInfo.dbname = strdup(dbFName);
|
pTaskInfo->schemaInfo.dbname = strdup(dbFName);
|
||||||
pTaskInfo->id.queryId = queryId;
|
|
||||||
pTaskInfo->execModel = model;
|
pTaskInfo->execModel = model;
|
||||||
pTaskInfo->pTableInfoList = tableListCreate();
|
pTaskInfo->pTableInfoList = tableListCreate();
|
||||||
pTaskInfo->stopInfo.pStopInfo = taosArrayInit(4, sizeof(SExchangeOpStopInfo));
|
pTaskInfo->stopInfo.pStopInfo = taosArrayInit(4, sizeof(SExchangeOpStopInfo));
|
||||||
pTaskInfo->pResultBlockList = taosArrayInit(128, POINTER_BYTES);
|
pTaskInfo->pResultBlockList = taosArrayInit(128, POINTER_BYTES);
|
||||||
|
|
||||||
// char* p = taosMemoryMalloc(64);
|
pTaskInfo->id.queryId = queryId;
|
||||||
// snprintf(p, 64, "TID:0x%" PRIx64 " QID:0x%" PRIx64, taskId, queryId);
|
|
||||||
pTaskInfo->id.str = buildTaskId(taskId, queryId);
|
pTaskInfo->id.str = buildTaskId(taskId, queryId);
|
||||||
return pTaskInfo;
|
return pTaskInfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -323,8 +323,13 @@ char *strbetween(char *string, char *begin, char *end) {
|
||||||
int32_t tintToHex(uint64_t val, char hex[]) {
|
int32_t tintToHex(uint64_t val, char hex[]) {
|
||||||
const char hexstr[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
const char hexstr[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||||
|
|
||||||
int32_t j = 0;
|
int32_t j = 0, k = 0;
|
||||||
int32_t k = 0;
|
if (val == 0) {
|
||||||
|
hex[j++] = hexstr[0];
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ignore the initial 0
|
||||||
while((val & (((uint64_t)0xfL) << ((15 - k) * 4))) == 0) {
|
while((val & (((uint64_t)0xfL) << ((15 - k) * 4))) == 0) {
|
||||||
k += 1;
|
k += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -294,4 +294,32 @@ TEST(utilTest, tstrncspn) {
|
||||||
const char* reject5 = "911";
|
const char* reject5 = "911";
|
||||||
v = tstrncspn(p2, strlen(p2), reject5, 0);
|
v = tstrncspn(p2, strlen(p2), reject5, 0);
|
||||||
ASSERT_EQ(v, 14);
|
ASSERT_EQ(v, 14);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(utilTest, intToHextStr) {
|
||||||
|
char buf[64] = {0};
|
||||||
|
|
||||||
|
int64_t v = 0;
|
||||||
|
tintToHex(0, buf);
|
||||||
|
ASSERT_STREQ(buf, "0");
|
||||||
|
|
||||||
|
v = 100000000;
|
||||||
|
tintToHex(v, buf);
|
||||||
|
|
||||||
|
char destBuf[128];
|
||||||
|
sprintf(destBuf, "%" PRIx64, v);
|
||||||
|
ASSERT_STREQ(buf, destBuf);
|
||||||
|
|
||||||
|
taosSeedRand(taosGetTimestampSec());
|
||||||
|
|
||||||
|
for(int32_t i = 0; i < 100000; ++i) {
|
||||||
|
memset(buf, 0, tListLen(buf));
|
||||||
|
memset(destBuf, 0, tListLen(destBuf));
|
||||||
|
|
||||||
|
v = taosRand();
|
||||||
|
tintToHex(v, buf);
|
||||||
|
|
||||||
|
sprintf(destBuf, "%" PRIx64, v);
|
||||||
|
ASSERT_STREQ(buf, destBuf);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue