refactor: do some internal refactor.
This commit is contained in:
parent
26ab0894a8
commit
cefe4be1ab
|
@ -234,6 +234,7 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF
|
|||
|
||||
int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows, bool clearPayload);
|
||||
int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows);
|
||||
int32_t blockDataEnsureCapacityNoClear(SSDataBlock* pDataBlock, uint32_t numOfRows);
|
||||
|
||||
void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows);
|
||||
void blockDataCleanup(SSDataBlock* pDataBlock);
|
||||
|
|
|
@ -1239,6 +1239,25 @@ int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
SColumnInfoData* p = taosArrayGet(pDataBlock->pDataBlock, i);
|
||||
code = doEnsureCapacity(p, &pDataBlock->info, numOfRows, true);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
pDataBlock->info.capacity = numOfRows;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t blockDataEnsureCapacityNoClear(SSDataBlock* pDataBlock, uint32_t numOfRows) {
|
||||
int32_t code = 0;
|
||||
if (numOfRows == 0 || numOfRows <= pDataBlock->info.capacity) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
SColumnInfoData* p = taosArrayGet(pDataBlock->pDataBlock, i);
|
||||
|
|
|
@ -40,7 +40,7 @@ static int32_t tsdbOpenFile(const char *path, int32_t szPage, int32_t flag, STsd
|
|||
}
|
||||
pFD->szPage = szPage;
|
||||
pFD->pgno = 0;
|
||||
pFD->pBuf = taosMemoryMalloc(szPage);
|
||||
pFD->pBuf = taosMemoryCalloc(1, szPage);
|
||||
if (pFD->pBuf == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosCloseFile(&pFD->pFD);
|
||||
|
|
|
@ -1749,7 +1749,7 @@ int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t n
|
|||
pAggSup->currentPageId = -1;
|
||||
pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput);
|
||||
pAggSup->keyBuf = taosMemoryCalloc(1, keyBufSize + POINTER_BYTES + sizeof(int64_t));
|
||||
pAggSup->pResultRowHashTable = tSimpleHashInit(10, hashFn);
|
||||
pAggSup->pResultRowHashTable = tSimpleHashInit(100, hashFn);
|
||||
|
||||
if (pAggSup->keyBuf == NULL || pAggSup->pResultRowHashTable == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
|
|
@ -886,7 +886,7 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
|||
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
pInfo->pResBlock = createDataBlockFromDescNode(pDescNode);
|
||||
blockDataEnsureCapacity(pInfo->pResBlock, pOperator->resultInfo.capacity);
|
||||
blockDataEnsureCapacityNoClear(pInfo->pResBlock, pOperator->resultInfo.capacity);
|
||||
|
||||
code = filterInitFromNode((SNode*)pTableScanNode->scan.node.pConditions, &pOperator->exprSupp.pFilterInfo, 0);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
|
|
@ -1658,24 +1658,6 @@ static bool allInvertible(SqlFunctionCtx* pFCtx, int32_t numOfCols) {
|
|||
static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SIntervalAggOperatorInfo* pInfo) {
|
||||
// the primary timestamp column
|
||||
bool needed = false;
|
||||
pInfo->pInterpCols = taosArrayInit(4, sizeof(SColumn));
|
||||
pInfo->pPrevValues = taosArrayInit(4, sizeof(SGroupKeys));
|
||||
|
||||
{ // ts column
|
||||
SColumn c = {0};
|
||||
c.colId = 1;
|
||||
c.slotId = pInfo->primaryTsIndex;
|
||||
c.type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
c.bytes = sizeof(int64_t);
|
||||
taosArrayPush(pInfo->pInterpCols, &c);
|
||||
|
||||
SGroupKeys key = {0};
|
||||
key.bytes = c.bytes;
|
||||
key.type = c.type;
|
||||
key.isNull = true; // to denote no value is assigned yet
|
||||
key.pData = taosMemoryCalloc(1, c.bytes);
|
||||
taosArrayPush(pInfo->pPrevValues, &key);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
SExprInfo* pExpr = pCtx[i].pExpr;
|
||||
|
@ -1696,6 +1678,27 @@ static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SInt
|
|||
}
|
||||
}
|
||||
|
||||
if (needed) {
|
||||
pInfo->pInterpCols = taosArrayInit(4, sizeof(SColumn));
|
||||
pInfo->pPrevValues = taosArrayInit(4, sizeof(SGroupKeys));
|
||||
|
||||
{ // ts column
|
||||
SColumn c = {0};
|
||||
c.colId = 1;
|
||||
c.slotId = pInfo->primaryTsIndex;
|
||||
c.type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
c.bytes = sizeof(int64_t);
|
||||
taosArrayPush(pInfo->pInterpCols, &c);
|
||||
|
||||
SGroupKeys key;
|
||||
key.bytes = c.bytes;
|
||||
key.type = c.type;
|
||||
key.isNull = true; // to denote no value is assigned yet
|
||||
key.pData = taosMemoryCalloc(1, c.bytes);
|
||||
taosArrayPush(pInfo->pPrevValues, &key);
|
||||
}
|
||||
}
|
||||
|
||||
return needed;
|
||||
}
|
||||
|
||||
|
@ -1737,7 +1740,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh
|
|||
|
||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||
initResultSizeInfo(&pOperator->resultInfo, 1024);
|
||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
||||
blockDataEnsureCapacityNoClear(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
||||
|
||||
int32_t num = 0;
|
||||
SExprInfo* pExprInfo = createExprInfo(pPhyNode->window.pFuncs, NULL, &num);
|
||||
|
|
|
@ -33,7 +33,7 @@ SArray* taosArrayInit(size_t size, size_t elemSize) {
|
|||
}
|
||||
|
||||
pArray->size = 0;
|
||||
pArray->pData = taosMemoryCalloc(size, elemSize);
|
||||
pArray->pData = taosMemoryMalloc(size * elemSize);
|
||||
if (pArray->pData == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(pArray);
|
||||
|
|
|
@ -244,7 +244,7 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool update, SHashLockTyp
|
|||
capacity = 4;
|
||||
}
|
||||
|
||||
SHashObj *pHashObj = (SHashObj *)taosMemoryCalloc(1, sizeof(SHashObj));
|
||||
SHashObj *pHashObj = (SHashObj *)taosMemoryMalloc(sizeof(SHashObj));
|
||||
if (pHashObj == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
|
@ -264,7 +264,7 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool update, SHashLockTyp
|
|||
|
||||
ASSERT((pHashObj->capacity & (pHashObj->capacity - 1)) == 0);
|
||||
|
||||
pHashObj->hashList = (SHashEntry **)taosMemoryCalloc(pHashObj->capacity, sizeof(void *));
|
||||
pHashObj->hashList = (SHashEntry **)taosMemoryMalloc(pHashObj->capacity * sizeof(void *));
|
||||
if (pHashObj->hashList == NULL) {
|
||||
taosMemoryFree(pHashObj);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
|
Loading…
Reference in New Issue