[TD-225] add logs.
This commit is contained in:
parent
a0ccfd3145
commit
d371c840f0
|
@ -124,6 +124,7 @@ typedef struct SQueryCostInfo {
|
|||
uint64_t firstStageMergeTime;
|
||||
uint64_t winInfoSize;
|
||||
uint64_t tableInfoSize;
|
||||
uint64_t hashSize;
|
||||
uint64_t numOfTimeWindows;
|
||||
} SQueryCostInfo;
|
||||
|
||||
|
|
|
@ -461,16 +461,16 @@ static SWindowResult *doSetTimeWindowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SWin
|
|||
|
||||
// more than the capacity, reallocate the resources
|
||||
if (pWindowResInfo->size >= pWindowResInfo->capacity) {
|
||||
int64_t newCap = 0;
|
||||
int64_t newCapacity = 0;
|
||||
if (pWindowResInfo->capacity > 10000) {
|
||||
newCap = (int64_t)(pWindowResInfo->capacity * 1.25);
|
||||
newCapacity = (int64_t)(pWindowResInfo->capacity * 1.25);
|
||||
} else {
|
||||
newCap = (int64_t)(pWindowResInfo->capacity * 1.5);
|
||||
newCapacity = (int64_t)(pWindowResInfo->capacity * 1.5);
|
||||
}
|
||||
|
||||
char *t = realloc(pWindowResInfo->pResult, (size_t)(newCap * sizeof(SWindowResult)));
|
||||
pRuntimeEnv->summary.winInfoSize += (newCap - pWindowResInfo->capacity) * sizeof(SWindowResult);
|
||||
pRuntimeEnv->summary.numOfTimeWindows += (newCap - pWindowResInfo->capacity);
|
||||
char *t = realloc(pWindowResInfo->pResult, (size_t)(newCapacity * sizeof(SWindowResult)));
|
||||
pRuntimeEnv->summary.winInfoSize += (newCapacity - pWindowResInfo->capacity) * sizeof(SWindowResult);
|
||||
pRuntimeEnv->summary.numOfTimeWindows += (newCapacity - pWindowResInfo->capacity);
|
||||
|
||||
if (t == NULL) {
|
||||
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
|
@ -478,19 +478,19 @@ static SWindowResult *doSetTimeWindowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SWin
|
|||
|
||||
pWindowResInfo->pResult = (SWindowResult *)t;
|
||||
|
||||
int32_t inc = (int32_t)newCap - pWindowResInfo->capacity;
|
||||
int32_t inc = (int32_t)newCapacity - pWindowResInfo->capacity;
|
||||
memset(&pWindowResInfo->pResult[pWindowResInfo->capacity], 0, sizeof(SWindowResult) * inc);
|
||||
|
||||
pRuntimeEnv->summary.winInfoSize += (pQuery->numOfOutput * sizeof(SResultInfo) + pRuntimeEnv->interBufSize) * inc;
|
||||
|
||||
for (int32_t i = pWindowResInfo->capacity; i < newCap; ++i) {
|
||||
for (int32_t i = pWindowResInfo->capacity; i < newCapacity; ++i) {
|
||||
int32_t ret = createQueryResultInfo(pQuery, &pWindowResInfo->pResult[i], pRuntimeEnv->stableQuery, pRuntimeEnv->interBufSize);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
|
||||
pWindowResInfo->capacity = (int32_t)newCap;
|
||||
pWindowResInfo->capacity = (int32_t)newCapacity;
|
||||
}
|
||||
|
||||
// add a new result set for a new group
|
||||
|
|
|
@ -49,16 +49,16 @@ int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRun
|
|||
SQueryCostInfo* pSummary = &pRuntimeEnv->summary;
|
||||
|
||||
// use the pointer arraylist
|
||||
pWindowResInfo->pResult = calloc(threshold, sizeof(SWindowResult));
|
||||
pWindowResInfo->pResult = calloc(pWindowResInfo->capacity, sizeof(SWindowResult));
|
||||
if (pWindowResInfo->pResult == NULL) {
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pWindowResInfo->interval = pRuntimeEnv->pQuery->interval.interval;
|
||||
|
||||
pSummary->winInfoSize += sizeof(SWindowResult) * threshold;
|
||||
pSummary->winInfoSize += sizeof(SWindowResult) * pWindowResInfo->capacity;
|
||||
pSummary->winInfoSize += (pRuntimeEnv->pQuery->numOfOutput * sizeof(SResultInfo) + pRuntimeEnv->interBufSize) * pWindowResInfo->capacity;
|
||||
pSummary->numOfTimeWindows = threshold;
|
||||
pSummary->numOfTimeWindows = pWindowResInfo->capacity;
|
||||
|
||||
for (int32_t i = 0; i < pWindowResInfo->capacity; ++i) {
|
||||
int32_t code = createQueryResultInfo(pRuntimeEnv->pQuery, &pWindowResInfo->pResult[i], pRuntimeEnv->stableQuery, pRuntimeEnv->interBufSize);
|
||||
|
|
|
@ -32,7 +32,6 @@ typedef void (*_hash_free_fn_t)(void *param);
|
|||
|
||||
typedef struct SHashNode {
|
||||
char *key;
|
||||
// struct SHashNode *prev;
|
||||
struct SHashNode *next;
|
||||
uint32_t hashVal; // the hash value of key, if hashVal == HASH_VALUE_IN_TRASH, this node is moved to trash
|
||||
uint32_t keyLen; // length of the key
|
||||
|
@ -175,6 +174,8 @@ void* taosHashDestroyIter(SHashMutableIterator* iter);
|
|||
*/
|
||||
int32_t taosHashGetMaxOverflowLinkLength(const SHashObj *pHashObj);
|
||||
|
||||
size_t taosHashGetMemSize(const SHashObj *pHashObj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -798,3 +798,11 @@ SHashNode *getNextHashNode(SHashMutableIterator *pIter) {
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t taosHashGetMemSize(const SHashObj *pHashObj) {
|
||||
if (pHashObj == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (pHashObj->capacity * sizeof(SHashEntry) + POINTER_BYTES) + sizeof(SHashNode) * taosHashGetSize(pHashObj);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue