提交 7e329087 编写于 作者: H Hongze Cheng

more api

上级 b96d9485
......@@ -118,6 +118,10 @@ uint8_t tColDataGetBitValue(const SColData *pColData, int32_t iVal);
int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest);
extern void (*tColDataCalcSMA[])(SColData *pColData, int64_t *sum, int64_t *max, int64_t *min, int16_t *numOfNull);
// for stmt bind
int32_t tColDataAddValueByBind(SColData *pColData, TAOS_MULTI_BIND *pBind);
int32_t tColDataSortMerge(SColData *aColData);
// STRUCT ================================
struct STColumn {
col_id_t colId;
......
......@@ -1660,6 +1660,74 @@ _exit:
return code;
}
int32_t tColDataAddValueByBind(SColData *pColData, TAOS_MULTI_BIND *pBind) {
int32_t code = 0;
bool allValue;
bool allNull;
if (pBind->is_null) {
bool same = (memcmp(pBind->is_null, pBind->is_null + 1, pBind->num - 1) == 0);
allNull = (same && pBind->is_null[0] != 0);
allValue = (same && pBind->is_null[0] == 0);
} else {
allNull = false;
allValue = true;
}
pColData->nVal += pBind->num;
if (IS_VAR_DATA_TYPE(pBind->buffer_type)) {
// var
for (int32_t i = 0; i < pBind->num; ++i) {
if (pBind->is_null[i]) {
// tColDataAppendNull(pColData);
} else {
uint8_t *pData = (uint8_t *)pBind->buffer + pBind->buffer_length * i;
SValue value = {.nData = pBind->length[i], .pData = pData};
}
}
} else {
// fix
pColData->nVal += pBind->num;
if (allValue) {
pColData->flag |= HAS_VALUE;
if (pColData->flag != HAS_VALUE) {
// todo
}
int32_t nData = pColData->nData + TYPE_BYTES[pBind->buffer_type] * pBind->num;
code = tRealloc(&pColData->pData, nData);
if (code) goto _exit;
memcpy(pColData->pData + pColData->nData, pBind->buffer, nData - pColData->nData);
pColData->nData = nData;
} else if (allNull) {
pColData->flag |= HAS_NULL;
// todo
} else {
for (int32_t i = 0; i < pBind->num; ++i) {
if (pBind->is_null[i]) {
code = tColDataAppendValue(pColData, &COL_VAL_NULL(pColData->cid, pColData->type));
// tColDataAppendNull(pColData);
} else {
uint8_t *pData = (uint8_t *)pBind->buffer + TYPE_BYTES[pBind->buffer_type] * i;
}
}
}
}
_exit:
return code;
}
int32_t tColDataSortMerge(SColData *aColData) {
// todo
return 0;
}
#define CALC_SUM_MAX_MIN(SUM, MAX, MIN, VAL) \
do { \
(SUM) += (VAL); \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册