Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
冷面1992
TDengine
提交
d0f62cff
TDengine
项目概览
冷面1992
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d0f62cff
编写于
10月 30, 2019
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug issue #643.
上级
09e34704
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
49 addition
and
35 deletion
+49
-35
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+17
-10
src/inc/tinterpolation.h
src/inc/tinterpolation.h
+2
-2
src/system/inc/vnode.h
src/system/inc/vnode.h
+8
-8
src/system/src/vnodeQueryImpl.c
src/system/src/vnodeQueryImpl.c
+12
-8
src/system/src/vnodeRead.c
src/system/src/vnodeRead.c
+2
-0
src/util/src/tinterpolation.c
src/util/src/tinterpolation.c
+8
-7
未找到文件。
src/client/src/tscSecondaryMerge.c
浏览文件 @
d0f62cff
...
...
@@ -279,8 +279,9 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
pRes
->
pLocalReducer
=
pReducer
;
pRes
->
numOfGroups
=
0
;
int16_t
prec
=
pCmd
->
pMeterMeta
->
precision
;
int64_t
stime
=
(
pCmd
->
stime
<
pCmd
->
etime
)
?
pCmd
->
stime
:
pCmd
->
etime
;
int64_t
revisedSTime
=
taosGetIntervalStartTimestamp
(
stime
,
pCmd
->
nAggTimeInterval
,
pCmd
->
intervalTimeUnit
);
int64_t
revisedSTime
=
taosGetIntervalStartTimestamp
(
stime
,
pCmd
->
nAggTimeInterval
,
pCmd
->
intervalTimeUnit
,
prec
);
SInterpolationInfo
*
pInterpoInfo
=
&
pReducer
->
interpolationInfo
;
taosInitInterpoInfo
(
pInterpoInfo
,
pCmd
->
order
.
order
,
revisedSTime
,
pCmd
->
groupbyExpr
.
numOfGroupbyCols
,
...
...
@@ -664,12 +665,11 @@ void adjustLoserTreeFromNewData(SLocalReducer *pLocalReducer, SLocalDataSource *
}
}
void
savePrevRecordAndSetupInterpoInfo
(
SLocalReducer
*
pLocalReducer
,
SSqlCmd
*
pCmd
,
SInterpolationInfo
*
pInterpoInfo
)
{
// discard following dataset in the same group and reset the interpolation information
void
savePrevRecordAndSetupInterpoInfo
(
SLocalReducer
*
pLocalReducer
,
SSqlCmd
*
pCmd
,
SInterpolationInfo
*
pInterpoInfo
)
{
// discard following dataset in the same group and reset the interpolation information
int16_t
prec
=
pCmd
->
pMeterMeta
->
precision
;
int64_t
stime
=
(
pCmd
->
stime
<
pCmd
->
etime
)
?
pCmd
->
stime
:
pCmd
->
etime
;
int64_t
revisedSTime
=
taosGetIntervalStartTimestamp
(
stime
,
pCmd
->
nAggTimeInterval
,
pCmd
->
intervalTimeUnit
);
int64_t
revisedSTime
=
taosGetIntervalStartTimestamp
(
stime
,
pCmd
->
nAggTimeInterval
,
pCmd
->
intervalTimeUnit
,
prec
);
taosInitInterpoInfo
(
pInterpoInfo
,
pCmd
->
order
.
order
,
revisedSTime
,
pCmd
->
groupbyExpr
.
numOfGroupbyCols
,
pLocalReducer
->
rowSize
);
...
...
@@ -811,9 +811,12 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
functions
[
i
]
=
tscSqlExprGet
(
pCmd
,
i
)
->
sqlFuncId
;
}
int8_t
precision
=
pCmd
->
pMeterMeta
->
precision
;
while
(
1
)
{
int32_t
remains
=
taosNumOfRemainPoints
(
pInterpoInfo
);
TSKEY
etime
=
taosGetRevisedEndKey
(
actualETime
,
pCmd
->
order
.
order
,
pCmd
->
nAggTimeInterval
,
pCmd
->
intervalTimeUnit
);
TSKEY
etime
=
taosGetRevisedEndKey
(
actualETime
,
pCmd
->
order
.
order
,
pCmd
->
nAggTimeInterval
,
pCmd
->
intervalTimeUnit
,
precision
);
int32_t
nrows
=
taosGetNumOfResultWithInterpo
(
pInterpoInfo
,
pPrimaryKeys
,
remains
,
pCmd
->
nAggTimeInterval
,
etime
,
pLocalReducer
->
resColModel
->
maxCapacity
);
...
...
@@ -1115,10 +1118,12 @@ static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer
pRes
->
numOfTotal
=
0
;
pCmd
->
limit
.
offset
=
pLocalReducer
->
offset
;
int16_t
precision
=
pCmd
->
pMeterMeta
->
precision
;
if
(
pCmd
->
interpoType
!=
TSDB_INTERPO_NONE
)
{
/* for group result interpolation, do not return if not data is generated */
int64_t
stime
=
(
pCmd
->
stime
<
pCmd
->
etime
)
?
pCmd
->
stime
:
pCmd
->
etime
;
int64_t
newTime
=
taosGetIntervalStartTimestamp
(
stime
,
pCmd
->
nAggTimeInterval
,
pCmd
->
intervalTimeUnit
);
int64_t
newTime
=
taosGetIntervalStartTimestamp
(
stime
,
pCmd
->
nAggTimeInterval
,
pCmd
->
intervalTimeUnit
,
precision
);
taosInitInterpoInfo
(
&
pLocalReducer
->
interpolationInfo
,
pCmd
->
order
.
order
,
newTime
,
pCmd
->
groupbyExpr
.
numOfGroupbyCols
,
pLocalReducer
->
rowSize
);
...
...
@@ -1135,6 +1140,7 @@ static bool doInterpolationForCurrentGroup(SSqlObj *pSql) {
SLocalReducer
*
pLocalReducer
=
pRes
->
pLocalReducer
;
SInterpolationInfo
*
pInterpoInfo
=
&
pLocalReducer
->
interpolationInfo
;
int8_t
p
=
pCmd
->
pMeterMeta
->
precision
;
if
(
taosHasRemainsDataForInterpolation
(
pInterpoInfo
))
{
assert
(
pCmd
->
interpoType
!=
TSDB_INTERPO_NONE
);
...
...
@@ -1143,7 +1149,7 @@ static bool doInterpolationForCurrentGroup(SSqlObj *pSql) {
int64_t
etime
=
*
(
int64_t
*
)(
pFinalDataBuf
->
data
+
TSDB_KEYSIZE
*
(
pInterpoInfo
->
numOfRawDataInRows
-
1
));
int32_t
remain
=
taosNumOfRemainPoints
(
pInterpoInfo
);
TSKEY
ekey
=
taosGetRevisedEndKey
(
etime
,
pCmd
->
order
.
order
,
pCmd
->
nAggTimeInterval
,
pCmd
->
intervalTimeUnit
);
TSKEY
ekey
=
taosGetRevisedEndKey
(
etime
,
pCmd
->
order
.
order
,
pCmd
->
nAggTimeInterval
,
pCmd
->
intervalTimeUnit
,
p
);
int32_t
rows
=
taosGetNumOfResultWithInterpo
(
pInterpoInfo
,
(
TSKEY
*
)
pLocalReducer
->
pBufForInterpo
,
remain
,
pCmd
->
nAggTimeInterval
,
ekey
,
pLocalReducer
->
resColModel
->
maxCapacity
);
if
(
rows
>
0
)
{
// do interpo
...
...
@@ -1164,6 +1170,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
SInterpolationInfo
*
pInterpoInfo
=
&
pLocalReducer
->
interpolationInfo
;
bool
prevGroupCompleted
=
(
!
pLocalReducer
->
discard
)
&&
pLocalReducer
->
hasUnprocessedRow
;
int8_t
precision
=
pCmd
->
pMeterMeta
->
precision
;
if
((
isAllSourcesCompleted
(
pLocalReducer
)
&&
!
pLocalReducer
->
hasPrevRow
)
||
pLocalReducer
->
pLocalDataSrc
[
0
]
==
NULL
||
prevGroupCompleted
)
{
...
...
@@ -1171,7 +1178,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
if
(
pCmd
->
interpoType
!=
TSDB_INTERPO_NONE
)
{
int64_t
etime
=
(
pCmd
->
stime
<
pCmd
->
etime
)
?
pCmd
->
etime
:
pCmd
->
stime
;
etime
=
taosGetRevisedEndKey
(
etime
,
pCmd
->
order
.
order
,
pCmd
->
nAggTimeInterval
,
pCmd
->
intervalTimeUnit
);
etime
=
taosGetRevisedEndKey
(
etime
,
pCmd
->
order
.
order
,
pCmd
->
nAggTimeInterval
,
pCmd
->
intervalTimeUnit
,
precision
);
int32_t
rows
=
taosGetNumOfResultWithInterpo
(
pInterpoInfo
,
NULL
,
0
,
pCmd
->
nAggTimeInterval
,
etime
,
pLocalReducer
->
resColModel
->
maxCapacity
);
if
(
rows
>
0
)
{
// do interpo
...
...
src/inc/tinterpolation.h
浏览文件 @
d0f62cff
...
...
@@ -40,14 +40,14 @@ typedef struct SPoint {
typedef
void
(
*
__interpo_callback_fn_t
)(
void
*
param
);
int64_t
taosGetIntervalStartTimestamp
(
int64_t
startTime
,
int64_t
timeRange
,
char
intervalTimeUnit
);
int64_t
taosGetIntervalStartTimestamp
(
int64_t
startTime
,
int64_t
timeRange
,
char
intervalTimeUnit
,
int16_t
precision
);
void
taosInitInterpoInfo
(
SInterpolationInfo
*
pInterpoInfo
,
int32_t
order
,
int64_t
startTimeStamp
,
int32_t
numOfTags
,
int32_t
rowSize
);
void
taosInterpoSetStartInfo
(
SInterpolationInfo
*
pInterpoInfo
,
int32_t
numOfRawDataInRows
,
int32_t
type
);
TSKEY
taosGetRevisedEndKey
(
TSKEY
ekey
,
int32_t
order
,
int32_t
timeInterval
,
int8_t
intervalTimeUnit
);
TSKEY
taosGetRevisedEndKey
(
TSKEY
ekey
,
int32_t
order
,
int32_t
timeInterval
,
int8_t
intervalTimeUnit
,
int8_t
precision
);
/**
*
...
...
src/system/inc/vnode.h
浏览文件 @
d0f62cff
...
...
@@ -278,14 +278,14 @@ typedef struct {
TSKEY
ekey
;
int64_t
nAggTimeInterval
;
char
intervalTimeUnit
;
// interval data type, used for daytime revise
int16_t
numOfOutputCols
;
int16_t
interpoType
;
int16_t
checkBufferInLoop
;
// check if the buffer is full during scan each block
SLimitVal
limit
;
int32_t
rowSize
;
int32_t
dataRowSize
;
// row size of each loaded data from disk, the value is
char
precision
;
int16_t
numOfOutputCols
;
int16_t
interpoType
;
int16_t
checkBufferInLoop
;
// check if the buffer is full during scan each block
SLimitVal
limit
;
int32_t
rowSize
;
int32_t
dataRowSize
;
// row size of each loaded data from disk, the value is
// used for prepare buffer
SSqlGroupbyExpr
*
pGroupbyExpr
;
SSqlFunctionExpr
*
pSelectExpr
;
...
...
src/system/src/vnodeQueryImpl.c
浏览文件 @
d0f62cff
...
...
@@ -1105,7 +1105,8 @@ static int32_t applyAllFunctions(SQueryRuntimeEnv *pRuntimeEnv, int32_t forwardS
TSKEY
ts
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
pQuery
->
skey
:
pQuery
->
ekey
;
int64_t
alignedTimestamp
=
taosGetIntervalStartTimestamp
(
ts
,
pQuery
->
nAggTimeInterval
,
pQuery
->
intervalTimeUnit
);
int64_t
alignedTimestamp
=
taosGetIntervalStartTimestamp
(
ts
,
pQuery
->
nAggTimeInterval
,
pQuery
->
intervalTimeUnit
,
pQuery
->
precision
);
setExecParams
(
pQuery
,
&
pCtx
[
k
],
alignedTimestamp
,
dataBlock
,
(
char
*
)
primaryKeyCol
,
forwardStep
,
functionId
,
tpField
,
hasNull
,
pRuntimeEnv
->
blockStatus
,
&
sas
,
pRuntimeEnv
->
scanFlag
);
...
...
@@ -1190,7 +1191,8 @@ static int32_t applyAllFunctions_Filter(SQueryRuntimeEnv *pRuntimeEnv, int32_t *
char
*
dataBlock
=
getDataBlocks
(
pRuntimeEnv
,
data
,
&
sasArray
[
k
],
k
,
isDiskFileBlock
);
TSKEY
ts
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
pQuery
->
skey
:
pQuery
->
ekey
;
int64_t
alignedTimestamp
=
taosGetIntervalStartTimestamp
(
ts
,
pQuery
->
nAggTimeInterval
,
pQuery
->
intervalTimeUnit
);
int64_t
alignedTimestamp
=
taosGetIntervalStartTimestamp
(
ts
,
pQuery
->
nAggTimeInterval
,
pQuery
->
intervalTimeUnit
,
pQuery
->
precision
);
setExecParams
(
pQuery
,
&
pCtx
[
k
],
alignedTimestamp
,
dataBlock
,
(
char
*
)
primaryKeyCol
,
(
*
forwardStep
),
functionId
,
pFields
,
hasNull
,
pRuntimeEnv
->
blockStatus
,
&
sasArray
[
k
],
pRuntimeEnv
->
scanFlag
);
...
...
@@ -2096,7 +2098,8 @@ static void doGetAlignedIntervalQueryRangeImpl(SQuery *pQuery, int64_t qualified
return
;
}
*
skey
=
taosGetIntervalStartTimestamp
(
qualifiedKey
,
pQuery
->
nAggTimeInterval
,
pQuery
->
intervalTimeUnit
);
*
skey
=
taosGetIntervalStartTimestamp
(
qualifiedKey
,
pQuery
->
nAggTimeInterval
,
pQuery
->
intervalTimeUnit
,
pQuery
->
precision
);
int64_t
endKey
=
*
skey
+
pQuery
->
nAggTimeInterval
-
1
;
if
(
*
skey
<
keyFirst
)
{
...
...
@@ -3276,7 +3279,8 @@ int32_t vnodeQuerySingleMeterPrepare(SQInfo *pQInfo, SMeterObj *pMeterObj, SMete
return
TSDB_CODE_SUCCESS
;
}
int64_t
rs
=
taosGetIntervalStartTimestamp
(
pSupporter
->
rawSKey
,
pQuery
->
nAggTimeInterval
,
pQuery
->
intervalTimeUnit
);
int64_t
rs
=
taosGetIntervalStartTimestamp
(
pSupporter
->
rawSKey
,
pQuery
->
nAggTimeInterval
,
pQuery
->
intervalTimeUnit
,
pQuery
->
precision
);
taosInitInterpoInfo
(
&
pSupporter
->
runtimeEnv
.
interpoInfo
,
pQuery
->
order
.
order
,
rs
,
0
,
0
);
allocMemForInterpo
(
pSupporter
,
pQuery
,
pMeterObj
);
...
...
@@ -3431,8 +3435,8 @@ int32_t vnodeMultiMeterQueryPrepare(SQInfo *pQInfo, SQuery *pQuery) {
pQuery
->
interpoType
=
TSDB_INTERPO_NONE
;
}
TSKEY
revisedStime
=
taosGetIntervalStartTimestamp
(
pSupporter
->
rawSKey
,
pQuery
->
nAggTimeInterval
,
pQuery
->
intervalTimeUnit
);
TSKEY
revisedStime
=
taosGetIntervalStartTimestamp
(
pSupporter
->
rawSKey
,
pQuery
->
nAggTimeInterval
,
pQuery
->
intervalTimeUnit
,
pQuery
->
precision
);
taosInitInterpoInfo
(
&
pSupporter
->
runtimeEnv
.
interpoInfo
,
pQuery
->
order
.
order
,
revisedStime
,
0
,
0
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -6117,7 +6121,7 @@ bool vnodeHasRemainResults(void *handle) {
if
(
Q_STATUS_EQUAL
(
pQuery
->
over
,
QUERY_COMPLETED
|
QUERY_NO_DATA_TO_CHECK
))
{
/* query has completed */
TSKEY
ekey
=
taosGetRevisedEndKey
(
pSupporter
->
rawEKey
,
pQuery
->
order
.
order
,
pQuery
->
nAggTimeInterval
,
pQuery
->
intervalTimeUnit
);
pQuery
->
intervalTimeUnit
,
pQuery
->
precision
);
int32_t
numOfTotal
=
taosGetNumOfResultWithInterpo
(
pInterpoInfo
,
(
TSKEY
*
)
pRuntimeEnv
->
pInterpoBuf
[
0
]
->
data
,
remain
,
pQuery
->
nAggTimeInterval
,
ekey
,
pQuery
->
pointsToRead
);
return
numOfTotal
>
0
;
...
...
@@ -6201,7 +6205,7 @@ int32_t vnodeQueryResultInterpolate(SQInfo *pQInfo, tFilePage **pDst, tFilePage
numOfRows
=
taosNumOfRemainPoints
(
&
pRuntimeEnv
->
interpoInfo
);
TSKEY
ekey
=
taosGetRevisedEndKey
(
pSupporter
->
rawEKey
,
pQuery
->
order
.
order
,
pQuery
->
nAggTimeInterval
,
pQuery
->
intervalTimeUnit
);
pQuery
->
intervalTimeUnit
,
pQuery
->
precision
);
int32_t
numOfFinalRows
=
taosGetNumOfResultWithInterpo
(
&
pRuntimeEnv
->
interpoInfo
,
(
TSKEY
*
)
pDataSrc
[
0
]
->
data
,
numOfRows
,
pQuery
->
nAggTimeInterval
,
ekey
,
pQuery
->
pointsToRead
);
...
...
src/system/src/vnodeRead.c
浏览文件 @
d0f62cff
...
...
@@ -222,6 +222,8 @@ static SQInfo *vnodeAllocateQInfoCommon(SQueryMeterMsg *pQueryMsg, SMeterObj *pM
}
vnodeUpdateFilterColumnIndex
(
pQuery
);
pQuery
->
precision
=
vnodeList
[
pMeterObj
->
vnode
].
cfg
.
precision
;
return
pQInfo
;
_clean_memory:
...
...
src/util/src/tinterpolation.c
浏览文件 @
d0f62cff
...
...
@@ -25,7 +25,7 @@
#define INTERPOL_IS_ASC_INTERPOL(interp) ((interp)->order == TSQL_SO_ASC)
int64_t
taosGetIntervalStartTimestamp
(
int64_t
startTime
,
int64_t
timeRange
,
char
intervalTimeUnit
)
{
int64_t
taosGetIntervalStartTimestamp
(
int64_t
startTime
,
int64_t
timeRange
,
char
intervalTimeUnit
,
int16_t
precision
)
{
if
(
timeRange
==
0
)
{
return
startTime
;
}
...
...
@@ -39,16 +39,17 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t timeRange, char
*
* TODO dynmaically decide the start time of a day
*/
#ifdef _MSC_VER
#if _MSC_VER >= 1900
#if
defined(WINDOWS) &&
_MSC_VER >= 1900
// see https://docs.microsoft.com/en-us/cpp/c-runtime-library/daylight-dstbias-timezone-and-tzname?view=vs-2019
int64_t
timezone
=
_timezone
;
int32_t
daylight
=
_daylight
;
char
**
tzname
=
_tzname
;
#endif
#endif
int64_t
revStartime
=
(
startTime
/
timeRange
)
*
timeRange
+
timezone
*
MILLISECOND_PER_SECOND
;
int64_t
t
=
(
precision
==
TSDB_TIME_PRECISION_MILLI
)
?
MILLISECOND_PER_SECOND
:
MILLISECOND_PER_SECOND
*
1000L
;
int64_t
revStartime
=
(
startTime
/
timeRange
)
*
timeRange
+
timezone
*
t
;
int64_t
revEndtime
=
revStartime
+
timeRange
-
1
;
if
(
revEndtime
<
startTime
)
{
revStartime
+=
timeRange
;
...
...
@@ -85,11 +86,11 @@ void taosInterpoSetStartInfo(SInterpolationInfo* pInterpoInfo, int32_t numOfRawD
pInterpoInfo
->
numOfRawDataInRows
=
numOfRawDataInRows
;
}
TSKEY
taosGetRevisedEndKey
(
TSKEY
ekey
,
int32_t
order
,
int32_t
timeInterval
,
int8_t
intervalTimeUnit
)
{
TSKEY
taosGetRevisedEndKey
(
TSKEY
ekey
,
int32_t
order
,
int32_t
timeInterval
,
int8_t
intervalTimeUnit
,
int8_t
precision
)
{
if
(
order
==
TSQL_SO_ASC
)
{
return
ekey
;
}
else
{
return
taosGetIntervalStartTimestamp
(
ekey
,
timeInterval
,
intervalTimeUnit
);
return
taosGetIntervalStartTimestamp
(
ekey
,
timeInterval
,
intervalTimeUnit
,
precision
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录