Merge pull request #942 from taosdata/feature/liaohj
fix bug in issue #941 [tbase-1359]
This commit is contained in:
commit
c3fc348645
|
@ -100,6 +100,32 @@ static int32_t tabObjResultComparator(const void* p1, const void* p2, void* para
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update the tag order index according to the tags column index. The tags column index needs to be checked one-by-one,
|
||||||
|
* since the normal columns may be passed to server for handling the group by on status column.
|
||||||
|
*
|
||||||
|
* @param pMetricMetaMsg
|
||||||
|
* @param tableIndex
|
||||||
|
* @param pOrderIndexInfo
|
||||||
|
* @param numOfTags
|
||||||
|
*/
|
||||||
|
static void mgmtUpdateOrderTagColIndex(SMetricMetaMsg* pMetricMetaMsg, int32_t tableIndex, tOrderIdx* pOrderIndexInfo,
|
||||||
|
int32_t numOfTags) {
|
||||||
|
SMetricMetaElemMsg* pElem = (SMetricMetaElemMsg*)((char*)pMetricMetaMsg + pMetricMetaMsg->metaElem[tableIndex]);
|
||||||
|
SColIndexEx* groupColumnList = (SColIndexEx*)((char*)pMetricMetaMsg + pElem->groupbyTagColumnList);
|
||||||
|
|
||||||
|
int32_t numOfGroupbyTags = 0;
|
||||||
|
for (int32_t i = 0; i < pElem->numOfGroupCols; ++i) {
|
||||||
|
if (groupColumnList[i].flag == TSDB_COL_TAG) { // ignore this column if it is not a tag column.
|
||||||
|
pOrderIndexInfo->pData[numOfGroupbyTags++] = groupColumnList[i].colIdx;
|
||||||
|
|
||||||
|
assert(groupColumnList[i].colIdx < numOfTags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pOrderIndexInfo->numOfOrderedCols = numOfGroupbyTags;
|
||||||
|
}
|
||||||
|
|
||||||
// todo merge sort function with losertree used
|
// todo merge sort function with losertree used
|
||||||
void mgmtReorganizeMetersInMetricMeta(SMetricMetaMsg* pMetricMetaMsg, int32_t tableIndex, tQueryResultset* pRes) {
|
void mgmtReorganizeMetersInMetricMeta(SMetricMetaMsg* pMetricMetaMsg, int32_t tableIndex, tQueryResultset* pRes) {
|
||||||
if (pRes->num <= 0) { // no result, no need to pagination
|
if (pRes->num <= 0) { // no result, no need to pagination
|
||||||
|
@ -122,13 +148,9 @@ void mgmtReorganizeMetersInMetricMeta(SMetricMetaMsg* pMetricMetaMsg, int32_t ta
|
||||||
|
|
||||||
int32_t* startPos = NULL;
|
int32_t* startPos = NULL;
|
||||||
int32_t numOfSubset = 1;
|
int32_t numOfSubset = 1;
|
||||||
|
|
||||||
if (pElem->numOfGroupCols > 0) {
|
mgmtUpdateOrderTagColIndex(pMetricMetaMsg, tableIndex, &descriptor->orderIdx, pMetric->numOfTags);
|
||||||
SColIndexEx* groupColumnList = (SColIndexEx*)((char*)pMetricMetaMsg + pElem->groupbyTagColumnList);
|
if (descriptor->orderIdx.numOfOrderedCols > 0) {
|
||||||
for (int32_t i = 0; i < pElem->numOfGroupCols; ++i) {
|
|
||||||
descriptor->orderIdx.pData[i] = groupColumnList[i].colIdx;
|
|
||||||
}
|
|
||||||
|
|
||||||
tQSortEx(pRes->pRes, POINTER_BYTES, 0, pRes->num - 1, descriptor, tabObjResultComparator);
|
tQSortEx(pRes->pRes, POINTER_BYTES, 0, pRes->num - 1, descriptor, tabObjResultComparator);
|
||||||
startPos = calculateSubGroup(pRes->pRes, pRes->num, &numOfSubset, descriptor, tabObjResultComparator);
|
startPos = calculateSubGroup(pRes->pRes, pRes->num, &numOfSubset, descriptor, tabObjResultComparator);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue