Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Tonvia
TDengine
提交
69142ea5
T
TDengine
项目概览
Tonvia
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
69142ea5
编写于
6月 01, 2020
作者:
B
Bomin Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-449: data is written to TSDB
上级
d34cabf2
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
49 addition
and
20 deletion
+49
-20
src/client/src/tscStream.c
src/client/src/tscStream.c
+6
-2
src/common/inc/tdataformat.h
src/common/inc/tdataformat.h
+1
-0
src/cq/src/cqMain.c
src/cq/src/cqMain.c
+36
-12
src/cq/test/cqtest.c
src/cq/test/cqtest.c
+1
-1
src/inc/tcq.h
src/inc/tcq.h
+1
-1
src/inc/tsdb.h
src/inc/tsdb.h
+1
-1
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+1
-1
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+1
-1
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+1
-1
未找到文件。
src/client/src/tscStream.c
浏览文件 @
69142ea5
...
...
@@ -19,6 +19,7 @@
#include "tscLog.h"
#include "tscUtil.h"
#include "tsched.h"
#include "tcache.h"
#include "tsclient.h"
#include "ttime.h"
#include "ttimer.h"
...
...
@@ -147,7 +148,8 @@ static void tscProcessStreamQueryCallback(void *param, TAOS_RES *tres, int numOf
retryDelay
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pStream
->
pSql
->
cmd
,
0
,
0
);
tscClearTableMetaInfo
(
pTableMetaInfo
,
true
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
pTableMetaInfo
->
pTableMeta
),
true
);
tfree
(
pTableMetaInfo
->
vgroupList
);
tscSetRetryTimer
(
pStream
,
pStream
->
pSql
,
retryDelay
);
return
;
...
...
@@ -259,7 +261,9 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
pStream
->
numOfRes
);
// release the metric/meter meta information reference, so data in cache can be updated
tscClearTableMetaInfo
(
pTableMetaInfo
,
false
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
pTableMetaInfo
->
pTableMeta
),
false
);
tfree
(
pTableMetaInfo
->
vgroupList
);
tscSetNextLaunchTimer
(
pStream
,
pSql
);
}
}
...
...
src/common/inc/tdataformat.h
浏览文件 @
69142ea5
...
...
@@ -70,6 +70,7 @@ typedef struct {
int
numOfCols
;
// Number of columns appended
int
tlen
;
// maximum length of a SDataRow without the header part
int
flen
;
// First part length in a SDataRow after the header part
int32_t
version
;
STColumn
columns
[];
}
STSchema
;
...
...
src/cq/src/cqMain.c
浏览文件 @
69142ea5
...
...
@@ -49,7 +49,8 @@ typedef struct {
}
SCqContext
;
typedef
struct
SCqObj
{
int
tid
;
// table ID
uint64_t
uid
;
int32_t
tid
;
// table ID
int
rowSize
;
// bytes of a row
char
*
sqlStr
;
// SQL string
STSchema
*
pSchema
;
// pointer to schema array
...
...
@@ -155,17 +156,19 @@ void cqStop(void *handle) {
pthread_mutex_unlock
(
&
pContext
->
mutex
);
}
void
*
cqCreate
(
void
*
handle
,
int
tid
,
char
*
sqlStr
,
STSchema
*
pSchema
)
{
void
*
cqCreate
(
void
*
handle
,
uint64_t
uid
,
int
tid
,
char
*
sqlStr
,
STSchema
*
pSchema
)
{
SCqContext
*
pContext
=
handle
;
SCqObj
*
pObj
=
calloc
(
sizeof
(
SCqObj
),
1
);
if
(
pObj
==
NULL
)
return
NULL
;
pObj
->
uid
=
uid
;
pObj
->
tid
=
tid
;
pObj
->
sqlStr
=
malloc
(
strlen
(
sqlStr
)
+
1
);
strcpy
(
pObj
->
sqlStr
,
sqlStr
);
pObj
->
pSchema
=
tdDupSchema
(
pSchema
);
pObj
->
rowSize
=
pSchema
->
tlen
;
cTrace
(
"vgId:%d, id:%d CQ:%s is created"
,
pContext
->
vgId
,
pObj
->
tid
,
pObj
->
sqlStr
);
...
...
@@ -213,8 +216,8 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) {
pContext
->
dbConn
=
taos_connect
(
"localhost"
,
pContext
->
user
,
pContext
->
pass
,
pContext
->
db
,
0
);
if
(
pContext
->
dbConn
==
NULL
)
{
cError
(
"vgId:%d, failed to connect to TDengine(%s)"
,
pContext
->
vgId
,
tstrerror
(
terrno
));
return
;
}
return
;
}
int64_t
lastKey
=
0
;
...
...
@@ -231,6 +234,7 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) {
static
void
cqProcessStreamRes
(
void
*
param
,
TAOS_RES
*
tres
,
TAOS_ROW
row
)
{
SCqObj
*
pObj
=
(
SCqObj
*
)
param
;
SCqContext
*
pContext
=
pObj
->
pContext
;
STSchema
*
pSchema
=
pObj
->
pSchema
;
if
(
pObj
->
pStream
==
NULL
)
return
;
cTrace
(
"vgId:%d, id:%d CQ:%s stream result is ready"
,
pContext
->
vgId
,
pObj
->
tid
,
pObj
->
sqlStr
);
...
...
@@ -240,18 +244,38 @@ static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row) {
char
*
buffer
=
calloc
(
size
,
1
);
SWalHead
*
pHead
=
(
SWalHead
*
)
buffer
;
pHead
->
msgType
=
TSDB_MSG_TYPE_SUBMIT
;
pHead
->
len
=
size
-
sizeof
(
SWalHead
);
SSubmitMsg
*
pSubmit
=
(
SSubmitMsg
*
)
(
buffer
+
sizeof
(
SWalHead
));
// to do: fill in the SSubmitMsg structure
pSubmit
->
numOfBlocks
=
1
;
SSubmitMsg
*
pMsg
=
(
SSubmitMsg
*
)
(
buffer
+
sizeof
(
SWalHead
));
SSubmitBlk
*
pBlk
=
(
SSubmitBlk
*
)
(
buffer
+
sizeof
(
SWalHead
)
+
sizeof
(
SSubmitMsg
));
int32_t
flen
=
0
;
for
(
int32_t
i
=
0
;
i
<
pSchema
->
numOfCols
;
i
++
)
{
flen
+=
TYPE_BYTES
[
pSchema
->
columns
[
i
].
type
];
}
SSubmitBlk
*
pBlk
=
(
SSubmitBlk
*
)
(
buffer
+
sizeof
(
SWalHead
)
+
sizeof
(
SSubmitMsg
));
// to do: fill in the SSubmitBlk strucuture
pBlk
->
tid
=
pObj
->
tid
;
SDataRow
trow
=
(
SDataRow
)
pBlk
->
data
;
dataRowSetLen
(
trow
,
TD_DATA_ROW_HEAD_SIZE
+
flen
);
int
toffset
=
0
;
for
(
int32_t
i
=
0
;
i
<
pSchema
->
numOfCols
;
i
++
)
{
tdAppendColVal
(
trow
,
row
[
i
],
pSchema
->
columns
[
i
].
type
,
pSchema
->
columns
[
i
].
bytes
,
toffset
);
toffset
+=
TYPE_BYTES
[
pSchema
->
columns
[
i
].
type
];
}
pBlk
->
len
=
htonl
(
dataRowLen
(
trow
));
pBlk
->
uid
=
htobe64
(
pObj
->
uid
);
pBlk
->
tid
=
htonl
(
pObj
->
tid
);
pBlk
->
numOfRows
=
htons
(
1
);
pBlk
->
sversion
=
htonl
(
pSchema
->
version
);
pBlk
->
padding
=
0
;
pMsg
->
header
.
vgId
=
htonl
(
pContext
->
vgId
);
pMsg
->
header
.
contLen
=
htonl
(
size
-
sizeof
(
SWalHead
));
pMsg
->
length
=
pMsg
->
header
.
contLen
;
pMsg
->
numOfBlocks
=
htonl
(
1
);
pHead
->
msgType
=
TSDB_MSG_TYPE_SUBMIT
;
pHead
->
len
=
size
-
sizeof
(
SWalHead
);
pHead
->
version
=
0
;
// write into vnode write queue
pContext
->
cqWrite
(
pContext
->
ahandle
,
pHead
,
TAOS_QTYPE_CQ
);
...
...
src/cq/test/cqtest.c
浏览文件 @
69142ea5
...
...
@@ -70,7 +70,7 @@ int main(int argc, char *argv[]) {
tdDestroyTSchemaBuilder
(
&
schemaBuilder
);
for
(
int
sid
=
1
;
sid
<
10
;
++
sid
)
{
cqCreate
(
pCq
,
sid
,
"select avg(speed) from demo.t1 sliding(1s) interval(5s)"
,
pSchema
);
cqCreate
(
pCq
,
sid
,
sid
,
"select avg(speed) from demo.t1 sliding(1s) interval(5s)"
,
pSchema
);
}
tdFreeSchema
(
pSchema
);
...
...
src/inc/tcq.h
浏览文件 @
69142ea5
...
...
@@ -42,7 +42,7 @@ void cqStart(void *handle);
void
cqStop
(
void
*
handle
);
// cqCreate is called by TSDB to start an instance of CQ
void
*
cqCreate
(
void
*
handle
,
int
sid
,
char
*
sqlStr
,
STSchema
*
pSchema
);
void
*
cqCreate
(
void
*
handle
,
uint64_t
uid
,
int
sid
,
char
*
sqlStr
,
STSchema
*
pSchema
);
// cqDrop is called by TSDB to stop an instance of CQ, handle is the return value of cqCreate
void
cqDrop
(
void
*
handle
);
...
...
src/inc/tsdb.h
浏览文件 @
69142ea5
...
...
@@ -43,7 +43,7 @@ typedef struct {
void
*
cqH
;
int
(
*
notifyStatus
)(
void
*
,
int
status
);
int
(
*
eventCallBack
)(
void
*
);
void
*
(
*
cqCreateFunc
)(
void
*
handle
,
int
sid
,
char
*
sqlStr
,
STSchema
*
pSchema
);
void
*
(
*
cqCreateFunc
)(
void
*
handle
,
uint64_t
uid
,
int
sid
,
char
*
sqlStr
,
STSchema
*
pSchema
);
void
(
*
cqDropFunc
)(
void
*
handle
);
void
*
(
*
configFunc
)(
int32_t
vgId
,
int32_t
sid
);
}
STsdbAppH
;
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
69142ea5
...
...
@@ -481,7 +481,7 @@ void tsdbStartStream(TsdbRepoT *repo) {
for
(
int
i
=
0
;
i
<
pRepo
->
config
.
maxTables
;
i
++
)
{
STable
*
pTable
=
pMeta
->
tables
[
i
];
if
(
pTable
&&
pTable
->
type
==
TSDB_STREAM_TABLE
)
{
pTable
->
cqhandle
=
(
*
pRepo
->
appH
.
cqCreateFunc
)(
pRepo
->
appH
.
cqH
,
pTable
->
tableId
.
tid
,
pTable
->
sql
,
tsdbGetTableSchema
(
pMeta
,
pTable
));
pTable
->
cqhandle
=
(
*
pRepo
->
appH
.
cqCreateFunc
)(
pRepo
->
appH
.
cqH
,
pTable
->
tableId
.
uid
,
pTable
->
tableId
.
tid
,
pTable
->
sql
,
tsdbGetTableSchema
(
pMeta
,
pTable
));
}
}
}
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
69142ea5
...
...
@@ -675,7 +675,7 @@ static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable, bool addIdx) {
tsdbAddTableIntoIndex
(
pMeta
,
pTable
);
}
if
(
pTable
->
type
==
TSDB_STREAM_TABLE
&&
addIdx
)
{
pTable
->
cqhandle
=
(
*
pRepo
->
appH
.
cqCreateFunc
)(
pRepo
->
appH
.
cqH
,
pTable
->
tableId
.
tid
,
pTable
->
sql
,
tsdbGetTableSchema
(
pMeta
,
pTable
));
pTable
->
cqhandle
=
(
*
pRepo
->
appH
.
cqCreateFunc
)(
pRepo
->
appH
.
cqH
,
pTable
->
tableId
.
uid
,
pTable
->
tableId
.
tid
,
pTable
->
sql
,
tsdbGetTableSchema
(
pMeta
,
pTable
));
}
pMeta
->
nTables
++
;
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
69142ea5
...
...
@@ -210,7 +210,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
SCqCfg
cqCfg
=
{
0
};
sprintf
(
cqCfg
.
user
,
"_root"
);
strcpy
(
cqCfg
.
pass
,
tsInternalPass
);
strcpy
(
cqCfg
.
db
,
"
s1_db0
"
);
// TODO: replace hard coded db name
strcpy
(
cqCfg
.
db
,
"
db
"
);
// TODO: replace hard coded db name
cqCfg
.
vgId
=
vnode
;
cqCfg
.
cqWrite
=
vnodeWriteToQueue
;
pVnode
->
cq
=
cqOpen
(
pVnode
,
&
cqCfg
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录