Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2ad31384
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
未验证
提交
2ad31384
编写于
8月 29, 2022
作者:
W
wade zhang
提交者:
GitHub
8月 29, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15818 from taosdata/feature/TD-14761
feat: get meta and data from tmq using snapshot
上级
fa0f6b50
e05a1fc0
变更
37
展开全部
显示空白变更内容
内联
并排
Showing
37 changed file
with
2021 addition
and
381 deletion
+2021
-381
examples/c/tmq_taosx.c
examples/c/tmq_taosx.c
+10
-1
include/common/tcommon.h
include/common/tcommon.h
+1
-0
include/common/tdataformat.h
include/common/tdataformat.h
+1
-0
include/common/tmsg.h
include/common/tmsg.h
+4
-23
include/libs/executor/executor.h
include/libs/executor/executor.h
+11
-2
source/client/src/clientSml.c
source/client/src/clientSml.c
+114
-86
source/client/src/taosx.c
source/client/src/taosx.c
+86
-40
source/client/src/tmq.c
source/client/src/tmq.c
+5
-3
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+49
-0
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+1
-0
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+20
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+19
-8
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+1
-1
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+31
-0
source/dnode/vnode/src/inc/tq.h
source/dnode/vnode/src/inc/tq.h
+10
-6
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+31
-0
source/dnode/vnode/src/meta/metaSnapshot.c
source/dnode/vnode/src/meta/metaSnapshot.c
+431
-0
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+21
-0
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+73
-51
source/dnode/vnode/src/tq/tqExec.c
source/dnode/vnode/src/tq/tqExec.c
+55
-33
source/dnode/vnode/src/tq/tqMeta.c
source/dnode/vnode/src/tq/tqMeta.c
+19
-12
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+2
-2
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+2
-2
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+18
-1
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+4
-1
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+171
-82
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+1
-0
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+149
-15
tests/system-test/2-query/sml.py
tests/system-test/2-query/sml.py
+3
-0
tests/system-test/7-tmq/stbTagFilter-1ctb.py
tests/system-test/7-tmq/stbTagFilter-1ctb.py
+2
-2
tests/system-test/7-tmq/tmqDropNtb-snapshot1.py
tests/system-test/7-tmq/tmqDropNtb-snapshot1.py
+4
-4
tests/system-test/7-tmq/tmqDropStbCtb.py
tests/system-test/7-tmq/tmqDropStbCtb.py
+6
-4
tests/system-test/7-tmq/tmq_taosx.py
tests/system-test/7-tmq/tmq_taosx.py
+143
-0
tests/test/c/CMakeLists.txt
tests/test/c/CMakeLists.txt
+8
-0
tests/test/c/sml_test.c
tests/test/c/sml_test.c
+1
-1
tests/test/c/tmq_taosx_ci.c
tests/test/c/tmq_taosx_ci.c
+2
-1
tests/test/c/tmq_taosx_snapshot_ci.c
tests/test/c/tmq_taosx_snapshot_ci.c
+512
-0
未找到文件。
examples/c/tmq_taosx.c
浏览文件 @
2ad31384
...
@@ -163,6 +163,13 @@ int32_t init_env() {
...
@@ -163,6 +163,13 @@ int32_t init_env() {
}
}
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table if not exists ct4 using st1(t3) tags('ct4')"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create child table ct4, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"insert into ct3 values(1626006833600, 5, 6, 'c') ct1 values(1626006833601, 2, 3, 'sds') (1626006833602, 4, 5, 'ddd') ct0 values(1626006833602, 4, 3, 'hwj') ct1 values(now+5s, 23, 32, 's21ds')"
);
pRes
=
taos_query
(
pConn
,
"insert into ct3 values(1626006833600, 5, 6, 'c') ct1 values(1626006833601, 2, 3, 'sds') (1626006833602, 4, 5, 'ddd') ct0 values(1626006833602, 4, 3, 'hwj') ct1 values(now+5s, 23, 32, 's21ds')"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to insert into ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"failed to insert into ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
...
@@ -379,6 +386,8 @@ tmq_t* build_consumer() {
...
@@ -379,6 +386,8 @@ tmq_t* build_consumer() {
tmq_conf_set
(
conf
,
"td.connect.pass"
,
"taosdata"
);
tmq_conf_set
(
conf
,
"td.connect.pass"
,
"taosdata"
);
tmq_conf_set
(
conf
,
"msg.with.table.name"
,
"true"
);
tmq_conf_set
(
conf
,
"msg.with.table.name"
,
"true"
);
tmq_conf_set
(
conf
,
"enable.auto.commit"
,
"true"
);
tmq_conf_set
(
conf
,
"enable.auto.commit"
,
"true"
);
tmq_conf_set
(
conf
,
"experimental.snapshot.enable"
,
"true"
);
/*tmq_conf_set(conf, "experimental.snapshot.enable", "true");*/
/*tmq_conf_set(conf, "experimental.snapshot.enable", "true");*/
...
@@ -406,7 +415,7 @@ void basic_consume_loop(tmq_t* tmq, tmq_list_t* topics) {
...
@@ -406,7 +415,7 @@ void basic_consume_loop(tmq_t* tmq, tmq_list_t* topics) {
}
}
int32_t
cnt
=
0
;
int32_t
cnt
=
0
;
while
(
running
)
{
while
(
running
)
{
TAOS_RES
*
tmqmessage
=
tmq_consumer_poll
(
tmq
,
-
1
);
TAOS_RES
*
tmqmessage
=
tmq_consumer_poll
(
tmq
,
1000
);
if
(
tmqmessage
)
{
if
(
tmqmessage
)
{
cnt
++
;
cnt
++
;
msg_process
(
tmqmessage
);
msg_process
(
tmqmessage
);
...
...
include/common/tcommon.h
浏览文件 @
2ad31384
...
@@ -184,6 +184,7 @@ typedef struct SQueryTableDataCond {
...
@@ -184,6 +184,7 @@ typedef struct SQueryTableDataCond {
STimeWindow
twindows
;
STimeWindow
twindows
;
int64_t
startVersion
;
int64_t
startVersion
;
int64_t
endVersion
;
int64_t
endVersion
;
int64_t
schemaVersion
;
}
SQueryTableDataCond
;
}
SQueryTableDataCond
;
int32_t
tEncodeDataBlock
(
void
**
buf
,
const
SSDataBlock
*
pBlock
);
int32_t
tEncodeDataBlock
(
void
**
buf
,
const
SSDataBlock
*
pBlock
);
...
...
include/common/tdataformat.h
浏览文件 @
2ad31384
...
@@ -96,6 +96,7 @@ char *tTagValToData(const STagVal *pTagVal, bool isJson);
...
@@ -96,6 +96,7 @@ char *tTagValToData(const STagVal *pTagVal, bool isJson);
int32_t
tEncodeTag
(
SEncoder
*
pEncoder
,
const
STag
*
pTag
);
int32_t
tEncodeTag
(
SEncoder
*
pEncoder
,
const
STag
*
pTag
);
int32_t
tDecodeTag
(
SDecoder
*
pDecoder
,
STag
**
ppTag
);
int32_t
tDecodeTag
(
SDecoder
*
pDecoder
,
STag
**
ppTag
);
int32_t
tTagToValArray
(
const
STag
*
pTag
,
SArray
**
ppArray
);
int32_t
tTagToValArray
(
const
STag
*
pTag
,
SArray
**
ppArray
);
void
tTagSetCid
(
const
STag
*
pTag
,
int16_t
iTag
,
int16_t
cid
);
void
debugPrintSTag
(
STag
*
pTag
,
const
char
*
tag
,
int32_t
ln
);
// TODO: remove
void
debugPrintSTag
(
STag
*
pTag
,
const
char
*
tag
,
int32_t
ln
);
// TODO: remove
int32_t
parseJsontoTagData
(
const
char
*
json
,
SArray
*
pTagVals
,
STag
**
ppTag
,
void
*
pMsgBuf
);
int32_t
parseJsontoTagData
(
const
char
*
json
,
SArray
*
pTagVals
,
STag
**
ppTag
,
void
*
pMsgBuf
);
...
...
include/common/tmsg.h
浏览文件 @
2ad31384
...
@@ -2617,7 +2617,7 @@ enum {
...
@@ -2617,7 +2617,7 @@ enum {
typedef
struct
{
typedef
struct
{
int8_t
type
;
int8_t
type
;
union
{
union
{
// snapshot
data
// snapshot
struct
{
struct
{
int64_t
uid
;
int64_t
uid
;
int64_t
ts
;
int64_t
ts
;
...
@@ -2936,33 +2936,14 @@ static FORCE_INLINE void tDeleteSMqSubTopicEp(SMqSubTopicEp* pSubTopicEp) {
...
@@ -2936,33 +2936,14 @@ static FORCE_INLINE void tDeleteSMqSubTopicEp(SMqSubTopicEp* pSubTopicEp) {
typedef
struct
{
typedef
struct
{
SMqRspHead
head
;
SMqRspHead
head
;
int64_t
reqOffset
;
STqOffsetVal
rspOffset
;
int64_t
rspOffset
;
STqOffsetVal
reqOffsetNew
;
STqOffsetVal
rspOffsetNew
;
int16_t
resMsgType
;
int16_t
resMsgType
;
int32_t
metaRspLen
;
int32_t
metaRspLen
;
void
*
metaRsp
;
void
*
metaRsp
;
}
SMqMetaRsp
;
}
SMqMetaRsp
;
static
FORCE_INLINE
int32_t
tEncodeSMqMetaRsp
(
void
**
buf
,
const
SMqMetaRsp
*
pRsp
)
{
int32_t
tEncodeSMqMetaRsp
(
SEncoder
*
pEncoder
,
const
SMqMetaRsp
*
pRsp
);
int32_t
tlen
=
0
;
int32_t
tDecodeSMqMetaRsp
(
SDecoder
*
pDecoder
,
SMqMetaRsp
*
pRsp
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pRsp
->
reqOffset
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pRsp
->
rspOffset
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pRsp
->
resMsgType
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
metaRspLen
);
tlen
+=
taosEncodeBinary
(
buf
,
pRsp
->
metaRsp
,
pRsp
->
metaRspLen
);
return
tlen
;
}
static
FORCE_INLINE
void
*
tDecodeSMqMetaRsp
(
const
void
*
buf
,
SMqMetaRsp
*
pRsp
)
{
buf
=
taosDecodeFixedI64
(
buf
,
&
pRsp
->
reqOffset
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pRsp
->
rspOffset
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pRsp
->
resMsgType
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pRsp
->
metaRspLen
);
buf
=
taosDecodeBinary
(
buf
,
&
pRsp
->
metaRsp
,
pRsp
->
metaRspLen
);
return
(
void
*
)
buf
;
}
typedef
struct
{
typedef
struct
{
SMqRspHead
head
;
SMqRspHead
head
;
...
...
include/libs/executor/executor.h
浏览文件 @
2ad31384
...
@@ -41,6 +41,9 @@ typedef struct {
...
@@ -41,6 +41,9 @@ typedef struct {
bool
initTableReader
;
bool
initTableReader
;
bool
initTqReader
;
bool
initTqReader
;
int32_t
numOfVgroups
;
int32_t
numOfVgroups
;
void
*
sContext
;
// SSnapContext*
void
*
pStateBackend
;
void
*
pStateBackend
;
}
SReadHandle
;
}
SReadHandle
;
...
@@ -181,11 +184,17 @@ int32_t qGetStreamScanStatus(qTaskInfo_t tinfo, uint64_t* uid, int64_t* ts);
...
@@ -181,11 +184,17 @@ int32_t qGetStreamScanStatus(qTaskInfo_t tinfo, uint64_t* uid, int64_t* ts);
int32_t
qStreamPrepareTsdbScan
(
qTaskInfo_t
tinfo
,
uint64_t
uid
,
int64_t
ts
);
int32_t
qStreamPrepareTsdbScan
(
qTaskInfo_t
tinfo
,
uint64_t
uid
,
int64_t
ts
);
int32_t
qStreamPrepareScan
(
qTaskInfo_t
tinfo
,
const
STqOffsetVal
*
pOffset
);
int32_t
qStreamPrepareScan
(
qTaskInfo_t
tinfo
,
STqOffsetVal
*
pOffset
,
int8_t
subType
);
int32_t
qStreamExtractOffset
(
qTaskInfo_t
tinfo
,
STqOffsetVal
*
pOffset
);
int32_t
qStreamExtractOffset
(
qTaskInfo_t
tinfo
,
STqOffsetVal
*
pOffset
);
void
*
qStreamExtractMetaMsg
(
qTaskInfo_t
tinfo
);
SMqMetaRsp
*
qStreamExtractMetaMsg
(
qTaskInfo_t
tinfo
);
int64_t
qStreamExtractPrepareUid
(
qTaskInfo_t
tinfo
);
const
SSchemaWrapper
*
qExtractSchemaFromTask
(
qTaskInfo_t
tinfo
);
const
char
*
qExtractTbnameFromTask
(
qTaskInfo_t
tinfo
);
void
*
qExtractReaderFromStreamScanner
(
void
*
scanner
);
void
*
qExtractReaderFromStreamScanner
(
void
*
scanner
);
...
...
source/client/src/clientSml.c
浏览文件 @
2ad31384
...
@@ -85,8 +85,11 @@ typedef TSDB_SML_PROTOCOL_TYPE SMLProtocolType;
...
@@ -85,8 +85,11 @@ typedef TSDB_SML_PROTOCOL_TYPE SMLProtocolType;
typedef
enum
{
typedef
enum
{
SCHEMA_ACTION_NULL
,
SCHEMA_ACTION_NULL
,
SCHEMA_ACTION_COLUMN
,
SCHEMA_ACTION_CREATE_STABLE
,
SCHEMA_ACTION_TAG
SCHEMA_ACTION_ADD_COLUMN
,
SCHEMA_ACTION_ADD_TAG
,
SCHEMA_ACTION_CHANGE_COLUMN_SIZE
,
SCHEMA_ACTION_CHANGE_TAG_SIZE
,
}
ESchemaAction
;
}
ESchemaAction
;
typedef
struct
{
typedef
struct
{
...
@@ -219,7 +222,7 @@ static int32_t smlBuildInvalidDataMsg(SSmlMsgBuf *pBuf, const char *msg1, const
...
@@ -219,7 +222,7 @@ static int32_t smlBuildInvalidDataMsg(SSmlMsgBuf *pBuf, const char *msg1, const
static
int32_t
smlGenerateSchemaAction
(
SSchema
*
colField
,
SHashObj
*
colHash
,
SSmlKv
*
kv
,
bool
isTag
,
static
int32_t
smlGenerateSchemaAction
(
SSchema
*
colField
,
SHashObj
*
colHash
,
SSmlKv
*
kv
,
bool
isTag
,
ESchemaAction
*
action
,
SSmlHandle
*
info
)
{
ESchemaAction
*
action
,
SSmlHandle
*
info
)
{
uint16_t
*
index
=
(
uint16_t
*
)
taosHashGet
(
colHash
,
kv
->
key
,
kv
->
keyLen
)
;
uint16_t
*
index
=
colHash
?
(
uint16_t
*
)
taosHashGet
(
colHash
,
kv
->
key
,
kv
->
keyLen
)
:
NULL
;
if
(
index
)
{
if
(
index
)
{
if
(
colField
[
*
index
].
type
!=
kv
->
type
)
{
if
(
colField
[
*
index
].
type
!=
kv
->
type
)
{
uError
(
"SML:0x%"
PRIx64
" point type and db type mismatch. key: %s. point type: %d, db type: %d"
,
info
->
id
,
uError
(
"SML:0x%"
PRIx64
" point type and db type mismatch. key: %s. point type: %d, db type: %d"
,
info
->
id
,
...
@@ -232,16 +235,16 @@ static int32_t smlGenerateSchemaAction(SSchema *colField, SHashObj *colHash, SSm
...
@@ -232,16 +235,16 @@ static int32_t smlGenerateSchemaAction(SSchema *colField, SHashObj *colHash, SSm
(
colField
[
*
index
].
type
==
TSDB_DATA_TYPE_NCHAR
&&
(
colField
[
*
index
].
type
==
TSDB_DATA_TYPE_NCHAR
&&
((
colField
[
*
index
].
bytes
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
<
kv
->
length
)))
{
((
colField
[
*
index
].
bytes
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
<
kv
->
length
)))
{
if
(
isTag
)
{
if
(
isTag
)
{
*
action
=
SCHEMA_ACTION_
TAG
;
*
action
=
SCHEMA_ACTION_
CHANGE_TAG_SIZE
;
}
else
{
}
else
{
*
action
=
SCHEMA_ACTION_C
OLUMN
;
*
action
=
SCHEMA_ACTION_C
HANGE_COLUMN_SIZE
;
}
}
}
}
}
else
{
}
else
{
if
(
isTag
)
{
if
(
isTag
)
{
*
action
=
SCHEMA_ACTION_TAG
;
*
action
=
SCHEMA_ACTION_
ADD_
TAG
;
}
else
{
}
else
{
*
action
=
SCHEMA_ACTION_COLUMN
;
*
action
=
SCHEMA_ACTION_
ADD_
COLUMN
;
}
}
}
}
return
0
;
return
0
;
...
@@ -310,9 +313,31 @@ static int32_t getBytes(uint8_t type, int32_t length){
...
@@ -310,9 +313,31 @@ static int32_t getBytes(uint8_t type, int32_t length){
}
}
}
}
static
int32_t
smlBuildFieldsList
(
SSmlHandle
*
info
,
SSchema
*
schemaField
,
SHashObj
*
schemaHash
,
SArray
*
cols
,
SArray
*
results
,
int32_t
numOfCols
,
bool
isTag
)
{
for
(
int
j
=
0
;
j
<
taosArrayGetSize
(
cols
);
++
j
)
{
SSmlKv
*
kv
=
(
SSmlKv
*
)
taosArrayGetP
(
cols
,
j
);
ESchemaAction
action
=
SCHEMA_ACTION_NULL
;
smlGenerateSchemaAction
(
schemaField
,
schemaHash
,
kv
,
isTag
,
&
action
,
info
);
if
(
action
==
SCHEMA_ACTION_ADD_COLUMN
||
action
==
SCHEMA_ACTION_ADD_TAG
){
SField
field
=
{
0
};
field
.
type
=
kv
->
type
;
field
.
bytes
=
getBytes
(
kv
->
type
,
kv
->
length
);
memcpy
(
field
.
name
,
kv
->
key
,
kv
->
keyLen
);
taosArrayPush
(
results
,
&
field
);
}
else
if
(
action
==
SCHEMA_ACTION_CHANGE_COLUMN_SIZE
||
action
==
SCHEMA_ACTION_CHANGE_TAG_SIZE
){
uint16_t
*
index
=
(
uint16_t
*
)
taosHashGet
(
schemaHash
,
kv
->
key
,
kv
->
keyLen
);
uint16_t
newIndex
=
*
index
;
if
(
isTag
)
newIndex
-=
numOfCols
;
SField
*
field
=
(
SField
*
)
taosArrayGet
(
results
,
newIndex
);
field
->
bytes
=
getBytes
(
kv
->
type
,
kv
->
length
);
}
}
return
TSDB_CODE_SUCCESS
;
}
//static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SSmlSTableMeta *sTableData,
//static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SSmlSTableMeta *sTableData,
// int32_t colVer, int32_t tagVer, int8_t source, uint64_t suid){
// int32_t colVer, int32_t tagVer, int8_t source, uint64_t suid){
static
int32_t
smlSendMetaMsg
(
SSmlHandle
*
info
,
SName
*
pName
,
S
SmlSTableMeta
*
sTableData
,
static
int32_t
smlSendMetaMsg
(
SSmlHandle
*
info
,
SName
*
pName
,
S
Array
*
pColumns
,
SArray
*
pTags
,
STableMeta
*
pTableMeta
,
ESchemaAction
action
){
STableMeta
*
pTableMeta
,
ESchemaAction
action
){
SRequestObj
*
pRequest
=
NULL
;
SRequestObj
*
pRequest
=
NULL
;
...
@@ -320,6 +345,12 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SSmlSTableMeta *s
...
@@ -320,6 +345,12 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SSmlSTableMeta *s
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SCmdMsgInfo
pCmdMsg
=
{
0
};
SCmdMsgInfo
pCmdMsg
=
{
0
};
// put front for free
pReq
.
numOfColumns
=
taosArrayGetSize
(
pColumns
);
pReq
.
pColumns
=
pColumns
;
pReq
.
numOfTags
=
taosArrayGetSize
(
pTags
);
pReq
.
pTags
=
pTags
;
code
=
buildRequest
(
info
->
taos
->
id
,
""
,
0
,
NULL
,
false
,
&
pRequest
);
code
=
buildRequest
(
info
->
taos
->
id
,
""
,
0
,
NULL
,
false
,
&
pRequest
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
end
;
goto
end
;
...
@@ -330,91 +361,41 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SSmlSTableMeta *s
...
@@ -330,91 +361,41 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SSmlSTableMeta *s
goto
end
;
goto
end
;
}
}
if
(
action
==
SCHEMA_ACTION_
NULL
){
if
(
action
==
SCHEMA_ACTION_
CREATE_STABLE
){
pReq
.
colVer
=
1
;
pReq
.
colVer
=
1
;
pReq
.
tagVer
=
1
;
pReq
.
tagVer
=
1
;
pReq
.
suid
=
0
;
pReq
.
suid
=
0
;
pReq
.
source
=
TD_REQ_FROM_APP
;
pReq
.
source
=
TD_REQ_FROM_APP
;
}
else
if
(
action
==
SCHEMA_ACTION_
TAG
){
}
else
if
(
action
==
SCHEMA_ACTION_
ADD_TAG
||
action
==
SCHEMA_ACTION_CHANGE_TAG_SIZE
){
pReq
.
colVer
=
pTableMeta
->
sversion
;
pReq
.
colVer
=
pTableMeta
->
sversion
;
pReq
.
tagVer
=
pTableMeta
->
tversion
+
1
;
pReq
.
tagVer
=
pTableMeta
->
tversion
+
1
;
pReq
.
suid
=
pTableMeta
->
uid
;
pReq
.
suid
=
pTableMeta
->
uid
;
pReq
.
source
=
TD_REQ_FROM_TAOX
;
pReq
.
source
=
TD_REQ_FROM_TAOX
;
}
else
if
(
action
==
SCHEMA_ACTION_
COLUMN
){
}
else
if
(
action
==
SCHEMA_ACTION_
ADD_COLUMN
||
action
==
SCHEMA_ACTION_CHANGE_COLUMN_SIZE
){
pReq
.
colVer
=
pTableMeta
->
sversion
+
1
;
pReq
.
colVer
=
pTableMeta
->
sversion
+
1
;
pReq
.
tagVer
=
pTableMeta
->
tversion
;
pReq
.
tagVer
=
pTableMeta
->
tversion
;
pReq
.
suid
=
pTableMeta
->
uid
;
pReq
.
suid
=
pTableMeta
->
uid
;
pReq
.
source
=
TD_REQ_FROM_TAOX
;
pReq
.
source
=
TD_REQ_FROM_TAOX
;
}
}
pReq
.
commentLen
=
-
1
;
pReq
.
igExists
=
true
;
tNameExtractFullName
(
pName
,
pReq
.
name
);
if
(
action
==
SCHEMA_ACTION_NULL
||
action
==
SCHEMA_ACTION_COLUMN
){
pReq
.
numOfColumns
=
taosArrayGetSize
(
sTableData
->
cols
);
pReq
.
pColumns
=
taosArrayInit
(
pReq
.
numOfColumns
,
sizeof
(
SField
));
for
(
int
i
=
0
;
i
<
pReq
.
numOfColumns
;
i
++
)
{
SSmlKv
*
kv
=
(
SSmlKv
*
)
taosArrayGetP
(
sTableData
->
cols
,
i
);
SField
field
=
{
0
};
field
.
type
=
kv
->
type
;
field
.
bytes
=
getBytes
(
kv
->
type
,
kv
->
length
);
memcpy
(
field
.
name
,
kv
->
key
,
kv
->
keyLen
);
taosArrayPush
(
pReq
.
pColumns
,
&
field
);
}
}
else
if
(
action
==
SCHEMA_ACTION_TAG
){
pReq
.
numOfColumns
=
pTableMeta
->
tableInfo
.
numOfColumns
;
pReq
.
pColumns
=
taosArrayInit
(
pReq
.
numOfColumns
,
sizeof
(
SField
));
for
(
int
i
=
0
;
i
<
pReq
.
numOfColumns
;
i
++
)
{
SSchema
*
s
=
&
pTableMeta
->
schema
[
i
];
SField
field
=
{
0
};
field
.
type
=
s
->
type
;
field
.
bytes
=
s
->
bytes
;
strcpy
(
field
.
name
,
s
->
name
);
taosArrayPush
(
pReq
.
pColumns
,
&
field
);
}
}
if
(
action
==
SCHEMA_ACTION_NULL
||
action
==
SCHEMA_ACTION_TAG
){
pReq
.
numOfTags
=
taosArrayGetSize
(
sTableData
->
tags
);
if
(
pReq
.
numOfTags
==
0
){
if
(
pReq
.
numOfTags
==
0
){
pReq
.
numOfTags
=
1
;
pReq
.
numOfTags
=
1
;
pReq
.
pTags
=
taosArrayInit
(
pReq
.
numOfTags
,
sizeof
(
SField
));
SField
field
=
{
0
};
SField
field
=
{
0
};
field
.
type
=
TSDB_DATA_TYPE_NCHAR
;
field
.
type
=
TSDB_DATA_TYPE_NCHAR
;
field
.
bytes
=
1
;
field
.
bytes
=
1
;
strcpy
(
field
.
name
,
tsSmlTagName
);
strcpy
(
field
.
name
,
tsSmlTagName
);
taosArrayPush
(
pReq
.
pTags
,
&
field
);
taosArrayPush
(
pReq
.
pTags
,
&
field
);
}
else
{
pReq
.
pTags
=
taosArrayInit
(
pReq
.
numOfTags
,
sizeof
(
SField
));
for
(
int
i
=
0
;
i
<
pReq
.
numOfTags
;
i
++
)
{
SSmlKv
*
kv
=
(
SSmlKv
*
)
taosArrayGetP
(
sTableData
->
tags
,
i
);
SField
field
=
{
0
};
field
.
type
=
kv
->
type
;
field
.
bytes
=
getBytes
(
kv
->
type
,
kv
->
length
);
memcpy
(
field
.
name
,
kv
->
key
,
kv
->
keyLen
);
taosArrayPush
(
pReq
.
pTags
,
&
field
);
}
}
}
else
if
(
action
==
SCHEMA_ACTION_COLUMN
){
pReq
.
numOfTags
=
pTableMeta
->
tableInfo
.
numOfTags
;
pReq
.
pTags
=
taosArrayInit
(
pReq
.
numOfTags
,
sizeof
(
SField
));
for
(
int
i
=
0
;
i
<
pReq
.
numOfTags
;
i
++
)
{
SSchema
*
s
=
&
pTableMeta
->
schema
[
i
+
pTableMeta
->
tableInfo
.
numOfColumns
];
SField
field
=
{
0
};
field
.
type
=
s
->
type
;
field
.
bytes
=
s
->
bytes
;
strcpy
(
field
.
name
,
s
->
name
);
taosArrayPush
(
pReq
.
pTags
,
&
field
);
}
}
}
pReq
.
commentLen
=
-
1
;
pReq
.
igExists
=
true
;
tNameExtractFullName
(
pName
,
pReq
.
name
);
pCmdMsg
.
epSet
=
getEpSet_s
(
&
info
->
taos
->
pAppInfo
->
mgmtEp
);
pCmdMsg
.
epSet
=
getEpSet_s
(
&
info
->
taos
->
pAppInfo
->
mgmtEp
);
pCmdMsg
.
msgType
=
TDMT_MND_CREATE_STB
;
pCmdMsg
.
msgType
=
TDMT_MND_CREATE_STB
;
pCmdMsg
.
msgLen
=
tSerializeSMCreateStbReq
(
NULL
,
0
,
&
pReq
);
pCmdMsg
.
msgLen
=
tSerializeSMCreateStbReq
(
NULL
,
0
,
&
pReq
);
pCmdMsg
.
pMsg
=
taosMemoryMalloc
(
pCmdMsg
.
msgLen
);
pCmdMsg
.
pMsg
=
taosMemoryMalloc
(
pCmdMsg
.
msgLen
);
if
(
NULL
==
pCmdMsg
.
pMsg
)
{
if
(
NULL
==
pCmdMsg
.
pMsg
)
{
tFreeSMCreateStbReq
(
&
pReq
);
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
end
;
goto
end
;
}
}
...
@@ -443,6 +424,9 @@ end:
...
@@ -443,6 +424,9 @@ end:
static
int32_t
smlModifyDBSchemas
(
SSmlHandle
*
info
)
{
static
int32_t
smlModifyDBSchemas
(
SSmlHandle
*
info
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SHashObj
*
hashTmp
=
NULL
;
STableMeta
*
pTableMeta
=
NULL
;
SName
pName
=
{
TSDB_TABLE_NAME_T
,
info
->
taos
->
acctId
,
{
0
},
{
0
}};
SName
pName
=
{
TSDB_TABLE_NAME_T
,
info
->
taos
->
acctId
,
{
0
},
{
0
}};
strcpy
(
pName
.
dbname
,
info
->
pRequest
->
pDb
);
strcpy
(
pName
.
dbname
,
info
->
pRequest
->
pDb
);
...
@@ -455,7 +439,6 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
...
@@ -455,7 +439,6 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
SSmlSTableMeta
**
tableMetaSml
=
(
SSmlSTableMeta
**
)
taosHashIterate
(
info
->
superTables
,
NULL
);
SSmlSTableMeta
**
tableMetaSml
=
(
SSmlSTableMeta
**
)
taosHashIterate
(
info
->
superTables
,
NULL
);
while
(
tableMetaSml
)
{
while
(
tableMetaSml
)
{
SSmlSTableMeta
*
sTableData
=
*
tableMetaSml
;
SSmlSTableMeta
*
sTableData
=
*
tableMetaSml
;
STableMeta
*
pTableMeta
=
NULL
;
bool
needCheckMeta
=
false
;
// for multi thread
bool
needCheckMeta
=
false
;
// for multi thread
size_t
superTableLen
=
0
;
size_t
superTableLen
=
0
;
...
@@ -466,14 +449,19 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
...
@@ -466,14 +449,19 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
code
=
catalogGetSTableMeta
(
info
->
pCatalog
,
&
conn
,
&
pName
,
&
pTableMeta
);
code
=
catalogGetSTableMeta
(
info
->
pCatalog
,
&
conn
,
&
pName
,
&
pTableMeta
);
if
(
code
==
TSDB_CODE_PAR_TABLE_NOT_EXIST
||
code
==
TSDB_CODE_MND_STB_NOT_EXIST
)
{
if
(
code
==
TSDB_CODE_PAR_TABLE_NOT_EXIST
||
code
==
TSDB_CODE_MND_STB_NOT_EXIST
)
{
code
=
smlSendMetaMsg
(
info
,
&
pName
,
sTableData
,
NULL
,
SCHEMA_ACTION_NULL
);
SArray
*
pColumns
=
taosArrayInit
(
taosArrayGetSize
(
sTableData
->
cols
),
sizeof
(
SField
));
SArray
*
pTags
=
taosArrayInit
(
taosArrayGetSize
(
sTableData
->
tags
),
sizeof
(
SField
));
smlBuildFieldsList
(
info
,
NULL
,
NULL
,
sTableData
->
tags
,
pTags
,
0
,
true
);
smlBuildFieldsList
(
info
,
NULL
,
NULL
,
sTableData
->
cols
,
pColumns
,
0
,
false
);
code
=
smlSendMetaMsg
(
info
,
&
pName
,
pColumns
,
pTags
,
NULL
,
SCHEMA_ACTION_CREATE_STABLE
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" smlSendMetaMsg failed. can not create %s"
,
info
->
id
,
superTable
);
uError
(
"SML:0x%"
PRIx64
" smlSendMetaMsg failed. can not create %s"
,
info
->
id
,
superTable
);
goto
end
;
goto
end
;
}
}
info
->
cost
.
numOfCreateSTables
++
;
info
->
cost
.
numOfCreateSTables
++
;
}
else
if
(
code
==
TSDB_CODE_SUCCESS
)
{
}
else
if
(
code
==
TSDB_CODE_SUCCESS
)
{
SHashObj
*
hashTmp
=
taosHashInit
(
pTableMeta
->
tableInfo
.
numOfTags
,
hashTmp
=
taosHashInit
(
pTableMeta
->
tableInfo
.
numOfTags
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
for
(
uint16_t
i
=
pTableMeta
->
tableInfo
.
numOfColumns
;
for
(
uint16_t
i
=
pTableMeta
->
tableInfo
.
numOfColumns
;
i
<
pTableMeta
->
tableInfo
.
numOfColumns
+
pTableMeta
->
tableInfo
.
numOfTags
;
i
++
)
{
i
<
pTableMeta
->
tableInfo
.
numOfColumns
+
pTableMeta
->
tableInfo
.
numOfTags
;
i
++
)
{
...
@@ -483,34 +471,70 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
...
@@ -483,34 +471,70 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
ESchemaAction
action
=
SCHEMA_ACTION_NULL
;
ESchemaAction
action
=
SCHEMA_ACTION_NULL
;
code
=
smlProcessSchemaAction
(
info
,
pTableMeta
->
schema
,
hashTmp
,
sTableData
->
tags
,
&
action
,
true
);
code
=
smlProcessSchemaAction
(
info
,
pTableMeta
->
schema
,
hashTmp
,
sTableData
->
tags
,
&
action
,
true
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
taosHashCleanup
(
hashTmp
);
goto
end
;
goto
end
;
}
}
if
(
action
==
SCHEMA_ACTION_TAG
){
if
(
action
!=
SCHEMA_ACTION_NULL
){
code
=
smlSendMetaMsg
(
info
,
&
pName
,
sTableData
,
pTableMeta
,
action
);
SArray
*
pColumns
=
taosArrayInit
(
taosArrayGetSize
(
sTableData
->
cols
)
+
pTableMeta
->
tableInfo
.
numOfColumns
,
sizeof
(
SField
));
SArray
*
pTags
=
taosArrayInit
(
taosArrayGetSize
(
sTableData
->
tags
)
+
pTableMeta
->
tableInfo
.
numOfTags
,
sizeof
(
SField
));
for
(
uint16_t
i
=
0
;
i
<
pTableMeta
->
tableInfo
.
numOfColumns
+
pTableMeta
->
tableInfo
.
numOfTags
;
i
++
)
{
SField
field
=
{
0
};
field
.
type
=
pTableMeta
->
schema
[
i
].
type
;
field
.
bytes
=
pTableMeta
->
schema
[
i
].
bytes
;
strcpy
(
field
.
name
,
pTableMeta
->
schema
[
i
].
name
);
if
(
i
<
pTableMeta
->
tableInfo
.
numOfColumns
){
taosArrayPush
(
pColumns
,
&
field
);
}
else
{
taosArrayPush
(
pTags
,
&
field
);
}
}
smlBuildFieldsList
(
info
,
pTableMeta
->
schema
,
hashTmp
,
sTableData
->
tags
,
pTags
,
pTableMeta
->
tableInfo
.
numOfColumns
,
true
);
code
=
smlSendMetaMsg
(
info
,
&
pName
,
pColumns
,
pTags
,
pTableMeta
,
action
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" smlSendMetaMsg failed. can not create %s"
,
info
->
id
,
superTable
);
uError
(
"SML:0x%"
PRIx64
" smlSendMetaMsg failed. can not create %s"
,
info
->
id
,
superTable
);
goto
end
;
goto
end
;
}
}
}
}
taosMemoryFreeClear
(
pTableMeta
);
code
=
catalogRefreshTableMeta
(
info
->
pCatalog
,
&
conn
,
&
pName
,
-
1
);
code
=
catalogRefreshTableMeta
(
info
->
pCatalog
,
&
conn
,
&
pName
,
-
1
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
end
;
goto
end
;
}
}
code
=
catalogGetSTableMeta
(
info
->
pCatalog
,
&
conn
,
&
pName
,
&
pTableMeta
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
end
;
}
taosHashClear
(
hashTmp
);
taosHashClear
(
hashTmp
);
for
(
uint16_t
i
=
1
;
i
<
pTableMeta
->
tableInfo
.
numOfColumns
;
i
++
)
{
for
(
uint16_t
i
=
0
;
i
<
pTableMeta
->
tableInfo
.
numOfColumns
;
i
++
)
{
taosHashPut
(
hashTmp
,
pTableMeta
->
schema
[
i
].
name
,
strlen
(
pTableMeta
->
schema
[
i
].
name
),
&
i
,
SHORT_BYTES
);
taosHashPut
(
hashTmp
,
pTableMeta
->
schema
[
i
].
name
,
strlen
(
pTableMeta
->
schema
[
i
].
name
),
&
i
,
SHORT_BYTES
);
}
}
action
=
SCHEMA_ACTION_NULL
;
action
=
SCHEMA_ACTION_NULL
;
code
=
smlProcessSchemaAction
(
info
,
pTableMeta
->
schema
,
hashTmp
,
sTableData
->
cols
,
&
action
,
false
);
code
=
smlProcessSchemaAction
(
info
,
pTableMeta
->
schema
,
hashTmp
,
sTableData
->
cols
,
&
action
,
false
);
taosHashCleanup
(
hashTmp
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
end
;
goto
end
;
}
}
if
(
action
==
SCHEMA_ACTION_COLUMN
){
if
(
action
!=
SCHEMA_ACTION_NULL
){
code
=
smlSendMetaMsg
(
info
,
&
pName
,
sTableData
,
pTableMeta
,
action
);
SArray
*
pColumns
=
taosArrayInit
(
taosArrayGetSize
(
sTableData
->
cols
)
+
pTableMeta
->
tableInfo
.
numOfColumns
,
sizeof
(
SField
));
SArray
*
pTags
=
taosArrayInit
(
taosArrayGetSize
(
sTableData
->
tags
)
+
pTableMeta
->
tableInfo
.
numOfTags
,
sizeof
(
SField
));
for
(
uint16_t
i
=
0
;
i
<
pTableMeta
->
tableInfo
.
numOfColumns
+
pTableMeta
->
tableInfo
.
numOfTags
;
i
++
)
{
SField
field
=
{
0
};
field
.
type
=
pTableMeta
->
schema
[
i
].
type
;
field
.
bytes
=
pTableMeta
->
schema
[
i
].
bytes
;
strcpy
(
field
.
name
,
pTableMeta
->
schema
[
i
].
name
);
if
(
i
<
pTableMeta
->
tableInfo
.
numOfColumns
){
taosArrayPush
(
pColumns
,
&
field
);
}
else
{
taosArrayPush
(
pTags
,
&
field
);
}
}
smlBuildFieldsList
(
info
,
pTableMeta
->
schema
,
hashTmp
,
sTableData
->
cols
,
pColumns
,
pTableMeta
->
tableInfo
.
numOfColumns
,
false
);
code
=
smlSendMetaMsg
(
info
,
&
pName
,
pColumns
,
pTags
,
pTableMeta
,
action
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" smlSendMetaMsg failed. can not create %s"
,
info
->
id
,
superTable
);
uError
(
"SML:0x%"
PRIx64
" smlSendMetaMsg failed. can not create %s"
,
info
->
id
,
superTable
);
goto
end
;
goto
end
;
...
@@ -526,7 +550,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
...
@@ -526,7 +550,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
uError
(
"SML:0x%"
PRIx64
" load table meta error: %s"
,
info
->
id
,
tstrerror
(
code
));
uError
(
"SML:0x%"
PRIx64
" load table meta error: %s"
,
info
->
id
,
tstrerror
(
code
));
goto
end
;
goto
end
;
}
}
if
(
pTableMeta
)
taosMemoryFree
(
pTableMeta
);
taosMemoryFreeClear
(
pTableMeta
);
code
=
catalogGetSTableMeta
(
info
->
pCatalog
,
&
conn
,
&
pName
,
&
pTableMeta
);
code
=
catalogGetSTableMeta
(
info
->
pCatalog
,
&
conn
,
&
pName
,
&
pTableMeta
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -551,10 +575,13 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
...
@@ -551,10 +575,13 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
sTableData
->
tableMeta
=
pTableMeta
;
sTableData
->
tableMeta
=
pTableMeta
;
tableMetaSml
=
(
SSmlSTableMeta
**
)
taosHashIterate
(
info
->
superTables
,
tableMetaSml
);
tableMetaSml
=
(
SSmlSTableMeta
**
)
taosHashIterate
(
info
->
superTables
,
tableMetaSml
);
taosHashCleanup
(
hashTmp
);
}
}
return
0
;
return
0
;
end:
end:
taosHashCleanup
(
hashTmp
);
taosMemoryFreeClear
(
pTableMeta
);
catalogRefreshTableMeta
(
info
->
pCatalog
,
&
conn
,
&
pName
,
1
);
catalogRefreshTableMeta
(
info
->
pCatalog
,
&
conn
,
&
pName
,
1
);
return
code
;
return
code
;
}
}
...
@@ -2057,10 +2084,6 @@ static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql) {
...
@@ -2057,10 +2084,6 @@ static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql) {
if
(
info
->
dataFormat
)
taosArrayDestroy
(
cols
);
if
(
info
->
dataFormat
)
taosArrayDestroy
(
cols
);
return
ret
;
return
ret
;
}
}
if
(
taosArrayGetSize
(
cols
)
>
TSDB_MAX_COLUMNS
)
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"too many columns than 4096"
,
NULL
);
return
TSDB_CODE_PAR_TOO_MANY_COLUMNS
;
}
bool
hasTable
=
true
;
bool
hasTable
=
true
;
SSmlTableInfo
*
tinfo
=
NULL
;
SSmlTableInfo
*
tinfo
=
NULL
;
...
@@ -2094,6 +2117,11 @@ static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql) {
...
@@ -2094,6 +2117,11 @@ static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql) {
return
TSDB_CODE_PAR_INVALID_TAGS_NUM
;
return
TSDB_CODE_PAR_INVALID_TAGS_NUM
;
}
}
if
(
taosArrayGetSize
(
cols
)
+
taosArrayGetSize
((
*
oneTable
)
->
tags
)
>
TSDB_MAX_COLUMNS
)
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"too many columns than 4096"
,
NULL
);
return
TSDB_CODE_PAR_TOO_MANY_COLUMNS
;
}
(
*
oneTable
)
->
sTableName
=
elements
.
measure
;
(
*
oneTable
)
->
sTableName
=
elements
.
measure
;
(
*
oneTable
)
->
sTableNameLen
=
elements
.
measureLen
;
(
*
oneTable
)
->
sTableNameLen
=
elements
.
measureLen
;
if
(
strlen
((
*
oneTable
)
->
childTableName
)
==
0
)
{
if
(
strlen
((
*
oneTable
)
->
childTableName
)
==
0
)
{
...
...
source/client/src/taosx.c
浏览文件 @
2ad31384
...
@@ -765,6 +765,29 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
...
@@ -765,6 +765,29 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
}
}
taosArrayPush
(
pRequest
->
tableList
,
&
pName
);
taosArrayPush
(
pRequest
->
tableList
,
&
pName
);
// change tag cid to new cid
if
(
pCreateReq
->
type
==
TSDB_CHILD_TABLE
){
STableMeta
*
pTableMeta
=
NULL
;
SName
sName
=
{
0
};
toName
(
pTscObj
->
acctId
,
pRequest
->
pDb
,
pCreateReq
->
ctb
.
name
,
&
sName
);
code
=
catalogGetTableMeta
(
pCatalog
,
&
conn
,
&
sName
,
&
pTableMeta
);
if
(
code
!=
TSDB_CODE_SUCCESS
){
uError
(
"taosCreateTable:catalogGetTableMeta failed. table name: %s"
,
pCreateReq
->
ctb
.
name
);
goto
end
;
}
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pCreateReq
->
ctb
.
tagName
);
i
++
){
char
*
tName
=
taosArrayGet
(
pCreateReq
->
ctb
.
tagName
,
i
);
for
(
int32_t
j
=
pTableMeta
->
tableInfo
.
numOfColumns
;
j
<
pTableMeta
->
tableInfo
.
numOfColumns
+
pTableMeta
->
tableInfo
.
numOfTags
;
j
++
){
SSchema
*
tag
=
&
pTableMeta
->
schema
[
j
];
if
(
strcmp
(
tag
->
name
,
tName
)
==
0
&&
tag
->
type
!=
TSDB_DATA_TYPE_JSON
){
tTagSetCid
((
STag
*
)
pCreateReq
->
ctb
.
pTag
,
i
,
tag
->
colId
);
}
}
}
taosMemoryFreeClear
(
pTableMeta
);
}
SVgroupCreateTableBatch
*
pTableBatch
=
taosHashGet
(
pVgroupHashmap
,
&
pInfo
.
vgId
,
sizeof
(
pInfo
.
vgId
));
SVgroupCreateTableBatch
*
pTableBatch
=
taosHashGet
(
pVgroupHashmap
,
&
pInfo
.
vgId
,
sizeof
(
pInfo
.
vgId
));
if
(
pTableBatch
==
NULL
)
{
if
(
pTableBatch
==
NULL
)
{
SVgroupCreateTableBatch
tBatch
=
{
0
};
SVgroupCreateTableBatch
tBatch
=
{
0
};
...
@@ -1305,6 +1328,7 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
...
@@ -1305,6 +1328,7 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
SQuery
*
pQuery
=
NULL
;
SQuery
*
pQuery
=
NULL
;
SMqRspObj
rspObj
=
{
0
};
SMqRspObj
rspObj
=
{
0
};
SDecoder
decoder
=
{
0
};
SDecoder
decoder
=
{
0
};
STableMeta
*
pTableMeta
=
NULL
;
terrno
=
TSDB_CODE_SUCCESS
;
terrno
=
TSDB_CODE_SUCCESS
;
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
createRequest
(
*
(
int64_t
*
)
taos
,
TSDB_SQL_INSERT
);
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
createRequest
(
*
(
int64_t
*
)
taos
,
TSDB_SQL_INSERT
);
...
@@ -1361,24 +1385,6 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
...
@@ -1361,24 +1385,6 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
goto
end
;
goto
end
;
}
}
uint16_t
fLen
=
0
;
int32_t
rowSize
=
0
;
int16_t
nVar
=
0
;
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
SSchema
*
schema
=
pSW
->
pSchema
+
i
;
fLen
+=
TYPE_BYTES
[
schema
->
type
];
rowSize
+=
schema
->
bytes
;
if
(
IS_VAR_DATA_TYPE
(
schema
->
type
))
{
nVar
++
;
}
}
int32_t
rows
=
rspObj
.
resInfo
.
numOfRows
;
int32_t
extendedRowSize
=
rowSize
+
TD_ROW_HEAD_LEN
-
sizeof
(
TSKEY
)
+
nVar
*
sizeof
(
VarDataOffsetT
)
+
(
int32_t
)
TD_BITMAP_BYTES
(
pSW
->
nCols
-
1
);
int32_t
schemaLen
=
0
;
int32_t
submitLen
=
sizeof
(
SSubmitBlk
)
+
schemaLen
+
rows
*
extendedRowSize
;
const
char
*
tbName
=
(
const
char
*
)
taosArrayGetP
(
rspObj
.
rsp
.
blockTbName
,
rspObj
.
resIter
);
const
char
*
tbName
=
(
const
char
*
)
taosArrayGetP
(
rspObj
.
rsp
.
blockTbName
,
rspObj
.
resIter
);
if
(
!
tbName
)
{
if
(
!
tbName
)
{
uError
(
"WriteRaw: tbname is null"
);
uError
(
"WriteRaw: tbname is null"
);
...
@@ -1398,6 +1404,35 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
...
@@ -1398,6 +1404,35 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
goto
end
;
goto
end
;
}
}
code
=
catalogGetTableMeta
(
pCatalog
,
&
conn
,
&
pName
,
&
pTableMeta
);
if
(
code
==
TSDB_CODE_PAR_TABLE_NOT_EXIST
){
uError
(
"WriteRaw:catalogGetTableMeta table not exist. table name: %s"
,
tbName
);
code
=
TSDB_CODE_SUCCESS
;
continue
;
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"WriteRaw:catalogGetTableMeta failed. table name: %s"
,
tbName
);
goto
end
;
}
uint16_t
fLen
=
0
;
int32_t
rowSize
=
0
;
int16_t
nVar
=
0
;
for
(
int
i
=
0
;
i
<
pTableMeta
->
tableInfo
.
numOfColumns
;
i
++
)
{
SSchema
*
schema
=
&
pTableMeta
->
schema
[
i
];
fLen
+=
TYPE_BYTES
[
schema
->
type
];
rowSize
+=
schema
->
bytes
;
if
(
IS_VAR_DATA_TYPE
(
schema
->
type
))
{
nVar
++
;
}
}
int32_t
rows
=
rspObj
.
resInfo
.
numOfRows
;
int32_t
extendedRowSize
=
rowSize
+
TD_ROW_HEAD_LEN
-
sizeof
(
TSKEY
)
+
nVar
*
sizeof
(
VarDataOffsetT
)
+
(
int32_t
)
TD_BITMAP_BYTES
(
pTableMeta
->
tableInfo
.
numOfColumns
-
1
);
int32_t
schemaLen
=
0
;
int32_t
submitLen
=
sizeof
(
SSubmitBlk
)
+
schemaLen
+
rows
*
extendedRowSize
;
SSubmitReq
*
subReq
=
NULL
;
SSubmitReq
*
subReq
=
NULL
;
SSubmitBlk
*
blk
=
NULL
;
SSubmitBlk
*
blk
=
NULL
;
void
*
hData
=
taosHashGet
(
pVgHash
,
&
vgData
.
vg
.
vgId
,
sizeof
(
vgData
.
vg
.
vgId
));
void
*
hData
=
taosHashGet
(
pVgHash
,
&
vgData
.
vg
.
vgId
,
sizeof
(
vgData
.
vg
.
vgId
));
...
@@ -1430,23 +1465,25 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
...
@@ -1430,23 +1465,25 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
blk
=
POINTER_SHIFT
(
vgData
.
data
,
sizeof
(
SSubmitReq
));
blk
=
POINTER_SHIFT
(
vgData
.
data
,
sizeof
(
SSubmitReq
));
}
}
STableMeta
*
pTableMeta
=
NULL
;
// pSW->pSchema should be same as pTableMeta->schema
code
=
catalogGetTableMeta
(
pCatalog
,
&
conn
,
&
pName
,
&
pTableMeta
);
// ASSERT(pSW->nCols == pTableMeta->tableInfo.numOfColumns);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"WriteRaw:catalogGetTableMeta failed. table name: %s"
,
tbName
);
goto
end
;
}
uint64_t
suid
=
(
TSDB_NORMAL_TABLE
==
pTableMeta
->
tableType
?
0
:
pTableMeta
->
suid
);
uint64_t
suid
=
(
TSDB_NORMAL_TABLE
==
pTableMeta
->
tableType
?
0
:
pTableMeta
->
suid
);
uint64_t
uid
=
pTableMeta
->
uid
;
uint64_t
uid
=
pTableMeta
->
uid
;
taosMemoryFreeClear
(
pTableMeta
)
;
int16_t
sver
=
pTableMeta
->
sversion
;
void
*
blkSchema
=
POINTER_SHIFT
(
blk
,
sizeof
(
SSubmitBlk
));
void
*
blkSchema
=
POINTER_SHIFT
(
blk
,
sizeof
(
SSubmitBlk
));
STSRow
*
rowData
=
POINTER_SHIFT
(
blkSchema
,
schemaLen
);
STSRow
*
rowData
=
POINTER_SHIFT
(
blkSchema
,
schemaLen
);
SRowBuilder
rb
=
{
0
};
SRowBuilder
rb
=
{
0
};
tdSRowInit
(
&
rb
,
pSW
->
version
);
tdSRowInit
(
&
rb
,
sver
);
tdSRowSetTpInfo
(
&
rb
,
pSW
->
nCols
,
fLen
);
tdSRowSetTpInfo
(
&
rb
,
pTableMeta
->
tableInfo
.
numOfColumns
,
fLen
);
int32_t
dataLen
=
0
;
int32_t
totalLen
=
0
;
SHashObj
*
schemaHash
=
taosHashInit
(
16
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
SSchema
*
schema
=
&
pSW
->
pSchema
[
i
];
taosHashPut
(
schemaHash
,
schema
->
name
,
strlen
(
schema
->
name
),
&
i
,
sizeof
(
int32_t
));
}
for
(
int32_t
j
=
0
;
j
<
rows
;
j
++
)
{
for
(
int32_t
j
=
0
;
j
<
rows
;
j
++
)
{
tdSRowResetBuf
(
&
rb
,
rowData
);
tdSRowResetBuf
(
&
rb
,
rowData
);
...
@@ -1455,33 +1492,41 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
...
@@ -1455,33 +1492,41 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
rspObj
.
resInfo
.
current
+=
1
;
rspObj
.
resInfo
.
current
+=
1
;
int32_t
offset
=
0
;
int32_t
offset
=
0
;
for
(
int32_t
k
=
0
;
k
<
pSW
->
nCols
;
k
++
)
{
for
(
int32_t
k
=
0
;
k
<
pTableMeta
->
tableInfo
.
numOfColumns
;
k
++
)
{
const
SSchema
*
pColumn
=
&
pSW
->
pSchema
[
k
];
const
SSchema
*
pColumn
=
&
pTableMeta
->
schema
[
k
];
char
*
data
=
rspObj
.
resInfo
.
row
[
k
];
int32_t
*
index
=
taosHashGet
(
schemaHash
,
pColumn
->
name
,
strlen
(
pColumn
->
name
));
if
(
!
data
)
{
if
(
!
index
){
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NULL
,
NULL
,
false
,
offset
,
k
);
}
else
{
char
*
colData
=
rspObj
.
resInfo
.
row
[
*
index
];
if
(
!
colData
)
{
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NULL
,
NULL
,
false
,
offset
,
k
);
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NULL
,
NULL
,
false
,
offset
,
k
);
}
else
{
}
else
{
if
(
IS_VAR_DATA_TYPE
(
pColumn
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pColumn
->
type
))
{
d
ata
-=
VARSTR_HEADER_SIZE
;
colD
ata
-=
VARSTR_HEADER_SIZE
;
}
}
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NORM
,
d
ata
,
true
,
offset
,
k
);
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NORM
,
colD
ata
,
true
,
offset
,
k
);
}
}
}
offset
+=
TYPE_BYTES
[
pColumn
->
type
];
offset
+=
TYPE_BYTES
[
pColumn
->
type
];
}
}
tdSRowEnd
(
&
rb
);
tdSRowEnd
(
&
rb
);
int32_t
rowLen
=
TD_ROW_LEN
(
rowData
);
int32_t
rowLen
=
TD_ROW_LEN
(
rowData
);
rowData
=
POINTER_SHIFT
(
rowData
,
rowLen
);
rowData
=
POINTER_SHIFT
(
rowData
,
rowLen
);
data
Len
+=
rowLen
;
total
Len
+=
rowLen
;
}
}
taosHashCleanup
(
schemaHash
);
blk
->
uid
=
htobe64
(
uid
);
blk
->
uid
=
htobe64
(
uid
);
blk
->
suid
=
htobe64
(
suid
);
blk
->
suid
=
htobe64
(
suid
);
blk
->
sversion
=
htonl
(
pSW
->
version
);
blk
->
sversion
=
htonl
(
sver
);
blk
->
schemaLen
=
htonl
(
schemaLen
);
blk
->
schemaLen
=
htonl
(
schemaLen
);
blk
->
numOfRows
=
htonl
(
rows
);
blk
->
numOfRows
=
htonl
(
rows
);
blk
->
dataLen
=
htonl
(
data
Len
);
blk
->
dataLen
=
htonl
(
total
Len
);
subReq
->
length
+=
sizeof
(
SSubmitBlk
)
+
schemaLen
+
data
Len
;
subReq
->
length
+=
sizeof
(
SSubmitBlk
)
+
schemaLen
+
total
Len
;
subReq
->
numOfBlocks
++
;
subReq
->
numOfBlocks
++
;
taosMemoryFreeClear
(
pTableMeta
);
}
}
pQuery
=
(
SQuery
*
)
nodesMakeNode
(
QUERY_NODE_QUERY
);
pQuery
=
(
SQuery
*
)
nodesMakeNode
(
QUERY_NODE_QUERY
);
...
@@ -1535,6 +1580,7 @@ end:
...
@@ -1535,6 +1580,7 @@ end:
qDestroyQuery
(
pQuery
);
qDestroyQuery
(
pQuery
);
destroyRequest
(
pRequest
);
destroyRequest
(
pRequest
);
taosHashCleanup
(
pVgHash
);
taosHashCleanup
(
pVgHash
);
taosMemoryFreeClear
(
pTableMeta
);
return
code
;
return
code
;
}
}
...
...
source/client/src/tmq.c
浏览文件 @
2ad31384
...
@@ -1132,7 +1132,10 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
...
@@ -1132,7 +1132,10 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
memcpy
(
&
pRspWrapper
->
dataRsp
,
pMsg
->
pData
,
sizeof
(
SMqRspHead
));
memcpy
(
&
pRspWrapper
->
dataRsp
,
pMsg
->
pData
,
sizeof
(
SMqRspHead
));
}
else
{
}
else
{
ASSERT
(
rspType
==
TMQ_MSG_TYPE__POLL_META_RSP
);
ASSERT
(
rspType
==
TMQ_MSG_TYPE__POLL_META_RSP
);
tDecodeSMqMetaRsp
(
POINTER_SHIFT
(
pMsg
->
pData
,
sizeof
(
SMqRspHead
)),
&
pRspWrapper
->
metaRsp
);
SDecoder
decoder
;
tDecoderInit
(
&
decoder
,
POINTER_SHIFT
(
pMsg
->
pData
,
sizeof
(
SMqRspHead
)),
pMsg
->
len
-
sizeof
(
SMqRspHead
));
tDecodeSMqMetaRsp
(
&
decoder
,
&
pRspWrapper
->
metaRsp
);
tDecoderClear
(
&
decoder
);
memcpy
(
&
pRspWrapper
->
metaRsp
,
pMsg
->
pData
,
sizeof
(
SMqRspHead
));
memcpy
(
&
pRspWrapper
->
metaRsp
,
pMsg
->
pData
,
sizeof
(
SMqRspHead
));
}
}
...
@@ -1581,8 +1584,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
...
@@ -1581,8 +1584,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
SMqClientVg
*
pVg
=
pollRspWrapper
->
vgHandle
;
SMqClientVg
*
pVg
=
pollRspWrapper
->
vgHandle
;
/*printf("vgId:%d, offset %" PRId64 " up to %" PRId64 "\n", pVg->vgId, pVg->currentOffset,
/*printf("vgId:%d, offset %" PRId64 " up to %" PRId64 "\n", pVg->vgId, pVg->currentOffset,
* rspMsg->msg.rspOffset);*/
* rspMsg->msg.rspOffset);*/
pVg
->
currentOffset
.
version
=
pollRspWrapper
->
metaRsp
.
rspOffset
;
pVg
->
currentOffset
=
pollRspWrapper
->
metaRsp
.
rspOffset
;
pVg
->
currentOffset
.
type
=
TMQ_OFFSET__LOG
;
atomic_store_32
(
&
pVg
->
vgStatus
,
TMQ_VG_STATUS__IDLE
);
atomic_store_32
(
&
pVg
->
vgStatus
,
TMQ_VG_STATUS__IDLE
);
// build rsp
// build rsp
SMqMetaRspObj
*
pRsp
=
tmqBuildMetaRspFromWrapper
(
pollRspWrapper
);
SMqMetaRspObj
*
pRsp
=
tmqBuildMetaRspFromWrapper
(
pollRspWrapper
);
...
...
source/client/test/smlTest.cpp
浏览文件 @
2ad31384
此差异已折叠。
点击以展开。
source/common/src/tdatablock.c
浏览文件 @
2ad31384
...
@@ -1228,6 +1228,7 @@ void blockDataFreeRes(SSDataBlock* pBlock) {
...
@@ -1228,6 +1228,7 @@ void blockDataFreeRes(SSDataBlock* pBlock) {
}
}
taosArrayDestroy
(
pBlock
->
pDataBlock
);
taosArrayDestroy
(
pBlock
->
pDataBlock
);
pBlock
->
pDataBlock
=
NULL
;
taosMemoryFreeClear
(
pBlock
->
pBlockAgg
);
taosMemoryFreeClear
(
pBlock
->
pBlockAgg
);
memset
(
&
pBlock
->
info
,
0
,
sizeof
(
SDataBlockInfo
));
memset
(
&
pBlock
->
info
,
0
,
sizeof
(
SDataBlockInfo
));
}
}
...
...
source/common/src/tdataformat.c
浏览文件 @
2ad31384
...
@@ -1064,6 +1064,26 @@ _err:
...
@@ -1064,6 +1064,26 @@ _err:
return
code
;
return
code
;
}
}
void
tTagSetCid
(
const
STag
*
pTag
,
int16_t
iTag
,
int16_t
cid
)
{
uint8_t
*
p
=
NULL
;
int8_t
isLarge
=
pTag
->
flags
&
TD_TAG_LARGE
;
int16_t
offset
=
0
;
if
(
isLarge
)
{
p
=
(
uint8_t
*
)
&
((
int16_t
*
)
pTag
->
idx
)[
pTag
->
nTag
];
}
else
{
p
=
(
uint8_t
*
)
&
pTag
->
idx
[
pTag
->
nTag
];
}
if
(
isLarge
)
{
offset
=
((
int16_t
*
)
pTag
->
idx
)[
iTag
];
}
else
{
offset
=
pTag
->
idx
[
iTag
];
}
tPutI16v
(
p
+
offset
,
cid
);
}
#if 1 // ===================================================================================================================
#if 1 // ===================================================================================================================
int
tdInitTSchemaBuilder
(
STSchemaBuilder
*
pBuilder
,
schema_ver_t
version
)
{
int
tdInitTSchemaBuilder
(
STSchemaBuilder
*
pBuilder
,
schema_ver_t
version
)
{
if
(
pBuilder
==
NULL
)
return
-
1
;
if
(
pBuilder
==
NULL
)
return
-
1
;
...
...
source/common/src/tmsg.c
浏览文件 @
2ad31384
...
@@ -5675,7 +5675,7 @@ void tFreeSMCreateStbRsp(SMCreateStbRsp *pRsp) {
...
@@ -5675,7 +5675,7 @@ void tFreeSMCreateStbRsp(SMCreateStbRsp *pRsp) {
int32_t
tEncodeSTqOffsetVal
(
SEncoder
*
pEncoder
,
const
STqOffsetVal
*
pOffsetVal
)
{
int32_t
tEncodeSTqOffsetVal
(
SEncoder
*
pEncoder
,
const
STqOffsetVal
*
pOffsetVal
)
{
if
(
tEncodeI8
(
pEncoder
,
pOffsetVal
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pOffsetVal
->
type
)
<
0
)
return
-
1
;
if
(
pOffsetVal
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
if
(
pOffsetVal
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
||
pOffsetVal
->
type
==
TMQ_OFFSET__SNAPSHOT_META
)
{
if
(
tEncodeI64
(
pEncoder
,
pOffsetVal
->
uid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pOffsetVal
->
uid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pOffsetVal
->
ts
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pOffsetVal
->
ts
)
<
0
)
return
-
1
;
}
else
if
(
pOffsetVal
->
type
==
TMQ_OFFSET__LOG
)
{
}
else
if
(
pOffsetVal
->
type
==
TMQ_OFFSET__LOG
)
{
...
@@ -5690,7 +5690,7 @@ int32_t tEncodeSTqOffsetVal(SEncoder *pEncoder, const STqOffsetVal *pOffsetVal)
...
@@ -5690,7 +5690,7 @@ int32_t tEncodeSTqOffsetVal(SEncoder *pEncoder, const STqOffsetVal *pOffsetVal)
int32_t
tDecodeSTqOffsetVal
(
SDecoder
*
pDecoder
,
STqOffsetVal
*
pOffsetVal
)
{
int32_t
tDecodeSTqOffsetVal
(
SDecoder
*
pDecoder
,
STqOffsetVal
*
pOffsetVal
)
{
if
(
tDecodeI8
(
pDecoder
,
&
pOffsetVal
->
type
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pOffsetVal
->
type
)
<
0
)
return
-
1
;
if
(
pOffsetVal
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
if
(
pOffsetVal
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
||
pOffsetVal
->
type
==
TMQ_OFFSET__SNAPSHOT_META
)
{
if
(
tDecodeI64
(
pDecoder
,
&
pOffsetVal
->
uid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pOffsetVal
->
uid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pOffsetVal
->
ts
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pOffsetVal
->
ts
)
<
0
)
return
-
1
;
}
else
if
(
pOffsetVal
->
type
==
TMQ_OFFSET__LOG
)
{
}
else
if
(
pOffsetVal
->
type
==
TMQ_OFFSET__LOG
)
{
...
@@ -5712,10 +5712,8 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) {
...
@@ -5712,10 +5712,8 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) {
snprintf
(
buf
,
maxLen
,
"offset(reset to latest)"
);
snprintf
(
buf
,
maxLen
,
"offset(reset to latest)"
);
}
else
if
(
pVal
->
type
==
TMQ_OFFSET__LOG
)
{
}
else
if
(
pVal
->
type
==
TMQ_OFFSET__LOG
)
{
snprintf
(
buf
,
maxLen
,
"offset(log) ver:%"
PRId64
,
pVal
->
version
);
snprintf
(
buf
,
maxLen
,
"offset(log) ver:%"
PRId64
,
pVal
->
version
);
}
else
if
(
pVal
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
}
else
if
(
pVal
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
||
pVal
->
type
==
TMQ_OFFSET__SNAPSHOT_META
)
{
snprintf
(
buf
,
maxLen
,
"offset(ss data) uid:%"
PRId64
", ts:%"
PRId64
,
pVal
->
uid
,
pVal
->
ts
);
snprintf
(
buf
,
maxLen
,
"offset(ss data) uid:%"
PRId64
", ts:%"
PRId64
,
pVal
->
uid
,
pVal
->
ts
);
}
else
if
(
pVal
->
type
==
TMQ_OFFSET__SNAPSHOT_META
)
{
snprintf
(
buf
,
maxLen
,
"offset(ss meta) uid:%"
PRId64
", ts:%"
PRId64
,
pVal
->
uid
,
pVal
->
ts
);
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
...
@@ -5729,9 +5727,7 @@ bool tOffsetEqual(const STqOffsetVal *pLeft, const STqOffsetVal *pRight) {
...
@@ -5729,9 +5727,7 @@ bool tOffsetEqual(const STqOffsetVal *pLeft, const STqOffsetVal *pRight) {
}
else
if
(
pLeft
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
}
else
if
(
pLeft
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
return
pLeft
->
uid
==
pRight
->
uid
&&
pLeft
->
ts
==
pRight
->
ts
;
return
pLeft
->
uid
==
pRight
->
uid
&&
pLeft
->
ts
==
pRight
->
ts
;
}
else
if
(
pLeft
->
type
==
TMQ_OFFSET__SNAPSHOT_META
)
{
}
else
if
(
pLeft
->
type
==
TMQ_OFFSET__SNAPSHOT_META
)
{
ASSERT
(
0
);
return
pLeft
->
uid
==
pRight
->
uid
;
// TODO
return
pLeft
->
uid
==
pRight
->
uid
&&
pLeft
->
ts
==
pRight
->
ts
;
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
/*ASSERT(pLeft->type == TMQ_OFFSET__RESET_NONE || pLeft->type == TMQ_OFFSET__RESET_EARLIEAST ||*/
/*ASSERT(pLeft->type == TMQ_OFFSET__RESET_NONE || pLeft->type == TMQ_OFFSET__RESET_EARLIEAST ||*/
...
@@ -5816,6 +5812,21 @@ int32_t tDecodeDeleteRes(SDecoder *pCoder, SDeleteRes *pRes) {
...
@@ -5816,6 +5812,21 @@ int32_t tDecodeDeleteRes(SDecoder *pCoder, SDeleteRes *pRes) {
if
(
tDecodeCStrTo
(
pCoder
,
pRes
->
tsColName
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
pCoder
,
pRes
->
tsColName
)
<
0
)
return
-
1
;
return
0
;
return
0
;
}
}
int32_t
tEncodeSMqMetaRsp
(
SEncoder
*
pEncoder
,
const
SMqMetaRsp
*
pRsp
)
{
if
(
tEncodeSTqOffsetVal
(
pEncoder
,
&
pRsp
->
rspOffset
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
pEncoder
,
pRsp
->
resMsgType
))
return
-
1
;
if
(
tEncodeBinary
(
pEncoder
,
pRsp
->
metaRsp
,
pRsp
->
metaRspLen
))
return
-
1
;
return
0
;
}
int32_t
tDecodeSMqMetaRsp
(
SDecoder
*
pDecoder
,
SMqMetaRsp
*
pRsp
)
{
if
(
tDecodeSTqOffsetVal
(
pDecoder
,
&
pRsp
->
rspOffset
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
pDecoder
,
&
pRsp
->
resMsgType
)
<
0
)
return
-
1
;
if
(
tDecodeBinaryAlloc
(
pDecoder
,
&
pRsp
->
metaRsp
,
(
uint64_t
*
)
&
pRsp
->
metaRspLen
)
<
0
)
return
-
1
;
return
0
;
}
int32_t
tEncodeSMqDataRsp
(
SEncoder
*
pEncoder
,
const
SMqDataRsp
*
pRsp
)
{
int32_t
tEncodeSMqDataRsp
(
SEncoder
*
pEncoder
,
const
SMqDataRsp
*
pRsp
)
{
if
(
tEncodeSTqOffsetVal
(
pEncoder
,
&
pRsp
->
reqOffset
)
<
0
)
return
-
1
;
if
(
tEncodeSTqOffsetVal
(
pEncoder
,
&
pRsp
->
reqOffset
)
<
0
)
return
-
1
;
if
(
tEncodeSTqOffsetVal
(
pEncoder
,
&
pRsp
->
rspOffset
)
<
0
)
return
-
1
;
if
(
tEncodeSTqOffsetVal
(
pEncoder
,
&
pRsp
->
rspOffset
)
<
0
)
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
2ad31384
...
@@ -536,7 +536,7 @@ int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate) {
...
@@ -536,7 +536,7 @@ int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate) {
return
-
1
;
return
-
1
;
}
}
if
(
pCreate
->
numOfColumns
<
TSDB_MIN_COLUMNS
||
pCreate
->
numOfColumns
>
TSDB_MAX_COLUMNS
)
{
if
(
pCreate
->
numOfColumns
<
TSDB_MIN_COLUMNS
||
pCreate
->
numOf
Tags
+
pCreate
->
numOf
Columns
>
TSDB_MAX_COLUMNS
)
{
terrno
=
TSDB_CODE_PAR_INVALID_COLUMNS_NUM
;
terrno
=
TSDB_CODE_PAR_INVALID_COLUMNS_NUM
;
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
2ad31384
...
@@ -157,6 +157,31 @@ void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity);
...
@@ -157,6 +157,31 @@ void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity);
size_t
tsdbCacheGetCapacity
(
SVnode
*
pVnode
);
size_t
tsdbCacheGetCapacity
(
SVnode
*
pVnode
);
// tq
// tq
typedef
struct
SMetaTableInfo
{
int64_t
suid
;
int64_t
uid
;
SSchemaWrapper
*
schema
;
char
tbName
[
TSDB_TABLE_NAME_LEN
];
}
SMetaTableInfo
;
typedef
struct
SIdInfo
{
int64_t
version
;
int32_t
index
;
}
SIdInfo
;
typedef
struct
SSnapContext
{
SMeta
*
pMeta
;
int64_t
snapVersion
;
TBC
*
pCur
;
int64_t
suid
;
int8_t
subType
;
SHashObj
*
idVersion
;
SHashObj
*
suidInfo
;
SArray
*
idList
;
int32_t
index
;
bool
withMeta
;
bool
queryMetaOrData
;
// true-get meta, false-get data
}
SSnapContext
;
typedef
struct
STqReader
{
typedef
struct
STqReader
{
int64_t
ver
;
int64_t
ver
;
...
@@ -207,6 +232,12 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWr
...
@@ -207,6 +232,12 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWr
int32_t
vnodeSnapWriterClose
(
SVSnapWriter
*
pWriter
,
int8_t
rollback
,
SSnapshot
*
pSnapshot
);
int32_t
vnodeSnapWriterClose
(
SVSnapWriter
*
pWriter
,
int8_t
rollback
,
SSnapshot
*
pSnapshot
);
int32_t
vnodeSnapWrite
(
SVSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
);
int32_t
vnodeSnapWrite
(
SVSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
);
int32_t
buildSnapContext
(
SMeta
*
pMeta
,
int64_t
snapVersion
,
int64_t
suid
,
int8_t
subType
,
bool
withMeta
,
SSnapContext
**
ctxRet
);
int32_t
getMetafromSnapShot
(
SSnapContext
*
ctx
,
void
**
pBuf
,
int32_t
*
contLen
,
int16_t
*
type
,
int64_t
*
uid
);
SMetaTableInfo
getUidfromSnapShot
(
SSnapContext
*
ctx
);
int32_t
setForSnapShot
(
SSnapContext
*
ctx
,
int64_t
uid
);
int32_t
destroySnapContext
(
SSnapContext
*
ctx
);
// structs
// structs
struct
STsdbCfg
{
struct
STsdbCfg
{
int8_t
precision
;
int8_t
precision
;
...
...
source/dnode/vnode/src/inc/tq.h
浏览文件 @
2ad31384
...
@@ -68,7 +68,6 @@ typedef struct {
...
@@ -68,7 +68,6 @@ typedef struct {
typedef
struct
{
typedef
struct
{
char
*
qmsg
;
char
*
qmsg
;
qTaskInfo_t
task
;
}
STqExecCol
;
}
STqExecCol
;
typedef
struct
{
typedef
struct
{
...
@@ -83,12 +82,13 @@ typedef struct {
...
@@ -83,12 +82,13 @@ typedef struct {
int8_t
subType
;
int8_t
subType
;
STqReader
*
pExecReader
;
STqReader
*
pExecReader
;
qTaskInfo_t
task
;
union
{
union
{
STqExecCol
execCol
;
STqExecCol
execCol
;
STqExecTb
execTb
;
STqExecTb
execTb
;
STqExecDb
execDb
;
STqExecDb
execDb
;
};
};
int32_t
numOfCols
;
// number of out pout column, temporarily used
//
int32_t numOfCols; // number of out pout column, temporarily used
SSchemaWrapper
*
pSchemaWrapper
;
// columns that are involved in query
SSchemaWrapper
*
pSchemaWrapper
;
// columns that are involved in query
}
STqExecHandle
;
}
STqExecHandle
;
...
@@ -101,7 +101,6 @@ typedef struct {
...
@@ -101,7 +101,6 @@ typedef struct {
int64_t
snapshotVer
;
int64_t
snapshotVer
;
// TODO remove
SWalReader
*
pWalReader
;
SWalReader
*
pWalReader
;
SWalRef
*
pRef
;
SWalRef
*
pRef
;
...
@@ -141,7 +140,7 @@ int32_t tEncodeSTqHandle(SEncoder* pEncoder, const STqHandle* pHandle);
...
@@ -141,7 +140,7 @@ int32_t tEncodeSTqHandle(SEncoder* pEncoder, const STqHandle* pHandle);
int32_t
tDecodeSTqHandle
(
SDecoder
*
pDecoder
,
STqHandle
*
pHandle
);
int32_t
tDecodeSTqHandle
(
SDecoder
*
pDecoder
,
STqHandle
*
pHandle
);
// tqRead
// tqRead
int64_t
tqScan
(
STQ
*
pTq
,
const
STqHandle
*
pHandle
,
SMqDataRsp
*
pRsp
,
STqOffsetVal
*
offset
);
int64_t
tqScan
(
STQ
*
pTq
,
const
STqHandle
*
pHandle
,
SMqDataRsp
*
pRsp
,
S
MqMetaRsp
*
pMetaRsp
,
S
TqOffsetVal
*
offset
);
int64_t
tqFetchLog
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
int64_t
*
fetchOffset
,
SWalCkHead
**
pHeadWithCkSum
);
int64_t
tqFetchLog
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
int64_t
*
fetchOffset
,
SWalCkHead
**
pHeadWithCkSum
);
// tqExec
// tqExec
...
@@ -182,6 +181,11 @@ static FORCE_INLINE void tqOffsetResetToData(STqOffsetVal* pOffsetVal, int64_t u
...
@@ -182,6 +181,11 @@ static FORCE_INLINE void tqOffsetResetToData(STqOffsetVal* pOffsetVal, int64_t u
pOffsetVal
->
ts
=
ts
;
pOffsetVal
->
ts
=
ts
;
}
}
static
FORCE_INLINE
void
tqOffsetResetToMeta
(
STqOffsetVal
*
pOffsetVal
,
int64_t
uid
)
{
pOffsetVal
->
type
=
TMQ_OFFSET__SNAPSHOT_META
;
pOffsetVal
->
uid
=
uid
;
}
static
FORCE_INLINE
void
tqOffsetResetToLog
(
STqOffsetVal
*
pOffsetVal
,
int64_t
ver
)
{
static
FORCE_INLINE
void
tqOffsetResetToLog
(
STqOffsetVal
*
pOffsetVal
,
int64_t
ver
)
{
pOffsetVal
->
type
=
TMQ_OFFSET__LOG
;
pOffsetVal
->
type
=
TMQ_OFFSET__LOG
;
pOffsetVal
->
version
=
ver
;
pOffsetVal
->
version
=
ver
;
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
2ad31384
...
@@ -887,6 +887,37 @@ const void *metaGetTableTagVal(void *pTag, int16_t type, STagVal *val) {
...
@@ -887,6 +887,37 @@ const void *metaGetTableTagVal(void *pTag, int16_t type, STagVal *val) {
if
(
!
find
)
{
if
(
!
find
)
{
return
NULL
;
return
NULL
;
}
}
#ifdef TAG_FILTER_DEBUG
if
(
IS_VAR_DATA_TYPE
(
val
->
type
))
{
char
*
buf
=
taosMemoryCalloc
(
val
->
nData
+
1
,
1
);
memcpy
(
buf
,
val
->
pData
,
val
->
nData
);
metaDebug
(
"metaTag table val varchar index:%d cid:%d type:%d value:%s"
,
1
,
val
->
cid
,
val
->
type
,
buf
);
taosMemoryFree
(
buf
);
}
else
{
double
dval
=
0
;
GET_TYPED_DATA
(
dval
,
double
,
val
->
type
,
&
val
->
i64
);
metaDebug
(
"metaTag table val number index:%d cid:%d type:%d value:%f"
,
1
,
val
->
cid
,
val
->
type
,
dval
);
}
SArray
*
pTagVals
=
NULL
;
tTagToValArray
((
STag
*
)
pTag
,
&
pTagVals
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pTagVals
);
i
++
)
{
STagVal
*
pTagVal
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
i
);
if
(
IS_VAR_DATA_TYPE
(
pTagVal
->
type
))
{
char
*
buf
=
taosMemoryCalloc
(
pTagVal
->
nData
+
1
,
1
);
memcpy
(
buf
,
pTagVal
->
pData
,
pTagVal
->
nData
);
metaDebug
(
"metaTag table varchar index:%d cid:%d type:%d value:%s"
,
i
,
pTagVal
->
cid
,
pTagVal
->
type
,
buf
);
taosMemoryFree
(
buf
);
}
else
{
double
dval
=
0
;
GET_TYPED_DATA
(
dval
,
double
,
pTagVal
->
type
,
&
pTagVal
->
i64
);
metaDebug
(
"metaTag table number index:%d cid:%d type:%d value:%f"
,
i
,
pTagVal
->
cid
,
pTagVal
->
type
,
dval
);
}
}
#endif
return
val
;
return
val
;
}
}
...
...
source/dnode/vnode/src/meta/metaSnapshot.c
浏览文件 @
2ad31384
...
@@ -195,3 +195,434 @@ _err:
...
@@ -195,3 +195,434 @@ _err:
metaError
(
"vgId:%d, vnode snapshot meta write failed since %s"
,
TD_VID
(
pMeta
->
pVnode
),
tstrerror
(
code
));
metaError
(
"vgId:%d, vnode snapshot meta write failed since %s"
,
TD_VID
(
pMeta
->
pVnode
),
tstrerror
(
code
));
return
code
;
return
code
;
}
}
typedef
struct
STableInfoForChildTable
{
char
*
tableName
;
SSchemaWrapper
*
schemaRow
;
SSchemaWrapper
*
tagRow
;
}
STableInfoForChildTable
;
static
void
destroySTableInfoForChildTable
(
void
*
data
)
{
STableInfoForChildTable
*
pData
=
(
STableInfoForChildTable
*
)
data
;
taosMemoryFree
(
pData
->
tableName
);
tDeleteSSchemaWrapper
(
pData
->
schemaRow
);
tDeleteSSchemaWrapper
(
pData
->
tagRow
);
}
static
void
MoveToSnapShotVersion
(
SSnapContext
*
ctx
){
tdbTbcClose
(
ctx
->
pCur
);
tdbTbcOpen
(
ctx
->
pMeta
->
pTbDb
,
&
ctx
->
pCur
,
NULL
);
STbDbKey
key
=
{.
version
=
ctx
->
snapVersion
,
.
uid
=
INT64_MAX
};
int
c
=
0
;
tdbTbcMoveTo
(
ctx
->
pCur
,
&
key
,
sizeof
(
key
),
&
c
);
if
(
c
<
0
){
tdbTbcMoveToPrev
(
ctx
->
pCur
);
}
}
static
int32_t
MoveToPosition
(
SSnapContext
*
ctx
,
int64_t
ver
,
int64_t
uid
){
tdbTbcClose
(
ctx
->
pCur
);
tdbTbcOpen
(
ctx
->
pMeta
->
pTbDb
,
&
ctx
->
pCur
,
NULL
);
STbDbKey
key
=
{.
version
=
ver
,
.
uid
=
uid
};
int
c
=
0
;
tdbTbcMoveTo
(
ctx
->
pCur
,
&
key
,
sizeof
(
key
),
&
c
);
return
c
;
}
static
void
MoveToFirst
(
SSnapContext
*
ctx
){
tdbTbcClose
(
ctx
->
pCur
);
tdbTbcOpen
(
ctx
->
pMeta
->
pTbDb
,
&
ctx
->
pCur
,
NULL
);
tdbTbcMoveToFirst
(
ctx
->
pCur
);
}
static
void
saveSuperTableInfoForChildTable
(
SMetaEntry
*
me
,
SHashObj
*
suidInfo
){
STableInfoForChildTable
*
data
=
(
STableInfoForChildTable
*
)
taosHashGet
(
suidInfo
,
&
me
->
uid
,
sizeof
(
tb_uid_t
));
if
(
data
){
return
;
}
STableInfoForChildTable
dataTmp
=
{
0
};
dataTmp
.
tableName
=
strdup
(
me
->
name
);
dataTmp
.
schemaRow
=
tCloneSSchemaWrapper
(
&
me
->
stbEntry
.
schemaRow
);
dataTmp
.
tagRow
=
tCloneSSchemaWrapper
(
&
me
->
stbEntry
.
schemaTag
);
taosHashPut
(
suidInfo
,
&
me
->
uid
,
sizeof
(
tb_uid_t
),
&
dataTmp
,
sizeof
(
STableInfoForChildTable
));
}
int32_t
buildSnapContext
(
SMeta
*
pMeta
,
int64_t
snapVersion
,
int64_t
suid
,
int8_t
subType
,
bool
withMeta
,
SSnapContext
**
ctxRet
){
SSnapContext
*
ctx
=
taosMemoryCalloc
(
1
,
sizeof
(
SSnapContext
));
if
(
ctx
==
NULL
)
return
-
1
;
*
ctxRet
=
ctx
;
ctx
->
pMeta
=
pMeta
;
ctx
->
snapVersion
=
snapVersion
;
ctx
->
suid
=
suid
;
ctx
->
subType
=
subType
;
ctx
->
queryMetaOrData
=
withMeta
;
ctx
->
withMeta
=
withMeta
;
ctx
->
idVersion
=
taosHashInit
(
100
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_NO_LOCK
);
if
(
ctx
->
idVersion
==
NULL
){
return
-
1
;
}
ctx
->
suidInfo
=
taosHashInit
(
100
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_NO_LOCK
);
if
(
ctx
->
suidInfo
==
NULL
){
return
-
1
;
}
taosHashSetFreeFp
(
ctx
->
suidInfo
,
destroySTableInfoForChildTable
);
ctx
->
index
=
0
;
ctx
->
idList
=
taosArrayInit
(
100
,
sizeof
(
int64_t
));
void
*
pKey
=
NULL
;
void
*
pVal
=
NULL
;
int
vLen
=
0
,
kLen
=
0
;
metaDebug
(
"tmqsnap init snapVersion:%"
PRIi64
,
ctx
->
snapVersion
);
MoveToFirst
(
ctx
);
while
(
1
){
int32_t
ret
=
tdbTbcNext
(
ctx
->
pCur
,
&
pKey
,
&
kLen
,
&
pVal
,
&
vLen
);
if
(
ret
<
0
)
break
;
STbDbKey
*
tmp
=
(
STbDbKey
*
)
pKey
;
if
(
tmp
->
version
>
ctx
->
snapVersion
)
break
;
SIdInfo
*
idData
=
(
SIdInfo
*
)
taosHashGet
(
ctx
->
idVersion
,
&
tmp
->
uid
,
sizeof
(
tb_uid_t
));
if
(
idData
)
{
continue
;
}
if
(
tdbTbGet
(
pMeta
->
pUidIdx
,
&
tmp
->
uid
,
sizeof
(
tb_uid_t
),
NULL
,
NULL
)
<
0
)
{
// check if table exist for now, need optimize later
continue
;
}
SDecoder
dc
=
{
0
};
SMetaEntry
me
=
{
0
};
tDecoderInit
(
&
dc
,
pVal
,
vLen
);
metaDecodeEntry
(
&
dc
,
&
me
);
if
(
ctx
->
subType
==
TOPIC_SUB_TYPE__TABLE
){
if
((
me
.
uid
!=
ctx
->
suid
&&
me
.
type
==
TSDB_SUPER_TABLE
)
||
(
me
.
ctbEntry
.
suid
!=
ctx
->
suid
&&
me
.
type
==
TSDB_CHILD_TABLE
)){
tDecoderClear
(
&
dc
);
continue
;
}
}
taosArrayPush
(
ctx
->
idList
,
&
tmp
->
uid
);
metaDebug
(
"tmqsnap init idlist name:%s, uid:%"
PRIi64
,
me
.
name
,
tmp
->
uid
);
SIdInfo
info
=
{
0
};
taosHashPut
(
ctx
->
idVersion
,
&
tmp
->
uid
,
sizeof
(
tb_uid_t
),
&
info
,
sizeof
(
SIdInfo
));
tDecoderClear
(
&
dc
);
}
taosHashClear
(
ctx
->
idVersion
);
MoveToSnapShotVersion
(
ctx
);
while
(
1
){
int32_t
ret
=
tdbTbcPrev
(
ctx
->
pCur
,
&
pKey
,
&
kLen
,
&
pVal
,
&
vLen
);
if
(
ret
<
0
)
break
;
STbDbKey
*
tmp
=
(
STbDbKey
*
)
pKey
;
SIdInfo
*
idData
=
(
SIdInfo
*
)
taosHashGet
(
ctx
->
idVersion
,
&
tmp
->
uid
,
sizeof
(
tb_uid_t
));
if
(
idData
){
continue
;
}
SIdInfo
info
=
{.
version
=
tmp
->
version
,
.
index
=
0
};
taosHashPut
(
ctx
->
idVersion
,
&
tmp
->
uid
,
sizeof
(
tb_uid_t
),
&
info
,
sizeof
(
SIdInfo
));
SDecoder
dc
=
{
0
};
SMetaEntry
me
=
{
0
};
tDecoderInit
(
&
dc
,
pVal
,
vLen
);
metaDecodeEntry
(
&
dc
,
&
me
);
if
(
ctx
->
subType
==
TOPIC_SUB_TYPE__TABLE
){
if
((
me
.
uid
!=
ctx
->
suid
&&
me
.
type
==
TSDB_SUPER_TABLE
)
||
(
me
.
ctbEntry
.
suid
!=
ctx
->
suid
&&
me
.
type
==
TSDB_CHILD_TABLE
)){
tDecoderClear
(
&
dc
);
continue
;
}
}
if
((
ctx
->
subType
==
TOPIC_SUB_TYPE__DB
&&
me
.
type
==
TSDB_SUPER_TABLE
)
||
(
ctx
->
subType
==
TOPIC_SUB_TYPE__TABLE
&&
me
.
uid
==
ctx
->
suid
))
{
saveSuperTableInfoForChildTable
(
&
me
,
ctx
->
suidInfo
);
}
tDecoderClear
(
&
dc
);
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
ctx
->
idList
);
i
++
){
int64_t
*
uid
=
taosArrayGet
(
ctx
->
idList
,
i
);
SIdInfo
*
idData
=
(
SIdInfo
*
)
taosHashGet
(
ctx
->
idVersion
,
uid
,
sizeof
(
int64_t
));
ASSERT
(
idData
);
idData
->
index
=
i
;
metaDebug
(
"tmqsnap init idVersion uid:%"
PRIi64
" version:%"
PRIi64
" index:%d"
,
*
uid
,
idData
->
version
,
idData
->
index
);
}
return
TDB_CODE_SUCCESS
;
}
int32_t
destroySnapContext
(
SSnapContext
*
ctx
){
tdbTbcClose
(
ctx
->
pCur
);
taosArrayDestroy
(
ctx
->
idList
);
taosHashCleanup
(
ctx
->
idVersion
);
taosHashCleanup
(
ctx
->
suidInfo
);
taosMemoryFree
(
ctx
);
return
0
;
}
static
int32_t
buildNormalChildTableInfo
(
SVCreateTbReq
*
req
,
void
**
pBuf
,
int32_t
*
contLen
){
int32_t
ret
=
0
;
SVCreateTbBatchReq
reqs
=
{
0
};
reqs
.
pArray
=
taosArrayInit
(
1
,
sizeof
(
struct
SVCreateTbReq
));
if
(
NULL
==
reqs
.
pArray
){
ret
=
-
1
;
goto
end
;
}
taosArrayPush
(
reqs
.
pArray
,
req
);
reqs
.
nReqs
=
1
;
tEncodeSize
(
tEncodeSVCreateTbBatchReq
,
&
reqs
,
*
contLen
,
ret
);
if
(
ret
<
0
){
ret
=
-
1
;
goto
end
;
}
*
contLen
+=
sizeof
(
SMsgHead
);
*
pBuf
=
taosMemoryMalloc
(
*
contLen
);
if
(
NULL
==
*
pBuf
)
{
ret
=
-
1
;
goto
end
;
}
SEncoder
coder
=
{
0
};
tEncoderInit
(
&
coder
,
POINTER_SHIFT
(
*
pBuf
,
sizeof
(
SMsgHead
)),
*
contLen
);
if
(
tEncodeSVCreateTbBatchReq
(
&
coder
,
&
reqs
)
<
0
)
{
taosMemoryFreeClear
(
*
pBuf
);
tEncoderClear
(
&
coder
);
ret
=
-
1
;
goto
end
;
}
tEncoderClear
(
&
coder
);
end:
taosArrayDestroy
(
reqs
.
pArray
);
return
ret
;
}
static
int32_t
buildSuperTableInfo
(
SVCreateStbReq
*
req
,
void
**
pBuf
,
int32_t
*
contLen
){
int32_t
ret
=
0
;
tEncodeSize
(
tEncodeSVCreateStbReq
,
req
,
*
contLen
,
ret
);
if
(
ret
<
0
)
{
return
-
1
;
}
*
contLen
+=
sizeof
(
SMsgHead
);
*
pBuf
=
taosMemoryMalloc
(
*
contLen
);
if
(
NULL
==
*
pBuf
)
{
return
-
1
;
}
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
POINTER_SHIFT
(
*
pBuf
,
sizeof
(
SMsgHead
)),
*
contLen
);
if
(
tEncodeSVCreateStbReq
(
&
encoder
,
req
)
<
0
)
{
taosMemoryFreeClear
(
*
pBuf
);
tEncoderClear
(
&
encoder
);
return
-
1
;
}
tEncoderClear
(
&
encoder
);
return
0
;
}
int32_t
setForSnapShot
(
SSnapContext
*
ctx
,
int64_t
uid
){
int
c
=
0
;
if
(
uid
==
0
){
ctx
->
index
=
0
;
return
c
;
}
SIdInfo
*
idInfo
=
(
SIdInfo
*
)
taosHashGet
(
ctx
->
idVersion
,
&
uid
,
sizeof
(
tb_uid_t
));
if
(
!
idInfo
){
return
-
1
;
}
ctx
->
index
=
idInfo
->
index
;
return
c
;
}
int32_t
getMetafromSnapShot
(
SSnapContext
*
ctx
,
void
**
pBuf
,
int32_t
*
contLen
,
int16_t
*
type
,
int64_t
*
uid
){
int32_t
ret
=
0
;
void
*
pKey
=
NULL
;
void
*
pVal
=
NULL
;
int
vLen
=
0
,
kLen
=
0
;
while
(
1
){
if
(
ctx
->
index
>=
taosArrayGetSize
(
ctx
->
idList
)){
metaDebug
(
"tmqsnap get meta end"
);
ctx
->
index
=
0
;
ctx
->
queryMetaOrData
=
false
;
// change to get data
return
0
;
}
int64_t
*
uidTmp
=
taosArrayGet
(
ctx
->
idList
,
ctx
->
index
);
ctx
->
index
++
;
SIdInfo
*
idInfo
=
(
SIdInfo
*
)
taosHashGet
(
ctx
->
idVersion
,
uidTmp
,
sizeof
(
tb_uid_t
));
ASSERT
(
idInfo
);
*
uid
=
*
uidTmp
;
ret
=
MoveToPosition
(
ctx
,
idInfo
->
version
,
*
uidTmp
);
if
(
ret
==
0
){
break
;
}
metaDebug
(
"tmqsnap get meta not exist uid:%"
PRIi64
" version:%"
PRIi64
,
*
uid
,
idInfo
->
version
);
}
tdbTbcGet
(
ctx
->
pCur
,
(
const
void
**
)
&
pKey
,
&
kLen
,
(
const
void
**
)
&
pVal
,
&
vLen
);
SDecoder
dc
=
{
0
};
SMetaEntry
me
=
{
0
};
tDecoderInit
(
&
dc
,
pVal
,
vLen
);
metaDecodeEntry
(
&
dc
,
&
me
);
metaDebug
(
"tmqsnap get meta uid:%"
PRIi64
" name:%s index:%d"
,
*
uid
,
me
.
name
,
ctx
->
index
-
1
);
if
((
ctx
->
subType
==
TOPIC_SUB_TYPE__DB
&&
me
.
type
==
TSDB_SUPER_TABLE
)
||
(
ctx
->
subType
==
TOPIC_SUB_TYPE__TABLE
&&
me
.
uid
==
ctx
->
suid
))
{
SVCreateStbReq
req
=
{
0
};
req
.
name
=
me
.
name
;
req
.
suid
=
me
.
uid
;
req
.
schemaRow
=
me
.
stbEntry
.
schemaRow
;
req
.
schemaTag
=
me
.
stbEntry
.
schemaTag
;
req
.
schemaRow
.
version
=
1
;
req
.
schemaTag
.
version
=
1
;
ret
=
buildSuperTableInfo
(
&
req
,
pBuf
,
contLen
);
*
type
=
TDMT_VND_CREATE_STB
;
}
else
if
((
ctx
->
subType
==
TOPIC_SUB_TYPE__DB
&&
me
.
type
==
TSDB_CHILD_TABLE
)
||
(
ctx
->
subType
==
TOPIC_SUB_TYPE__TABLE
&&
me
.
type
==
TSDB_CHILD_TABLE
&&
me
.
ctbEntry
.
suid
==
ctx
->
suid
))
{
STableInfoForChildTable
*
data
=
(
STableInfoForChildTable
*
)
taosHashGet
(
ctx
->
suidInfo
,
&
me
.
ctbEntry
.
suid
,
sizeof
(
tb_uid_t
));
ASSERT
(
data
);
SVCreateTbReq
req
=
{
0
};
req
.
type
=
TSDB_CHILD_TABLE
;
req
.
name
=
me
.
name
;
req
.
uid
=
me
.
uid
;
req
.
commentLen
=
-
1
;
req
.
ctb
.
suid
=
me
.
ctbEntry
.
suid
;
req
.
ctb
.
tagNum
=
data
->
tagRow
->
nCols
;
req
.
ctb
.
name
=
data
->
tableName
;
SArray
*
tagName
=
taosArrayInit
(
req
.
ctb
.
tagNum
,
TSDB_COL_NAME_LEN
);
STag
*
p
=
(
STag
*
)
me
.
ctbEntry
.
pTags
;
if
(
tTagIsJson
(
p
)){
if
(
p
->
nTag
!=
0
)
{
SSchema
*
schema
=
&
data
->
tagRow
->
pSchema
[
0
];
taosArrayPush
(
tagName
,
schema
->
name
);
}
}
else
{
SArray
*
pTagVals
=
NULL
;
if
(
tTagToValArray
((
const
STag
*
)
p
,
&
pTagVals
)
!=
0
)
{
ASSERT
(
0
);
}
int16_t
nCols
=
taosArrayGetSize
(
pTagVals
);
for
(
int
j
=
0
;
j
<
nCols
;
++
j
)
{
STagVal
*
pTagVal
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
j
);
for
(
int
i
=
0
;
i
<
data
->
tagRow
->
nCols
;
i
++
){
SSchema
*
schema
=
&
data
->
tagRow
->
pSchema
[
i
];
if
(
schema
->
colId
==
pTagVal
->
cid
){
taosArrayPush
(
tagName
,
schema
->
name
);
}
}
}
}
// SIdInfo* sidInfo = (SIdInfo*)taosHashGet(ctx->idVersion, &me.ctbEntry.suid, sizeof(tb_uid_t));
// if(sidInfo->version >= idInfo->version){
// // need parse tag
// STag* p = (STag*)me.ctbEntry.pTags;
// SArray* pTagVals = NULL;
// if (tTagToValArray((const STag*)p, &pTagVals) != 0) {
// }
//
// int16_t nCols = taosArrayGetSize(pTagVals);
// for (int j = 0; j < nCols; ++j) {
// STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, j);
// }
// }else{
req
.
ctb
.
pTag
=
me
.
ctbEntry
.
pTags
;
// }
req
.
ctb
.
tagName
=
tagName
;
ret
=
buildNormalChildTableInfo
(
&
req
,
pBuf
,
contLen
);
*
type
=
TDMT_VND_CREATE_TABLE
;
taosArrayDestroy
(
tagName
);
}
else
if
(
ctx
->
subType
==
TOPIC_SUB_TYPE__DB
){
SVCreateTbReq
req
=
{
0
};
req
.
type
=
TSDB_NORMAL_TABLE
;
req
.
name
=
me
.
name
;
req
.
uid
=
me
.
uid
;
req
.
commentLen
=
-
1
;
req
.
ntb
.
schemaRow
=
me
.
ntbEntry
.
schemaRow
;
ret
=
buildNormalChildTableInfo
(
&
req
,
pBuf
,
contLen
);
*
type
=
TDMT_VND_CREATE_TABLE
;
}
else
{
ASSERT
(
0
);
}
tDecoderClear
(
&
dc
);
return
ret
;
}
SMetaTableInfo
getUidfromSnapShot
(
SSnapContext
*
ctx
){
SMetaTableInfo
result
=
{
0
};
void
*
pKey
=
NULL
;
void
*
pVal
=
NULL
;
int
vLen
,
kLen
;
while
(
1
){
if
(
ctx
->
index
>=
taosArrayGetSize
(
ctx
->
idList
)){
metaDebug
(
"tmqsnap get uid info end"
);
return
result
;
}
int64_t
*
uidTmp
=
taosArrayGet
(
ctx
->
idList
,
ctx
->
index
);
ctx
->
index
++
;
SIdInfo
*
idInfo
=
(
SIdInfo
*
)
taosHashGet
(
ctx
->
idVersion
,
uidTmp
,
sizeof
(
tb_uid_t
));
ASSERT
(
idInfo
);
int32_t
ret
=
MoveToPosition
(
ctx
,
idInfo
->
version
,
*
uidTmp
);
if
(
ret
!=
0
)
{
metaDebug
(
"tmqsnap getUidfromSnapShot not exist uid:%"
PRIi64
" version:%"
PRIi64
,
*
uidTmp
,
idInfo
->
version
);
continue
;
}
tdbTbcGet
(
ctx
->
pCur
,
(
const
void
**
)
&
pKey
,
&
kLen
,
(
const
void
**
)
&
pVal
,
&
vLen
);
SDecoder
dc
=
{
0
};
SMetaEntry
me
=
{
0
};
tDecoderInit
(
&
dc
,
pVal
,
vLen
);
metaDecodeEntry
(
&
dc
,
&
me
);
metaDebug
(
"tmqsnap get uid info uid:%"
PRIi64
" name:%s index:%d"
,
me
.
uid
,
me
.
name
,
ctx
->
index
-
1
);
if
(
ctx
->
subType
==
TOPIC_SUB_TYPE__DB
&&
me
.
type
==
TSDB_CHILD_TABLE
){
STableInfoForChildTable
*
data
=
(
STableInfoForChildTable
*
)
taosHashGet
(
ctx
->
suidInfo
,
&
me
.
ctbEntry
.
suid
,
sizeof
(
tb_uid_t
));
result
.
uid
=
me
.
uid
;
result
.
suid
=
me
.
ctbEntry
.
suid
;
result
.
schema
=
tCloneSSchemaWrapper
(
data
->
schemaRow
);
strcpy
(
result
.
tbName
,
me
.
name
);
tDecoderClear
(
&
dc
);
break
;
}
else
if
(
ctx
->
subType
==
TOPIC_SUB_TYPE__DB
&&
me
.
type
==
TSDB_NORMAL_TABLE
)
{
result
.
uid
=
me
.
uid
;
result
.
suid
=
0
;
strcpy
(
result
.
tbName
,
me
.
name
);
result
.
schema
=
tCloneSSchemaWrapper
(
&
me
.
ntbEntry
.
schemaRow
);
tDecoderClear
(
&
dc
);
break
;
}
else
if
(
ctx
->
subType
==
TOPIC_SUB_TYPE__TABLE
&&
me
.
type
==
TSDB_CHILD_TABLE
&&
me
.
ctbEntry
.
suid
==
ctx
->
suid
)
{
STableInfoForChildTable
*
data
=
(
STableInfoForChildTable
*
)
taosHashGet
(
ctx
->
suidInfo
,
&
me
.
ctbEntry
.
suid
,
sizeof
(
tb_uid_t
));
result
.
uid
=
me
.
uid
;
result
.
suid
=
me
.
ctbEntry
.
suid
;
strcpy
(
result
.
tbName
,
me
.
name
);
result
.
schema
=
tCloneSSchemaWrapper
(
data
->
schemaRow
);
tDecoderClear
(
&
dc
);
break
;
}
else
{
metaDebug
(
"tmqsnap get uid continue"
);
tDecoderClear
(
&
dc
);
continue
;
}
}
return
result
;
}
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
2ad31384
...
@@ -99,6 +99,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
...
@@ -99,6 +99,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
memcpy
(
val
,
(
uint16_t
*
)
&
len
,
VARSTR_HEADER_SIZE
);
memcpy
(
val
,
(
uint16_t
*
)
&
len
,
VARSTR_HEADER_SIZE
);
type
=
TSDB_DATA_TYPE_VARCHAR
;
type
=
TSDB_DATA_TYPE_VARCHAR
;
term
=
indexTermCreate
(
suid
,
ADD_VALUE
,
type
,
key
,
nKey
,
val
,
len
);
term
=
indexTermCreate
(
suid
,
ADD_VALUE
,
type
,
key
,
nKey
,
val
,
len
);
taosMemoryFree
(
val
);
}
else
if
(
pTagVal
->
nData
==
0
)
{
}
else
if
(
pTagVal
->
nData
==
0
)
{
term
=
indexTermCreate
(
suid
,
ADD_VALUE
,
TSDB_DATA_TYPE_VARCHAR
,
key
,
nKey
,
pTagVal
->
pData
,
0
);
term
=
indexTermCreate
(
suid
,
ADD_VALUE
,
TSDB_DATA_TYPE_VARCHAR
,
key
,
nKey
,
pTagVal
->
pData
,
0
);
}
}
...
@@ -115,6 +116,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
...
@@ -115,6 +116,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
indexMultiTermAdd
(
terms
,
term
);
indexMultiTermAdd
(
terms
,
term
);
}
}
}
}
taosArrayDestroy
(
pTagVals
);
indexJsonPut
(
pMeta
->
pTagIvtIdx
,
terms
,
tuid
);
indexJsonPut
(
pMeta
->
pTagIvtIdx
,
terms
,
tuid
);
indexMultiTermDestroy
(
terms
);
indexMultiTermDestroy
(
terms
);
#endif
#endif
...
@@ -413,6 +415,25 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq, STableMe
...
@@ -413,6 +415,25 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq, STableMe
me
.
ctbEntry
.
suid
=
pReq
->
ctb
.
suid
;
me
.
ctbEntry
.
suid
=
pReq
->
ctb
.
suid
;
me
.
ctbEntry
.
pTags
=
pReq
->
ctb
.
pTag
;
me
.
ctbEntry
.
pTags
=
pReq
->
ctb
.
pTag
;
#ifdef TAG_FILTER_DEBUG
SArray
*
pTagVals
=
NULL
;
int32_t
code
=
tTagToValArray
((
STag
*
)
pReq
->
ctb
.
pTag
,
&
pTagVals
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pTagVals
);
i
++
)
{
STagVal
*
pTagVal
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
i
);
if
(
IS_VAR_DATA_TYPE
(
pTagVal
->
type
))
{
char
*
buf
=
taosMemoryCalloc
(
pTagVal
->
nData
+
1
,
1
);
memcpy
(
buf
,
pTagVal
->
pData
,
pTagVal
->
nData
);
metaDebug
(
"metaTag table:%s varchar index:%d cid:%d type:%d value:%s"
,
pReq
->
name
,
i
,
pTagVal
->
cid
,
pTagVal
->
type
,
buf
);
taosMemoryFree
(
buf
);
}
else
{
double
val
=
0
;
GET_TYPED_DATA
(
val
,
double
,
pTagVal
->
type
,
&
pTagVal
->
i64
);
metaDebug
(
"metaTag table:%s number index:%d cid:%d type:%d value:%f"
,
pReq
->
name
,
i
,
pTagVal
->
cid
,
pTagVal
->
type
,
val
);
}
}
#endif
++
pMeta
->
pVnode
->
config
.
vndStats
.
numOfCTables
;
++
pMeta
->
pVnode
->
config
.
vndStats
.
numOfCTables
;
}
else
{
}
else
{
me
.
ntbEntry
.
ctime
=
pReq
->
ctime
;
me
.
ntbEntry
.
ctime
=
pReq
->
ctime
;
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
2ad31384
...
@@ -100,7 +100,13 @@ void tqClose(STQ* pTq) {
...
@@ -100,7 +100,13 @@ void tqClose(STQ* pTq) {
}
}
int32_t
tqSendMetaPollRsp
(
STQ
*
pTq
,
const
SRpcMsg
*
pMsg
,
const
SMqPollReq
*
pReq
,
const
SMqMetaRsp
*
pRsp
)
{
int32_t
tqSendMetaPollRsp
(
STQ
*
pTq
,
const
SRpcMsg
*
pMsg
,
const
SMqPollReq
*
pReq
,
const
SMqMetaRsp
*
pRsp
)
{
int32_t
tlen
=
sizeof
(
SMqRspHead
)
+
tEncodeSMqMetaRsp
(
NULL
,
pRsp
);
int32_t
len
=
0
;
int32_t
code
=
0
;
tEncodeSize
(
tEncodeSMqMetaRsp
,
pRsp
,
len
,
code
);
if
(
code
<
0
)
{
return
-
1
;
}
int32_t
tlen
=
sizeof
(
SMqRspHead
)
+
len
;
void
*
buf
=
rpcMallocCont
(
tlen
);
void
*
buf
=
rpcMallocCont
(
tlen
);
if
(
buf
==
NULL
)
{
if
(
buf
==
NULL
)
{
return
-
1
;
return
-
1
;
...
@@ -111,7 +117,11 @@ int32_t tqSendMetaPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq,
...
@@ -111,7 +117,11 @@ int32_t tqSendMetaPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq,
((
SMqRspHead
*
)
buf
)
->
consumerId
=
pReq
->
consumerId
;
((
SMqRspHead
*
)
buf
)
->
consumerId
=
pReq
->
consumerId
;
void
*
abuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMqRspHead
));
void
*
abuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMqRspHead
));
tEncodeSMqMetaRsp
(
&
abuf
,
pRsp
);
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
abuf
,
len
);
tEncodeSMqMetaRsp
(
&
encoder
,
pRsp
);
tEncoderClear
(
&
encoder
);
SRpcMsg
resp
=
{
SRpcMsg
resp
=
{
.
info
=
pMsg
->
info
,
.
info
=
pMsg
->
info
,
...
@@ -121,9 +131,8 @@ int32_t tqSendMetaPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq,
...
@@ -121,9 +131,8 @@ int32_t tqSendMetaPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq,
};
};
tmsgSendRsp
(
&
resp
);
tmsgSendRsp
(
&
resp
);
tqDebug
(
"vgId:%d, from consumer:%"
PRId64
", (epoch %d) send rsp, res msg type %d, reqOffset:%"
PRId64
tqDebug
(
"vgId:%d, from consumer:%"
PRId64
", (epoch %d) send rsp, res msg type %d, offset type:%d"
,
", rspOffset:%"
PRId64
,
TD_VID
(
pTq
->
pVnode
),
pReq
->
consumerId
,
pReq
->
epoch
,
pRsp
->
resMsgType
,
pRsp
->
rspOffset
.
type
);
TD_VID
(
pTq
->
pVnode
),
pReq
->
consumerId
,
pReq
->
epoch
,
pRsp
->
resMsgType
,
pRsp
->
reqOffset
,
pRsp
->
rspOffset
);
return
0
;
return
0
;
}
}
...
@@ -202,7 +211,7 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, int64_t version, char* msg, int32_t m
...
@@ -202,7 +211,7 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, int64_t version, char* msg, int32_t m
}
}
tDecoderClear
(
&
decoder
);
tDecoderClear
(
&
decoder
);
if
(
offset
.
val
.
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
if
(
offset
.
val
.
type
==
TMQ_OFFSET__SNAPSHOT_DATA
||
offset
.
val
.
type
==
TMQ_OFFSET__SNAPSHOT_META
)
{
tqDebug
(
"receive offset commit msg to %s on vgId:%d, offset(type:snapshot) uid:%"
PRId64
", ts:%"
PRId64
,
tqDebug
(
"receive offset commit msg to %s on vgId:%d, offset(type:snapshot) uid:%"
PRId64
", ts:%"
PRId64
,
offset
.
subKey
,
TD_VID
(
pTq
->
pVnode
),
offset
.
val
.
uid
,
offset
.
val
.
ts
);
offset
.
subKey
,
TD_VID
(
pTq
->
pVnode
),
offset
.
val
.
uid
,
offset
.
val
.
ts
);
}
else
if
(
offset
.
val
.
type
==
TMQ_OFFSET__LOG
)
{
}
else
if
(
offset
.
val
.
type
==
TMQ_OFFSET__LOG
)
{
...
@@ -297,7 +306,6 @@ static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t su
...
@@ -297,7 +306,6 @@ static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t su
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
SMqPollReq
*
pReq
=
pMsg
->
pCont
;
SMqPollReq
*
pReq
=
pMsg
->
pCont
;
int64_t
consumerId
=
pReq
->
consumerId
;
int64_t
consumerId
=
pReq
->
consumerId
;
int64_t
timeout
=
pReq
->
timeout
;
int32_t
reqEpoch
=
pReq
->
epoch
;
int32_t
reqEpoch
=
pReq
->
epoch
;
int32_t
code
=
0
;
int32_t
code
=
0
;
STqOffsetVal
reqOffset
=
pReq
->
reqOffset
;
STqOffsetVal
reqOffset
=
pReq
->
reqOffset
;
...
@@ -349,12 +357,11 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
...
@@ -349,12 +357,11 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
TD_VID
(
pTq
->
pVnode
),
formatBuf
);
TD_VID
(
pTq
->
pVnode
),
formatBuf
);
}
else
{
}
else
{
if
(
reqOffset
.
type
==
TMQ_OFFSET__RESET_EARLIEAST
)
{
if
(
reqOffset
.
type
==
TMQ_OFFSET__RESET_EARLIEAST
)
{
if
(
pReq
->
useSnapshot
&&
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
if
(
pReq
->
useSnapshot
)
{
if
(
!
pHandle
->
fetchMeta
)
{
if
(
pHandle
->
fetchMeta
)
{
tqOffsetResetTo
Data
(
&
fetchOffsetNew
,
0
,
0
);
tqOffsetResetTo
Meta
(
&
fetchOffsetNew
,
0
);
}
else
{
}
else
{
// reset to meta
tqOffsetResetToData
(
&
fetchOffsetNew
,
0
,
0
);
ASSERT
(
0
);
}
}
}
else
{
}
else
{
tqOffsetResetToLog
(
&
fetchOffsetNew
,
walGetFirstVer
(
pTq
->
pVnode
->
pWal
));
tqOffsetResetToLog
(
&
fetchOffsetNew
,
walGetFirstVer
(
pTq
->
pVnode
->
pWal
));
...
@@ -378,28 +385,34 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
...
@@ -378,28 +385,34 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
}
}
}
}
// 3.query
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
||
fetchOffsetNew
.
type
!=
TMQ_OFFSET__LOG
){
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
SMqMetaRsp
metaRsp
=
{
0
};
/*if (fetchOffsetNew.type == TMQ_OFFSET__LOG) {*/
tqScan
(
pTq
,
pHandle
,
&
dataRsp
,
&
metaRsp
,
&
fetchOffsetNew
);
/*fetchOffsetNew.version++;*/
/*}*/
if
(
metaRsp
.
metaRspLen
>
0
){
if
(
tqScan
(
pTq
,
pHandle
,
&
dataRsp
,
&
fetchOffsetNew
)
<
0
)
{
if
(
tqSendMetaPollRsp
(
pTq
,
pMsg
,
pReq
,
&
metaRsp
)
<
0
)
{
ASSERT
(
0
);
code
=
-
1
;
code
=
-
1
;
goto
OVER
;
}
}
if
(
dataRsp
.
blockNum
==
0
)
{
tqDebug
(
"tmq poll: consumer %ld, subkey %s, vg %d, send meta offset type:%d,uid:%ld,version:%ld"
,
consumerId
,
pHandle
->
subKey
,
// TODO add to async task pool
TD_VID
(
pTq
->
pVnode
),
metaRsp
.
rspOffset
.
type
,
metaRsp
.
rspOffset
.
uid
,
metaRsp
.
rspOffset
.
version
);
/*dataRsp.rspOffset.version--;*/
taosMemoryFree
(
metaRsp
.
metaRsp
);
goto
OVER
;
}
}
if
(
dataRsp
.
blockNum
>
0
){
if
(
tqSendDataRsp
(
pTq
,
pMsg
,
pReq
,
&
dataRsp
)
<
0
)
{
if
(
tqSendDataRsp
(
pTq
,
pMsg
,
pReq
,
&
dataRsp
)
<
0
)
{
code
=
-
1
;
code
=
-
1
;
}
}
goto
OVER
;
goto
OVER
;
}
else
{
fetchOffsetNew
=
dataRsp
.
rspOffset
;
}
}
if
(
pHandle
->
execHandle
.
subType
!=
TOPIC_SUB_TYPE__COLUMN
)
{
tqDebug
(
"tmq poll: consumer %ld, subkey %s, vg %d, send data blockNum:%d, offset type:%d,uid:%ld,version:%ld"
,
consumerId
,
pHandle
->
subKey
,
ASSERT
(
fetchOffsetNew
.
type
==
TMQ_OFFSET__LOG
);
TD_VID
(
pTq
->
pVnode
),
dataRsp
.
blockNum
,
dataRsp
.
rspOffset
.
type
,
dataRsp
.
rspOffset
.
uid
,
dataRsp
.
rspOffset
.
version
);
}
if
(
pHandle
->
execHandle
.
subType
!=
TOPIC_SUB_TYPE__COLUMN
&&
fetchOffsetNew
.
type
==
TMQ_OFFSET__LOG
)
{
int64_t
fetchVer
=
fetchOffsetNew
.
version
+
1
;
int64_t
fetchVer
=
fetchOffsetNew
.
version
+
1
;
pCkHead
=
taosMemoryMalloc
(
sizeof
(
SWalCkHead
)
+
2048
);
pCkHead
=
taosMemoryMalloc
(
sizeof
(
SWalCkHead
)
+
2048
);
if
(
pCkHead
==
NULL
)
{
if
(
pCkHead
==
NULL
)
{
...
@@ -422,7 +435,6 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
...
@@ -422,7 +435,6 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
// TODO add push mgr
// TODO add push mgr
tqOffsetResetToLog
(
&
dataRsp
.
rspOffset
,
fetchVer
);
tqOffsetResetToLog
(
&
dataRsp
.
rspOffset
,
fetchVer
);
ASSERT
(
dataRsp
.
rspOffset
.
version
>=
dataRsp
.
reqOffset
.
version
);
if
(
tqSendDataRsp
(
pTq
,
pMsg
,
pReq
,
&
dataRsp
)
<
0
)
{
if
(
tqSendDataRsp
(
pTq
,
pMsg
,
pReq
,
&
dataRsp
)
<
0
)
{
code
=
-
1
;
code
=
-
1
;
}
}
...
@@ -444,8 +456,6 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
...
@@ -444,8 +456,6 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
// TODO continue scan until meeting batch requirement
// TODO continue scan until meeting batch requirement
if
(
dataRsp
.
blockNum
>
0
/* threshold */
)
{
if
(
dataRsp
.
blockNum
>
0
/* threshold */
)
{
tqOffsetResetToLog
(
&
dataRsp
.
rspOffset
,
fetchVer
);
tqOffsetResetToLog
(
&
dataRsp
.
rspOffset
,
fetchVer
);
ASSERT
(
dataRsp
.
rspOffset
.
version
>=
dataRsp
.
reqOffset
.
version
);
if
(
tqSendDataRsp
(
pTq
,
pMsg
,
pReq
,
&
dataRsp
)
<
0
)
{
if
(
tqSendDataRsp
(
pTq
,
pMsg
,
pReq
,
&
dataRsp
)
<
0
)
{
code
=
-
1
;
code
=
-
1
;
}
}
...
@@ -459,11 +469,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
...
@@ -459,11 +469,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
ASSERT
(
IS_META_MSG
(
pHead
->
msgType
));
ASSERT
(
IS_META_MSG
(
pHead
->
msgType
));
tqDebug
(
"fetch meta msg, ver:%"
PRId64
", type:%d"
,
pHead
->
version
,
pHead
->
msgType
);
tqDebug
(
"fetch meta msg, ver:%"
PRId64
", type:%d"
,
pHead
->
version
,
pHead
->
msgType
);
SMqMetaRsp
metaRsp
=
{
0
};
SMqMetaRsp
metaRsp
=
{
0
};
/*metaRsp.reqOffset = pReq->reqOffset.version;*/
tqOffsetResetToLog
(
&
metaRsp
.
rspOffset
,
fetchVer
);
metaRsp
.
rspOffset
=
fetchVer
;
/*metaRsp.rspOffsetNew.version = fetchVer;*/
tqOffsetResetToLog
(
&
metaRsp
.
reqOffsetNew
,
pReq
->
reqOffset
.
version
);
tqOffsetResetToLog
(
&
metaRsp
.
rspOffsetNew
,
fetchVer
);
metaRsp
.
resMsgType
=
pHead
->
msgType
;
metaRsp
.
resMsgType
=
pHead
->
msgType
;
metaRsp
.
metaRspLen
=
pHead
->
bodyLen
;
metaRsp
.
metaRspLen
=
pHead
->
bodyLen
;
metaRsp
.
metaRsp
=
pHead
->
body
;
metaRsp
.
metaRsp
=
pHead
->
body
;
...
@@ -477,6 +483,11 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
...
@@ -477,6 +483,11 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
}
}
}
}
// send empty to client
if
(
tqSendDataRsp
(
pTq
,
pMsg
,
pReq
,
&
dataRsp
)
<
0
)
{
code
=
-
1
;
}
OVER:
OVER:
if
(
pCkHead
)
taosMemoryFree
(
pCkHead
);
if
(
pCkHead
)
taosMemoryFree
(
pCkHead
);
// TODO wrap in destroy func
// TODO wrap in destroy func
...
@@ -561,6 +572,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe
...
@@ -561,6 +572,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe
pHandle
->
execHandle
.
subType
=
req
.
subType
;
pHandle
->
execHandle
.
subType
=
req
.
subType
;
pHandle
->
fetchMeta
=
req
.
withMeta
;
pHandle
->
fetchMeta
=
req
.
withMeta
;
// TODO version should be assigned and refed during preprocess
// TODO version should be assigned and refed during preprocess
SWalRef
*
pRef
=
walRefCommittedVer
(
pTq
->
pVnode
->
pWal
);
SWalRef
*
pRef
=
walRefCommittedVer
(
pTq
->
pVnode
->
pWal
);
if
(
pRef
==
NULL
)
{
if
(
pRef
==
NULL
)
{
...
@@ -570,10 +582,6 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe
...
@@ -570,10 +582,6 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe
int64_t
ver
=
pRef
->
refVer
;
int64_t
ver
=
pRef
->
refVer
;
pHandle
->
pRef
=
pRef
;
pHandle
->
pRef
=
pRef
;
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
pHandle
->
execHandle
.
execCol
.
qmsg
=
req
.
qmsg
;
pHandle
->
snapshotVer
=
ver
;
req
.
qmsg
=
NULL
;
SReadHandle
handle
=
{
SReadHandle
handle
=
{
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
vnode
=
pTq
->
pVnode
,
.
vnode
=
pTq
->
pVnode
,
...
@@ -581,25 +589,35 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe
...
@@ -581,25 +589,35 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe
.
initTqReader
=
true
,
.
initTqReader
=
true
,
.
version
=
ver
,
.
version
=
ver
,
};
};
pHandle
->
execHandle
.
execCol
.
task
=
pHandle
->
snapshotVer
=
ver
;
qCreateQueueExecTaskInfo
(
pHandle
->
execHandle
.
execCol
.
qmsg
,
&
handle
,
&
pHandle
->
execHandle
.
numOfCols
,
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
pHandle
->
execHandle
.
execCol
.
qmsg
=
req
.
qmsg
;
req
.
qmsg
=
NULL
;
pHandle
->
execHandle
.
task
=
qCreateQueueExecTaskInfo
(
pHandle
->
execHandle
.
execCol
.
qmsg
,
&
handle
,
NULL
,
&
pHandle
->
execHandle
.
pSchemaWrapper
);
&
pHandle
->
execHandle
.
pSchemaWrapper
);
ASSERT
(
pHandle
->
execHandle
.
execCol
.
task
);
ASSERT
(
pHandle
->
execHandle
.
task
);
void
*
scanner
=
NULL
;
void
*
scanner
=
NULL
;
qExtractStreamScanner
(
pHandle
->
execHandle
.
execCol
.
task
,
&
scanner
);
qExtractStreamScanner
(
pHandle
->
execHandle
.
task
,
&
scanner
);
ASSERT
(
scanner
);
ASSERT
(
scanner
);
pHandle
->
execHandle
.
pExecReader
=
qExtractReaderFromStreamScanner
(
scanner
);
pHandle
->
execHandle
.
pExecReader
=
qExtractReaderFromStreamScanner
(
scanner
);
ASSERT
(
pHandle
->
execHandle
.
pExecReader
);
ASSERT
(
pHandle
->
execHandle
.
pExecReader
);
}
else
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__DB
)
{
}
else
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__DB
)
{
pHandle
->
pWalReader
=
walOpenReader
(
pTq
->
pVnode
->
pWal
,
NULL
);
pHandle
->
pWalReader
=
walOpenReader
(
pTq
->
pVnode
->
pWal
,
NULL
);
pHandle
->
execHandle
.
pExecReader
=
tqOpenReader
(
pTq
->
pVnode
);
pHandle
->
execHandle
.
pExecReader
=
tqOpenReader
(
pTq
->
pVnode
);
pHandle
->
execHandle
.
execDb
.
pFilterOutTbUid
=
pHandle
->
execHandle
.
execDb
.
pFilterOutTbUid
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
buildSnapContext
(
handle
.
meta
,
handle
.
version
,
0
,
pHandle
->
execHandle
.
subType
,
pHandle
->
fetchMeta
,
(
SSnapContext
**
)(
&
handle
.
sContext
));
pHandle
->
execHandle
.
task
=
qCreateQueueExecTaskInfo
(
NULL
,
&
handle
,
NULL
,
NULL
);
}
else
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
}
else
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
pHandle
->
pWalReader
=
walOpenReader
(
pTq
->
pVnode
->
pWal
,
NULL
);
pHandle
->
pWalReader
=
walOpenReader
(
pTq
->
pVnode
->
pWal
,
NULL
);
pHandle
->
execHandle
.
execTb
.
suid
=
req
.
suid
;
pHandle
->
execHandle
.
execTb
.
suid
=
req
.
suid
;
SArray
*
tbUidList
=
taosArrayInit
(
0
,
sizeof
(
int64_t
));
SArray
*
tbUidList
=
taosArrayInit
(
0
,
sizeof
(
int64_t
));
vnodeGetCtbIdList
(
pTq
->
pVnode
,
req
.
suid
,
tbUidList
);
vnodeGetCtbIdList
(
pTq
->
pVnode
,
req
.
suid
,
tbUidList
);
tqDebug
(
"vgId:%d, tq try to get all ctb, suid:%"
PRId64
,
pTq
->
pVnode
->
config
.
vgId
,
req
.
suid
);
tqDebug
(
"vgId:%d, tq try to get all ctb, suid:%"
PRId64
,
pTq
->
pVnode
->
config
.
vgId
,
req
.
suid
);
...
@@ -610,6 +628,10 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe
...
@@ -610,6 +628,10 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe
pHandle
->
execHandle
.
pExecReader
=
tqOpenReader
(
pTq
->
pVnode
);
pHandle
->
execHandle
.
pExecReader
=
tqOpenReader
(
pTq
->
pVnode
);
tqReaderSetTbUidList
(
pHandle
->
execHandle
.
pExecReader
,
tbUidList
);
tqReaderSetTbUidList
(
pHandle
->
execHandle
.
pExecReader
,
tbUidList
);
taosArrayDestroy
(
tbUidList
);
taosArrayDestroy
(
tbUidList
);
buildSnapContext
(
handle
.
meta
,
handle
.
version
,
req
.
suid
,
pHandle
->
execHandle
.
subType
,
pHandle
->
fetchMeta
,
(
SSnapContext
**
)(
&
handle
.
sContext
));
pHandle
->
execHandle
.
task
=
qCreateQueueExecTaskInfo
(
NULL
,
&
handle
,
NULL
,
NULL
);
}
}
taosHashPut
(
pTq
->
pHandle
,
req
.
subKey
,
strlen
(
req
.
subKey
),
pHandle
,
sizeof
(
STqHandle
));
taosHashPut
(
pTq
->
pHandle
,
req
.
subKey
,
strlen
(
req
.
subKey
),
pHandle
,
sizeof
(
STqHandle
));
tqDebug
(
"try to persist handle %s consumer %"
PRId64
,
req
.
subKey
,
pHandle
->
consumerId
);
tqDebug
(
"try to persist handle %s consumer %"
PRId64
,
req
.
subKey
,
pHandle
->
consumerId
);
...
...
source/dnode/vnode/src/tq/tqExec.c
浏览文件 @
2ad31384
...
@@ -60,18 +60,18 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp) {
...
@@ -60,18 +60,18 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp) {
return
0
;
return
0
;
}
}
int64_t
tqScan
(
STQ
*
pTq
,
const
STqHandle
*
pHandle
,
SMqDataRsp
*
pRsp
,
STqOffsetVal
*
pOffset
)
{
int64_t
tqScan
(
STQ
*
pTq
,
const
STqHandle
*
pHandle
,
SMqDataRsp
*
pRsp
,
S
MqMetaRsp
*
pMetaRsp
,
S
TqOffsetVal
*
pOffset
)
{
const
STqExecHandle
*
pExec
=
&
pHandle
->
execHandle
;
const
STqExecHandle
*
pExec
=
&
pHandle
->
execHandle
;
qTaskInfo_t
task
=
pExec
->
execCol
.
task
;
qTaskInfo_t
task
=
pExec
->
task
;
if
(
qStreamPrepareScan
(
task
,
pOffset
)
<
0
)
{
if
(
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
)
<
0
)
{
tqDebug
(
"prepare scan failed, return"
);
tqDebug
(
"prepare scan failed, return"
);
if
(
pOffset
->
type
==
TMQ_OFFSET__LOG
)
{
if
(
pOffset
->
type
==
TMQ_OFFSET__LOG
)
{
pRsp
->
rspOffset
=
*
pOffset
;
pRsp
->
rspOffset
=
*
pOffset
;
return
0
;
return
0
;
}
else
{
}
else
{
tqOffsetResetToLog
(
pOffset
,
pHandle
->
snapshotVer
);
tqOffsetResetToLog
(
pOffset
,
pHandle
->
snapshotVer
);
if
(
qStreamPrepareScan
(
task
,
pOffset
)
<
0
)
{
if
(
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
)
<
0
)
{
tqDebug
(
"prepare scan failed, return"
);
tqDebug
(
"prepare scan failed, return"
);
pRsp
->
rspOffset
=
*
pOffset
;
pRsp
->
rspOffset
=
*
pOffset
;
return
0
;
return
0
;
...
@@ -83,24 +83,34 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVa
...
@@ -83,24 +83,34 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVa
while
(
1
)
{
while
(
1
)
{
SSDataBlock
*
pDataBlock
=
NULL
;
SSDataBlock
*
pDataBlock
=
NULL
;
uint64_t
ts
=
0
;
uint64_t
ts
=
0
;
tqDebug
(
"task start to execute"
);
tqDebug
(
"t
mqsnap t
ask start to execute"
);
if
(
qExecTask
(
task
,
&
pDataBlock
,
&
ts
)
<
0
)
{
if
(
qExecTask
(
task
,
&
pDataBlock
,
&
ts
)
<
0
)
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
tqDebug
(
"task execute end, get %p"
,
pDataBlock
);
tqDebug
(
"t
mqsnap t
ask execute end, get %p"
,
pDataBlock
);
if
(
pDataBlock
!=
NULL
)
{
if
(
pDataBlock
!=
NULL
)
{
if
(
pRsp
->
withTbName
)
{
if
(
pRsp
->
withTbName
)
{
int64_t
uid
=
0
;
if
(
pOffset
->
type
==
TMQ_OFFSET__LOG
)
{
if
(
pOffset
->
type
==
TMQ_OFFSET__LOG
)
{
int64_t
uid
=
pExec
->
pExecReader
->
msgIter
.
uid
;
uid
=
pExec
->
pExecReader
->
msgIter
.
uid
;
if
(
tqAddTbNameToRsp
(
pTq
,
uid
,
pRsp
)
<
0
)
{
if
(
tqAddTbNameToRsp
(
pTq
,
uid
,
pRsp
)
<
0
)
{
continue
;
continue
;
}
}
}
else
{
}
else
{
pRsp
->
withTbName
=
0
;
char
*
tbName
=
strdup
(
qExtractTbnameFromTask
(
task
));
taosArrayPush
(
pRsp
->
blockTbName
,
&
tbName
);
}
}
if
(
pRsp
->
withSchema
){
if
(
pOffset
->
type
==
TMQ_OFFSET__LOG
)
{
tqAddBlockSchemaToRsp
(
pExec
,
pRsp
);
}
else
{
SSchemaWrapper
*
pSW
=
tCloneSSchemaWrapper
(
qExtractSchemaFromTask
(
task
));
taosArrayPush
(
pRsp
->
blockSchema
,
&
pSW
);
}
}
}
}
tqAddBlockDataToRsp
(
pDataBlock
,
pRsp
,
pExec
->
numOfCols
);
tqAddBlockDataToRsp
(
pDataBlock
,
pRsp
,
taosArrayGetSize
(
pDataBlock
->
pDataBlock
)
);
pRsp
->
blockNum
++
;
pRsp
->
blockNum
++
;
if
(
pOffset
->
type
==
TMQ_OFFSET__LOG
)
{
if
(
pOffset
->
type
==
TMQ_OFFSET__LOG
)
{
continue
;
continue
;
...
@@ -110,39 +120,51 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVa
...
@@ -110,39 +120,51 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVa
}
}
}
}
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
){
if
(
pRsp
->
blockNum
==
0
&&
pOffset
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
if
(
pRsp
->
blockNum
==
0
&&
pOffset
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
tqDebug
(
"vgId: %d, tsdb consume over, switch to wal, ver %"
PRId64
,
TD_VID
(
pTq
->
pVnode
),
tqDebug
(
"vgId: %d, tsdb consume over, switch to wal, ver %"
PRId64
,
TD_VID
(
pTq
->
pVnode
),
pHandle
->
snapshotVer
+
1
);
pHandle
->
snapshotVer
+
1
);
tqOffsetResetToLog
(
pOffset
,
pHandle
->
snapshotVer
);
tqOffsetResetToLog
(
pOffset
,
pHandle
->
snapshotVer
);
qStreamPrepareScan
(
task
,
pOffset
);
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
);
continue
;
continue
;
}
}
}
else
{
void
*
meta
=
qStreamExtractMetaMsg
(
task
);
if
(
pDataBlock
==
NULL
&&
pOffset
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
){
if
(
meta
!=
NULL
)
{
if
(
qStreamExtractPrepareUid
(
task
)
!=
0
)
{
// tq add meta to rsp
continue
;
}
}
tqDebug
(
"tmqsnap vgId: %d, tsdb consume over, switch to wal, ver %"
PRId64
,
TD_VID
(
pTq
->
pVnode
),
if
(
qStreamExtractOffset
(
task
,
&
pRsp
->
rspOffset
)
<
0
)
{
pHandle
->
snapshotVer
+
1
);
ASSERT
(
0
)
;
break
;
}
}
ASSERT
(
pRsp
->
rspOffset
.
type
!=
0
);
if
(
pRsp
->
blockNum
>
0
){
tqDebug
(
"tmqsnap task exec exited, get data"
);
break
;
}
#if 0
SMqMetaRsp
*
tmp
=
qStreamExtractMetaMsg
(
task
);
if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) {
if
(
tmp
->
rspOffset
.
type
==
TMQ_OFFSET__SNAPSHOT_DATA
){
if (pRsp->blockNum > 0) {
tqOffsetResetToData
(
pOffset
,
tmp
->
rspOffset
.
uid
,
tmp
->
rspOffset
.
ts
);
ASSERT(pRsp->rspOffset.version > pRsp->reqOffset.version);
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
);
} else {
tmp
->
rspOffset
.
type
=
TMQ_OFFSET__SNAPSHOT_META
;
ASSERT(pRsp->rspOffset.version >= pRsp->reqOffset.version);
tqDebug
(
"tmqsnap task exec change to get data"
);
continue
;
}
}
*
pMetaRsp
=
*
tmp
;
tqDebug
(
"tmqsnap task exec exited, get meta"
);
}
}
#endif
tqDebug
(
"task exec exited"
);
tqDebug
(
"task exec exited"
);
break
;
break
;
}
}
if
(
qStreamExtractOffset
(
task
,
&
pRsp
->
rspOffset
)
<
0
)
{
ASSERT
(
0
);
}
ASSERT
(
pRsp
->
rspOffset
.
type
!=
0
);
return
0
;
return
0
;
}
}
...
...
source/dnode/vnode/src/tq/tqMeta.c
浏览文件 @
2ad31384
...
@@ -249,7 +249,6 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
...
@@ -249,7 +249,6 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
}
}
walRefVer
(
handle
.
pRef
,
handle
.
snapshotVer
);
walRefVer
(
handle
.
pRef
,
handle
.
snapshotVer
);
if
(
handle
.
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
SReadHandle
reader
=
{
SReadHandle
reader
=
{
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
vnode
=
pTq
->
pVnode
,
.
vnode
=
pTq
->
pVnode
,
...
@@ -258,18 +257,26 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
...
@@ -258,18 +257,26 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
.
version
=
handle
.
snapshotVer
,
.
version
=
handle
.
snapshotVer
,
};
};
handle
.
execHandle
.
execCol
.
task
=
qCreateQueueExecTaskInfo
(
if
(
handle
.
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
handle
.
execHandle
.
execCol
.
qmsg
,
&
reader
,
&
handle
.
execHandle
.
numOfCols
,
&
handle
.
execHandle
.
pSchemaWrapper
);
ASSERT
(
handle
.
execHandle
.
execCol
.
task
);
handle
.
execHandle
.
task
=
qCreateQueueExecTaskInfo
(
handle
.
execHandle
.
execCol
.
qmsg
,
&
reader
,
NULL
,
&
handle
.
execHandle
.
pSchemaWrapper
);
ASSERT
(
handle
.
execHandle
.
task
);
void
*
scanner
=
NULL
;
void
*
scanner
=
NULL
;
qExtractStreamScanner
(
handle
.
execHandle
.
execCol
.
task
,
&
scanner
);
qExtractStreamScanner
(
handle
.
execHandle
.
task
,
&
scanner
);
ASSERT
(
scanner
);
ASSERT
(
scanner
);
handle
.
execHandle
.
pExecReader
=
qExtractReaderFromStreamScanner
(
scanner
);
handle
.
execHandle
.
pExecReader
=
qExtractReaderFromStreamScanner
(
scanner
);
ASSERT
(
handle
.
execHandle
.
pExecReader
);
ASSERT
(
handle
.
execHandle
.
pExecReader
);
}
else
{
}
else
{
handle
.
pWalReader
=
walOpenReader
(
pTq
->
pVnode
->
pWal
,
NULL
);
handle
.
pWalReader
=
walOpenReader
(
pTq
->
pVnode
->
pWal
,
NULL
);
handle
.
execHandle
.
execDb
.
pFilterOutTbUid
=
handle
.
execHandle
.
execDb
.
pFilterOutTbUid
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
// handle.execHandle.pExecReader = tqOpenReader(pTq->pVnode);
buildSnapContext
(
reader
.
meta
,
reader
.
version
,
0
,
handle
.
execHandle
.
subType
,
handle
.
fetchMeta
,
(
SSnapContext
**
)(
&
reader
.
sContext
));
handle
.
execHandle
.
task
=
qCreateQueueExecTaskInfo
(
NULL
,
&
reader
,
NULL
,
NULL
);
}
}
tqDebug
(
"tq restore %s consumer %"
PRId64
" vgId:%d"
,
handle
.
subKey
,
handle
.
consumerId
,
TD_VID
(
pTq
->
pVnode
));
tqDebug
(
"tq restore %s consumer %"
PRId64
" vgId:%d"
,
handle
.
subKey
,
handle
.
consumerId
,
TD_VID
(
pTq
->
pVnode
));
taosHashPut
(
pTq
->
pHandle
,
pKey
,
kLen
,
&
handle
,
sizeof
(
STqHandle
));
taosHashPut
(
pTq
->
pHandle
,
pKey
,
kLen
,
&
handle
,
sizeof
(
STqHandle
));
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
2ad31384
...
@@ -68,7 +68,7 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHea
...
@@ -68,7 +68,7 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHea
offset
++
;
offset
++
;
}
}
}
}
END:
END:
taosThreadMutexUnlock
(
&
pHandle
->
pWalReader
->
mutex
);
taosThreadMutexUnlock
(
&
pHandle
->
pWalReader
->
mutex
);
return
code
;
return
code
;
}
}
...
@@ -398,7 +398,7 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
...
@@ -398,7 +398,7 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
STqHandle
*
pExec
=
(
STqHandle
*
)
pIter
;
STqHandle
*
pExec
=
(
STqHandle
*
)
pIter
;
if
(
pExec
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
if
(
pExec
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
int32_t
code
=
qUpdateQualifiedTableId
(
pExec
->
execHandle
.
execCol
.
task
,
tbUidList
,
isAdd
);
int32_t
code
=
qUpdateQualifiedTableId
(
pExec
->
execHandle
.
task
,
tbUidList
,
isAdd
);
ASSERT
(
code
==
0
);
ASSERT
(
code
==
0
);
}
else
if
(
pExec
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__DB
)
{
}
else
if
(
pExec
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__DB
)
{
if
(
!
isAdd
)
{
if
(
!
isAdd
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
2ad31384
...
@@ -3349,10 +3349,10 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
...
@@ -3349,10 +3349,10 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
}
}
if
(
pCond
->
suid
!=
0
)
{
if
(
pCond
->
suid
!=
0
)
{
pReader
->
pSchema
=
metaGetTbTSchema
(
pReader
->
pTsdb
->
pVnode
->
pMeta
,
pReader
->
suid
,
-
1
);
pReader
->
pSchema
=
metaGetTbTSchema
(
pReader
->
pTsdb
->
pVnode
->
pMeta
,
pReader
->
suid
,
pCond
->
schemaVersion
);
}
else
if
(
taosArrayGetSize
(
pTableList
)
>
0
)
{
}
else
if
(
taosArrayGetSize
(
pTableList
)
>
0
)
{
STableKeyInfo
*
pKey
=
taosArrayGet
(
pTableList
,
0
);
STableKeyInfo
*
pKey
=
taosArrayGet
(
pTableList
,
0
);
pReader
->
pSchema
=
metaGetTbTSchema
(
pReader
->
pTsdb
->
pVnode
->
pMeta
,
pKey
->
uid
,
-
1
);
pReader
->
pSchema
=
metaGetTbTSchema
(
pReader
->
pTsdb
->
pVnode
->
pMeta
,
pKey
->
uid
,
pCond
->
schemaVersion
);
}
}
int32_t
numOfTables
=
taosArrayGetSize
(
pTableList
);
int32_t
numOfTables
=
taosArrayGetSize
(
pTableList
);
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
2ad31384
...
@@ -142,7 +142,9 @@ typedef struct {
...
@@ -142,7 +142,9 @@ typedef struct {
//TODO remove prepareStatus
//TODO remove prepareStatus
STqOffsetVal
prepareStatus
;
// for tmq
STqOffsetVal
prepareStatus
;
// for tmq
STqOffsetVal
lastStatus
;
// for tmq
STqOffsetVal
lastStatus
;
// for tmq
void
*
metaBlk
;
// for tmq fetching meta
SMqMetaRsp
metaRsp
;
// for tmq fetching meta
SSchemaWrapper
*
schema
;
char
tbName
[
TSDB_TABLE_NAME_LEN
];
SSDataBlock
*
pullOverBlk
;
// for streaming
SSDataBlock
*
pullOverBlk
;
// for streaming
SWalFilterCond
cond
;
SWalFilterCond
cond
;
int64_t
lastScanUid
;
int64_t
lastScanUid
;
...
@@ -489,6 +491,19 @@ typedef struct SStreamScanInfo {
...
@@ -489,6 +491,19 @@ typedef struct SStreamScanInfo {
SNode
*
pTagIndexCond
;
SNode
*
pTagIndexCond
;
}
SStreamScanInfo
;
}
SStreamScanInfo
;
typedef
struct
SStreamRawScanInfo
{
// int8_t subType;
// bool withMeta;
// int64_t suid;
// int64_t snapVersion;
// void *metaInfo;
// void *dataInfo;
SVnode
*
vnode
;
SSDataBlock
pRes
;
// result SSDataBlock
STsdbReader
*
dataReader
;
SSnapContext
*
sContext
;
}
SStreamRawScanInfo
;
typedef
struct
SSysTableScanInfo
{
typedef
struct
SSysTableScanInfo
{
SRetrieveMetaTableRsp
*
pRsp
;
SRetrieveMetaTableRsp
*
pRsp
;
SRetrieveTableReq
req
;
SRetrieveTableReq
req
;
...
@@ -931,6 +946,8 @@ SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SReadHandle* re
...
@@ -931,6 +946,8 @@ SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SReadHandle* re
SOperatorInfo
*
createStreamScanOperatorInfo
(
SReadHandle
*
pHandle
,
STableScanPhysiNode
*
pTableScanNode
,
SNode
*
pTagCond
,
SOperatorInfo
*
createStreamScanOperatorInfo
(
SReadHandle
*
pHandle
,
STableScanPhysiNode
*
pTableScanNode
,
SNode
*
pTagCond
,
SExecTaskInfo
*
pTaskInfo
);
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createRawScanOperatorInfo
(
SReadHandle
*
pHandle
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createFillOperatorInfo
(
SOperatorInfo
*
downstream
,
SFillPhysiNode
*
pPhyFillNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createFillOperatorInfo
(
SOperatorInfo
*
downstream
,
SFillPhysiNode
*
pPhyFillNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createStatewindowOperatorInfo
(
SOperatorInfo
*
downstream
,
SStateWinodwPhysiNode
*
pStateNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createStatewindowOperatorInfo
(
SOperatorInfo
*
downstream
,
SStateWinodwPhysiNode
*
pStateNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createPartitionOperatorInfo
(
SOperatorInfo
*
downstream
,
SPartitionPhysiNode
*
pPartNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createPartitionOperatorInfo
(
SOperatorInfo
*
downstream
,
SPartitionPhysiNode
*
pPartNode
,
SExecTaskInfo
*
pTaskInfo
);
...
...
source/libs/executor/src/executil.c
浏览文件 @
2ad31384
...
@@ -349,7 +349,7 @@ static int32_t createResultData(SDataType* pType, int32_t numOfRows, SScalarPara
...
@@ -349,7 +349,7 @@ static int32_t createResultData(SDataType* pType, int32_t numOfRows, SScalarPara
int32_t
code
=
colInfoDataEnsureCapacity
(
pColumnData
,
numOfRows
);
int32_t
code
=
colInfoDataEnsureCapacity
(
pColumnData
,
numOfRows
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
code
;
taosMemoryFree
(
pColumnData
);
taosMemoryFree
(
pColumnData
);
return
terrno
;
return
terrno
;
}
}
...
@@ -367,6 +367,7 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
...
@@ -367,6 +367,7 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
SScalarParam
output
=
{
0
};
SScalarParam
output
=
{
0
};
tagFilterAssist
ctx
=
{
0
};
tagFilterAssist
ctx
=
{
0
};
ctx
.
colHash
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_SMALLINT
),
false
,
HASH_NO_LOCK
);
ctx
.
colHash
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_SMALLINT
),
false
,
HASH_NO_LOCK
);
if
(
ctx
.
colHash
==
NULL
)
{
if
(
ctx
.
colHash
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -474,6 +475,7 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
...
@@ -474,6 +475,7 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
terrno
=
code
;
qError
(
"failed to create result, reason:%s"
,
tstrerror
(
code
));
qError
(
"failed to create result, reason:%s"
,
tstrerror
(
code
));
terrno
=
code
;
goto
end
;
goto
end
;
}
}
...
@@ -1298,6 +1300,7 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi
...
@@ -1298,6 +1300,7 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi
pCond
->
type
=
TIMEWINDOW_RANGE_CONTAINED
;
pCond
->
type
=
TIMEWINDOW_RANGE_CONTAINED
;
pCond
->
startVersion
=
-
1
;
pCond
->
startVersion
=
-
1
;
pCond
->
endVersion
=
-
1
;
pCond
->
endVersion
=
-
1
;
pCond
->
schemaVersion
=
-
1
;
// pCond->type = pTableScanNode->scanFlag;
// pCond->type = pTableScanNode->scanFlag;
int32_t
j
=
0
;
int32_t
j
=
0
;
...
...
source/libs/executor/src/executor.c
浏览文件 @
2ad31384
...
@@ -140,8 +140,24 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO
...
@@ -140,8 +140,24 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO
qTaskInfo_t
qCreateQueueExecTaskInfo
(
void
*
msg
,
SReadHandle
*
readers
,
int32_t
*
numOfCols
,
SSchemaWrapper
**
pSchema
)
{
qTaskInfo_t
qCreateQueueExecTaskInfo
(
void
*
msg
,
SReadHandle
*
readers
,
int32_t
*
numOfCols
,
SSchemaWrapper
**
pSchema
)
{
if
(
msg
==
NULL
)
{
if
(
msg
==
NULL
)
{
// TODO create raw scan
// TODO create raw scan
SExecTaskInfo
*
pTaskInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SExecTaskInfo
));
if
(
NULL
==
pTaskInfo
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
setTaskStatus
(
pTaskInfo
,
TASK_NOT_COMPLETED
);
pTaskInfo
->
cost
.
created
=
taosGetTimestampMs
();
pTaskInfo
->
execModel
=
OPTR_EXEC_MODEL_QUEUE
;
pTaskInfo
->
pRoot
=
createRawScanOperatorInfo
(
readers
,
pTaskInfo
);
if
(
NULL
==
pTaskInfo
->
pRoot
){
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
taosMemoryFree
(
pTaskInfo
);
return
NULL
;
}
return
pTaskInfo
;
}
struct
SSubplan
*
pPlan
=
NULL
;
struct
SSubplan
*
pPlan
=
NULL
;
int32_t
code
=
qStringToSubplan
(
msg
,
&
pPlan
);
int32_t
code
=
qStringToSubplan
(
msg
,
&
pPlan
);
...
@@ -161,13 +177,13 @@ qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* n
...
@@ -161,13 +177,13 @@ qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* n
// extract the number of output columns
// extract the number of output columns
SDataBlockDescNode
*
pDescNode
=
pPlan
->
pNode
->
pOutputDataBlockDesc
;
SDataBlockDescNode
*
pDescNode
=
pPlan
->
pNode
->
pOutputDataBlockDesc
;
*
numOfCols
=
0
;
if
(
numOfCols
)
*
numOfCols
=
0
;
SNode
*
pNode
;
SNode
*
pNode
;
FOREACH
(
pNode
,
pDescNode
->
pSlots
)
{
FOREACH
(
pNode
,
pDescNode
->
pSlots
)
{
SSlotDescNode
*
pSlotDesc
=
(
SSlotDescNode
*
)
pNode
;
SSlotDescNode
*
pSlotDesc
=
(
SSlotDescNode
*
)
pNode
;
if
(
pSlotDesc
->
output
)
{
if
(
pSlotDesc
->
output
)
{
++
(
*
numOfCols
);
if
(
numOfCols
)
++
(
*
numOfCols
);
}
}
}
}
...
@@ -669,15 +685,26 @@ void* qExtractReaderFromStreamScanner(void* scanner) {
...
@@ -669,15 +685,26 @@ void* qExtractReaderFromStreamScanner(void* scanner) {
return
(
void
*
)
pInfo
->
tqReader
;
return
(
void
*
)
pInfo
->
tqReader
;
}
}
const
SSchemaWrapper
*
qExtractSchemaFrom
StreamScanner
(
void
*
scanner
)
{
const
SSchemaWrapper
*
qExtractSchemaFrom
Task
(
qTaskInfo_t
tinfo
)
{
S
StreamScanInfo
*
pInfo
=
scanner
;
S
ExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
return
p
Info
->
tqReader
->
pSchemaWrapper
;
return
p
TaskInfo
->
streamInfo
.
schema
;
}
}
void
*
qStreamExtractMetaMsg
(
qTaskInfo_t
tinfo
)
{
const
char
*
qExtractTbnameFromTask
(
qTaskInfo_t
tinfo
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
return
pTaskInfo
->
streamInfo
.
tbName
;
}
SMqMetaRsp
*
qStreamExtractMetaMsg
(
qTaskInfo_t
tinfo
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
ASSERT
(
pTaskInfo
->
execModel
==
OPTR_EXEC_MODEL_QUEUE
);
return
&
pTaskInfo
->
streamInfo
.
metaRsp
;
}
int64_t
qStreamExtractPrepareUid
(
qTaskInfo_t
tinfo
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
ASSERT
(
pTaskInfo
->
execModel
==
OPTR_EXEC_MODEL_QUEUE
);
ASSERT
(
pTaskInfo
->
execModel
==
OPTR_EXEC_MODEL_QUEUE
);
return
pTaskInfo
->
streamInfo
.
metaBlk
;
return
pTaskInfo
->
streamInfo
.
prepareStatus
.
uid
;
}
}
int32_t
qStreamExtractOffset
(
qTaskInfo_t
tinfo
,
STqOffsetVal
*
pOffset
)
{
int32_t
qStreamExtractOffset
(
qTaskInfo_t
tinfo
,
STqOffsetVal
*
pOffset
)
{
...
@@ -687,13 +714,41 @@ int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset) {
...
@@ -687,13 +714,41 @@ int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset) {
return
0
;
return
0
;
}
}
int32_t
qStreamPrepareScan
(
qTaskInfo_t
tinfo
,
const
STqOffsetVal
*
pOffset
)
{
int32_t
initQueryTableDataCondForTmq
(
SQueryTableDataCond
*
pCond
,
SSnapContext
*
sContext
,
SMetaTableInfo
mtInfo
)
{
memset
(
pCond
,
0
,
sizeof
(
SQueryTableDataCond
));
pCond
->
order
=
TSDB_ORDER_ASC
;
pCond
->
numOfCols
=
mtInfo
.
schema
->
nCols
;
pCond
->
colList
=
taosMemoryCalloc
(
pCond
->
numOfCols
,
sizeof
(
SColumnInfo
));
if
(
pCond
->
colList
==
NULL
)
{
terrno
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
terrno
;
}
pCond
->
twindows
=
(
STimeWindow
){.
skey
=
INT64_MIN
,
.
ekey
=
INT64_MAX
};
pCond
->
suid
=
mtInfo
.
suid
;
pCond
->
type
=
TIMEWINDOW_RANGE_CONTAINED
;
pCond
->
startVersion
=
-
1
;
pCond
->
endVersion
=
sContext
->
snapVersion
;
pCond
->
schemaVersion
=
sContext
->
snapVersion
;
for
(
int32_t
i
=
0
;
i
<
pCond
->
numOfCols
;
++
i
)
{
pCond
->
colList
[
i
].
type
=
mtInfo
.
schema
->
pSchema
[
i
].
type
;
pCond
->
colList
[
i
].
bytes
=
mtInfo
.
schema
->
pSchema
[
i
].
bytes
;
pCond
->
colList
[
i
].
colId
=
mtInfo
.
schema
->
pSchema
[
i
].
colId
;
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
qStreamPrepareScan
(
qTaskInfo_t
tinfo
,
STqOffsetVal
*
pOffset
,
int8_t
subType
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
SOperatorInfo
*
pOperator
=
pTaskInfo
->
pRoot
;
SOperatorInfo
*
pOperator
=
pTaskInfo
->
pRoot
;
ASSERT
(
pTaskInfo
->
execModel
==
OPTR_EXEC_MODEL_QUEUE
);
ASSERT
(
pTaskInfo
->
execModel
==
OPTR_EXEC_MODEL_QUEUE
);
pTaskInfo
->
streamInfo
.
prepareStatus
=
*
pOffset
;
pTaskInfo
->
streamInfo
.
prepareStatus
=
*
pOffset
;
if
(
!
tOffsetEqual
(
pOffset
,
&
pTaskInfo
->
streamInfo
.
lastStatus
))
{
if
(
tOffsetEqual
(
pOffset
,
&
pTaskInfo
->
streamInfo
.
lastStatus
))
{
while
(
1
)
{
return
0
;
}
if
(
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
uint16_t
type
=
pOperator
->
operatorType
;
uint16_t
type
=
pOperator
->
operatorType
;
pOperator
->
status
=
OP_OPENED
;
pOperator
->
status
=
OP_OPENED
;
// TODO add more check
// TODO add more check
...
@@ -740,7 +795,6 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, const STqOffsetVal* pOffset) {
...
@@ -740,7 +795,6 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, const STqOffsetVal* pOffset) {
int32_t
tableSz
=
taosArrayGetSize
(
pTaskInfo
->
tableqinfoList
.
pTableList
);
int32_t
tableSz
=
taosArrayGetSize
(
pTaskInfo
->
tableqinfoList
.
pTableList
);
#ifndef NDEBUG
#ifndef NDEBUG
qDebug
(
"switch to next table %"
PRId64
" (cursor %d), %"
PRId64
" rows returned"
,
uid
,
qDebug
(
"switch to next table %"
PRId64
" (cursor %d), %"
PRId64
" rows returned"
,
uid
,
pTableScanInfo
->
currentTable
,
pInfo
->
pTableScanOp
->
resultInfo
.
totalRows
);
pTableScanInfo
->
currentTable
,
pInfo
->
pTableScanOp
->
resultInfo
.
totalRows
);
pInfo
->
pTableScanOp
->
resultInfo
.
totalRows
=
0
;
pInfo
->
pTableScanOp
->
resultInfo
.
totalRows
=
0
;
...
@@ -777,12 +831,47 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, const STqOffsetVal* pOffset) {
...
@@ -777,12 +831,47 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, const STqOffsetVal* pOffset) {
qDebug
(
"tsdb reader offset seek to uid %"
PRId64
" ts %"
PRId64
", table cur set to %d , all table num %d"
,
uid
,
qDebug
(
"tsdb reader offset seek to uid %"
PRId64
" ts %"
PRId64
", table cur set to %d , all table num %d"
,
uid
,
ts
,
pTableScanInfo
->
currentTable
,
tableSz
);
ts
,
pTableScanInfo
->
currentTable
,
tableSz
);
/*}*/
/*}*/
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
return
0
;
}
else
if
(
pOffset
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
){
SStreamRawScanInfo
*
pInfo
=
pOperator
->
info
;
SSnapContext
*
sContext
=
pInfo
->
sContext
;
if
(
setForSnapShot
(
sContext
,
pOffset
->
uid
)
!=
0
)
{
qError
(
"setDataForSnapShot error. uid:%"
PRIi64
,
pOffset
->
uid
);
return
-
1
;
}
SMetaTableInfo
mtInfo
=
getUidfromSnapShot
(
sContext
);
tsdbReaderClose
(
pInfo
->
dataReader
);
pInfo
->
dataReader
=
NULL
;
cleanupQueryTableDataCond
(
&
pTaskInfo
->
streamInfo
.
tableCond
);
taosArrayDestroy
(
pTaskInfo
->
tableqinfoList
.
pTableList
);
if
(
mtInfo
.
uid
==
0
)
return
0
;
// no data
initQueryTableDataCondForTmq
(
&
pTaskInfo
->
streamInfo
.
tableCond
,
sContext
,
mtInfo
);
pTaskInfo
->
streamInfo
.
tableCond
.
twindows
.
skey
=
pOffset
->
ts
;
pTaskInfo
->
tableqinfoList
.
pTableList
=
taosArrayInit
(
1
,
sizeof
(
STableKeyInfo
));
taosArrayPush
(
pTaskInfo
->
tableqinfoList
.
pTableList
,
&
(
STableKeyInfo
){.
uid
=
mtInfo
.
uid
,
.
groupId
=
0
});
tsdbReaderOpen
(
pInfo
->
vnode
,
&
pTaskInfo
->
streamInfo
.
tableCond
,
pTaskInfo
->
tableqinfoList
.
pTableList
,
&
pInfo
->
dataReader
,
NULL
);
strcpy
(
pTaskInfo
->
streamInfo
.
tbName
,
mtInfo
.
tbName
);
tDeleteSSchemaWrapper
(
pTaskInfo
->
streamInfo
.
schema
);
pTaskInfo
->
streamInfo
.
schema
=
mtInfo
.
schema
;
qDebug
(
"tmqsnap qStreamPrepareScan snapshot data uid %ld ts %ld"
,
mtInfo
.
uid
,
pOffset
->
ts
);
}
else
if
(
pOffset
->
type
==
TMQ_OFFSET__SNAPSHOT_META
){
SStreamRawScanInfo
*
pInfo
=
pOperator
->
info
;
SSnapContext
*
sContext
=
pInfo
->
sContext
;
if
(
setForSnapShot
(
sContext
,
pOffset
->
uid
)
!=
0
)
{
qError
(
"setForSnapShot error. uid:%"
PRIi64
" ,version:%"
PRIi64
,
pOffset
->
uid
);
return
-
1
;
}
}
qDebug
(
"tmqsnap qStreamPrepareScan snapshot meta uid %ld ts %ld"
,
pOffset
->
uid
);
}
else
if
(
pOffset
->
type
==
TMQ_OFFSET__LOG
)
{
SStreamRawScanInfo
*
pInfo
=
pOperator
->
info
;
tsdbReaderClose
(
pInfo
->
dataReader
);
pInfo
->
dataReader
=
NULL
;
qDebug
(
"tmqsnap qStreamPrepareScan snapshot log"
);
}
}
return
0
;
return
0
;
}
}
source/libs/executor/src/executorimpl.c
浏览文件 @
2ad31384
...
@@ -3997,6 +3997,7 @@ static int32_t initTableblockDistQueryCond(uint64_t uid, SQueryTableDataCond* pC
...
@@ -3997,6 +3997,7 @@ static int32_t initTableblockDistQueryCond(uint64_t uid, SQueryTableDataCond* pC
pCond
->
type
=
TIMEWINDOW_RANGE_CONTAINED
;
pCond
->
type
=
TIMEWINDOW_RANGE_CONTAINED
;
pCond
->
startVersion
=
-
1
;
pCond
->
startVersion
=
-
1
;
pCond
->
endVersion
=
-
1
;
pCond
->
endVersion
=
-
1
;
pCond
->
schemaVersion
=
-
1
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
2ad31384
...
@@ -1334,9 +1334,9 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
...
@@ -1334,9 +1334,9 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
}
}
}
else
if
(
ret
.
fetchType
==
FETCH_TYPE__META
)
{
}
else
if
(
ret
.
fetchType
==
FETCH_TYPE__META
)
{
ASSERT
(
0
);
ASSERT
(
0
);
pTaskInfo
->
streamInfo
.
lastStatus
=
ret
.
offset
;
//
pTaskInfo->streamInfo.lastStatus = ret.offset;
pTaskInfo
->
streamInfo
.
metaBlk
=
ret
.
meta
;
//
pTaskInfo->streamInfo.metaBlk = ret.meta;
return
NULL
;
//
return NULL;
}
else
if
(
ret
.
fetchType
==
FETCH_TYPE__NONE
)
{
}
else
if
(
ret
.
fetchType
==
FETCH_TYPE__NONE
)
{
pTaskInfo
->
streamInfo
.
lastStatus
=
ret
.
offset
;
pTaskInfo
->
streamInfo
.
lastStatus
=
ret
.
offset
;
ASSERT
(
pTaskInfo
->
streamInfo
.
lastStatus
.
version
>=
pTaskInfo
->
streamInfo
.
prepareStatus
.
version
);
ASSERT
(
pTaskInfo
->
streamInfo
.
lastStatus
.
version
>=
pTaskInfo
->
streamInfo
.
prepareStatus
.
version
);
...
@@ -1357,10 +1357,6 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
...
@@ -1357,10 +1357,6 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
}
}
qDebug
(
"stream scan tsdb return null"
);
qDebug
(
"stream scan tsdb return null"
);
return
NULL
;
return
NULL
;
}
else
if
(
pTaskInfo
->
streamInfo
.
prepareStatus
.
type
==
TMQ_OFFSET__SNAPSHOT_META
)
{
// TODO scan meta
ASSERT
(
0
);
return
NULL
;
}
}
if
(
pTaskInfo
->
streamInfo
.
recoverStep
==
STREAM_RECOVER_STEP__PREPARE
)
{
if
(
pTaskInfo
->
streamInfo
.
recoverStep
==
STREAM_RECOVER_STEP__PREPARE
)
{
...
@@ -1545,11 +1541,6 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
...
@@ -1545,11 +1541,6 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
}
}
}
}
static
SSDataBlock
*
doRawScan
(
SOperatorInfo
*
pInfo
)
{
//
return
NULL
;
}
static
SArray
*
extractTableIdList
(
const
STableListInfo
*
pTableGroupInfo
)
{
static
SArray
*
extractTableIdList
(
const
STableListInfo
*
pTableGroupInfo
)
{
SArray
*
tableIdList
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
SArray
*
tableIdList
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
...
@@ -1562,17 +1553,160 @@ static SArray* extractTableIdList(const STableListInfo* pTableGroupInfo) {
...
@@ -1562,17 +1553,160 @@ static SArray* extractTableIdList(const STableListInfo* pTableGroupInfo) {
return
tableIdList
;
return
tableIdList
;
}
}
static
SSDataBlock
*
doRawScan
(
SOperatorInfo
*
pOperator
)
{
// NOTE: this operator does never check if current status is done or not
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SStreamRawScanInfo
*
pInfo
=
pOperator
->
info
;
pTaskInfo
->
streamInfo
.
metaRsp
.
metaRspLen
=
0
;
// use metaRspLen !=0 to judge if data is meta
pTaskInfo
->
streamInfo
.
metaRsp
.
metaRsp
=
NULL
;
qDebug
(
"tmqsnap doRawScan called"
);
if
(
pTaskInfo
->
streamInfo
.
prepareStatus
.
type
==
TMQ_OFFSET__SNAPSHOT_DATA
){
SSDataBlock
*
pBlock
=
&
pInfo
->
pRes
;
if
(
pInfo
->
dataReader
&&
tsdbNextDataBlock
(
pInfo
->
dataReader
))
{
if
(
isTaskKilled
(
pTaskInfo
))
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_TSC_QUERY_CANCELLED
);
}
tsdbRetrieveDataBlockInfo
(
pInfo
->
dataReader
,
&
pBlock
->
info
);
SArray
*
pCols
=
tsdbRetrieveDataBlock
(
pInfo
->
dataReader
,
NULL
);
pBlock
->
pDataBlock
=
pCols
;
if
(
pCols
==
NULL
)
{
longjmp
(
pTaskInfo
->
env
,
terrno
);
}
qDebug
(
"tmqsnap doRawScan get data uid:%ld"
,
pBlock
->
info
.
uid
);
pTaskInfo
->
streamInfo
.
lastStatus
.
type
=
TMQ_OFFSET__SNAPSHOT_DATA
;
pTaskInfo
->
streamInfo
.
lastStatus
.
uid
=
pBlock
->
info
.
uid
;
pTaskInfo
->
streamInfo
.
lastStatus
.
ts
=
pBlock
->
info
.
window
.
ekey
;
return
pBlock
;
}
SMetaTableInfo
mtInfo
=
getUidfromSnapShot
(
pInfo
->
sContext
);
if
(
mtInfo
.
uid
==
0
){
//read snapshot done, change to get data from wal
qDebug
(
"tmqsnap read snapshot done, change to get data from wal"
);
pTaskInfo
->
streamInfo
.
prepareStatus
.
uid
=
mtInfo
.
uid
;
pTaskInfo
->
streamInfo
.
lastStatus
.
type
=
TMQ_OFFSET__LOG
;
pTaskInfo
->
streamInfo
.
lastStatus
.
version
=
pInfo
->
sContext
->
snapVersion
;
tDeleteSSchemaWrapper
(
pTaskInfo
->
streamInfo
.
schema
);
}
else
{
pTaskInfo
->
streamInfo
.
prepareStatus
.
uid
=
mtInfo
.
uid
;
pTaskInfo
->
streamInfo
.
prepareStatus
.
ts
=
INT64_MIN
;
qDebug
(
"tmqsnap change get data uid:%ld"
,
mtInfo
.
uid
);
qStreamPrepareScan
(
pTaskInfo
,
&
pTaskInfo
->
streamInfo
.
prepareStatus
,
pInfo
->
sContext
->
subType
);
strcpy
(
pTaskInfo
->
streamInfo
.
tbName
,
mtInfo
.
tbName
);
tDeleteSSchemaWrapper
(
pTaskInfo
->
streamInfo
.
schema
);
pTaskInfo
->
streamInfo
.
schema
=
mtInfo
.
schema
;
}
qDebug
(
"tmqsnap stream scan tsdb return null"
);
return
NULL
;
}
else
if
(
pTaskInfo
->
streamInfo
.
prepareStatus
.
type
==
TMQ_OFFSET__SNAPSHOT_META
){
SSnapContext
*
sContext
=
pInfo
->
sContext
;
void
*
data
=
NULL
;
int32_t
dataLen
=
0
;
int16_t
type
=
0
;
int64_t
uid
=
0
;
if
(
getMetafromSnapShot
(
sContext
,
&
data
,
&
dataLen
,
&
type
,
&
uid
)
<
0
){
qError
(
"tmqsnap getMetafromSnapShot error"
);
taosMemoryFreeClear
(
data
);
return
NULL
;
}
if
(
!
sContext
->
queryMetaOrData
){
// change to get data next poll request
pTaskInfo
->
streamInfo
.
lastStatus
.
type
=
TMQ_OFFSET__SNAPSHOT_META
;
pTaskInfo
->
streamInfo
.
lastStatus
.
uid
=
uid
;
pTaskInfo
->
streamInfo
.
metaRsp
.
rspOffset
.
type
=
TMQ_OFFSET__SNAPSHOT_DATA
;
pTaskInfo
->
streamInfo
.
metaRsp
.
rspOffset
.
uid
=
0
;
pTaskInfo
->
streamInfo
.
metaRsp
.
rspOffset
.
ts
=
INT64_MIN
;
}
else
{
pTaskInfo
->
streamInfo
.
lastStatus
.
type
=
TMQ_OFFSET__SNAPSHOT_META
;
pTaskInfo
->
streamInfo
.
lastStatus
.
uid
=
uid
;
pTaskInfo
->
streamInfo
.
metaRsp
.
rspOffset
=
pTaskInfo
->
streamInfo
.
lastStatus
;
pTaskInfo
->
streamInfo
.
metaRsp
.
resMsgType
=
type
;
pTaskInfo
->
streamInfo
.
metaRsp
.
metaRspLen
=
dataLen
;
pTaskInfo
->
streamInfo
.
metaRsp
.
metaRsp
=
data
;
}
return
NULL
;
}
// else if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__LOG) {
// int64_t fetchVer = pTaskInfo->streamInfo.prepareStatus.version + 1;
//
// while(1){
// if (tqFetchLog(pInfo->tqReader->pWalReader, pInfo->sContext->withMeta, &fetchVer, &pInfo->pCkHead) < 0) {
// qDebug("tmqsnap tmq poll: consumer log end. offset %" PRId64, fetchVer);
// pTaskInfo->streamInfo.lastStatus.version = fetchVer;
// pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__LOG;
// return NULL;
// }
// SWalCont* pHead = &pInfo->pCkHead->head;
// qDebug("tmqsnap tmq poll: consumer log offset %" PRId64 " msgType %d", fetchVer, pHead->msgType);
//
// if (pHead->msgType == TDMT_VND_SUBMIT) {
// SSubmitReq* pCont = (SSubmitReq*)&pHead->body;
// tqReaderSetDataMsg(pInfo->tqReader, pCont, 0);
// SSDataBlock* block = tqLogScanExec(pInfo->sContext->subType, pInfo->tqReader, pInfo->pFilterOutTbUid, &pInfo->pRes);
// if(block){
// pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__LOG;
// pTaskInfo->streamInfo.lastStatus.version = fetchVer;
// qDebug("tmqsnap fetch data msg, ver:%" PRId64 ", type:%d", pHead->version, pHead->msgType);
// return block;
// }else{
// fetchVer++;
// }
// } else{
// ASSERT(pInfo->sContext->withMeta);
// ASSERT(IS_META_MSG(pHead->msgType));
// qDebug("tmqsnap fetch meta msg, ver:%" PRId64 ", type:%d", pHead->version, pHead->msgType);
// pTaskInfo->streamInfo.metaRsp.rspOffset.version = fetchVer;
// pTaskInfo->streamInfo.metaRsp.rspOffset.type = TMQ_OFFSET__LOG;
// pTaskInfo->streamInfo.metaRsp.resMsgType = pHead->msgType;
// pTaskInfo->streamInfo.metaRsp.metaRspLen = pHead->bodyLen;
// pTaskInfo->streamInfo.metaRsp.metaRsp = taosMemoryMalloc(pHead->bodyLen);
// memcpy(pTaskInfo->streamInfo.metaRsp.metaRsp, pHead->body, pHead->bodyLen);
// return NULL;
// }
// }
return
NULL
;
}
static
void
destroyRawScanOperatorInfo
(
void
*
param
)
{
SStreamRawScanInfo
*
pRawScan
=
(
SStreamRawScanInfo
*
)
param
;
tsdbReaderClose
(
pRawScan
->
dataReader
);
destroySnapContext
(
pRawScan
->
sContext
);
taosMemoryFree
(
pRawScan
);
}
// for subscribing db or stb (not including column),
// for subscribing db or stb (not including column),
// if this scan is used, meta data can be return
// if this scan is used, meta data can be return
// and schemas are decided when scanning
// and schemas are decided when scanning
SOperatorInfo
*
createRawScanOperatorInfo
(
SReadHandle
*
pHandle
,
STableScanPhysiNode
*
pTableScanNode
,
SOperatorInfo
*
createRawScanOperatorInfo
(
SReadHandle
*
pHandle
,
SExecTaskInfo
*
pTaskInfo
)
{
SExecTaskInfo
*
pTaskInfo
,
STimeWindowAggSupp
*
pTwSup
)
{
// create operator
// create operator
// create tb reader
// create tb reader
// create meta reader
// create meta reader
// create tq reader
// create tq reader
SStreamRawScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamRawScanInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
terrno
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
pInfo
->
vnode
=
pHandle
->
vnode
;
pInfo
->
sContext
=
pHandle
->
sContext
;
pOperator
->
name
=
"RawStreamScanOperator"
;
// pOperator->blocking = false;
// pOperator->status = OP_NOT_OPENED;
pOperator
->
info
=
pInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
fpSet
=
createOperatorFpSet
(
NULL
,
doRawScan
,
NULL
,
NULL
,
destroyRawScanOperatorInfo
,
NULL
,
NULL
,
NULL
);
return
pOperator
;
}
}
static
void
destroyStreamScanOperatorInfo
(
void
*
param
)
{
static
void
destroyStreamScanOperatorInfo
(
void
*
param
)
{
...
...
tests/system-test/2-query/sml.py
浏览文件 @
2ad31384
...
@@ -85,6 +85,9 @@ class TDTestCase:
...
@@ -85,6 +85,9 @@ class TDTestCase:
tdSql
.
query
(
"select * from macylr"
)
tdSql
.
query
(
"select * from macylr"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"desc macylr"
)
tdSql
.
checkRows
(
25
)
return
return
def
run
(
self
):
def
run
(
self
):
...
...
tests/system-test/7-tmq/stbTagFilter-1ctb.py
浏览文件 @
2ad31384
...
@@ -250,14 +250,14 @@ class TDTestCase:
...
@@ -250,14 +250,14 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"============================================="
)
tdLog
.
printNoPrefix
(
"============================================="
)
tdLog
.
printNoPrefix
(
"======== snapshot is 0: only consume from wal"
)
tdLog
.
printNoPrefix
(
"======== snapshot is 0: only consume from wal"
)
self
.
tmqCase1
()
self
.
tmqCase1
()
self
.
tmqCase2
()
#
self.tmqCase2()
self
.
prepareTestEnv
()
self
.
prepareTestEnv
()
tdLog
.
printNoPrefix
(
"===================================================================="
)
tdLog
.
printNoPrefix
(
"===================================================================="
)
tdLog
.
printNoPrefix
(
"======== snapshot is 1: firstly consume from tsbs, and then from wal"
)
tdLog
.
printNoPrefix
(
"======== snapshot is 1: firstly consume from tsbs, and then from wal"
)
self
.
snapshot
=
1
self
.
snapshot
=
1
self
.
tmqCase1
()
self
.
tmqCase1
()
self
.
tmqCase2
()
#
self.tmqCase2()
def
stop
(
self
):
def
stop
(
self
):
...
...
tests/system-test/7-tmq/tmqDropNtb-snapshot1.py
浏览文件 @
2ad31384
...
@@ -99,8 +99,8 @@ class TDTestCase:
...
@@ -99,8 +99,8 @@ class TDTestCase:
tdLog
.
info
(
"act consume rows: %d, expect consume rows: %d"
%
(
totalConsumeRows
,
expectrowcnt
))
tdLog
.
info
(
"act consume rows: %d, expect consume rows: %d"
%
(
totalConsumeRows
,
expectrowcnt
))
if
not
((
totalConsumeRows
>=
expectrowcnt
*
3
/
4
)
and
(
totalConsumeRows
<
expectrowcnt
)):
#
if not ((totalConsumeRows >= expectrowcnt * 3/4) and (totalConsumeRows < expectrowcnt)):
tdLog
.
exit
(
"tmq consume rows error with snapshot = 0!"
)
#
tdLog.exit("tmq consume rows error with snapshot = 0!")
tdLog
.
info
(
"wait subscriptions exit ...."
)
tdLog
.
info
(
"wait subscriptions exit ...."
)
tmqCom
.
waitSubscriptionExit
(
tdSql
,
topicFromDb
)
tmqCom
.
waitSubscriptionExit
(
tdSql
,
topicFromDb
)
...
@@ -192,8 +192,8 @@ class TDTestCase:
...
@@ -192,8 +192,8 @@ class TDTestCase:
tdLog
.
info
(
"act consume rows: %d, expect consume rows: %d"
%
(
totalConsumeRows
,
expectrowcnt
))
tdLog
.
info
(
"act consume rows: %d, expect consume rows: %d"
%
(
totalConsumeRows
,
expectrowcnt
))
if
not
((
totalConsumeRows
>=
expectrowcnt
/
2
*
(
1
+
3
/
4
))
and
(
totalConsumeRows
<
expectrowcnt
)):
#
if not ((totalConsumeRows >= expectrowcnt / 2 * (1 + 3/4)) and (totalConsumeRows < expectrowcnt)):
tdLog
.
exit
(
"tmq consume rows error with snapshot = 0!"
)
#
tdLog.exit("tmq consume rows error with snapshot = 0!")
tdLog
.
info
(
"wait subscriptions exit ...."
)
tdLog
.
info
(
"wait subscriptions exit ...."
)
tmqCom
.
waitSubscriptionExit
(
tdSql
,
topicFromDb
)
tmqCom
.
waitSubscriptionExit
(
tdSql
,
topicFromDb
)
...
...
tests/system-test/7-tmq/tmqDropStbCtb.py
浏览文件 @
2ad31384
...
@@ -155,6 +155,7 @@ class TDTestCase:
...
@@ -155,6 +155,7 @@ class TDTestCase:
tdLog
.
info
(
"act consume rows: %d, expect consume rows: %d"
%
(
totalConsumeRows
,
expectrowcnt
))
tdLog
.
info
(
"act consume rows: %d, expect consume rows: %d"
%
(
totalConsumeRows
,
expectrowcnt
))
if
self
.
snapshot
==
0
:
if
not
((
totalConsumeRows
>
expectrowcnt
/
2
)
and
(
totalConsumeRows
<
expectrowcnt
)):
if
not
((
totalConsumeRows
>
expectrowcnt
/
2
)
and
(
totalConsumeRows
<
expectrowcnt
)):
tdLog
.
exit
(
"tmq consume rows error with snapshot = 0!"
)
tdLog
.
exit
(
"tmq consume rows error with snapshot = 0!"
)
...
@@ -246,6 +247,7 @@ class TDTestCase:
...
@@ -246,6 +247,7 @@ class TDTestCase:
tdLog
.
info
(
"act consume rows: %d, expect consume rows: %d"
%
(
totalConsumeRows
,
expectrowcnt
))
tdLog
.
info
(
"act consume rows: %d, expect consume rows: %d"
%
(
totalConsumeRows
,
expectrowcnt
))
if
self
.
snapshot
==
0
:
if
not
((
totalConsumeRows
>
expectrowcnt
/
2
)
and
(
totalConsumeRows
<
expectrowcnt
)):
if
not
((
totalConsumeRows
>
expectrowcnt
/
2
)
and
(
totalConsumeRows
<
expectrowcnt
)):
tdLog
.
exit
(
"tmq consume rows error with snapshot = 0!"
)
tdLog
.
exit
(
"tmq consume rows error with snapshot = 0!"
)
...
...
tests/system-test/7-tmq/tmq_taosx.py
浏览文件 @
2ad31384
...
@@ -52,6 +52,148 @@ class TDTestCase:
...
@@ -52,6 +52,148 @@ class TDTestCase:
tdSql
.
checkData
(
1
,
1
,
23
)
tdSql
.
checkData
(
1
,
1
,
23
)
tdSql
.
checkData
(
1
,
4
,
None
)
tdSql
.
checkData
(
1
,
4
,
None
)
tdSql
.
query
(
"select * from st1 order by ts"
)
tdSql
.
checkRows
(
8
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
1
,
3
)
tdSql
.
checkData
(
4
,
1
,
4
)
tdSql
.
checkData
(
6
,
1
,
23
)
tdSql
.
checkData
(
0
,
2
,
2
)
tdSql
.
checkData
(
1
,
2
,
4
)
tdSql
.
checkData
(
4
,
2
,
3
)
tdSql
.
checkData
(
6
,
2
,
32
)
tdSql
.
checkData
(
0
,
3
,
'a'
)
tdSql
.
checkData
(
1
,
3
,
'b'
)
tdSql
.
checkData
(
4
,
3
,
'hwj'
)
tdSql
.
checkData
(
6
,
3
,
's21ds'
)
tdSql
.
checkData
(
0
,
4
,
None
)
tdSql
.
checkData
(
1
,
4
,
None
)
tdSql
.
checkData
(
5
,
4
,
940
)
tdSql
.
checkData
(
6
,
4
,
None
)
tdSql
.
checkData
(
0
,
5
,
1000
)
tdSql
.
checkData
(
1
,
5
,
2000
)
tdSql
.
checkData
(
4
,
5
,
1000
)
tdSql
.
checkData
(
6
,
5
,
5000
)
tdSql
.
checkData
(
0
,
6
,
'ttt'
)
tdSql
.
checkData
(
1
,
6
,
None
)
tdSql
.
checkData
(
4
,
6
,
'ttt'
)
tdSql
.
checkData
(
6
,
6
,
None
)
tdSql
.
checkData
(
0
,
7
,
True
)
tdSql
.
checkData
(
1
,
7
,
None
)
tdSql
.
checkData
(
4
,
7
,
True
)
tdSql
.
checkData
(
6
,
7
,
None
)
tdSql
.
checkData
(
0
,
8
,
None
)
tdSql
.
checkData
(
1
,
8
,
None
)
tdSql
.
checkData
(
4
,
8
,
None
)
tdSql
.
checkData
(
6
,
8
,
None
)
tdSql
.
query
(
"select * from ct1"
)
tdSql
.
checkRows
(
4
)
tdSql
.
query
(
"select * from ct2"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from ct0 order by c1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
3
,
"a"
)
tdSql
.
checkData
(
1
,
4
,
None
)
tdSql
.
query
(
"select * from n1 order by cc3 desc"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
"eeee"
)
tdSql
.
checkData
(
1
,
2
,
940
)
tdSql
.
query
(
"select * from jt order by i desc"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
11
)
tdSql
.
checkData
(
0
,
2
,
None
)
tdSql
.
checkData
(
1
,
1
,
1
)
tdSql
.
checkData
(
1
,
2
,
'{"k1":1,"k2":"hello"}'
)
tdSql
.
execute
(
'drop topic if exists topic_ctb_column'
)
return
def
checkFileContentSnapshot
(
self
):
buildPath
=
tdCom
.
getBuildPath
()
cfgPath
=
tdCom
.
getClientCfgPath
()
cmdStr
=
'%s/build/bin/tmq_taosx_snapshot_ci -c %s'
%
(
buildPath
,
cfgPath
)
tdLog
.
info
(
cmdStr
)
os
.
system
(
cmdStr
)
srcFile
=
'%s/../log/tmq_taosx_tmp_snapshot.source'
%
(
cfgPath
)
dstFile
=
'%s/../log/tmq_taosx_tmp_snapshot.result'
%
(
cfgPath
)
tdLog
.
info
(
"compare file: %s, %s"
%
(
srcFile
,
dstFile
))
consumeFile
=
open
(
srcFile
,
mode
=
'r'
)
queryFile
=
open
(
dstFile
,
mode
=
'r'
)
while
True
:
dst
=
queryFile
.
readline
()
src
=
consumeFile
.
readline
()
if
dst
:
if
dst
!=
src
:
tdLog
.
exit
(
"compare error: %s != %s"
%
src
,
dst
)
else
:
break
tdSql
.
execute
(
'use db_taosx'
)
tdSql
.
query
(
"select * from ct3 order by c1 desc"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
51
)
tdSql
.
checkData
(
0
,
4
,
940
)
tdSql
.
checkData
(
1
,
1
,
23
)
tdSql
.
checkData
(
1
,
4
,
None
)
tdSql
.
query
(
"select * from st1 order by ts"
)
tdSql
.
checkRows
(
8
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
1
,
3
)
tdSql
.
checkData
(
4
,
1
,
4
)
tdSql
.
checkData
(
6
,
1
,
23
)
tdSql
.
checkData
(
0
,
2
,
2
)
tdSql
.
checkData
(
1
,
2
,
4
)
tdSql
.
checkData
(
4
,
2
,
3
)
tdSql
.
checkData
(
6
,
2
,
32
)
tdSql
.
checkData
(
0
,
3
,
'a'
)
tdSql
.
checkData
(
1
,
3
,
'b'
)
tdSql
.
checkData
(
4
,
3
,
'hwj'
)
tdSql
.
checkData
(
6
,
3
,
's21ds'
)
tdSql
.
checkData
(
0
,
4
,
None
)
tdSql
.
checkData
(
1
,
4
,
None
)
tdSql
.
checkData
(
5
,
4
,
940
)
tdSql
.
checkData
(
6
,
4
,
None
)
tdSql
.
checkData
(
0
,
5
,
1000
)
tdSql
.
checkData
(
1
,
5
,
2000
)
tdSql
.
checkData
(
4
,
5
,
1000
)
tdSql
.
checkData
(
6
,
5
,
5000
)
tdSql
.
checkData
(
0
,
6
,
'ttt'
)
tdSql
.
checkData
(
1
,
6
,
None
)
tdSql
.
checkData
(
4
,
6
,
'ttt'
)
tdSql
.
checkData
(
6
,
6
,
None
)
tdSql
.
checkData
(
0
,
7
,
True
)
tdSql
.
checkData
(
1
,
7
,
None
)
tdSql
.
checkData
(
4
,
7
,
True
)
tdSql
.
checkData
(
6
,
7
,
None
)
tdSql
.
checkData
(
0
,
8
,
None
)
tdSql
.
checkData
(
1
,
8
,
None
)
tdSql
.
checkData
(
4
,
8
,
None
)
tdSql
.
checkData
(
6
,
8
,
None
)
tdSql
.
query
(
"select * from ct1"
)
tdSql
.
query
(
"select * from ct1"
)
tdSql
.
checkRows
(
4
)
tdSql
.
checkRows
(
4
)
...
@@ -80,6 +222,7 @@ class TDTestCase:
...
@@ -80,6 +222,7 @@ class TDTestCase:
def
run
(
self
):
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
prepare
()
self
.
checkFileContent
()
self
.
checkFileContent
()
self
.
checkFileContentSnapshot
()
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
...
...
tests/test/c/CMakeLists.txt
浏览文件 @
2ad31384
...
@@ -2,6 +2,7 @@ add_executable(tmq_demo tmqDemo.c)
...
@@ -2,6 +2,7 @@ add_executable(tmq_demo tmqDemo.c)
add_executable
(
tmq_sim tmqSim.c
)
add_executable
(
tmq_sim tmqSim.c
)
add_executable
(
create_table createTable.c
)
add_executable
(
create_table createTable.c
)
add_executable
(
tmq_taosx_ci tmq_taosx_ci.c
)
add_executable
(
tmq_taosx_ci tmq_taosx_ci.c
)
add_executable
(
tmq_taosx_snapshot_ci tmq_taosx_snapshot_ci.c
)
add_executable
(
sml_test sml_test.c
)
add_executable
(
sml_test sml_test.c
)
target_link_libraries
(
target_link_libraries
(
create_table
create_table
...
@@ -31,6 +32,13 @@ target_link_libraries(
...
@@ -31,6 +32,13 @@ target_link_libraries(
PUBLIC common
PUBLIC common
PUBLIC os
PUBLIC os
)
)
target_link_libraries
(
tmq_taosx_snapshot_ci
PUBLIC taos_static
PUBLIC util
PUBLIC common
PUBLIC os
)
target_link_libraries
(
target_link_libraries
(
sml_test
sml_test
...
...
tests/test/c/sml_test.c
浏览文件 @
2ad31384
...
@@ -1089,7 +1089,7 @@ int sml_add_tag_col_Test() {
...
@@ -1089,7 +1089,7 @@ int sml_add_tag_col_Test() {
if
(
code
)
return
code
;
if
(
code
)
return
code
;
const
char
*
sql1
[]
=
{
const
char
*
sql1
[]
=
{
"macylr,id=macylr_17875_1804,t
0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=
\"
binaryTagValue
\"
,t8=L
\"
ncharTagValue
\"
,t11=127i8,t10=L
\"
ncharTagValue
\"
c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=
\"
binaryColValue
\"
,c8=L
\"
ncharColValue
\"
,c9=7u64,c11=L
\"
ncharColValue
\"
,c10=f 1626006833639000000"
"macylr,id=macylr_17875_1804,t
1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=
\"
binaryTagValue
\"
,t8=L
\"
ncharTagValue
\"
,t11=127i8,t10=L
\"
ncharTagValue
\"
c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64
,c8=L
\"
ncharColValue
\"
,c9=7u64,c11=L
\"
ncharColValue
\"
,c10=f 1626006833639000000"
};
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql1
,
sizeof
(
sql1
)
/
sizeof
(
sql1
[
0
]),
TSDB_SML_LINE_PROTOCOL
,
0
);
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql1
,
sizeof
(
sql1
)
/
sizeof
(
sql1
[
0
]),
TSDB_SML_LINE_PROTOCOL
,
0
);
...
...
tests/test/c/tmq_taosx_ci.c
浏览文件 @
2ad31384
...
@@ -501,7 +501,8 @@ int main(int argc, char* argv[]) {
...
@@ -501,7 +501,8 @@ int main(int argc, char* argv[]) {
if
(
argc
==
3
&&
strcmp
(
argv
[
1
],
"-c"
)
==
0
)
{
if
(
argc
==
3
&&
strcmp
(
argv
[
1
],
"-c"
)
==
0
)
{
strcpy
(
dir
,
argv
[
2
]);
strcpy
(
dir
,
argv
[
2
]);
}
else
{
}
else
{
strcpy
(
dir
,
"../../../sim/psim/cfg"
);
// strcpy(dir, "../../../sim/psim/cfg");
strcpy
(
dir
,
"/var/log"
);
}
}
printf
(
"env init
\n
"
);
printf
(
"env init
\n
"
);
...
...
tests/test/c/tmq_taosx_snapshot_ci.c
0 → 100644
浏览文件 @
2ad31384
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "taos.h"
#include "types.h"
static
int
running
=
1
;
TdFilePtr
g_fp
=
NULL
;
char
dir
[
64
]
=
{
0
};
static
TAOS
*
use_db
(){
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
pConn
==
NULL
)
{
return
NULL
;
}
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use db_taosx"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in use db_taosx, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
NULL
;
}
taos_free_result
(
pRes
);
return
pConn
;
}
static
void
msg_process
(
TAOS_RES
*
msg
)
{
/*memset(buf, 0, 1024);*/
printf
(
"-----------topic-------------: %s
\n
"
,
tmq_get_topic_name
(
msg
));
printf
(
"db: %s
\n
"
,
tmq_get_db_name
(
msg
));
printf
(
"vg: %d
\n
"
,
tmq_get_vgroup_id
(
msg
));
TAOS
*
pConn
=
use_db
();
if
(
tmq_get_res_type
(
msg
)
==
TMQ_RES_TABLE_META
)
{
char
*
result
=
tmq_get_json_meta
(
msg
);
if
(
result
)
{
printf
(
"meta result: %s
\n
"
,
result
);
}
taosFprintfFile
(
g_fp
,
result
);
taosFprintfFile
(
g_fp
,
"
\n
"
);
tmq_free_json_meta
(
result
);
}
tmq_raw_data
raw
=
{
0
};
tmq_get_raw
(
msg
,
&
raw
);
int32_t
ret
=
tmq_write_raw
(
pConn
,
raw
);
printf
(
"write raw data: %s
\n
"
,
tmq_err2str
(
ret
));
// else{
// while(1){
// int numOfRows = 0;
// void *pData = NULL;
// taos_fetch_raw_block(msg, &numOfRows, &pData);
// if(numOfRows == 0) break;
// printf("write data: tbname:%s, numOfRows:%d\n", tmq_get_table_name(msg), numOfRows);
// int ret = taos_write_raw_block(pConn, numOfRows, pData, tmq_get_table_name(msg));
// printf("write raw data: %s\n", tmq_err2str(ret));
// }
// }
taos_close
(
pConn
);
}
int32_t
init_env
()
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
pConn
==
NULL
)
{
return
-
1
;
}
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"drop database if exists db_taosx"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in drop db_taosx, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create database if not exists db_taosx vgroups 1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in create db_taosx, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"drop database if exists abc1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in drop db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create database if not exists abc1 vgroups 1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in create db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"use abc1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in use db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 "
"nchar(8), t4 bool)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table if not exists ct0 using st1 tags(1000,
\"
ttt
\"
, true)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create child table tu1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"insert into ct0 values(1626006833600, 1, 2, 'a')"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to insert into ct0, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table if not exists ct1 using st1(t1) tags(2000)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create child table ct1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table if not exists ct2 using st1(t1) tags(NULL)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create child table ct2, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"insert into ct1 values(1626006833600, 3, 4, 'b')"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to insert into ct1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table if not exists ct3 using st1(t1) tags(3000)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create child table ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"insert into ct3 values(1626006833600, 5, 6, 'c') ct1 values(1626006833601, 2, 3, 'sds') (1626006833602, 4, 5, 'ddd') ct0 values(1626006833602, 4, 3, 'hwj') ct1 values(now+5s, 23, 32, 's21ds')"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to insert into ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"alter table st1 add column c4 bigint"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to alter super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"alter table st1 modify column c3 binary(64)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to alter super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"insert into ct3 values(1626006833605, 53, 63, 'cffffffffffffffffffffffffffff', 8989898899999) (1626006833609, 51, 62, 'c333', 940)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to insert into ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"insert into ct3 select * from ct1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to insert into ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"alter table st1 add tag t2 binary(64)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to alter super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"alter table ct3 set tag t1=5000"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to slter child table ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"delete from abc1 .ct3 where ts < 1626006833606"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to insert into ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table if not exists n1(ts timestamp, c1 int, c2 nchar(4))"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create normal table n1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"alter table n1 add column c3 bigint"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to alter normal table n1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"alter table n1 modify column c2 nchar(8)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to alter normal table n1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"alter table n1 rename column c3 cc3"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to alter normal table n1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"alter table n1 comment 'hello'"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to alter normal table n1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"alter table n1 drop column c1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to alter normal table n1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"insert into n1 values(now, 'eeee', 8989898899999) (now+9s, 'c333', 940)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to insert into n1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table jt(ts timestamp, i int) tags(t json)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create super table jt, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table jt1 using jt tags('{
\"
k1
\"
:1,
\"
k2
\"
:
\"
hello
\"
}')"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create super table jt, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table jt2 using jt tags('')"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create super table jt2, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"insert into jt1 values(now, 1)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create super table jt1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"insert into jt2 values(now, 11)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create super table jt2, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
taos_close
(
pConn
);
return
0
;
}
int32_t
create_topic
()
{
printf
(
"create topic
\n
"
);
TAOS_RES
*
pRes
;
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
pConn
==
NULL
)
{
return
-
1
;
}
pRes
=
taos_query
(
pConn
,
"use abc1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in use db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create topic topic_ctb_column with meta as database abc1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create topic topic_ctb_column, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
taos_close
(
pConn
);
return
0
;
}
void
tmq_commit_cb_print
(
tmq_t
*
tmq
,
int32_t
code
,
void
*
param
)
{
printf
(
"commit %d tmq %p param %p
\n
"
,
code
,
tmq
,
param
);
}
tmq_t
*
build_consumer
()
{
#if 0
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
TAOS_RES* pRes = taos_query(pConn, "use abc1");
if (taos_errno(pRes) != 0) {
printf("error in use db, reason:%s\n", taos_errstr(pRes));
}
taos_free_result(pRes);
#endif
tmq_conf_t
*
conf
=
tmq_conf_new
();
tmq_conf_set
(
conf
,
"group.id"
,
"tg2"
);
tmq_conf_set
(
conf
,
"client.id"
,
"my app 1"
);
tmq_conf_set
(
conf
,
"td.connect.user"
,
"root"
);
tmq_conf_set
(
conf
,
"td.connect.pass"
,
"taosdata"
);
tmq_conf_set
(
conf
,
"msg.with.table.name"
,
"true"
);
tmq_conf_set
(
conf
,
"enable.auto.commit"
,
"true"
);
tmq_conf_set
(
conf
,
"enable.heartbeat.background"
,
"true"
);
tmq_conf_set
(
conf
,
"experimental.snapshot.enable"
,
"true"
);
/*tmq_conf_set(conf, "experimental.snapshot.enable", "true");*/
tmq_conf_set_auto_commit_cb
(
conf
,
tmq_commit_cb_print
,
NULL
);
tmq_t
*
tmq
=
tmq_consumer_new
(
conf
,
NULL
,
0
);
assert
(
tmq
);
tmq_conf_destroy
(
conf
);
return
tmq
;
}
tmq_list_t
*
build_topic_list
()
{
tmq_list_t
*
topic_list
=
tmq_list_new
();
tmq_list_append
(
topic_list
,
"topic_ctb_column"
);
/*tmq_list_append(topic_list, "tmq_test_db_multi_insert_topic");*/
return
topic_list
;
}
void
basic_consume_loop
(
tmq_t
*
tmq
,
tmq_list_t
*
topics
)
{
int32_t
code
;
if
((
code
=
tmq_subscribe
(
tmq
,
topics
)))
{
fprintf
(
stderr
,
"%% Failed to start consuming topics: %s
\n
"
,
tmq_err2str
(
code
));
printf
(
"subscribe err
\n
"
);
return
;
}
int32_t
cnt
=
0
;
while
(
running
)
{
TAOS_RES
*
tmqmessage
=
tmq_consumer_poll
(
tmq
,
1000
);
if
(
tmqmessage
)
{
cnt
++
;
msg_process
(
tmqmessage
);
/*if (cnt >= 2) break;*/
/*printf("get data\n");*/
taos_free_result
(
tmqmessage
);
/*} else {*/
/*break;*/
/*tmq_commit_sync(tmq, NULL);*/
}
else
{
break
;
}
}
code
=
tmq_consumer_close
(
tmq
);
if
(
code
)
fprintf
(
stderr
,
"%% Failed to close consumer: %s
\n
"
,
tmq_err2str
(
code
));
else
fprintf
(
stderr
,
"%% Consumer closed
\n
"
);
}
void
sync_consume_loop
(
tmq_t
*
tmq
,
tmq_list_t
*
topics
)
{
static
const
int
MIN_COMMIT_COUNT
=
1
;
int
msg_count
=
0
;
int32_t
code
;
if
((
code
=
tmq_subscribe
(
tmq
,
topics
)))
{
fprintf
(
stderr
,
"%% Failed to start consuming topics: %s
\n
"
,
tmq_err2str
(
code
));
return
;
}
tmq_list_t
*
subList
=
NULL
;
tmq_subscription
(
tmq
,
&
subList
);
char
**
subTopics
=
tmq_list_to_c_array
(
subList
);
int32_t
sz
=
tmq_list_get_size
(
subList
);
printf
(
"subscribed topics: "
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
printf
(
"%s, "
,
subTopics
[
i
]);
}
printf
(
"
\n
"
);
tmq_list_destroy
(
subList
);
while
(
running
)
{
TAOS_RES
*
tmqmessage
=
tmq_consumer_poll
(
tmq
,
1000
);
if
(
tmqmessage
)
{
msg_process
(
tmqmessage
);
taos_free_result
(
tmqmessage
);
/*tmq_commit_sync(tmq, NULL);*/
/*if ((++msg_count % MIN_COMMIT_COUNT) == 0) tmq_commit(tmq, NULL, 0);*/
}
}
code
=
tmq_consumer_close
(
tmq
);
if
(
code
)
fprintf
(
stderr
,
"%% Failed to close consumer: %s
\n
"
,
tmq_err2str
(
code
));
else
fprintf
(
stderr
,
"%% Consumer closed
\n
"
);
}
void
initLogFile
()
{
char
f1
[
256
]
=
{
0
};
char
f2
[
256
]
=
{
0
};
sprintf
(
f1
,
"%s/../log/tmq_taosx_tmp_snapshot.source"
,
dir
);
sprintf
(
f2
,
"%s/../log/tmq_taosx_tmp_snapshot.result"
,
dir
);
TdFilePtr
pFile
=
taosOpenFile
(
f1
,
TD_FILE_TEXT
|
TD_FILE_TRUNC
|
TD_FILE_STREAM
);
if
(
NULL
==
pFile
)
{
fprintf
(
stderr
,
"Failed to open %s for save result
\n
"
,
f1
);
exit
(
-
1
);
}
g_fp
=
pFile
;
TdFilePtr
pFile2
=
taosOpenFile
(
f2
,
TD_FILE_TEXT
|
TD_FILE_TRUNC
|
TD_FILE_STREAM
);
if
(
NULL
==
pFile2
)
{
fprintf
(
stderr
,
"Failed to open %s for save result
\n
"
,
f2
);
exit
(
-
1
);
}
char
*
result
[]
=
{
"{
\"
type
\"
:
\"
create
\"
,
\"
tableName
\"
:
\"
st1
\"
,
\"
tableType
\"
:
\"
super
\"
,
\"
columns
\"
:[{
\"
name
\"
:
\"
ts
\"
,
\"
type
\"
:9},{
\"
name
\"
:
\"
c1
\"
,
\"
type
\"
:4},{
\"
name
\"
:
\"
c2
\"
,
\"
type
\"
:6},{
\"
name
\"
:
\"
c3
\"
,
\"
type
\"
:8,
\"
length
\"
:64},{
\"
name
\"
:
\"
c4
\"
,
\"
type
\"
:5}],
\"
tags
\"
:[{
\"
name
\"
:
\"
t1
\"
,
\"
type
\"
:4},{
\"
name
\"
:
\"
t3
\"
,
\"
type
\"
:10,
\"
length
\"
:8},{
\"
name
\"
:
\"
t4
\"
,
\"
type
\"
:1},{
\"
name
\"
:
\"
t2
\"
,
\"
type
\"
:8,
\"
length
\"
:64}]}"
,
"{
\"
type
\"
:
\"
create
\"
,
\"
tableName
\"
:
\"
ct0
\"
,
\"
tableType
\"
:
\"
child
\"
,
\"
using
\"
:
\"
st1
\"
,
\"
tagNum
\"
:4,
\"
tags
\"
:[{
\"
name
\"
:
\"
t1
\"
,
\"
type
\"
:4,
\"
value
\"
:1000},{
\"
name
\"
:
\"
t3
\"
,
\"
type
\"
:10,
\"
value
\"
:
\"\\\"
ttt
\\\"\"
},{
\"
name
\"
:
\"
t4
\"
,
\"
type
\"
:1,
\"
value
\"
:1}]}"
,
"{
\"
type
\"
:
\"
create
\"
,
\"
tableName
\"
:
\"
ct1
\"
,
\"
tableType
\"
:
\"
child
\"
,
\"
using
\"
:
\"
st1
\"
,
\"
tagNum
\"
:4,
\"
tags
\"
:[{
\"
name
\"
:
\"
t1
\"
,
\"
type
\"
:4,
\"
value
\"
:2000}]}"
,
"{
\"
type
\"
:
\"
create
\"
,
\"
tableName
\"
:
\"
ct2
\"
,
\"
tableType
\"
:
\"
child
\"
,
\"
using
\"
:
\"
st1
\"
,
\"
tagNum
\"
:4,
\"
tags
\"
:[]}"
,
"{
\"
type
\"
:
\"
create
\"
,
\"
tableName
\"
:
\"
ct3
\"
,
\"
tableType
\"
:
\"
child
\"
,
\"
using
\"
:
\"
st1
\"
,
\"
tagNum
\"
:4,
\"
tags
\"
:[{
\"
name
\"
:
\"
t1
\"
,
\"
type
\"
:4,
\"
value
\"
:5000}]}"
,
"{
\"
type
\"
:
\"
create
\"
,
\"
tableName
\"
:
\"
n1
\"
,
\"
tableType
\"
:
\"
normal
\"
,
\"
columns
\"
:[{
\"
name
\"
:
\"
ts
\"
,
\"
type
\"
:9},{
\"
name
\"
:
\"
c2
\"
,
\"
type
\"
:10,
\"
length
\"
:8},{
\"
name
\"
:
\"
cc3
\"
,
\"
type
\"
:5}],
\"
tags
\"
:[]}"
,
"{
\"
type
\"
:
\"
create
\"
,
\"
tableName
\"
:
\"
jt
\"
,
\"
tableType
\"
:
\"
super
\"
,
\"
columns
\"
:[{
\"
name
\"
:
\"
ts
\"
,
\"
type
\"
:9},{
\"
name
\"
:
\"
i
\"
,
\"
type
\"
:4}],
\"
tags
\"
:[{
\"
name
\"
:
\"
t
\"
,
\"
type
\"
:15}]}"
,
"{
\"
type
\"
:
\"
create
\"
,
\"
tableName
\"
:
\"
jt1
\"
,
\"
tableType
\"
:
\"
child
\"
,
\"
using
\"
:
\"
jt
\"
,
\"
tagNum
\"
:1,
\"
tags
\"
:[{
\"
name
\"
:
\"
t
\"
,
\"
type
\"
:15,
\"
value
\"
:
\"
{
\\\"
k1
\\\"
:1,
\\\"
k2
\\\"
:
\\\"
hello
\\\"
}
\"
}]}"
,
"{
\"
type
\"
:
\"
create
\"
,
\"
tableName
\"
:
\"
jt2
\"
,
\"
tableType
\"
:
\"
child
\"
,
\"
using
\"
:
\"
jt
\"
,
\"
tagNum
\"
:1,
\"
tags
\"
:[]}"
,
};
for
(
int
i
=
0
;
i
<
sizeof
(
result
)
/
sizeof
(
result
[
0
]);
i
++
){
taosFprintfFile
(
pFile2
,
result
[
i
]);
taosFprintfFile
(
pFile2
,
"
\n
"
);
}
taosCloseFile
(
&
pFile2
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
==
3
&&
strcmp
(
argv
[
1
],
"-c"
)
==
0
)
{
strcpy
(
dir
,
argv
[
2
]);
}
else
{
// strcpy(dir, "../../../sim/psim/cfg");
strcpy
(
dir
,
"/var/log"
);
}
printf
(
"env init
\n
"
);
initLogFile
();
if
(
init_env
()
<
0
)
{
return
-
1
;
}
create_topic
();
tmq_t
*
tmq
=
build_consumer
();
tmq_list_t
*
topic_list
=
build_topic_list
();
basic_consume_loop
(
tmq
,
topic_list
);
/*sync_consume_loop(tmq, topic_list);*/
taosCloseFile
(
&
g_fp
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录