Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
80336357
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
80336357
编写于
6月 13, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
other: add debug logs
上级
f35baac5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
200 addition
and
1 deletion
+200
-1
source/common/src/trow.c
source/common/src/trow.c
+17
-0
source/dnode/vnode/src/sma/smaTimeRange.c
source/dnode/vnode/src/sma/smaTimeRange.c
+178
-0
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+5
-1
未找到文件。
source/common/src/trow.c
浏览文件 @
80336357
...
...
@@ -523,8 +523,24 @@ static int32_t tdAppendTpRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols
SCellVal
sVal
=
{
0
};
if
(
pRowCol
->
colId
==
pDataCol
->
colId
)
{
if
(
tdGetTpRowValOfCol
(
&
sVal
,
pRow
,
pBitmap
,
pRowCol
->
type
,
pRowCol
->
offset
-
sizeof
(
TSKEY
),
rcol
-
1
)
<
0
)
{
ASSERT
(
0
);
return
terrno
;
}
if
(
pRowCol
->
colId
==
2
)
{
ASSERT
(
sVal
.
valType
==
0
);
int32_t
val
=
*
(
int32_t
*
)
sVal
.
val
;
ASSERT
(
val
==
7
);
}
else
if
(
pRowCol
->
colId
==
3
)
{
ASSERT
(
sVal
.
valType
==
0
);
int64_t
val
=
*
(
int64_t
*
)
sVal
.
val
;
ASSERT
(
val
==
77777
);
}
else
if
(
pRowCol
->
colId
==
4
)
{
ASSERT
(
sVal
.
valType
==
0
);
int16_t
val
=
*
(
int16_t
*
)
sVal
.
val
;
ASSERT
(
val
==
777
);
}
tdAppendValToDataCol
(
pDataCol
,
sVal
.
valType
,
sVal
.
val
,
pCols
->
numOfRows
,
pCols
->
maxPoints
,
pCols
->
bitmapMode
,
isMerge
);
++
dcol
;
...
...
@@ -535,6 +551,7 @@ static int32_t tdAppendTpRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols
tdAppendValToDataCol
(
pDataCol
,
TD_VTYPE_NULL
,
NULL
,
pCols
->
numOfRows
,
pCols
->
maxPoints
,
pCols
->
bitmapMode
,
isMerge
);
++
dcol
;
ASSERT
(
0
);
}
}
#if 0
...
...
source/dnode/vnode/src/sma/smaTimeRange.c
0 → 100644
浏览文件 @
80336357
/*
* 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 "sma.h"
#include "tsdb.h"
#define SMA_STORAGE_MINUTES_MAX 86400
#define SMA_STORAGE_MINUTES_DAY 1440
#define SMA_STORAGE_SPLIT_FACTOR 14400 // least records in tsma file
/**
* @brief Judge the tsma file split days
*
* @param pCfg
* @param pCont
* @param contLen
* @param days unit is minute
* @return int32_t
*/
int32_t
tdProcessTSmaGetDaysImpl
(
SVnodeCfg
*
pCfg
,
void
*
pCont
,
uint32_t
contLen
,
int32_t
*
days
)
{
SDecoder
coder
=
{
0
};
tDecoderInit
(
&
coder
,
pCont
,
contLen
);
STSma
tsma
=
{
0
};
if
(
tDecodeSVCreateTSmaReq
(
&
coder
,
&
tsma
)
<
0
)
{
terrno
=
TSDB_CODE_MSG_DECODE_ERROR
;
goto
_err
;
}
STsdbCfg
*
pTsdbCfg
=
&
pCfg
->
tsdbCfg
;
int64_t
sInterval
=
convertTimeFromPrecisionToUnit
(
tsma
.
interval
,
pTsdbCfg
->
precision
,
TIME_UNIT_SECOND
);
if
(
sInterval
<=
0
)
{
*
days
=
pTsdbCfg
->
days
;
return
0
;
}
int64_t
records
=
pTsdbCfg
->
days
*
60
/
sInterval
;
if
(
records
>=
SMA_STORAGE_SPLIT_FACTOR
)
{
*
days
=
pTsdbCfg
->
days
;
}
else
{
int64_t
mInterval
=
convertTimeFromPrecisionToUnit
(
tsma
.
interval
,
pTsdbCfg
->
precision
,
TIME_UNIT_MINUTE
);
int64_t
daysPerFile
=
mInterval
*
SMA_STORAGE_MINUTES_DAY
*
2
;
if
(
daysPerFile
>
SMA_STORAGE_MINUTES_MAX
)
{
*
days
=
SMA_STORAGE_MINUTES_MAX
;
}
else
{
*
days
=
(
int32_t
)
daysPerFile
;
}
if
(
*
days
<
pTsdbCfg
->
days
)
{
*
days
=
pTsdbCfg
->
days
;
}
}
tDecoderClear
(
&
coder
);
return
0
;
_err:
tDecoderClear
(
&
coder
);
return
-
1
;
}
/**
* @brief create tsma meta and result stable
*
* @param pSma
* @param version
* @param pMsg
* @return int32_t
*/
int32_t
tdProcessTSmaCreateImpl
(
SSma
*
pSma
,
int64_t
version
,
const
char
*
pMsg
)
{
SSmaCfg
*
pCfg
=
(
SSmaCfg
*
)
pMsg
;
if
(
TD_VID
(
pSma
->
pVnode
)
==
pCfg
->
dstVgId
)
{
// create tsma meta in dstVgId
if
(
metaCreateTSma
(
SMA_META
(
pSma
),
version
,
pCfg
)
<
0
)
{
return
-
1
;
}
// create stable to save tsma result in dstVgId
SVCreateStbReq
pReq
=
{
0
};
pReq
.
name
=
pCfg
->
dstTbName
;
pReq
.
suid
=
pCfg
->
dstTbUid
;
pReq
.
schemaRow
=
pCfg
->
schemaRow
;
pReq
.
schemaTag
=
pCfg
->
schemaTag
;
if
(
metaCreateSTable
(
SMA_META
(
pSma
),
version
,
&
pReq
)
<
0
)
{
return
-
1
;
}
}
return
0
;
}
/**
* @brief Insert/Update Time-range-wise SMA data.
*
* @param pSma
* @param msg
* @return int32_t
*/
int32_t
tdProcessTSmaInsertImpl
(
SSma
*
pSma
,
int64_t
indexUid
,
const
char
*
msg
)
{
const
SArray
*
pDataBlocks
=
(
const
SArray
*
)
msg
;
// TODO: destroy SSDataBlocks(msg)
if
(
!
pDataBlocks
)
{
terrno
=
TSDB_CODE_TSMA_INVALID_PTR
;
smaWarn
(
"vgId:%d, insert tsma data failed since pDataBlocks is NULL"
,
SMA_VID
(
pSma
));
return
terrno
;
}
if
(
taosArrayGetSize
(
pDataBlocks
)
<=
0
)
{
terrno
=
TSDB_CODE_TSMA_INVALID_PARA
;
smaWarn
(
"vgId:%d, insert tsma data failed since pDataBlocks is empty"
,
SMA_VID
(
pSma
));
return
TSDB_CODE_FAILED
;
}
if
(
tdCheckAndInitSmaEnv
(
pSma
,
TSDB_SMA_TYPE_TIME_RANGE
)
!=
0
)
{
terrno
=
TSDB_CODE_TSMA_INIT_FAILED
;
return
TSDB_CODE_FAILED
;
}
SSmaEnv
*
pEnv
=
SMA_TSMA_ENV
(
pSma
);
SSmaStat
*
pStat
=
NULL
;
SSmaStatItem
*
pItem
=
NULL
;
if
(
!
pEnv
||
!
(
pStat
=
SMA_ENV_STAT
(
pEnv
)))
{
terrno
=
TSDB_CODE_TSMA_INVALID_STAT
;
return
TSDB_CODE_FAILED
;
}
tdRefSmaStat
(
pSma
,
pStat
);
pItem
=
&
pStat
->
tsmaStatItem
;
ASSERT
(
pItem
);
if
(
!
pItem
->
pTSma
)
{
// cache smaMeta
STSma
*
pTSma
=
metaGetSmaInfoByIndex
(
SMA_META
(
pSma
),
indexUid
);
if
(
!
pTSma
)
{
terrno
=
TSDB_CODE_TSMA_NO_INDEX_IN_META
;
smaWarn
(
"vgId:%d, tsma insert for smaIndex %"
PRIi64
" since %s"
,
SMA_VID
(
pSma
),
indexUid
,
tstrerror
(
terrno
));
return
TSDB_CODE_FAILED
;
}
pItem
->
pTSma
=
pTSma
;
}
STSma
*
pTSma
=
pItem
->
pTSma
;
ASSERT
(
pTSma
->
indexUid
==
indexUid
);
SMetaReader
mr
=
{
0
};
const
char
*
dbName
=
"testDb"
;
if
(
metaGetTableEntryByName
(
&
mr
,
dbName
)
!=
0
)
{
smaDebug
(
"vgId:%d, tsma no table testTb exists for smaIndex %"
PRIi64
" since %s"
,
SMA_VID
(
pSma
),
indexUid
,
tstrerror
(
terrno
));
SVCreateStbReq
pReq
=
{
0
};
pReq
.
name
=
dbName
;
pReq
.
suid
=
pTSma
->
dstTbUid
;
pReq
.
schemaRow
=
pCfg
->
schemaRow
;
pReq
.
schemaTag
=
pCfg
->
schemaTag
;
}
SSubmitReq
*
pSubmitReq
=
NULL
;
buildSubmitReqFromDataBlock
(
&
pSubmitReq
,
(
const
SArray
*
)
msg
,
NULL
,
pItem
->
pTSma
->
dstVgId
,
pItem
->
pTSma
->
dstTbUid
);
tdUnRefSmaStat
(
pSma
,
pStat
);
return
TSDB_CODE_SUCCESS
;
}
\ No newline at end of file
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
80336357
...
...
@@ -15,6 +15,8 @@
#include "vnd.h"
int32_t
gForceCommit
=
1
;
static
int32_t
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
static
int32_t
vnodeProcessAlterStbReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
static
int32_t
vnodeProcessDropStbReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
...
...
@@ -182,7 +184,8 @@ int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
}
// commit if need
if
(
vnodeShouldCommit
(
pVnode
))
{
if
((
gForceCommit
==
1
)
||
vnodeShouldCommit
(
pVnode
))
{
gForceCommit
=
0
;
vInfo
(
"vgId:%d, commit at version %"
PRId64
,
TD_VID
(
pVnode
),
version
);
// commit current change
vnodeCommit
(
pVnode
);
...
...
@@ -719,6 +722,7 @@ static int32_t vnodeDebugPrintSubmitMsg(SVnode *pVnode, SSubmitReq *pMsg, const
}
static
int32_t
vnodeProcessSubmitReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
)
{
gForceCommit
=
1
;
SSubmitReq
*
pSubmitReq
=
(
SSubmitReq
*
)
pReq
;
SSubmitRsp
submitRsp
=
{
0
};
SSubmitMsgIter
msgIter
=
{
0
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录