feat(query): add sample function
This commit is contained in:
parent
18ac565a93
commit
c1666e7e02
|
@ -848,7 +848,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.getEnvFunc = getSampleFuncEnv,
|
.getEnvFunc = getSampleFuncEnv,
|
||||||
.initFunc = sampleFunctionSetup,
|
.initFunc = sampleFunctionSetup,
|
||||||
.processFunc = sampleFunction,
|
.processFunc = sampleFunction,
|
||||||
.finalizeFunc = sampleFinalize
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "abs",
|
.name = "abs",
|
||||||
|
|
|
@ -3124,19 +3124,19 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) {
|
||||||
return pInfo->numSampled;
|
return pInfo->numSampled;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
//int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
// SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
SSampleInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
// SSampleInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||||
int32_t slotId = pCtx->pExpr->base.resSchema.slotId;
|
// int32_t slotId = pCtx->pExpr->base.resSchema.slotId;
|
||||||
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
|
// SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
|
//
|
||||||
//int32_t currentRow = pBlock->info.rows;
|
// //int32_t currentRow = pBlock->info.rows;
|
||||||
pResInfo->numOfRes = pInfo->numSampled;
|
// pResInfo->numOfRes = pInfo->numSampled;
|
||||||
|
//
|
||||||
for (int32_t i = 0; i < pInfo->numSampled; ++i) {
|
// for (int32_t i = 0; i < pInfo->numSampled; ++i) {
|
||||||
colDataAppend(pCol, i, pInfo->data + i * pInfo->colBytes, false);
|
// colDataAppend(pCol, i, pInfo->data + i * pInfo->colBytes, false);
|
||||||
//TODO: handle ts output
|
// //TODO: handle ts output
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return pResInfo->numOfRes;
|
// return pResInfo->numOfRes;
|
||||||
}
|
//}
|
||||||
|
|
Loading…
Reference in New Issue