more code

This commit is contained in:
Hongze Cheng 2022-11-27 19:55:17 +08:00
parent 0d39f49d28
commit b840cd3f34
1 changed files with 18 additions and 31 deletions

View File

@ -1762,6 +1762,19 @@ _exit:
int32_t tColDataAddValueByBind(SColData *pColData, TAOS_MULTI_BIND *pBind) {
int32_t code = 0;
ASSERT(pColData->type == pBind->buffer_type);
if (IS_VAR_DATA_TYPE(pBind->buffer_type)) { // var-length data type
for (int32_t i = 0; i < pBind->num; ++i) {
if (pBind->is_null && pBind->is_null[i]) {
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0);
if (code) goto _exit;
} else {
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](
pColData, (uint8_t *)pBind->buffer + pBind->buffer_length * i, pBind->length[i]);
}
}
} else { // fixed-length data type
bool allValue;
bool allNull;
if (pBind->is_null) {
@ -1773,44 +1786,18 @@ int32_t tColDataAddValueByBind(SColData *pColData, TAOS_MULTI_BIND *pBind) {
allValue = true;
}
pColData->nVal += pBind->num;
if (IS_VAR_DATA_TYPE(pBind->buffer_type)) { // var-length data type
if (allValue) {
// todo
} else if (allNull) {
// todo
} else {
for (int32_t i = 0; i < pBind->num; ++i) {
if (pBind->is_null[i]) {
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0);
if (code) goto _exit;
} else {
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](
pColData, (uint8_t *)pBind->buffer + pBind->buffer_length * i, pBind->length[i]);
}
}
} else { // fixed-length data type
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;
pColData, (uint8_t *)pBind->buffer + TYPE_BYTES[pColData->type] * i, pBind->buffer_length);
}
}
}