Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e27cccd1
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e27cccd1
编写于
9月 18, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-6129<feature> fix json encode error
上级
c93306a8
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
49 addition
and
19 deletion
+49
-19
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+2
-2
src/tsdb/inc/tsdbMeta.h
src/tsdb/inc/tsdbMeta.h
+2
-1
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+11
-7
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+34
-9
未找到文件。
src/client/src/tscUtil.c
浏览文件 @
e27cccd1
...
...
@@ -5272,7 +5272,7 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
if
(
item
->
type
==
cJSON_String
){
// add json value format: type|data
output
=
0
;
*
tagVal
=
item
->
type
;
// type
char
*
tagData
=
tagVal
+
CHAR_BYTES
;
char
*
tagData
=
POINTER_SHIFT
(
tagVal
,
CHAR_BYTES
)
;
if
(
!
taosMbsToUcs4
(
item
->
valuestring
,
strlen
(
item
->
valuestring
),
varDataVal
(
tagData
),
TSDB_MAX_TAGS_LEN
-
VARSTR_HEADER_SIZE
,
&
output
))
{
tscError
(
"json string error:%s|%s"
,
strerror
(
errno
),
item
->
string
);
retCode
=
tscSQLSyntaxErrMsg
(
errMsg
,
"serizelize json error"
,
NULL
);
...
...
@@ -5283,7 +5283,7 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
tdAddColToKVRow
(
kvRowBuilder
,
jsonIndex
++
,
TSDB_DATA_TYPE_NCHAR
,
tagVal
,
true
);
}
else
if
(
item
->
type
==
cJSON_Number
){
*
tagVal
=
item
->
type
;
// type
char
*
tagData
=
tagVal
+
CHAR_BYTES
;
char
*
tagData
=
POINTER_SHIFT
(
tagVal
,
CHAR_BYTES
)
;
*
((
double
*
)
tagData
)
=
item
->
valuedouble
;
tdAddColToKVRow
(
kvRowBuilder
,
jsonIndex
++
,
TSDB_DATA_TYPE_BIGINT
,
tagVal
,
true
);
}
else
{
...
...
src/tsdb/inc/tsdbMeta.h
浏览文件 @
e27cccd1
...
...
@@ -20,7 +20,7 @@
#pragma pack (push,1)
typedef
struct
jsonMapValue
{
uint64_t
uid
;
// the unique table ID
void
*
table
;
// STable *
int16_t
colId
;
// the json col ID.
}
JsonMapValue
;
...
...
@@ -97,6 +97,7 @@ int16_t tsdbGetLastColumnsIndexByColId(STable* pTable, int16_t colId);
int
tsdbUpdateLastColSchema
(
STable
*
pTable
,
STSchema
*
pNewSchema
);
STSchema
*
tsdbGetTableLatestSchema
(
STable
*
pTable
);
void
tsdbFreeLastColumns
(
STable
*
pTable
);
int
tscCompareJsonMapValue
(
const
void
*
a
,
const
void
*
b
);
static
FORCE_INLINE
int
tsdbCompareSchemaVersion
(
const
void
*
key1
,
const
void
*
key2
)
{
if
(
*
(
int16_t
*
)
key1
<
schemaVersion
(
*
(
STSchema
**
)
key2
))
{
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
e27cccd1
...
...
@@ -1083,11 +1083,11 @@ static void tsdbRemoveTableFromMeta(STsdbRepo *pRepo, STable *pTable, bool rmFro
tsdbUnRefTable
(
pTable
);
}
static
int
tscCompareJsonMapValue
(
const
void
*
a
,
const
void
*
b
)
{
int
tscCompareJsonMapValue
(
const
void
*
a
,
const
void
*
b
)
{
const
JsonMapValue
*
x
=
(
const
JsonMapValue
*
)
a
;
const
JsonMapValue
*
y
=
(
const
JsonMapValue
*
)
b
;
if
(
x
->
uid
>
y
->
uid
)
return
1
;
if
(
x
->
uid
<
y
->
uid
)
return
-
1
;
if
(
x
->
table
>
y
->
table
)
return
1
;
if
(
x
->
table
<
y
->
table
)
return
-
1
;
return
0
;
}
...
...
@@ -1127,9 +1127,13 @@ static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable, bool refSuper
}
tablist
=
tablistNew
;
}
JsonMapValue
jmvalue
=
{
TABLE_UID
(
pTable
),
pColIdx
->
colId
};
JsonMapValue
jmvalue
=
{
pTable
,
pColIdx
->
colId
};
void
*
p
=
taosArraySearch
(
tablist
,
&
jmvalue
,
tscCompareJsonMapValue
,
TD_EQ
);
if
(
p
==
NULL
)
{
taosArrayPush
(
tablist
,
&
jmvalue
);
taosArraySort
(
tablist
,
tscCompareJsonMapValue
);
}
else
{
taosArrayInsert
(
tablist
,
TARRAY_ELEM_IDX
((
SArray
*
)
tablist
,
p
),
&
jmvalue
);
}
}
}
else
{
tSkipListPut
(
pSTable
->
pIndex
,
(
void
*
)
pTable
);
...
...
@@ -1165,7 +1169,7 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) {
continue
;
}
JsonMapValue
jmvalue
=
{
TABLE_UID
(
pTable
)
,
pColIdx
->
colId
};
JsonMapValue
jmvalue
=
{
pTable
,
pColIdx
->
colId
};
void
*
p
=
taosArraySearch
(
tablist
,
&
jmvalue
,
tscCompareJsonMapValue
,
TD_EQ
);
if
(
p
==
NULL
)
{
tsdbError
(
"json tag no tableid error,%d"
,
j
);
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
e27cccd1
...
...
@@ -2676,6 +2676,28 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
}
static
int32_t
getAllTableList
(
STable
*
pSuperTable
,
SArray
*
list
)
{
STSchema
*
pTagSchema
=
tsdbGetTableTagSchema
(
pSuperTable
);
if
(
pTagSchema
->
numOfCols
==
1
&&
pTagSchema
->
columns
[
0
].
type
==
TSDB_DATA_TYPE_JSON
){
SArray
*
pRecord
=
taosHashIterate
(
pSuperTable
->
jsonKeyMap
,
NULL
);
SArray
*
tablist
=
taosArrayInit
(
32
,
sizeof
(
JsonMapValue
));
while
(
pRecord
){
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pRecord
);
++
i
)
{
void
*
p
=
taosArrayGet
(
pRecord
,
i
);
void
*
pFind
=
taosArraySearch
(
tablist
,
p
,
tscCompareJsonMapValue
,
TD_EQ
);
if
(
pFind
==
NULL
){
taosArrayPush
(
tablist
,
p
);
}
}
pRecord
=
taosHashIterate
(
pSuperTable
->
jsonKeyMap
,
pRecord
);
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tablist
);
++
i
)
{
JsonMapValue
*
p
=
taosArrayGet
(
pRecord
,
i
);
STableKeyInfo
info
=
{.
pTable
=
p
->
table
,
.
lastKey
=
TSKEY_INITIAL_VAL
};
taosArrayPush
(
list
,
&
info
);
}
taosArrayDestroy
(
tablist
);
}
else
{
SSkipListIterator
*
iter
=
tSkipListCreateIter
(
pSuperTable
->
pIndex
);
while
(
tSkipListIterNext
(
iter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
...
...
@@ -2687,6 +2709,7 @@ static int32_t getAllTableList(STable* pSuperTable, SArray* list) {
}
tSkipListDestroyIter
(
iter
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -3626,6 +3649,7 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
int32_t
tsdbQuerySTableByTagCond
(
STsdbRepo
*
tsdb
,
uint64_t
uid
,
TSKEY
skey
,
const
char
*
pTagCond
,
size_t
len
,
STableGroupInfo
*
pGroupInfo
,
SColIndex
*
pColIndex
,
int32_t
numOfCols
)
{
SArray
*
res
=
NULL
;
if
(
tsdbRLockRepoMeta
(
tsdb
)
<
0
)
goto
_error
;
STable
*
pTable
=
tsdbGetTableByUid
(
tsdbGetMeta
(
tsdb
),
uid
);
...
...
@@ -3647,7 +3671,7 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
}
//NOTE: not add ref count for super table
SArray
*
res
=
taosArrayInit
(
8
,
sizeof
(
STableKeyInfo
));
res
=
taosArrayInit
(
8
,
sizeof
(
STableKeyInfo
));
STSchema
*
pTagSchema
=
tsdbGetTableTagSchema
(
pTable
);
// no tags and tbname condition, all child tables of this stable are involved
...
...
@@ -3711,6 +3735,7 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
return
ret
;
_error:
taosArrayDestroy
(
res
);
return
terrno
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录