Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
be94e05e
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看板
未验证
提交
be94e05e
编写于
7月 12, 2022
作者:
H
Haojun Liao
提交者:
GitHub
7月 12, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14805 from taosdata/feature/3_liaohj
fix(query): set the ts to be the time window start key value
上级
0e603a17
4d73720f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
21 deletion
+30
-21
source/libs/executor/inc/tfill.h
source/libs/executor/inc/tfill.h
+3
-2
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+3
-1
source/libs/executor/src/tfill.c
source/libs/executor/src/tfill.c
+24
-18
未找到文件。
source/libs/executor/inc/tfill.h
浏览文件 @
be94e05e
...
...
@@ -42,6 +42,7 @@ typedef struct SFillInfo {
TSKEY
start
;
// start timestamp
TSKEY
end
;
// endKey for fill
TSKEY
currentKey
;
// current active timestamp, the value may be changed during the fill procedure.
int32_t
tsSlotId
;
// primary time stamp slot id
int32_t
order
;
// order [TSDB_ORDER_ASC|TSDB_ORDER_DESC]
int32_t
type
;
// fill type
int32_t
numOfRows
;
// number of rows in the input data block
...
...
@@ -74,8 +75,8 @@ struct SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, co
bool
taosFillHasMoreResults
(
struct
SFillInfo
*
pFillInfo
);
SFillInfo
*
taosCreateFillInfo
(
int32_t
order
,
TSKEY
skey
,
int32_t
numOfTags
,
int32_t
capacity
,
int32_t
numOfCols
,
SInterval
*
pInterval
,
int32_t
fillType
,
struct
SFillColInfo
*
pCol
,
const
char
*
id
);
SInterval
*
pInterval
,
int32_t
fillType
,
struct
SFillColInfo
*
pCol
,
int32_t
slotId
,
const
char
*
id
);
void
*
taosDestroyFillInfo
(
struct
SFillInfo
*
pFillInfo
);
int64_t
taosFillResultDataBlock
(
struct
SFillInfo
*
pFillInfo
,
SSDataBlock
*
p
,
int32_t
capacity
);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
be94e05e
...
...
@@ -4013,10 +4013,12 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t
w
=
getFirstQualifiedTimeWindow
(
win
.
skey
,
&
w
,
pInterval
,
TSDB_ORDER_ASC
);
int32_t
order
=
TSDB_ORDER_ASC
;
pInfo
->
pFillInfo
=
taosCreateFillInfo
(
order
,
w
.
skey
,
0
,
capacity
,
numOfCols
,
pInterval
,
fillType
,
pColInfo
,
id
);
pInfo
->
pFillInfo
=
taosCreateFillInfo
(
order
,
w
.
skey
,
0
,
capacity
,
numOfCols
,
pInterval
,
fillType
,
pColInfo
,
pInfo
->
primaryTsCol
,
id
);
pInfo
->
win
=
win
;
pInfo
->
p
=
taosMemoryCalloc
(
numOfCols
,
POINTER_BYTES
);
if
(
pInfo
->
pFillInfo
==
NULL
||
pInfo
->
p
==
NULL
)
{
taosMemoryFree
(
pInfo
->
pFillInfo
);
taosMemoryFree
(
pInfo
->
p
);
...
...
source/libs/executor/src/tfill.c
浏览文件 @
be94e05e
...
...
@@ -14,6 +14,7 @@
*/
#include "os.h"
#include "query.h"
#include "taosdef.h"
#include "tmsg.h"
#include "ttypes.h"
...
...
@@ -48,14 +49,15 @@ static void setTagsValue(SFillInfo* pFillInfo, void** data, int32_t genRows) {
}
}
static
void
setNullRow
(
SSDataBlock
*
pBlock
,
int
32_t
numOfCol
,
int32_t
rowIndex
)
{
static
void
setNullRow
(
SSDataBlock
*
pBlock
,
int
64_t
ts
,
int32_t
rowIndex
)
{
// the first are always the timestamp column, so start from the second column.
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pBlock
->
pDataBlock
);
++
i
)
{
SColumnInfoData
*
p
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
if
(
p
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
&&
i
==
0
)
{
continue
;
if
(
p
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
colDataAppend
(
p
,
rowIndex
,
(
const
char
*
)
&
ts
,
false
);
}
else
{
colDataAppendNULL
(
p
,
rowIndex
);
}
colDataAppendNULL
(
p
,
rowIndex
);
}
}
...
...
@@ -64,16 +66,17 @@ static void setNullRow(SSDataBlock* pBlock, int32_t numOfCol, int32_t rowIndex)
static
void
doSetVal
(
SColumnInfoData
*
pDstColInfoData
,
int32_t
rowIndex
,
const
SGroupKeys
*
pKey
);
static
void
doFillOneRow
Result
(
SFillInfo
*
pFillInfo
,
SSDataBlock
*
pBlock
,
SSDataBlock
*
pSrcBlock
,
int64_t
ts
,
bool
outOfBound
)
{
static
void
doFillOneRow
(
SFillInfo
*
pFillInfo
,
SSDataBlock
*
pBlock
,
SSDataBlock
*
pSrcBlock
,
int64_t
ts
,
bool
outOfBound
)
{
SPoint
point1
,
point2
,
point
;
int32_t
step
=
GET_FORWARD_DIRECTION_FACTOR
(
pFillInfo
->
order
);
// set the primary timestamp column value
int32_t
index
=
pFillInfo
->
numOfCurrent
;
SColumnInfoData
*
pCol0
=
taosArrayGet
(
pBlock
->
pDataBlock
,
0
);
SColumnInfoData
*
pCol0
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pFillInfo
->
tsSlotId
);
char
*
val
=
colDataGetData
(
pCol0
,
index
);
// set the primary timestamp value
*
(
TSKEY
*
)
val
=
pFillInfo
->
currentKey
;
// set the other values
...
...
@@ -92,7 +95,7 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSData
}
}
else
if
(
pFillInfo
->
type
==
TSDB_FILL_NEXT
)
{
SArray
*
p
=
FILL_IS_ASC_FILL
(
pFillInfo
)
?
pFillInfo
->
next
:
pFillInfo
->
prev
;
// todo refactor: start from 0 not 1
for
(
int32_t
i
=
1
;
i
<
pFillInfo
->
numOfCols
;
++
i
)
{
SFillColInfo
*
pCol
=
&
pFillInfo
->
pFillCol
[
i
];
if
(
TSDB_COL_IS_TAG
(
pCol
->
flag
))
{
...
...
@@ -106,7 +109,7 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSData
}
else
if
(
pFillInfo
->
type
==
TSDB_FILL_LINEAR
)
{
// TODO : linear interpolation supports NULL value
if
(
outOfBound
)
{
setNullRow
(
pBlock
,
pFillInfo
->
numOfCols
,
index
);
setNullRow
(
pBlock
,
pFillInfo
->
currentKey
,
index
);
}
else
{
for
(
int32_t
i
=
1
;
i
<
pFillInfo
->
numOfCols
;
++
i
)
{
SFillColInfo
*
pCol
=
&
pFillInfo
->
pFillCol
[
i
];
...
...
@@ -143,7 +146,7 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSData
}
}
}
else
if
(
pFillInfo
->
type
==
TSDB_FILL_NULL
)
{
// fill with NULL
setNullRow
(
pBlock
,
pFillInfo
->
numOfCols
,
index
);
setNullRow
(
pBlock
,
pFillInfo
->
currentKey
,
index
);
}
else
{
// fill with user specified value for each column
for
(
int32_t
i
=
1
;
i
<
pFillInfo
->
numOfCols
;
++
i
)
{
SFillColInfo
*
pCol
=
&
pFillInfo
->
pFillCol
[
i
];
...
...
@@ -166,6 +169,8 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSData
int64_t
v
=
0
;
GET_TYPED_DATA
(
v
,
int64_t
,
pVar
->
nType
,
&
pVar
->
i
);
colDataAppend
(
pDst
,
index
,
(
char
*
)
&
v
,
false
);
}
else
if
(
pDst
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
colDataAppend
(
pDst
,
index
,
(
const
char
*
)
&
pFillInfo
->
currentKey
,
false
);
}
}
}
...
...
@@ -247,7 +252,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
// fill the gap between two input rows
while
(((
pFillInfo
->
currentKey
<
ts
&&
ascFill
)
||
(
pFillInfo
->
currentKey
>
ts
&&
!
ascFill
))
&&
pFillInfo
->
numOfCurrent
<
outputRows
)
{
doFillOneRow
Result
(
pFillInfo
,
pBlock
,
pFillInfo
->
pSrcBlock
,
ts
,
false
);
doFillOneRow
(
pFillInfo
,
pBlock
,
pFillInfo
->
pSrcBlock
,
ts
,
false
);
}
// output buffer is full, abort
...
...
@@ -343,7 +348,7 @@ static int64_t appendFilledResult(SFillInfo* pFillInfo, SSDataBlock* pBlock, int
*/
pFillInfo
->
numOfCurrent
=
0
;
while
(
pFillInfo
->
numOfCurrent
<
resultCapacity
)
{
doFillOneRow
Result
(
pFillInfo
,
pBlock
,
pFillInfo
->
pSrcBlock
,
pFillInfo
->
start
,
true
);
doFillOneRow
(
pFillInfo
,
pBlock
,
pFillInfo
->
pSrcBlock
,
pFillInfo
->
start
,
true
);
}
pFillInfo
->
numOfTotal
+=
pFillInfo
->
numOfCurrent
;
...
...
@@ -408,7 +413,7 @@ static int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) {
}
struct
SFillInfo
*
taosCreateFillInfo
(
int32_t
order
,
TSKEY
skey
,
int32_t
numOfTags
,
int32_t
capacity
,
int32_t
numOfCols
,
SInterval
*
pInterval
,
int32_t
fillType
,
struct
SFillColInfo
*
pCol
,
SInterval
*
pInterval
,
int32_t
fillType
,
struct
SFillColInfo
*
pCol
,
int32_t
primaryTsSlotId
,
const
char
*
id
)
{
if
(
fillType
==
TSDB_FILL_NONE
)
{
return
NULL
;
...
...
@@ -420,6 +425,8 @@ struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTag
return
NULL
;
}
pFillInfo
->
tsSlotId
=
primaryTsSlotId
;
taosResetFillInfo
(
pFillInfo
,
skey
);
pFillInfo
->
order
=
order
;
...
...
@@ -589,11 +596,10 @@ int64_t taosFillResultDataBlock(SFillInfo* pFillInfo, SSDataBlock* p, int32_t ca
assert
(
numOfRes
==
pFillInfo
->
numOfCurrent
);
}
// qDebug("fill:%p, generated fill result, src block:%d, index:%d, brange:%"PRId64"-%"PRId64", currentKey:%"PRId64",
// current:%d, total:%d, %p",
// pFillInfo, pFillInfo->numOfRows, pFillInfo->index, pFillInfo->start, pFillInfo->end, pFillInfo->currentKey,
// pFillInfo->numOfCurrent,
// pFillInfo->numOfTotal, pFillInfo->handle);
qDebug
(
"fill:%p, generated fill result, src block:%d, index:%d, brange:%"
PRId64
"-%"
PRId64
", currentKey:%"
PRId64
", current : % d, total : % d, %s"
,
pFillInfo
,
pFillInfo
->
numOfRows
,
pFillInfo
->
index
,
pFillInfo
->
start
,
pFillInfo
->
end
,
pFillInfo
->
currentKey
,
pFillInfo
->
numOfCurrent
,
pFillInfo
->
numOfTotal
,
pFillInfo
->
id
);
return
numOfRes
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录