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,21 +1762,11 @@ _exit:
int32_t tColDataAddValueByBind(SColData *pColData, TAOS_MULTI_BIND *pBind) { int32_t tColDataAddValueByBind(SColData *pColData, TAOS_MULTI_BIND *pBind) {
int32_t code = 0; int32_t code = 0;
bool allValue; ASSERT(pColData->type == pBind->buffer_type);
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-length data type if (IS_VAR_DATA_TYPE(pBind->buffer_type)) { // var-length data type
for (int32_t i = 0; i < pBind->num; ++i) { for (int32_t i = 0; i < pBind->num; ++i) {
if (pBind->is_null[i]) { if (pBind->is_null && pBind->is_null[i]) {
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0); code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0);
if (code) goto _exit; if (code) goto _exit;
} else { } else {
@ -1785,32 +1775,29 @@ int32_t tColDataAddValueByBind(SColData *pColData, TAOS_MULTI_BIND *pBind) {
} }
} }
} else { // fixed-length data type } else { // fixed-length data type
pColData->nVal += pBind->num; 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;
}
if (allValue) { 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 // todo
} else if (allNull) {
// todo
} else { } else {
for (int32_t i = 0; i < pBind->num; ++i) { for (int32_t i = 0; i < pBind->num; ++i) {
if (pBind->is_null[i]) { if (pBind->is_null[i]) {
code = tColDataAppendValue(pColData, &COL_VAL_NULL(pColData->cid, pColData->type)); code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0);
// tColDataAppendNull(pColData); if (code) goto _exit;
} else { } else {
uint8_t *pData = (uint8_t *)pBind->buffer + TYPE_BYTES[pBind->buffer_type] * i; code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](
pColData, (uint8_t *)pBind->buffer + TYPE_BYTES[pColData->type] * i, pBind->buffer_length);
} }
} }
} }