Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
878bd921
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
878bd921
编写于
7月 17, 2022
作者:
S
shenglian-zhou
提交者:
GitHub
7月 17, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15022 from taosdata/szhou/feature/user-tags
feat: processing nchar and json columns of user tags
上级
e0c71378
4a545b71
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
94 deletion
+16
-94
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+16
-94
未找到文件。
source/libs/executor/src/scanoperator.c
浏览文件 @
878bd921
...
...
@@ -1802,83 +1802,6 @@ static SSDataBlock* buildInfoSchemaTableMetaBlock(char* tableName) {
return
pBlock
;
}
// TODO: check more datatype, json? and return detailed error when len is not enough
static
int32_t
convertTagDataToTagVarchar
(
int8_t
tagType
,
char
*
tagVal
,
uint32_t
tagLen
,
char
*
varData
,
int32_t
bufSize
)
{
int
outputLen
=
-
1
;
switch
(
tagType
)
{
case
TSDB_DATA_TYPE_TINYINT
:
outputLen
=
snprintf
(
varDataVal
(
varData
),
bufSize
,
"%d"
,
*
((
int8_t
*
)
tagVal
));
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
outputLen
=
snprintf
(
varDataVal
(
varData
),
bufSize
,
"%u"
,
*
((
uint8_t
*
)
tagVal
));
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
outputLen
=
snprintf
(
varDataVal
(
varData
),
bufSize
,
"%d"
,
*
((
int16_t
*
)
tagVal
));
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
outputLen
=
snprintf
(
varDataVal
(
varData
),
bufSize
,
"%u"
,
*
((
uint16_t
*
)
tagVal
));
break
;
case
TSDB_DATA_TYPE_INT
:
outputLen
=
snprintf
(
varDataVal
(
varData
),
bufSize
,
"%d"
,
*
((
int32_t
*
)
tagVal
));
break
;
case
TSDB_DATA_TYPE_UINT
:
outputLen
=
snprintf
(
varDataVal
(
varData
),
bufSize
,
"%u"
,
*
((
uint32_t
*
)
tagVal
));
break
;
case
TSDB_DATA_TYPE_BIGINT
:
outputLen
=
snprintf
(
varDataVal
(
varData
),
bufSize
,
"%"
PRId64
,
*
((
int64_t
*
)
tagVal
));
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
outputLen
=
snprintf
(
varDataVal
(
varData
),
bufSize
,
"%"
PRIu64
,
*
((
uint64_t
*
)
tagVal
));
break
;
case
TSDB_DATA_TYPE_FLOAT
:
{
float
fv
=
0
;
fv
=
GET_FLOAT_VAL
(
tagVal
);
outputLen
=
snprintf
(
varDataVal
(
varData
),
bufSize
,
"%f"
,
fv
);
break
;
}
case
TSDB_DATA_TYPE_DOUBLE
:
{
double
dv
=
0
;
dv
=
GET_DOUBLE_VAL
(
tagVal
);
outputLen
=
snprintf
(
varDataVal
(
varData
),
bufSize
,
"%lf"
,
dv
);
break
;
}
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_JSON
:
{
memcpy
(
varDataVal
(
varData
),
tagVal
,
tagLen
);
outputLen
=
tagLen
;
break
;
}
case
TSDB_DATA_TYPE_TIMESTAMP
:
outputLen
=
snprintf
(
varDataVal
(
varData
),
bufSize
,
"%"
PRId64
,
*
((
int64_t
*
)
tagVal
));
break
;
case
TSDB_DATA_TYPE_BOOL
:
outputLen
=
snprintf
(
varDataVal
(
varData
),
bufSize
,
"%d"
,
*
((
int8_t
*
)
tagVal
));
break
;
default:
return
TSDB_CODE_FAILED
;
}
if
(
outputLen
<
0
||
outputLen
==
bufSize
&&
!
IS_VAR_DATA_TYPE
(
tagType
)
||
outputLen
>
bufSize
)
{
return
TSDB_CODE_FAILED
;
}
varDataSetLen
(
varData
,
outputLen
);
return
TSDB_CODE_SUCCESS
;
}
static
SSDataBlock
*
sysTableScanUserTags
(
SOperatorInfo
*
pOperator
)
{
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SSysTableScanInfo
*
pInfo
=
pOperator
->
info
;
...
...
@@ -1962,10 +1885,9 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
tagVal
.
cid
=
smr
.
me
.
stbEntry
.
schemaTag
.
pSchema
[
i
].
colId
;
char
*
tagData
=
NULL
;
uint32_t
tagLen
=
0
;
if
(
tagType
==
TSDB_DATA_TYPE_JSON
)
{
// TODO: json type?+varheader+data
tagData
=
varDataVal
(
pInfo
->
pCur
->
mr
.
me
.
ctbEntry
.
pTags
+
1
);
tagLen
=
varDataLen
(
pInfo
->
pCur
->
mr
.
me
.
ctbEntry
.
pTags
+
1
);
tagData
=
(
char
*
)
pInfo
->
pCur
->
mr
.
me
.
ctbEntry
.
pTags
;
}
else
{
bool
exist
=
tTagGet
((
STag
*
)
pInfo
->
pCur
->
mr
.
me
.
ctbEntry
.
pTags
,
&
tagVal
);
if
(
exist
)
{
...
...
@@ -1979,27 +1901,27 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
}
}
int32_t
bufSize
=
IS_VAR_DATA_TYPE
(
tagType
)
?
(
tagLen
+
VARSTR_HEADER_SIZE
)
:
(
3
+
DBL_MANT_DIG
-
DBL_MIN_EXP
+
VARSTR_HEADER_SIZE
);
char
*
tagVarChar
=
NULL
;
char
*
tagVarChar
=
NULL
;
if
(
tagData
!=
NULL
)
{
tagVarChar
=
taosMemoryMalloc
(
bufSize
);
code
=
convertTagDataToTagVarchar
(
tagType
,
tagData
,
tagLen
,
tagVarChar
,
bufSize
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"failed to get super table meta, uid:0x%"
PRIx64
", code:%s, %s"
,
suid
,
tstrerror
(
terrno
),
GET_TASKID
(
pTaskInfo
));
taosMemoryFree
(
tagVarChar
);
metaReaderClear
(
&
smr
);
metaCloseTbCursor
(
pInfo
->
pCur
);
pInfo
->
pCur
=
NULL
;
longjmp
(
pTaskInfo
->
env
,
terrno
);
if
(
tagType
==
TSDB_DATA_TYPE_JSON
)
{
char
*
tagJson
=
parseTagDatatoJson
(
tagData
);
tagVarChar
=
taosMemoryMalloc
(
strlen
(
tagJson
)
+
VARSTR_HEADER_SIZE
);
memcpy
(
varDataVal
(
tagVarChar
),
tagJson
,
strlen
(
tagJson
));
varDataSetLen
(
tagVarChar
,
strlen
(
tagJson
));
taosMemoryFree
(
tagJson
);
}
else
{
int32_t
bufSize
=
IS_VAR_DATA_TYPE
(
tagType
)
?
(
tagLen
+
VARSTR_HEADER_SIZE
)
:
(
3
+
DBL_MANT_DIG
-
DBL_MIN_EXP
+
VARSTR_HEADER_SIZE
);
tagVarChar
=
taosMemoryMalloc
(
bufSize
);
int32_t
len
=
-
1
;
dataConverToStr
(
varDataVal
(
tagVarChar
),
tagType
,
tagData
,
tagLen
,
&
len
);
varDataSetLen
(
tagVarChar
,
len
);
}
}
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
5
);
colDataAppend
(
pColInfoData
,
numOfRows
,
tagVarChar
,
(
tagData
==
NULL
)
||
(
tagType
==
TSDB_DATA_TYPE_JSON
&&
tTagIsJsonNull
(
tagData
)));
taosMemoryFree
(
tagVarChar
);
++
numOfRows
;
}
metaReaderClear
(
&
smr
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录