提交 93f9ffe0 编写于 作者: H Haojun Liao

fix(query): set correct vgId and add some test case.

上级 c4a53438
...@@ -1254,9 +1254,10 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -1254,9 +1254,10 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
if (pQueryInfo->tsBuf != NULL) { if (pQueryInfo->tsBuf != NULL) {
// note: here used the idx instead of actual vnode id. // note: here used the idx instead of actual vnode id.
int32_t vgId = 0; int32_t vgId = 0;
if (pTableMetaInfo->vgroupList != NULL) { if (pTableMetaInfo->pVgroupTables != NULL) {
int32_t vnodeIndex = pTableMetaInfo->vgroupIndex; int32_t vnodeIndex = pTableMetaInfo->vgroupIndex;
vgId = pTableMetaInfo->vgroupList->vgroups[vnodeIndex].vgId; SVgroupTableInfo* pTableInfo = taosArrayGet(pTableMetaInfo->pVgroupTables, vnodeIndex);
vgId = pTableInfo->vgInfo.vgId;
} else { } else {
vgId = query.vgId; vgId = query.vgId;
} }
......
...@@ -30,11 +30,11 @@ IF (HEADER_GTEST_INCLUDE_DIR AND (LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) ...@@ -30,11 +30,11 @@ IF (HEADER_GTEST_INCLUDE_DIR AND (LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR))
ENDIF() ENDIF()
ENDIF() ENDIF()
SET_SOURCE_FILES_PROPERTIES(./astTest.cpp PROPERTIES COMPILE_FLAGS -w) #SET_SOURCE_FILES_PROPERTIES(./astTest.cpp PROPERTIES COMPILE_FLAGS -w)
SET_SOURCE_FILES_PROPERTIES(./histogramTest.cpp PROPERTIES COMPILE_FLAGS -w) #SET_SOURCE_FILES_PROPERTIES(./histogramTest.cpp PROPERTIES COMPILE_FLAGS -w)
SET_SOURCE_FILES_PROPERTIES(./percentileTest.cpp PROPERTIES COMPILE_FLAGS -w) #SET_SOURCE_FILES_PROPERTIES(./percentileTest.cpp PROPERTIES COMPILE_FLAGS -w)
SET_SOURCE_FILES_PROPERTIES(./apercentileTest.cpp PROPERTIES COMPILE_FLAGS -w) #SET_SOURCE_FILES_PROPERTIES(./apercentileTest.cpp PROPERTIES COMPILE_FLAGS -w)
SET_SOURCE_FILES_PROPERTIES(./resultBufferTest.cpp PROPERTIES COMPILE_FLAGS -w) #SET_SOURCE_FILES_PROPERTIES(./resultBufferTest.cpp PROPERTIES COMPILE_FLAGS -w)
SET_SOURCE_FILES_PROPERTIES(./tsBufTest.cpp PROPERTIES COMPILE_FLAGS -w) SET_SOURCE_FILES_PROPERTIES(./tsBufTest.cpp PROPERTIES COMPILE_FLAGS -w)
SET_SOURCE_FILES_PROPERTIES(./unitTest.cpp PROPERTIES COMPILE_FLAGS -w) #SET_SOURCE_FILES_PROPERTIES(./unitTest.cpp PROPERTIES COMPILE_FLAGS -w)
SET_SOURCE_FILES_PROPERTIES(./rangeMergeTest.cpp PROPERTIES COMPILE_FLAGS -w) #SET_SOURCE_FILES_PROPERTIES(./rangeMergeTest.cpp PROPERTIES COMPILE_FLAGS -w)
...@@ -291,13 +291,13 @@ void tdigestTest() { ...@@ -291,13 +291,13 @@ void tdigestTest() {
for (int32_t j = 0; j < typeTimes; ++j) { for (int32_t j = 0; j < typeTimes; ++j) {
printf("DMode:%d,Type:%d,randP:%d -", dataMode[i], dataTypes[j], randPers[p]); printf("DMode:%d,Type:%d,randP:%d -", dataMode[i], dataTypes[j], randPers[p]);
for (int32_t m = 0; m < numTimes; ++m) { for (int32_t m = 0; m < numTimes; ++m) {
printf(" %d:%f", totalNum[m], useTime[0][i][j][m][p]); printf(" %ld:%f", totalNum[m], useTime[0][i][j][m][p]);
} }
printf("\n"); printf("\n");
printf("HMode:%d,Type:%d,randP:%d -", dataMode[i], dataTypes[j], randPers[p]); printf("HMode:%d,Type:%d,randP:%d -", dataMode[i], dataTypes[j], randPers[p]);
for (int32_t m = 0; m < numTimes; ++m) { for (int32_t m = 0; m < numTimes; ++m) {
printf(" %d:%f", totalNum[m], useTime[1][i][j][m][p]); printf(" %ld:%f", totalNum[m], useTime[1][i][j][m][p]);
} }
printf("\n"); printf("\n");
} }
...@@ -307,13 +307,13 @@ void tdigestTest() { ...@@ -307,13 +307,13 @@ void tdigestTest() {
for (int32_t j = 0; j < typeTimes; ++j) { for (int32_t j = 0; j < typeTimes; ++j) {
printf("DMode:%d,Type:%d,randL:%d -", dataMode[i], dataTypes[j], randLimits[p]); printf("DMode:%d,Type:%d,randL:%d -", dataMode[i], dataTypes[j], randLimits[p]);
for (int64_t m = 0; m < numTimes; ++m) { for (int64_t m = 0; m < numTimes; ++m) {
printf(" %d:%f", totalNum[m], useTime[0][i][j][m][p]); printf(" %ld:%f", totalNum[m], useTime[0][i][j][m][p]);
} }
printf("\n"); printf("\n");
printf("HMode:%d,Type:%d,randL:%d -", dataMode[i], dataTypes[j], randLimits[p]); printf("HMode:%d,Type:%d,randL:%d -", dataMode[i], dataTypes[j], randLimits[p]);
for (int64_t m = 0; m < numTimes; ++m) { for (int64_t m = 0; m < numTimes; ++m) {
printf(" %d:%f", totalNum[m], useTime[1][i][j][m][p]); printf(" %ld:%f", totalNum[m], useTime[1][i][j][m][p]);
} }
printf("\n"); printf("\n");
} }
...@@ -322,13 +322,13 @@ void tdigestTest() { ...@@ -322,13 +322,13 @@ void tdigestTest() {
for (int32_t j = 0; j < typeTimes; ++j) { for (int32_t j = 0; j < typeTimes; ++j) {
printf("DMode:%d,Type:%d -", dataMode[i], dataTypes[j]); printf("DMode:%d,Type:%d -", dataMode[i], dataTypes[j]);
for (int64_t m = 0; m < numTimes; ++m) { for (int64_t m = 0; m < numTimes; ++m) {
printf(" %d:%f", totalNum[m], useTime[0][i][j][m][0]); printf(" %ld:%f", totalNum[m], useTime[0][i][j][m][0]);
} }
printf("\n"); printf("\n");
printf("HMode:%d,Type:%d -", dataMode[i], dataTypes[j]); printf("HMode:%d,Type:%d -", dataMode[i], dataTypes[j]);
for (int64_t m = 0; m < numTimes; ++m) { for (int64_t m = 0; m < numTimes; ++m) {
printf(" %d:%f", totalNum[m], useTime[1][i][j][m][0]); printf(" %ld:%f", totalNum[m], useTime[1][i][j][m][0]);
} }
printf("\n"); printf("\n");
} }
......
...@@ -35,7 +35,7 @@ void doHistogramAddTest() { ...@@ -35,7 +35,7 @@ void doHistogramAddTest() {
(int64_t)systemTime.tv_sec * 1000L + (uint64_t)systemTime.tv_usec / 1000; (int64_t)systemTime.tv_sec * 1000L + (uint64_t)systemTime.tv_usec / 1000;
printf("total elapsed time: %ld\n", et - st); printf("total elapsed time: %ld\n", et - st);
printf("elements: %d, slot:%d \n", pHisto->numOfElems, pHisto->numOfEntries); printf("elements: %ld, slot:%d \n", pHisto->numOfElems, pHisto->numOfEntries);
tHistogramPrint(pHisto); tHistogramPrint(pHisto);
printf("%ld\n", tHistogramSum(pHisto, 1.5)); printf("%ld\n", tHistogramSum(pHisto, 1.5));
......
...@@ -497,19 +497,103 @@ void mergeIdenticalVnodeBufferTest() { ...@@ -497,19 +497,103 @@ void mergeIdenticalVnodeBufferTest() {
tsBufDestroy(pTSBuf1); tsBufDestroy(pTSBuf1);
tsBufDestroy(pTSBuf2); tsBufDestroy(pTSBuf2);
} }
void mergeMultiBlockFromOneGroupTest() {
STSBuf* pTSBuf1 = tsBufCreate(true, TSDB_ORDER_ASC);
STSBuf* pTSBuf2 = tsBufCreate(true, TSDB_ORDER_ASC);
tVariant t = {0};
t.nType = TSDB_DATA_TYPE_BIGINT;
int32_t step = 30;
int32_t num = 1000;
int32_t numOfTags = 2;
// vnodeId:0
int64_t start = 10000;
for (int32_t i = 0; i < numOfTags; ++i) {
int64_t* list = createTsList(num, start, step);
t.i64 = i;
tsBufAppend(pTSBuf1, 12, &t, (const char*)list, num * sizeof(int64_t));
free(list);
start += step * num;
}
tsBufFlush(pTSBuf1);
for (int32_t i = numOfTags; i < numOfTags * 2; ++i) {
int64_t* list = createTsList(num, start, step);
t.i64 = i;
tsBufAppend(pTSBuf1, 77, &t, (const char*)list, num * sizeof(int64_t));
free(list);
start += step * num;
}
tsBufFlush(pTSBuf1);
start = 10000;
for (int32_t i = 911; i < 912; ++i) {
int64_t* list = createTsList(num, start, step);
t.i64 = i;
tsBufAppend(pTSBuf1, 12, &t, (const char*)list, num * sizeof(int64_t));
free(list);
start += step * num;
}
tsBufFlush(pTSBuf1);
char* p = (char*) malloc(1024768);
int32_t len = 0;
int32_t numOfBlocks = 0;
dumpFileBlockByGroupId(pTSBuf1, 12, p, &len, &numOfBlocks);
STSBuf* pNew = tsBufCreateFromCompBlocks(p, numOfBlocks, len, 1, 12);
printf("%p\n", pNew);
tsBufDisplay(pNew);
// tsBufMerge(pTSBuf1, pTSBuf2);
// EXPECT_EQ(pTSBuf1->numOfGroups, 2);
// EXPECT_EQ(pTSBuf1->numOfTotal, numOfTags * 2 * num);
//
// tsBufResetPos(pTSBuf1);
//
// int32_t count = 0;
// while (tsBufNextPos(pTSBuf1)) {
// STSElem elem = tsBufGetElem(pTSBuf1);
//
// if (count++ < numOfTags * num) {
// EXPECT_EQ(elem.id, 12);
// } else {
// EXPECT_EQ(elem.id, 77);
// }
//
// printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.id, elem.tag->i64, elem.ts);
// }
//
// tsBufDestroy(pTSBuf1);
// tsBufDestroy(pTSBuf2);
}
} // namespace } // namespace
//TODO add binary tag value test case //TODO add binary tag value test case
TEST(testCase, tsBufTest) { TEST(testCase, tsBufTest) {
simpleTest(); // simpleTest();
largeTSTest(); // largeTSTest();
multiTagsTest(); // multiTagsTest();
multiVnodeTagsTest(); // multiVnodeTagsTest();
loadDataTest(); // loadDataTest();
invalidFileTest(); // invalidFileTest();
// randomIncTsTest(); // randomIncTsTest();
TSTraverse(); // TSTraverse();
mergeDiffVnodeBufferTest(); // mergeDiffVnodeBufferTest();
mergeIdenticalVnodeBufferTest(); // mergeIdenticalVnodeBufferTest();
mergeMultiBlockFromOneGroupTest();
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册