Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
eee5408d
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
eee5408d
编写于
6月 11, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/3_liaohj' of github.com:taosdata/tdengine into feature/3_liaohj
上级
0f99cc08
0b8dd61f
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
83 addition
and
29 deletion
+83
-29
source/common/src/ttime.c
source/common/src/ttime.c
+35
-11
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+4
-1
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-0
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+11
-2
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+7
-3
source/libs/function/inc/builtinsimpl.h
source/libs/function/inc/builtinsimpl.h
+1
-0
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+2
-2
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+22
-10
未找到文件。
source/common/src/ttime.c
浏览文件 @
eee5408d
...
@@ -76,22 +76,22 @@ void deltaToUtcInitOnce() {
...
@@ -76,22 +76,22 @@ void deltaToUtcInitOnce() {
static
int64_t
parseFraction
(
char
*
str
,
char
**
end
,
int32_t
timePrec
);
static
int64_t
parseFraction
(
char
*
str
,
char
**
end
,
int32_t
timePrec
);
static
int32_t
parseTimeWithTz
(
const
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
,
char
delim
);
static
int32_t
parseTimeWithTz
(
const
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
,
char
delim
);
static
int32_t
parseLocaltime
(
char
*
timestr
,
int
64_t
*
time
,
int32_t
timePrec
);
static
int32_t
parseLocaltime
(
char
*
timestr
,
int
32_t
len
,
int64_t
*
u
time
,
int32_t
timePrec
);
static
int32_t
parseLocaltimeDst
(
char
*
timestr
,
int
64_t
*
time
,
int32_t
timePrec
);
static
int32_t
parseLocaltimeDst
(
char
*
timestr
,
int
32_t
len
,
int64_t
*
u
time
,
int32_t
timePrec
);
static
char
*
forwardToTimeStringEnd
(
char
*
str
);
static
char
*
forwardToTimeStringEnd
(
char
*
str
);
static
bool
checkTzPresent
(
const
char
*
str
,
int32_t
len
);
static
bool
checkTzPresent
(
const
char
*
str
,
int32_t
len
);
static
int32_t
(
*
parseLocaltimeFp
[])(
char
*
timestr
,
int
64_t
*
time
,
int32_t
timePrec
)
=
{
parseLocaltime
,
static
int32_t
(
*
parseLocaltimeFp
[])(
char
*
timestr
,
int
32_t
len
,
int64_t
*
u
time
,
int32_t
timePrec
)
=
{
parseLocaltime
,
parseLocaltimeDst
};
parseLocaltimeDst
};
int32_t
taosParseTime
(
const
char
*
timestr
,
int64_t
*
time
,
int32_t
len
,
int32_t
timePrec
,
int8_t
day_light
)
{
int32_t
taosParseTime
(
const
char
*
timestr
,
int64_t
*
u
time
,
int32_t
len
,
int32_t
timePrec
,
int8_t
day_light
)
{
/* parse datatime string in with tz */
/* parse datatime string in with tz */
if
(
strnchr
(
timestr
,
'T'
,
len
,
false
)
!=
NULL
)
{
if
(
strnchr
(
timestr
,
'T'
,
len
,
false
)
!=
NULL
)
{
return
parseTimeWithTz
(
timestr
,
time
,
timePrec
,
'T'
);
return
parseTimeWithTz
(
timestr
,
u
time
,
timePrec
,
'T'
);
}
else
if
(
checkTzPresent
(
timestr
,
len
))
{
}
else
if
(
checkTzPresent
(
timestr
,
len
))
{
return
parseTimeWithTz
(
timestr
,
time
,
timePrec
,
0
);
return
parseTimeWithTz
(
timestr
,
u
time
,
timePrec
,
0
);
}
else
{
}
else
{
return
(
*
parseLocaltimeFp
[
day_light
])((
char
*
)
timestr
,
time
,
timePrec
);
return
(
*
parseLocaltimeFp
[
day_light
])((
char
*
)
timestr
,
len
,
u
time
,
timePrec
);
}
}
}
}
...
@@ -309,12 +309,36 @@ int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, ch
...
@@ -309,12 +309,36 @@ int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, ch
return
0
;
return
0
;
}
}
int32_t
parseLocaltime
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
)
{
static
FORCE_INLINE
bool
validateTm
(
struct
tm
*
pTm
)
{
if
(
pTm
==
NULL
)
{
return
false
;
}
int32_t
dayOfMonth
[
12
]
=
{
31
,
28
,
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
};
int32_t
leapYearMonthDay
=
29
;
int32_t
year
=
pTm
->
tm_year
+
1900
;
bool
isLeapYear
=
((
year
%
100
)
==
0
)
?
((
year
%
400
)
==
0
)
:
((
year
%
4
)
==
0
);
if
(
isLeapYear
&&
(
pTm
->
tm_mon
==
1
))
{
if
(
pTm
->
tm_mday
>
leapYearMonthDay
)
{
return
false
;
}
}
else
{
if
(
pTm
->
tm_mday
>
dayOfMonth
[
pTm
->
tm_mon
])
{
return
false
;
}
}
return
true
;
}
int32_t
parseLocaltime
(
char
*
timestr
,
int32_t
len
,
int64_t
*
time
,
int32_t
timePrec
)
{
*
time
=
0
;
*
time
=
0
;
struct
tm
tm
=
{
0
};
struct
tm
tm
=
{
0
};
char
*
str
=
taosStrpTime
(
timestr
,
"%Y-%m-%d %H:%M:%S"
,
&
tm
);
char
*
str
=
taosStrpTime
(
timestr
,
"%Y-%m-%d %H:%M:%S"
,
&
tm
);
if
(
str
==
NULL
)
{
if
(
str
==
NULL
||
(((
str
-
timestr
)
<
len
)
&&
(
*
str
!=
'.'
))
||
!
validateTm
(
&
tm
)
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -343,13 +367,13 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec) {
...
@@ -343,13 +367,13 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec) {
return
0
;
return
0
;
}
}
int32_t
parseLocaltimeDst
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
)
{
int32_t
parseLocaltimeDst
(
char
*
timestr
,
int
32_t
len
,
int
64_t
*
time
,
int32_t
timePrec
)
{
*
time
=
0
;
*
time
=
0
;
struct
tm
tm
=
{
0
};
struct
tm
tm
=
{
0
};
tm
.
tm_isdst
=
-
1
;
tm
.
tm_isdst
=
-
1
;
char
*
str
=
taosStrpTime
(
timestr
,
"%Y-%m-%d %H:%M:%S"
,
&
tm
);
char
*
str
=
taosStrpTime
(
timestr
,
"%Y-%m-%d %H:%M:%S"
,
&
tm
);
if
(
str
==
NULL
)
{
if
(
str
==
NULL
||
(((
str
-
timestr
)
<
len
)
&&
(
*
str
!=
'.'
))
||
!
validateTm
(
&
tm
)
)
{
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
eee5408d
...
@@ -3665,7 +3665,7 @@ static void* doFreeColumnInfoData(SArray* pColumnInfoData) {
...
@@ -3665,7 +3665,7 @@ static void* doFreeColumnInfoData(SArray* pColumnInfoData) {
size_t
cols
=
taosArrayGetSize
(
pColumnInfoData
);
size_t
cols
=
taosArrayGetSize
(
pColumnInfoData
);
for
(
int32_t
i
=
0
;
i
<
cols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
cols
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pColumnInfoData
,
i
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pColumnInfoData
,
i
);
taosMemoryFreeClear
(
pColInfo
->
pData
);
colDataDestroy
(
pColInfo
);
}
}
taosArrayDestroy
(
pColumnInfoData
);
taosArrayDestroy
(
pColumnInfoData
);
...
@@ -3697,6 +3697,7 @@ void tsdbCleanupReadHandle(tsdbReaderT queryHandle) {
...
@@ -3697,6 +3697,7 @@ void tsdbCleanupReadHandle(tsdbReaderT queryHandle) {
taosMemoryFreeClear
(
pTsdbReadHandle
->
pDataBlockInfo
);
taosMemoryFreeClear
(
pTsdbReadHandle
->
pDataBlockInfo
);
taosMemoryFreeClear
(
pTsdbReadHandle
->
suppInfo
.
pstatis
);
taosMemoryFreeClear
(
pTsdbReadHandle
->
suppInfo
.
pstatis
);
taosMemoryFreeClear
(
pTsdbReadHandle
->
suppInfo
.
plist
);
taosMemoryFreeClear
(
pTsdbReadHandle
->
suppInfo
.
plist
);
taosMemoryFree
(
pTsdbReadHandle
->
suppInfo
.
slotIds
);
if
(
!
emptyQueryTimewindow
(
pTsdbReadHandle
))
{
if
(
!
emptyQueryTimewindow
(
pTsdbReadHandle
))
{
// tsdbMayUnTakeMemSnapshot(pTsdbReadHandle);
// tsdbMayUnTakeMemSnapshot(pTsdbReadHandle);
...
@@ -3723,5 +3724,7 @@ void tsdbCleanupReadHandle(tsdbReaderT queryHandle) {
...
@@ -3723,5 +3724,7 @@ void tsdbCleanupReadHandle(tsdbReaderT queryHandle) {
pTsdbReadHandle
,
pCost
->
headFileLoad
,
pCost
->
headFileLoadTime
,
pCost
->
statisInfoLoadTime
,
pTsdbReadHandle
,
pCost
->
headFileLoad
,
pCost
->
headFileLoadTime
,
pCost
->
statisInfoLoadTime
,
pCost
->
blockLoadTime
,
pCost
->
checkForNextTime
,
pTsdbReadHandle
->
idStr
);
pCost
->
blockLoadTime
,
pCost
->
checkForNextTime
,
pTsdbReadHandle
->
idStr
);
taosMemoryFree
(
pTsdbReadHandle
->
idStr
);
taosMemoryFree
(
pTsdbReadHandle
->
pSchema
);
taosMemoryFreeClear
(
pTsdbReadHandle
);
taosMemoryFreeClear
(
pTsdbReadHandle
);
}
}
source/libs/executor/inc/executorimpl.h
浏览文件 @
eee5408d
...
@@ -781,6 +781,7 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
...
@@ -781,6 +781,7 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
SExprInfo
*
createExprInfo
(
SNodeList
*
pNodeList
,
SNodeList
*
pGroupKeys
,
int32_t
*
numOfExprs
);
SExprInfo
*
createExprInfo
(
SNodeList
*
pNodeList
,
SNodeList
*
pGroupKeys
,
int32_t
*
numOfExprs
);
SSDataBlock
*
createResDataBlock
(
SDataBlockDescNode
*
pNode
);
SSDataBlock
*
createResDataBlock
(
SDataBlockDescNode
*
pNode
);
int32_t
initQueryTableDataCond
(
SQueryTableDataCond
*
pCond
,
const
STableScanPhysiNode
*
pTableScanNode
);
int32_t
initQueryTableDataCond
(
SQueryTableDataCond
*
pCond
,
const
STableScanPhysiNode
*
pTableScanNode
);
void
clearupQueryTableDataCond
(
SQueryTableDataCond
*
pCond
);
SResultRow
*
doSetResultOutBufByKey
(
SDiskbasedBuf
*
pResultBuf
,
SResultRowInfo
*
pResultRowInfo
,
SResultRow
*
doSetResultOutBufByKey
(
SDiskbasedBuf
*
pResultBuf
,
SResultRowInfo
*
pResultRowInfo
,
char
*
pData
,
int16_t
bytes
,
bool
masterscan
,
uint64_t
groupId
,
char
*
pData
,
int16_t
bytes
,
bool
masterscan
,
uint64_t
groupId
,
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
eee5408d
...
@@ -2562,7 +2562,8 @@ void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray
...
@@ -2562,7 +2562,8 @@ void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray
}
}
if
(
p
->
info
.
colId
==
pmInfo
->
colId
)
{
if
(
p
->
info
.
colId
==
pmInfo
->
colId
)
{
taosArraySet
(
pBlock
->
pDataBlock
,
pmInfo
->
targetSlotId
,
p
);
SColumnInfoData
*
pDst
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pmInfo
->
targetSlotId
);
colDataAssign
(
pDst
,
p
,
pBlock
->
info
.
rows
);
i
++
;
i
++
;
j
++
;
j
++
;
}
else
if
(
p
->
info
.
colId
<
pmInfo
->
colId
)
{
}
else
if
(
p
->
info
.
colId
<
pmInfo
->
colId
)
{
...
@@ -4906,6 +4907,11 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi
...
@@ -4906,6 +4907,11 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
void
clearupQueryTableDataCond
(
SQueryTableDataCond
*
pCond
)
{
taosMemoryFree
(
pCond
->
twindows
);
taosMemoryFree
(
pCond
->
colList
);
}
SColumn
extractColumnFromColumnNode
(
SColumnNode
*
pColNode
)
{
SColumn
extractColumnFromColumnNode
(
SColumnNode
*
pColNode
)
{
SColumn
c
=
{
0
};
SColumn
c
=
{
0
};
c
.
slotId
=
pColNode
->
slotId
;
c
.
slotId
=
pColNode
->
slotId
;
...
@@ -5111,7 +5117,10 @@ tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle*
...
@@ -5111,7 +5117,10 @@ tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle*
goto
_error
;
goto
_error
;
}
}
return
tsdbReaderOpen
(
pHandle
->
vnode
,
&
cond
,
pTableListInfo
,
queryId
,
taskId
);
tsdbReaderT
*
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
&
cond
,
pTableListInfo
,
queryId
,
taskId
);
clearupQueryTableDataCond
(
&
cond
);
return
pReader
;
_error:
_error:
terrno
=
code
;
terrno
=
code
;
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
eee5408d
...
@@ -525,7 +525,9 @@ static int32_t getTableScannerExecInfo(struct SOperatorInfo* pOptr, void** pOptr
...
@@ -525,7 +525,9 @@ static int32_t getTableScannerExecInfo(struct SOperatorInfo* pOptr, void** pOptr
static
void
destroyTableScanOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
static
void
destroyTableScanOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
STableScanInfo
*
pTableScanInfo
=
(
STableScanInfo
*
)
param
;
STableScanInfo
*
pTableScanInfo
=
(
STableScanInfo
*
)
param
;
taosMemoryFree
(
pTableScanInfo
->
pResBlock
);
blockDataDestroy
(
pTableScanInfo
->
pResBlock
);
clearupQueryTableDataCond
(
&
pTableScanInfo
->
cond
);
tsdbCleanupReadHandle
(
pTableScanInfo
->
dataReader
);
tsdbCleanupReadHandle
(
pTableScanInfo
->
dataReader
);
taosArrayDestroy
(
pTableScanInfo
->
pGroupCols
);
taosArrayDestroy
(
pTableScanInfo
->
pGroupCols
);
...
@@ -1439,16 +1441,18 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
...
@@ -1439,16 +1441,18 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
pRsp
->
numOfRows
,
pInfo
->
loadInfo
.
totalRows
);
pRsp
->
numOfRows
,
pInfo
->
loadInfo
.
totalRows
);
if
(
pRsp
->
numOfRows
==
0
)
{
if
(
pRsp
->
numOfRows
==
0
)
{
taosMemoryFree
(
pRsp
);
return
NULL
;
return
NULL
;
}
}
}
}
SRetrieveMetaTableRsp
*
pTableRsp
=
pInfo
->
pRsp
;
setDataBlockFromFetchRsp
(
pInfo
->
pRes
,
&
pInfo
->
loadInfo
,
pRsp
->
numOfRows
,
pRsp
->
data
,
pRsp
->
compLen
,
setDataBlockFromFetchRsp
(
pInfo
->
pRes
,
&
pInfo
->
loadInfo
,
pTableRsp
->
numOfRows
,
pTableRsp
->
data
,
pTableRsp
->
compLen
,
pOperator
->
numOfExprs
,
startTs
,
NULL
,
pInfo
->
scanCols
);
pOperator
->
numOfExprs
,
startTs
,
NULL
,
pInfo
->
scanCols
);
// todo log the filter info
// todo log the filter info
doFilterResult
(
pInfo
);
doFilterResult
(
pInfo
);
taosMemoryFree
(
pRsp
);
if
(
pInfo
->
pRes
->
info
.
rows
>
0
)
{
if
(
pInfo
->
pRes
->
info
.
rows
>
0
)
{
return
pInfo
->
pRes
;
return
pInfo
->
pRes
;
}
}
...
...
source/libs/function/inc/builtinsimpl.h
浏览文件 @
eee5408d
...
@@ -155,6 +155,7 @@ int32_t mavgFunction(SqlFunctionCtx* pCtx);
...
@@ -155,6 +155,7 @@ int32_t mavgFunction(SqlFunctionCtx* pCtx);
bool
getSampleFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getSampleFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
sampleFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
sampleFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
sampleFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
sampleFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
sampleFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
bool
getTailFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getTailFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
tailFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
tailFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
...
...
source/libs/function/src/builtins.c
浏览文件 @
eee5408d
...
@@ -1754,12 +1754,12 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -1754,12 +1754,12 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
{
.
name
=
"sample"
,
.
name
=
"sample"
,
.
type
=
FUNCTION_TYPE_SAMPLE
,
.
type
=
FUNCTION_TYPE_SAMPLE
,
.
classification
=
FUNC_MGT_
INDEFINITE_ROWS_FUNC
|
FUNC_MGT_TIMELINE
_FUNC
,
.
classification
=
FUNC_MGT_
AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_INDEFINITE_ROWS
_FUNC
,
.
translateFunc
=
translateSample
,
.
translateFunc
=
translateSample
,
.
getEnvFunc
=
getSampleFuncEnv
,
.
getEnvFunc
=
getSampleFuncEnv
,
.
initFunc
=
sampleFunctionSetup
,
.
initFunc
=
sampleFunctionSetup
,
.
processFunc
=
sampleFunction
,
.
processFunc
=
sampleFunction
,
.
finalizeFunc
=
NULL
.
finalizeFunc
=
sampleFinalize
},
},
{
{
.
name
=
"tail"
,
.
name
=
"tail"
,
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
eee5408d
...
@@ -198,7 +198,7 @@ typedef struct SSampleInfo {
...
@@ -198,7 +198,7 @@ typedef struct SSampleInfo {
int32_t
numSampled
;
int32_t
numSampled
;
uint8_t
colType
;
uint8_t
colType
;
int16_t
colBytes
;
int16_t
colBytes
;
char
*
data
;
char
*
data
;
int64_t
*
timestamp
;
int64_t
*
timestamp
;
}
SSampleInfo
;
}
SSampleInfo
;
...
@@ -4183,26 +4183,38 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) {
...
@@ -4183,26 +4183,38 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) {
SSampleInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
SSampleInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
TSKEY
*
tsList
=
(
int64_t
*
)
pInput
->
pPTS
->
pData
;
SColumnInfoData
*
pInputCol
=
pInput
->
pData
[
0
];
TSKEY
*
tsList
=
NULL
;
SColumnInfoData
*
pOutput
=
(
SColumnInfoData
*
)
pCtx
->
pOutput
;
if
(
pInput
->
pPTS
!=
NULL
)
{
tsList
=
(
int64_t
*
)
pInput
->
pPTS
->
pData
;
}
int32_t
startOffset
=
pCtx
->
offset
;
SColumnInfoData
*
pInputCol
=
pInput
->
pData
[
0
]
;
for
(
int32_t
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
for
(
int32_t
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
if
(
colDataIsNull_s
(
pInputCol
,
i
))
{
if
(
colDataIsNull_s
(
pInputCol
,
i
))
{
//colDataAppendNULL(pOutput, i);
continue
;
continue
;
}
}
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
doReservoirSample
(
pInfo
,
data
,
tsList
[
i
]
,
i
);
doReservoirSample
(
pInfo
,
data
,
/*tsList[i]*/
0
,
i
);
}
}
SET_VAL
(
pResInfo
,
pInfo
->
numSampled
,
pInfo
->
numSampled
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
sampleFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
SResultRowEntryInfo
*
pEntryInfo
=
GET_RES_INFO
(
pCtx
);
SSampleInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pEntryInfo
);
pEntryInfo
->
complete
=
true
;
int32_t
slotId
=
pCtx
->
pExpr
->
base
.
resSchema
.
slotId
;
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
slotId
);
int32_t
currentRow
=
pBlock
->
info
.
rows
;
for
(
int32_t
i
=
0
;
i
<
pInfo
->
numSampled
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInfo
->
numSampled
;
++
i
)
{
int32_t
pos
=
startOffset
+
i
;
colDataAppend
(
pCol
,
currentRow
+
i
,
pInfo
->
data
+
i
*
pInfo
->
colBytes
,
false
);
colDataAppend
(
pOutput
,
pos
,
pInfo
->
data
+
i
*
pInfo
->
colBytes
,
false
);
//TODO: handle ts output
}
}
return
pInfo
->
numSampled
;
return
pInfo
->
numSampled
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录