refactor: do some internal refactor.
This commit is contained in:
parent
dc67c5041a
commit
411371ba48
|
@ -973,7 +973,7 @@ static void copyNumericCols(const SColData* pData, SFileBlockDumpInfo* pDumpInfo
|
||||||
int32_t mid = dumpedRows >> 1u;
|
int32_t mid = dumpedRows >> 1u;
|
||||||
int8_t* pts = (int8_t*)pColData->pData;
|
int8_t* pts = (int8_t*)pColData->pData;
|
||||||
for (int32_t j = 0; j < mid; ++j) {
|
for (int32_t j = 0; j < mid; ++j) {
|
||||||
int64_t t = pts[j];
|
int8_t t = pts[j];
|
||||||
pts[j] = pts[dumpedRows - j - 1];
|
pts[j] = pts[dumpedRows - j - 1];
|
||||||
pts[dumpedRows - j - 1] = t;
|
pts[dumpedRows - j - 1] = t;
|
||||||
}
|
}
|
||||||
|
@ -998,7 +998,7 @@ static void copyNumericCols(const SColData* pData, SFileBlockDumpInfo* pDumpInfo
|
||||||
int32_t mid = dumpedRows >> 1u;
|
int32_t mid = dumpedRows >> 1u;
|
||||||
int32_t* pts = (int32_t*)pColData->pData;
|
int32_t* pts = (int32_t*)pColData->pData;
|
||||||
for (int32_t j = 0; j < mid; ++j) {
|
for (int32_t j = 0; j < mid; ++j) {
|
||||||
int64_t t = pts[j];
|
int32_t t = pts[j];
|
||||||
pts[j] = pts[dumpedRows - j - 1];
|
pts[j] = pts[dumpedRows - j - 1];
|
||||||
pts[dumpedRows - j - 1] = t;
|
pts[dumpedRows - j - 1] = t;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3096,6 +3096,8 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int64_t* pts = (int64_t*)pInput->pPTS->pData;
|
int64_t* pts = (int64_t*)pInput->pPTS->pData;
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(pInputCol->info.type)) {
|
||||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
if (pInputCol->hasNull && colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) {
|
if (pInputCol->hasNull && colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -3103,13 +3105,29 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
numOfElems++;
|
numOfElems++;
|
||||||
|
|
||||||
char* data = colDataGetData(pInputCol, i);
|
char* data = colDataGetVarData(pInputCol, i);
|
||||||
TSKEY cts = pts[i];
|
TSKEY cts = pts[i];
|
||||||
if (pResInfo->numOfRes == 0 || pInfo->ts < cts) {
|
if (pResInfo->numOfRes == 0 || pInfo->ts < cts) {
|
||||||
doSaveCurrentVal(pCtx, i, cts, type, data);
|
doSaveCurrentVal(pCtx, i, cts, type, data);
|
||||||
pResInfo->numOfRes = 1;
|
pResInfo->numOfRes = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
|
if (pInputCol->hasNull && colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
numOfElems++;
|
||||||
|
|
||||||
|
char* data = colDataGetNumData(pInputCol, i);
|
||||||
|
TSKEY cts = pts[i];
|
||||||
|
if (pResInfo->numOfRes == 0 || pInfo->ts < cts) {
|
||||||
|
doSaveCurrentVal(pCtx, i, cts, type, data);
|
||||||
|
pResInfo->numOfRes = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// save selectivity value for column consisted of all null values
|
// save selectivity value for column consisted of all null values
|
||||||
|
@ -3266,8 +3284,8 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) {
|
||||||
#if 0
|
#if 0
|
||||||
int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||||
|
|
||||||
// the optimized version only function if all tuples in one block are monotonious increasing or descreasing.
|
// the optimized version only valid if all tuples in one block are monotonious increasing or descreasing.
|
||||||
// this is NOT always works if project operator exists in downstream.
|
// this assumption is NOT always works if project operator exists in downstream.
|
||||||
if (blockDataOrder == TSDB_ORDER_ASC) {
|
if (blockDataOrder == TSDB_ORDER_ASC) {
|
||||||
for (int32_t i = pInput->numOfRows + pInput->startRowIndex - 1; i >= pInput->startRowIndex; --i) {
|
for (int32_t i = pInput->numOfRows + pInput->startRowIndex - 1; i >= pInput->startRowIndex; --i) {
|
||||||
char* data = colDataGetData(pInputCol, i);
|
char* data = colDataGetData(pInputCol, i);
|
||||||
|
|
Loading…
Reference in New Issue