From 6390536449ff7d3a42ae5e48a98150a5c19c0693 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Wed, 27 May 2020 04:01:34 +0000 Subject: [PATCH] [TD-90] add insert and modify tag schema --- src/common/inc/tdataformat.h | 2 +- src/common/src/tdataformat.c | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h index 497279fb27..528e9b2825 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -259,7 +259,7 @@ typedef struct { #define tagColSize(r) (sizeof(STagCol) + r.colLen) -int tdInsertTagCol(SDataRow row, void *value, int16_t len, int8_t type, int16_t colId); //insert tag value and update all the information +int tdSetTagCol(SDataRow row, void *value, int16_t len, int8_t type, int16_t colId); //insert tag value and update all the information int tdDeleteTagCol(SDataRow row, int16_t colId); // delete tag value and update all the information void * tdQueryTagByID(SDataRow row, int16_t colId, int16_t *type); //if find tag, 0, else return -1; int tdAppendTagColVal(SDataRow row, void *value, int8_t type, int32_t bytes, int16_t colId); diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index 6a567c6e6c..8c6e26d5e1 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -152,8 +152,10 @@ SDataRow tdNewDataRowFromSchema(STSchema *pSchema) { return row; } -int tdInsertTagCol(SDataRow row, void *value, int16_t len, int8_t type, int16_t colId){ //insert tag value and update all the information - //todo +int tdSetTagCol(SDataRow row, void *value, int16_t len, int8_t type, int16_t colId){ //insert/update tag value and update all the information + ASSERT(((STagRow *)row)->pData != NULL); + //STagCol * stCol = tdQueryTagColByID() + return 0; }; @@ -172,7 +174,22 @@ static int compTagId(const void *key1, const void *key2) { } } -void * tdQueryTagByID(SDataRow row, int16_t colId, int16_t *type) { //if find tag, 0, else return -1; +/** + * Find tag structure by colId, if find, return tag structure, else return NULL; + */ +STagCol * tdQueryTagColByID(SDataRow row, int16_t colId, int flags) { //if find tag, 0, else return -1; + ASSERT(((STagRow *)row)->pData != NULL); + STagCol *pBase = ((STagRow *)row)->tagCols; + int16_t nCols = ((STagRow *)row)->ncols; + STagCol key = {colId,0,0}; + STagCol * stCol = taosbsearch(&key, pBase, nCols, sizeof(STagCol), compTagId, flags); + return stCol; +}; + +/** +* Find tag value by colId, if find, return tag value, else return NULL; +*/ +void * tdQueryTagByID(SDataRow row, int16_t colId, int16_t *type) { ASSERT(((STagRow *)row)->pData != NULL); STagCol *pBase = ((STagRow *)row)->tagCols; int16_t nCols = ((STagRow *)row)->ncols;