Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
4afd80c5
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
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看板
提交
4afd80c5
编写于
10月 31, 2019
作者:
陶建辉(Jeff)
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/taosdata/TDengine
上级
a54e96fc
d0f62cff
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
104 addition
and
61 deletion
+104
-61
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+17
-10
src/inc/tinterpolation.h
src/inc/tinterpolation.h
+2
-2
src/os/linux/inc/os.h
src/os/linux/inc/os.h
+5
-0
src/system/inc/vnode.h
src/system/inc/vnode.h
+8
-8
src/system/src/vnodeQueryImpl.c
src/system/src/vnodeQueryImpl.c
+17
-13
src/system/src/vnodeQueryProcess.c
src/system/src/vnodeQueryProcess.c
+44
-20
src/system/src/vnodeRead.c
src/system/src/vnodeRead.c
+2
-0
src/util/src/tcache.c
src/util/src/tcache.c
+1
-1
src/util/src/tinterpolation.c
src/util/src/tinterpolation.c
+8
-7
未找到文件。
src/client/src/tscSecondaryMerge.c
浏览文件 @
4afd80c5
...
...
@@ -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
浏览文件 @
4afd80c5
...
...
@@ -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/os/linux/inc/os.h
浏览文件 @
4afd80c5
...
...
@@ -60,8 +60,13 @@
#define __sync_val_compare_and_swap_64 __sync_val_compare_and_swap
#define __sync_val_compare_and_swap_32 __sync_val_compare_and_swap
#define __sync_add_and_fetch_64 __sync_add_and_fetch
#define __sync_add_and_fetch_32 __sync_add_and_fetch
#define __sync_sub_and_fetch_64 __sync_sub_and_fetch
#define __sync_sub_and_fetch_32 __sync_sub_and_fetch
int32_t
__sync_val_load_32
(
int32_t
*
ptr
);
void
__sync_val_restore_32
(
int32_t
*
ptr
,
int32_t
newval
);
...
...
src/system/inc/vnode.h
浏览文件 @
4afd80c5
...
...
@@ -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
浏览文件 @
4afd80c5
...
...
@@ -810,14 +810,14 @@ SCacheBlock *getCacheDataBlock(SMeterObj *pMeterObj, SQuery *pQuery, int32_t slo
SCacheBlock
*
pBlock
=
pCacheInfo
->
cacheBlocks
[
slot
];
if
(
pBlock
==
NULL
)
{
dError
(
"QInfo:%p NULL Block In Cache, available block:%d, last block:%d, accessed null block:%d, pBlockId:%d"
,
GET_QINFO_ADDR
(
pQuery
),
pCacheInfo
->
numOfBlocks
,
pCacheInfo
->
currentSlot
,
slot
,
pQuery
->
blockId
);
GET_QINFO_ADDR
(
pQuery
),
pCacheInfo
->
numOfBlocks
,
pCacheInfo
->
currentSlot
,
slot
,
pQuery
->
blockId
);
return
NULL
;
}
if
(
pMeterObj
!=
pBlock
->
pMeterObj
||
pBlock
->
blockId
>
pQuery
->
blockId
||
pBlock
->
numOfPoints
<=
0
)
{
dWarn
(
"QInfo:%p vid:%d sid:%d id:%s, cache block is overwritten, slot:%d blockId:%d qBlockId:%d"
,
GET_QINFO_ADDR
(
pQuery
),
pMeterObj
->
vnode
,
pMeterObj
->
sid
,
pMeterObj
->
meterId
,
pQuery
->
slot
,
pBlock
->
blockId
,
pQuery
->
blockId
);
if
(
pMeterObj
!=
pBlock
->
pMeterObj
||
pBlock
->
blockId
>
pQuery
->
blockId
)
{
dWarn
(
"QInfo:%p vid:%d sid:%d id:%s, cache block is overwritten, slot:%d blockId:%d qBlockId:%d
, meterObj:%p, blockMeterObj:%p
"
,
GET_QINFO_ADDR
(
pQuery
),
pMeterObj
->
vnode
,
pMeterObj
->
sid
,
pMeterObj
->
meterId
,
pQuery
->
slot
,
pBlock
->
blockId
,
pQuery
->
blockId
,
pMeterObj
,
pBlock
->
pMeterObj
);
return
NULL
;
}
...
...
@@ -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/vnodeQueryProcess.c
浏览文件 @
4afd80c5
...
...
@@ -27,6 +27,12 @@
#include "vnodeQueryImpl.h"
#define ALL_CACHE_BLOCKS_CHECKED(q) \
((q)->slot == (q)->currentSlot && QUERY_IS_ASC_QUERY(q) || (q)->slot == (q)->firstSlot && (!QUERY_IS_ASC_QUERY(q)))
#define FORWARD_CACHE_BLOCK_CHECK_SLOT(slot, step, maxblocks) (slot) = ((slot) + (step) + (maxblocks)) % (maxblocks);
static
bool
doCheckWithPrevQueryRange
(
SQInfo
*
pQInfo
,
TSKEY
nextKey
,
SMeterDataInfo
*
pMeterInfo
)
{
SMeterQuerySupportObj
*
pSupporter
=
pQInfo
->
pMeterQuerySupporter
;
SQuery
*
pQuery
=
&
pQInfo
->
query
;
...
...
@@ -49,6 +55,22 @@ static bool doCheckWithPrevQueryRange(SQInfo *pQInfo, TSKEY nextKey, SMeterDataI
return
true
;
}
/**
* The start position of the first check cache block is located before starting the loop.
* And the start position for next cache blocks needs to be decided before checking each cache block.
*/
static
void
setStartPositionForCacheBlock
(
SQuery
*
pQuery
,
SCacheBlock
*
pBlock
,
bool
*
firstCheckSlot
)
{
if
(
!
(
*
firstCheckSlot
))
{
if
(
QUERY_IS_ASC_QUERY
(
pQuery
))
{
pQuery
->
pos
=
0
;
}
else
{
pQuery
->
pos
=
pBlock
->
numOfPoints
-
1
;
}
}
else
{
(
*
firstCheckSlot
)
=
false
;
}
}
static
SMeterDataInfo
*
queryOnMultiDataCache
(
SQInfo
*
pQInfo
,
SMeterDataInfo
*
pMeterInfo
)
{
SQuery
*
pQuery
=
&
pQInfo
->
query
;
SMeterQuerySupportObj
*
pSupporter
=
pQInfo
->
pMeterQuerySupporter
;
...
...
@@ -147,24 +169,39 @@ static SMeterDataInfo *queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMe
continue
;
}
bool
firstCheckSlot
=
true
;
SCacheInfo
*
pCacheInfo
=
(
SCacheInfo
*
)
pMeterObj
->
pCache
;
for
(
int32_t
i
=
0
;
i
<
pCacheInfo
->
maxBlocks
;
++
i
)
{
pBlock
=
getCacheDataBlock
(
pMeterObj
,
pQuery
,
pQuery
->
slot
);
// cache block may be flushed to disk, so it is not available, ignore it and try next
if
(
pBlock
==
NULL
)
{
pQuery
->
slot
=
(
pQuery
->
slot
+
step
+
pCacheInfo
->
maxBlocks
)
%
pCacheInfo
->
maxBlocks
;
/*
* 1. pBlock == NULL. The cache block may be flushed to disk, so it is not available, skip and try next
*
* 2. pBlock->numOfPoints == 0. There is a empty block, which is caused by allocate-and-write data into cache
* procedure. The block has been allocated but data has not been put into yet. If the block is the last
* block(newly allocated block), abort query. Otherwise, skip it and go on.
*/
if
((
pBlock
==
NULL
)
||
(
pBlock
->
numOfPoints
==
0
))
{
if
(
ALL_CACHE_BLOCKS_CHECKED
(
pQuery
))
{
break
;
}
FORWARD_CACHE_BLOCK_CHECK_SLOT
(
pQuery
->
slot
,
step
,
pCacheInfo
->
maxBlocks
);
continue
;
}
setStartPositionForCacheBlock
(
pQuery
,
pBlock
,
&
firstCheckSlot
);
TSKEY
*
primaryKeys
=
(
TSKEY
*
)
pBlock
->
offset
[
0
];
// in handling file data block, this query condition is checked during fetching candidate file blocks
// in handling file data block, the timestamp range validation is done during fetching candidate file blocks
if
((
primaryKeys
[
pQuery
->
pos
]
>
pSupporter
->
rawEKey
&&
QUERY_IS_ASC_QUERY
(
pQuery
))
||
(
primaryKeys
[
pQuery
->
pos
]
<
pSupporter
->
rawEKey
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
)))
{
break
;
}
/
* only record the key on last block */
/
/ only record the key on last block
SET_CACHE_BLOCK_FLAG
(
pRuntimeEnv
->
blockStatus
);
SBlockInfo
binfo
=
getBlockBasicInfo
(
pBlock
,
BLK_CACHE_BLOCK
);
...
...
@@ -176,24 +213,11 @@ static SMeterDataInfo *queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMe
queryOnBlock
(
pSupporter
,
primaryKeys
,
pRuntimeEnv
->
blockStatus
,
(
char
*
)
pBlock
,
&
binfo
,
&
pMeterInfo
[
k
],
NULL
,
searchFn
);
// todo refactor
if
((
pQuery
->
slot
==
pQuery
->
currentSlot
&&
QUERY_IS_ASC_QUERY
(
pQuery
))
||
(
pQuery
->
slot
==
pQuery
->
firstSlot
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
)))
{
if
(
ALL_CACHE_BLOCKS_CHECKED
(
pQuery
))
{
break
;
}
// try next cache block
pQuery
->
slot
=
(
pQuery
->
slot
+
step
+
pCacheInfo
->
maxBlocks
)
%
pCacheInfo
->
maxBlocks
;
if
(
QUERY_IS_ASC_QUERY
(
pQuery
))
{
pQuery
->
pos
=
0
;
}
else
{
// backwards traverse encounter the cache invalid, abort scan cache.
SCacheBlock
*
pNextBlock
=
getCacheDataBlock
(
pMeterObj
,
pQuery
,
pQuery
->
slot
);
if
(
pNextBlock
==
NULL
)
{
break
;
// todo fix
}
else
{
pQuery
->
pos
=
pNextBlock
->
numOfPoints
-
1
;
}
}
FORWARD_CACHE_BLOCK_CHECK_SLOT
(
pQuery
->
slot
,
step
,
pCacheInfo
->
maxBlocks
);
}
}
}
...
...
src/system/src/vnodeRead.c
浏览文件 @
4afd80c5
...
...
@@ -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/tcache.c
浏览文件 @
4afd80c5
...
...
@@ -614,7 +614,7 @@ static FORCE_INLINE void taosDecRef(SDataNode *pNode) {
}
if
(
pNode
->
refCount
>
0
)
{
__sync_
add_and_fetch_32
(
&
pNode
->
refCount
,
-
1
);
__sync_
sub_and_fetch_32
(
&
pNode
->
refCount
,
1
);
pTrace
(
"key:%s is released by app.refcnt:%d"
,
pNode
->
key
,
pNode
->
refCount
);
}
else
{
/*
...
...
src/util/src/tinterpolation.c
浏览文件 @
4afd80c5
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录