Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a4629e56
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
a4629e56
编写于
4月 29, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor:add schemaless function
上级
990205d6
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
518 addition
and
877 deletion
+518
-877
include/common/tcommon.h
include/common/tcommon.h
+7
-1
include/common/ttypes.h
include/common/ttypes.h
+8
-8
source/client/inc/clientSml.h
source/client/inc/clientSml.h
+29
-22
source/client/src/clientSml.c
source/client/src/clientSml.c
+446
-835
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+28
-11
未找到文件。
include/common/tcommon.h
浏览文件 @
a4629e56
...
...
@@ -246,7 +246,13 @@ typedef struct {
int32_t
keyLen
;
uint8_t
type
;
int16_t
length
;
const
char
*
value
;
union
{
const
char
*
value
;
int64_t
i
;
uint64_t
u
;
double
d
;
float
f
;
};
int32_t
valueLen
;
}
SSmlKv
;
...
...
include/common/ttypes.h
浏览文件 @
a4629e56
...
...
@@ -186,14 +186,14 @@ typedef struct {
#define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t)))
#define IS_MATHABLE_TYPE(_t) (IS_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP))
#define IS_VALID_TINYINT(_t) ((_t) > INT8_MIN && (_t) <= INT8_MAX)
#define IS_VALID_SMALLINT(_t) ((_t) > INT16_MIN && (_t) <= INT16_MAX)
#define IS_VALID_INT(_t) ((_t) > INT32_MIN && (_t) <= INT32_MAX)
#define IS_VALID_BIGINT(_t) ((_t) > INT64_MIN && (_t) <= INT64_MAX)
#define IS_VALID_UTINYINT(_t) ((_t) >= 0 && (_t) < UINT8_MAX)
#define IS_VALID_USMALLINT(_t) ((_t) >= 0 && (_t) < UINT16_MAX)
#define IS_VALID_UINT(_t) ((_t) >= 0 && (_t) < UINT32_MAX)
#define IS_VALID_UBIGINT(_t) ((_t) >= 0 && (_t) < UINT64_MAX)
#define IS_VALID_TINYINT(_t) ((_t) >
=
INT8_MIN && (_t) <= INT8_MAX)
#define IS_VALID_SMALLINT(_t) ((_t) >
=
INT16_MIN && (_t) <= INT16_MAX)
#define IS_VALID_INT(_t) ((_t) >
=
INT32_MIN && (_t) <= INT32_MAX)
#define IS_VALID_BIGINT(_t) ((_t) >
=
INT64_MIN && (_t) <= INT64_MAX)
#define IS_VALID_UTINYINT(_t) ((_t) >= 0 && (_t) <
=
UINT8_MAX)
#define IS_VALID_USMALLINT(_t) ((_t) >= 0 && (_t) <
=
UINT16_MAX)
#define IS_VALID_UINT(_t) ((_t) >= 0 && (_t) <
=
UINT32_MAX)
#define IS_VALID_UBIGINT(_t) ((_t) >= 0 && (_t) <
=
UINT64_MAX)
#define IS_VALID_FLOAT(_t) ((_t) >= -FLT_MAX && (_t) <= FLT_MAX)
#define IS_VALID_DOUBLE(_t) ((_t) >= -DBL_MAX && (_t) <= DBL_MAX)
...
...
source/client/inc/clientSml.h
浏览文件 @
a4629e56
...
...
@@ -36,48 +36,55 @@ typedef struct {
int32_t
measureTagsLen
;
int32_t
tagsLen
;
int32_t
colsLen
;
int32_t
timestampLen
;
}
TAOS_PARSE_ELEMENTS
;
typedef
struct
{
const
char
*
sTableName
;
// super table name
uint8_t
sTableNameLen
;
char
childTableName
[
TSDB_TABLE_NAME_LEN
];
uint64_t
uid
;
char
childTableName
[
TSDB_TABLE_NAME_LEN
];
uint64_t
uid
;
SArray
*
tags
;
SArray
*
cols
;
SArray
*
tags
;
SArray
*
cols
;
// elements are SHashObj<key, SSmlKv*> for find by key quickly
SArray
colsColumn
;
// elements are cols key string
}
TAOS_SML_DATA_POINT_TAGS
;
typedef
struct
SSmlSTableMeta
{
// char *sTableName; // super table name
// uint8_t sTableNameLen;
uint8_t
precision
;
// the number of precision
SHashObj
*
tagHash
;
SHashObj
*
fieldHash
;
uint8_t
precision
;
// the number of precision
SHashObj
*
tagHash
;
SHashObj
*
fieldHash
;
}
SSmlSTableMeta
;
typedef
struct
SMsgBuf
{
int32_t
len
;
char
*
buf
;
}
SMsgBuf
;
typedef
struct
{
uint64_t
id
;
uint64_t
id
;
SMLProtocolType
protocol
;
int32_t
tsType
;
SMLProtocolType
protocol
;
int32_t
tsType
;
SHashObj
*
childTables
;
SHashObj
*
superTables
;
SHashObj
*
childTables
;
SHashObj
*
superTables
;
SHashObj
*
metaHashObj
;
SHashObj
*
pVgHash
;
SHashObj
*
metaHashObj
;
SHashObj
*
pVgHash
;
void
*
exec
;
void
*
exec
;
STscObj
*
taos
;
SCatalog
*
pCatalog
;
SRequestObj
*
pRequest
;
SQuery
*
pQuery
;
STscObj
*
taos
;
SCatalog
*
pCatalog
;
SRequestObj
*
pRequest
;
SQuery
*
pQuery
;
int32_t
affectedRows
;
char
*
msgBuf
;
int16_t
msgLen
;
int32_t
affectedRows
;
SMsgBuf
msgBuf
;
}
SSmlLinesInfo
;
int
smlInsert
(
TAOS
*
taos
,
SSmlLinesInfo
*
info
);
...
...
source/client/src/clientSml.c
浏览文件 @
a4629e56
此差异已折叠。
点击以展开。
source/libs/parser/src/parInsert.c
浏览文件 @
a4629e56
...
...
@@ -1539,7 +1539,7 @@ static int32_t smlBoundColumns(SArray *cols, SParsedDataColInfo* pColList, SSche
col_id_t
lastColIdx
=
-
1
;
// last column found
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
cols
);
++
i
)
{
SSmlKv
*
kv
=
taosArrayGetP
(
cols
,
i
);
SToken
sToken
=
{.
n
=
kv
->
keyLen
,
.
z
=
kv
->
key
};
SToken
sToken
=
{.
n
=
kv
->
keyLen
,
.
z
=
(
char
*
)
kv
->
key
};
col_id_t
t
=
lastColIdx
+
1
;
col_id_t
index
=
findCol
(
&
sToken
,
t
,
nCols
,
pSchema
);
if
(
index
<
0
&&
t
>
0
)
{
...
...
@@ -1596,18 +1596,17 @@ static int32_t smlBoundColumns(SArray *cols, SParsedDataColInfo* pColList, SSche
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
smlParseTags
(
SArray
*
cols
,
SKVRowBuilder
*
tagsBuilder
,
SParsedDataColInfo
*
tags
,
SSchema
*
pSchema
,
SVCreateTbReq
*
createTblReq
)
{
static
int32_t
smlParseTags
(
SArray
*
cols
,
SKVRowBuilder
*
tagsBuilder
,
SParsedDataColInfo
*
tags
,
SSchema
*
pSchema
,
SVCreateTbReq
*
createTblReq
,
SMsgBuf
*
msg
)
{
if
(
tdInitKVRowBuilder
(
tagsBuilder
)
<
0
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
SKvParam
param
=
{.
builder
=
tagsBuilder
};
for
(
int
i
=
0
;
i
<
tags
->
numOfBound
;
++
i
)
{
SSchema
*
pTagSchema
=
&
pSchema
[
tags
->
boundColumns
[
i
]
-
1
];
// colId starts with 1
param
.
schema
=
pTagSchema
;
SSmlKv
*
kv
=
taosArrayGetP
(
cols
,
i
);
KvRowAppend
(
NULL
,
kv
->
value
,
kv
->
valueLen
,
&
param
)
;
KvRowAppend
(
msg
,
kv
->
value
,
kv
->
valueLen
,
&
param
)
;
}
...
...
@@ -1630,18 +1629,33 @@ int32_t smlBind(void *handle, SArray *tags, SArray *cols, STableMeta *pTableMeta
SmlExecHandle
*
smlHandle
=
(
SmlExecHandle
*
)
handle
;
SSchema
*
pTagsSchema
=
getTableTagSchema
(
pTableMeta
);
smlBoundColumns
(
tags
,
&
smlHandle
->
tags
,
pTagsSchema
);
smlParseTags
(
tags
,
&
smlHandle
->
tagsBuilder
,
&
smlHandle
->
tags
,
pTagsSchema
,
&
smlHandle
->
createTblReq
);
setBoundColumnInfo
(
&
smlHandle
->
tags
,
pTagsSchema
,
getNumOfTags
(
pTableMeta
));
int
ret
=
smlBoundColumns
(
tags
,
&
smlHandle
->
tags
,
pTagsSchema
);
if
(
ret
!=
TSDB_CODE_SUCCESS
){
buildInvalidOperationMsg
(
&
pBuf
,
"bound tags error"
);
return
ret
;
}
ret
=
smlParseTags
(
tags
,
&
smlHandle
->
tagsBuilder
,
&
smlHandle
->
tags
,
pTagsSchema
,
&
smlHandle
->
createTblReq
,
&
pBuf
);
if
(
ret
!=
TSDB_CODE_SUCCESS
){
return
ret
;
}
STableDataBlocks
*
pDataBlock
=
NULL
;
getDataBlockFromList
(
smlHandle
->
pBlockHash
,
pTableMeta
->
uid
,
TSDB_DEFAULT_PAYLOAD_SIZE
,
ret
=
getDataBlockFromList
(
smlHandle
->
pBlockHash
,
pTableMeta
->
uid
,
TSDB_DEFAULT_PAYLOAD_SIZE
,
sizeof
(
SSubmitBlk
),
getTableInfo
(
pTableMeta
).
rowSize
,
pTableMeta
,
&
pDataBlock
,
NULL
,
&
smlHandle
->
createTblReq
);
if
(
ret
!=
TSDB_CODE_SUCCESS
){
buildInvalidOperationMsg
(
&
pBuf
,
"create data block error"
);
return
ret
;
}
SSchema
*
pSchema
=
getTableColumnSchema
(
pTableMeta
);
smlBoundColumns
(
taosArrayGetP
(
cols
,
0
),
&
pDataBlock
->
boundColumnInfo
,
pSchema
);
ret
=
smlBoundColumns
(
taosArrayGetP
(
cols
,
0
),
&
pDataBlock
->
boundColumnInfo
,
pSchema
);
if
(
ret
!=
TSDB_CODE_SUCCESS
){
buildInvalidOperationMsg
(
&
pBuf
,
"bound cols error"
);
return
ret
;
}
int32_t
extendedRowSize
=
getExtendedRowSize
(
pDataBlock
);
SParsedDataColInfo
*
spd
=
&
pDataBlock
->
boundColumnInfo
;
SRowBuilder
*
pBuilder
=
&
pDataBlock
->
rowBuilder
;
...
...
@@ -1649,8 +1663,11 @@ int32_t smlBind(void *handle, SArray *tags, SArray *cols, STableMeta *pTableMeta
initRowBuilder
(
&
pDataBlock
->
rowBuilder
,
pDataBlock
->
pTableMeta
->
sversion
,
&
pDataBlock
->
boundColumnInfo
);
allocateMemForSize
(
pDataBlock
,
extendedRowSize
*
rowNum
);
ret
=
allocateMemForSize
(
pDataBlock
,
extendedRowSize
*
rowNum
);
if
(
ret
!=
TSDB_CODE_SUCCESS
){
buildInvalidOperationMsg
(
&
pBuf
,
"allocate memory error"
);
return
ret
;
}
for
(
int32_t
r
=
0
;
r
<
rowNum
;
++
r
)
{
STSRow
*
row
=
(
STSRow
*
)(
pDataBlock
->
pData
+
pDataBlock
->
size
);
// skip the SSubmitBlk header
tdSRowResetBuf
(
pBuilder
,
row
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录