feat:[TD-31242]add new interface taos_get_column_data_null to get if raw data is null

This commit is contained in:
wangmm0220 2024-08-28 18:00:40 +08:00
parent df33b71bef
commit b86f416645
3 changed files with 9 additions and 6 deletions

View File

@ -210,12 +210,12 @@ DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
DLL_EXPORT int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields);
DLL_EXPORT void taos_stop_query(TAOS_RES *res);
DLL_EXPORT bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col);
DLL_EXPORT int taos_is_null_by_column(TAOS_RES *res, int columnIndex, bool result[], int *rows);
DLL_EXPORT bool taos_is_update_query(TAOS_RES *res);
DLL_EXPORT int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows);
DLL_EXPORT int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows);
DLL_EXPORT int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData);
DLL_EXPORT int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex);
DLL_EXPORT int taos_get_column_data_null(TAOS_RES *res, int columnIndex, bool result[], int rows);
DLL_EXPORT int taos_validate_sql(TAOS *taos, const char *sql);
DLL_EXPORT void taos_reset_current_db(TAOS *taos);

View File

@ -859,8 +859,8 @@ int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) {
return pResInfo->pCol[columnIndex].offset;
}
int taos_get_column_data_null(TAOS_RES *res, int columnIndex, bool result[], int rows){
if (res == NULL || result == NULL || rows <= 0 || TD_RES_TMQ_META(res) || TD_RES_TMQ_BATCH_META(res)) {
int taos_is_null_by_column(TAOS_RES *res, int columnIndex, bool result[], int *rows){
if (res == NULL || result == NULL || *rows <= 0 || TD_RES_TMQ_META(res) || TD_RES_TMQ_BATCH_META(res)) {
return TSDB_CODE_INVALID_PARA;
}
@ -873,8 +873,11 @@ int taos_get_column_data_null(TAOS_RES *res, int columnIndex, bool result[], int
TAOS_FIELD *pField = &pResInfo->userFields[columnIndex];
SResultColumn *pCol = &pResInfo->pCol[columnIndex];
if (*rows > pResInfo->numOfRows){
*rows = pResInfo->numOfRows;
}
if (IS_VAR_DATA_TYPE(pField->type)) {
for(int i = 0; i < rows && i < pResInfo->numOfRows; i++){
for(int i = 0; i < *rows; i++){
if(pCol->offset[i] == -1){
result[i] = true;
}else{
@ -882,7 +885,7 @@ int taos_get_column_data_null(TAOS_RES *res, int columnIndex, bool result[], int
}
}
}else{
for(int i = 0; i < rows && i < pResInfo->numOfRows; i++){
for(int i = 0; i < *rows; i++){
if (colDataIsNull_f(pCol->nullbitmap, i)){
result[i] = true;
}else{

View File

@ -69,7 +69,7 @@ void* consumeThreadFunc(void* param) {
}
int64_t end = taosGetTimestampUs();
bool* isNULL = taosMemoryCalloc(rows, sizeof(bool));
int code = taos_get_column_data_null(pRes, i, isNULL, rows);
int code = taos_is_null_by_column(pRes, i, isNULL, &rows);
printf("taos_fetch_raw_block gourp:%s total rows:%d cost %"PRId64" us, code:%d\n", groupId, totalRows, end - start, code);
}