fix assert in tpercentile.c
This commit is contained in:
parent
5b88f0fffb
commit
d454ec970d
|
@ -88,7 +88,7 @@ static void resetPosInfo(SSlotInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
double findOnlyResult(tMemBucket *pMemBucket) {
|
double findOnlyResult(tMemBucket *pMemBucket) {
|
||||||
assert(pMemBucket->total == 1);
|
ASSERTS(pMemBucket->total == 1);
|
||||||
|
|
||||||
for (int32_t i = 0; i < pMemBucket->numOfSlots; ++i) {
|
for (int32_t i = 0; i < pMemBucket->numOfSlots; ++i) {
|
||||||
tMemBucketSlot *pSlot = &pMemBucket->pSlots[i];
|
tMemBucketSlot *pSlot = &pMemBucket->pSlots[i];
|
||||||
|
@ -100,11 +100,11 @@ double findOnlyResult(tMemBucket *pMemBucket) {
|
||||||
SArray **pList = taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId));
|
SArray **pList = taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId));
|
||||||
if (pList != NULL) {
|
if (pList != NULL) {
|
||||||
SArray *list = *pList;
|
SArray *list = *pList;
|
||||||
assert(list->size == 1);
|
ASSERTS(list->size == 1);
|
||||||
|
|
||||||
int32_t *pageId = taosArrayGet(list, 0);
|
int32_t *pageId = taosArrayGet(list, 0);
|
||||||
SFilePage *pPage = getBufPage(pMemBucket->pBuffer, *pageId);
|
SFilePage *pPage = getBufPage(pMemBucket->pBuffer, *pageId);
|
||||||
assert(pPage->num == 1);
|
ASSERTS(pPage->num == 1);
|
||||||
|
|
||||||
double v = 0;
|
double v = 0;
|
||||||
GET_TYPED_DATA(v, double, pMemBucket->type, pPage->data);
|
GET_TYPED_DATA(v, double, pMemBucket->type, pPage->data);
|
||||||
|
@ -140,7 +140,8 @@ int32_t tBucketIntHash(tMemBucket *pBucket, const void *value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(index >= 0 && index < pBucket->numOfSlots);
|
ASSERTS(index >= 0 && index < pBucket->numOfSlots, "tBucketIntHash Error, index:%d, numOfSlots:%d",
|
||||||
|
index, pBucket->numOfSlots);
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +168,7 @@ int32_t tBucketUintHash(tMemBucket *pBucket, const void *value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(index >= 0 && index < pBucket->numOfSlots);
|
ASSERTS(index >= 0 && index < pBucket->numOfSlots);
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +199,7 @@ int32_t tBucketDoubleHash(tMemBucket *pBucket, const void *value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(index >= 0 && index < pBucket->numOfSlots);
|
ASSERTS(index >= 0 && index < pBucket->numOfSlots);
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +332,7 @@ void tMemBucketUpdateBoundingBox(MinMaxEntry *r, const char *data, int32_t dataT
|
||||||
r->dMaxVal = v;
|
r->dMaxVal = v;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(0);
|
ASSERTS(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +340,7 @@ void tMemBucketUpdateBoundingBox(MinMaxEntry *r, const char *data, int32_t dataT
|
||||||
* in memory bucket, we only accept data array list
|
* in memory bucket, we only accept data array list
|
||||||
*/
|
*/
|
||||||
int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
|
int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
|
||||||
assert(pBucket != NULL && data != NULL && size > 0);
|
ASSERTS(pBucket != NULL && data != NULL && size > 0);
|
||||||
|
|
||||||
int32_t count = 0;
|
int32_t count = 0;
|
||||||
int32_t bytes = pBucket->bytes;
|
int32_t bytes = pBucket->bytes;
|
||||||
|
@ -361,7 +362,7 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
|
||||||
|
|
||||||
if (pSlot->info.data == NULL || pSlot->info.data->num >= pBucket->elemPerPage) {
|
if (pSlot->info.data == NULL || pSlot->info.data->num >= pBucket->elemPerPage) {
|
||||||
if (pSlot->info.data != NULL) {
|
if (pSlot->info.data != NULL) {
|
||||||
assert(pSlot->info.data->num >= pBucket->elemPerPage && pSlot->info.size > 0);
|
ASSERTS(pSlot->info.data->num >= pBucket->elemPerPage && pSlot->info.size > 0);
|
||||||
|
|
||||||
// keep the pointer in memory
|
// keep the pointer in memory
|
||||||
setBufPageDirty(pSlot->info.data, true);
|
setBufPageDirty(pSlot->info.data, true);
|
||||||
|
@ -407,14 +408,14 @@ static MinMaxEntry getMinMaxEntryOfNextSlotWithData(tMemBucket *pMemBucket, int3
|
||||||
++j;
|
++j;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(j < pMemBucket->numOfSlots);
|
ASSERTS(j < pMemBucket->numOfSlots);
|
||||||
return pMemBucket->pSlots[j].range;
|
return pMemBucket->pSlots[j].range;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isIdenticalData(tMemBucket *pMemBucket, int32_t index);
|
static bool isIdenticalData(tMemBucket *pMemBucket, int32_t index);
|
||||||
|
|
||||||
static double getIdenticalDataVal(tMemBucket *pMemBucket, int32_t slotIndex) {
|
static double getIdenticalDataVal(tMemBucket *pMemBucket, int32_t slotIndex) {
|
||||||
assert(isIdenticalData(pMemBucket, slotIndex));
|
ASSERTS(isIdenticalData(pMemBucket, slotIndex));
|
||||||
|
|
||||||
tMemBucketSlot *pSlot = &pMemBucket->pSlots[slotIndex];
|
tMemBucketSlot *pSlot = &pMemBucket->pSlots[slotIndex];
|
||||||
|
|
||||||
|
@ -461,7 +462,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
|
||||||
minOfNextSlot = (double)next.dMinVal;
|
minOfNextSlot = (double)next.dMinVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(minOfNextSlot > maxOfThisSlot);
|
ASSERTS(minOfNextSlot > maxOfThisSlot);
|
||||||
|
|
||||||
double val = (1 - fraction) * maxOfThisSlot + fraction * minOfNextSlot;
|
double val = (1 - fraction) * maxOfThisSlot + fraction * minOfNextSlot;
|
||||||
return val;
|
return val;
|
||||||
|
@ -499,7 +500,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
|
||||||
|
|
||||||
int32_t groupId = getGroupId(pMemBucket->numOfSlots, i, pMemBucket->times - 1);
|
int32_t groupId = getGroupId(pMemBucket->numOfSlots, i, pMemBucket->times - 1);
|
||||||
SArray* list = *(SArray **)taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId));
|
SArray* list = *(SArray **)taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId));
|
||||||
ASSERT(list != NULL && list->size > 0);
|
ASSERTS(list != NULL && list->size > 0);
|
||||||
|
|
||||||
for (int32_t f = 0; f < list->size; ++f) {
|
for (int32_t f = 0; f < list->size; ++f) {
|
||||||
int32_t *pageId = taosArrayGet(list, f);
|
int32_t *pageId = taosArrayGet(list, f);
|
||||||
|
|
Loading…
Reference in New Issue