Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yiicenne
TDengine
提交
9376be5f
TDengine
项目概览
yiicenne
/
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,发现更多精彩内容 >>
提交
9376be5f
编写于
5月 16, 2020
作者:
H
hjLiao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] fix bugs for fill operation in both table/super table query
上级
08968b94
变更
19
展开全部
隐藏空白更改
内联
并排
Showing
19 changed file
with
622 addition
and
637 deletion
+622
-637
src/client/inc/tscSecondaryMerge.h
src/client/inc/tscSecondaryMerge.h
+3
-3
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-1
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+5
-5
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+5
-5
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+142
-150
src/client/src/tscServer.c
src/client/src/tscServer.c
+2
-2
src/client/src/tscStream.c
src/client/src/tscStream.c
+1
-1
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+5
-5
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+2
-2
src/inc/taosmsg.h
src/inc/taosmsg.h
+13
-13
src/query/inc/qextbuffer.h
src/query/inc/qextbuffer.h
+1
-1
src/query/inc/qinterpolation.h
src/query/inc/qinterpolation.h
+42
-44
src/query/inc/queryExecutor.h
src/query/inc/queryExecutor.h
+7
-9
src/query/src/qextbuffer.c
src/query/src/qextbuffer.c
+14
-14
src/query/src/qinterpolation.c
src/query/src/qinterpolation.c
+245
-197
src/query/src/qpercentile.c
src/query/src/qpercentile.c
+8
-8
src/query/src/queryExecutor.c
src/query/src/queryExecutor.c
+124
-175
src/util/inc/talgo.h
src/util/inc/talgo.h
+2
-0
src/util/src/talgo.c
src/util/src/talgo.c
+0
-2
未找到文件。
src/client/inc/tscSecondaryMerge.h
浏览文件 @
9376be5f
...
...
@@ -60,7 +60,7 @@ typedef struct SLocalReducer {
char
*
prevRowOfInput
;
tFilePage
*
pResultBuf
;
int32_t
nResultBufSize
;
char
*
pBufForInterpo
;
// intermediate buffer for interpolation
//
char * pBufForInterpo; // intermediate buffer for interpolation
tFilePage
*
pTempBuffer
;
struct
SQLFunctionCtx
*
pCtx
;
int32_t
rowSize
;
// size of each intermediate result.
...
...
@@ -68,9 +68,9 @@ typedef struct SLocalReducer {
bool
hasPrevRow
;
// cannot be released
bool
hasUnprocessedRow
;
tOrderDescriptor
*
pDesc
;
SColumnModel
*
resColModel
;
SColumnModel
*
resColModel
;
tExtMemBuffer
**
pExtMemBuffer
;
// disk-based buffer
S
InterpolationInfo
interpolationInfo
;
// interpolation support structure
S
FillInfo
*
pFillInfo
;
// interpolation support structure
char
*
pFinalRes
;
// result data after interpo
tFilePage
*
discardData
;
SResultInfo
*
pResInfo
;
...
...
src/client/inc/tsclient.h
浏览文件 @
9376be5f
...
...
@@ -210,7 +210,7 @@ typedef struct SQueryInfo {
SLimitVal
slimit
;
STagCond
tagCond
;
SOrderVal
order
;
int16_t
interpo
Type
;
// interpolate type
int16_t
fill
Type
;
// interpolate type
int16_t
numOfTables
;
STableMetaInfo
**
pTableMetaInfo
;
struct
STSBuf
*
tsBuf
;
...
...
src/client/src/tscFunctionImpl.c
浏览文件 @
9376be5f
...
...
@@ -4159,16 +4159,16 @@ static void interp_function(SQLFunctionCtx *pCtx) {
SInterpInfoDetail
*
pInfoDetail
=
interpInfo
.
pInterpDetail
;
/* set no output result */
if
(
pInfoDetail
->
type
==
TSDB_
INTERPO
_NONE
)
{
if
(
pInfoDetail
->
type
==
TSDB_
FILL
_NONE
)
{
pCtx
->
param
[
3
].
i64Key
=
0
;
}
else
if
(
pInfoDetail
->
primaryCol
==
1
)
{
*
(
TSKEY
*
)
pCtx
->
aOutputBuf
=
pInfoDetail
->
ts
;
}
else
{
if
(
pInfoDetail
->
type
==
TSDB_
INTERPO
_NULL
)
{
if
(
pInfoDetail
->
type
==
TSDB_
FILL
_NULL
)
{
setNull
(
pCtx
->
aOutputBuf
,
pCtx
->
outputType
,
pCtx
->
outputBytes
);
}
else
if
(
pInfoDetail
->
type
==
TSDB_
INTERPO
_SET_VALUE
)
{
}
else
if
(
pInfoDetail
->
type
==
TSDB_
FILL
_SET_VALUE
)
{
tVariantDump
(
&
pCtx
->
param
[
1
],
pCtx
->
aOutputBuf
,
pCtx
->
inputType
);
}
else
if
(
pInfoDetail
->
type
==
TSDB_
INTERPO
_PREV
)
{
}
else
if
(
pInfoDetail
->
type
==
TSDB_
FILL
_PREV
)
{
char
*
data
=
pCtx
->
param
[
1
].
pz
;
char
*
pVal
=
data
+
TSDB_KEYSIZE
;
...
...
@@ -4179,7 +4179,7 @@ static void interp_function(SQLFunctionCtx *pCtx) {
assignVal
(
pCtx
->
aOutputBuf
,
pVal
,
pCtx
->
outputBytes
,
pCtx
->
outputType
);
}
}
else
if
(
pInfoDetail
->
type
==
TSDB_
INTERPO
_LINEAR
)
{
}
else
if
(
pInfoDetail
->
type
==
TSDB_
FILL
_LINEAR
)
{
char
*
data1
=
pCtx
->
param
[
1
].
pz
;
char
*
data2
=
pCtx
->
param
[
2
].
pz
;
...
...
src/client/src/tscSQLParser.c
浏览文件 @
9376be5f
...
...
@@ -4020,19 +4020,19 @@ int32_t parseFillClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL) {
}
if
(
strncasecmp
(
pItem
->
pVar
.
pz
,
"none"
,
4
)
==
0
&&
pItem
->
pVar
.
nLen
==
4
)
{
pQueryInfo
->
interpoType
=
TSDB_INTERPO
_NONE
;
pQueryInfo
->
fillType
=
TSDB_FILL
_NONE
;
}
else
if
(
strncasecmp
(
pItem
->
pVar
.
pz
,
"null"
,
4
)
==
0
&&
pItem
->
pVar
.
nLen
==
4
)
{
pQueryInfo
->
interpoType
=
TSDB_INTERPO
_NULL
;
pQueryInfo
->
fillType
=
TSDB_FILL
_NULL
;
for
(
int32_t
i
=
START_INTERPO_COL_IDX
;
i
<
size
;
++
i
)
{
TAOS_FIELD
*
pFields
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fieldsInfo
,
i
);
setNull
((
char
*
)
&
pQueryInfo
->
defaultVal
[
i
],
pFields
->
type
,
pFields
->
bytes
);
}
}
else
if
(
strncasecmp
(
pItem
->
pVar
.
pz
,
"prev"
,
4
)
==
0
&&
pItem
->
pVar
.
nLen
==
4
)
{
pQueryInfo
->
interpoType
=
TSDB_INTERPO
_PREV
;
pQueryInfo
->
fillType
=
TSDB_FILL
_PREV
;
}
else
if
(
strncasecmp
(
pItem
->
pVar
.
pz
,
"linear"
,
6
)
==
0
&&
pItem
->
pVar
.
nLen
==
6
)
{
pQueryInfo
->
interpoType
=
TSDB_INTERPO
_LINEAR
;
pQueryInfo
->
fillType
=
TSDB_FILL
_LINEAR
;
}
else
if
(
strncasecmp
(
pItem
->
pVar
.
pz
,
"value"
,
5
)
==
0
&&
pItem
->
pVar
.
nLen
==
5
)
{
pQueryInfo
->
interpoType
=
TSDB_INTERPO
_SET_VALUE
;
pQueryInfo
->
fillType
=
TSDB_FILL
_SET_VALUE
;
if
(
pFillToken
->
nExpr
==
1
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
...
...
src/client/src/tscSecondaryMerge.c
浏览文件 @
9376be5f
此差异已折叠。
点击以展开。
src/client/src/tscServer.c
浏览文件 @
9376be5f
...
...
@@ -672,7 +672,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pQueryMsg
->
order
=
htons
(
pQueryInfo
->
order
.
order
);
pQueryMsg
->
orderColId
=
htons
(
pQueryInfo
->
order
.
orderColId
);
pQueryMsg
->
interpoType
=
htons
(
pQueryInfo
->
interpo
Type
);
pQueryMsg
->
fillType
=
htons
(
pQueryInfo
->
fill
Type
);
pQueryMsg
->
limit
=
htobe64
(
pQueryInfo
->
limit
.
limit
);
pQueryMsg
->
offset
=
htobe64
(
pQueryInfo
->
limit
.
offset
);
pQueryMsg
->
numOfCols
=
htons
(
taosArrayGetSize
(
pQueryInfo
->
colList
));
...
...
@@ -800,7 +800,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
if
(
pQueryInfo
->
interpoType
!=
TSDB_INTERPO
_NONE
)
{
if
(
pQueryInfo
->
fillType
!=
TSDB_FILL
_NONE
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
*
((
int64_t
*
)
pMsg
)
=
htobe64
(
pQueryInfo
->
defaultVal
[
i
]);
pMsg
+=
sizeof
(
pQueryInfo
->
defaultVal
[
0
]);
...
...
src/client/src/tscStream.c
浏览文件 @
9376be5f
...
...
@@ -208,7 +208,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
if
(
pStream
->
numOfRes
==
0
)
{
if
(
pQueryInfo
->
interpoType
==
TSDB_INTERPO_SET_VALUE
||
pQueryInfo
->
interpoType
==
TSDB_INTERPO
_NULL
)
{
if
(
pQueryInfo
->
fillType
==
TSDB_FILL_SET_VALUE
||
pQueryInfo
->
fillType
==
TSDB_FILL
_NULL
)
{
SSqlRes
*
pRes
=
&
pSql
->
res
;
/* failed to retrieve any result in this retrieve */
...
...
src/client/src/tscSubquery.c
浏览文件 @
9376be5f
...
...
@@ -1390,7 +1390,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
tExtMemBufferClear
(
trsupport
->
pExtMemBuffer
[
subqueryIndex
]);
// clear local saved number of results
trsupport
->
localBuffer
->
num
OfElems
=
0
;
trsupport
->
localBuffer
->
num
=
0
;
pthread_mutex_unlock
(
&
trsupport
->
queryMutex
);
tscTrace
(
"%p sub:%p retrieve failed, code:%s, orderOfSub:%d, retry:%d"
,
trsupport
->
pParentSqlObj
,
pSql
,
...
...
@@ -1457,7 +1457,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
STableMetaInfo
*
pTableMetaInfo
=
pQueryInfo
->
pTableMetaInfo
[
0
];
// data in from current vnode is stored in cache and disk
uint32_t
numOfRowsFromSubquery
=
trsupport
->
pExtMemBuffer
[
idx
]
->
numOfTotalElems
+
trsupport
->
localBuffer
->
num
OfElems
;
uint32_t
numOfRowsFromSubquery
=
trsupport
->
pExtMemBuffer
[
idx
]
->
numOfTotalElems
+
trsupport
->
localBuffer
->
num
;
tscTrace
(
"%p sub:%p all data retrieved from ip:%u,vgId:%d, numOfRows:%d, orderOfSub:%d"
,
pPObj
,
pSql
,
pTableMetaInfo
->
vgroupList
->
vgroups
[
0
].
ipAddr
[
0
].
fqdn
,
pTableMetaInfo
->
vgroupList
->
vgroups
[
0
].
vgId
,
numOfRowsFromSubquery
,
idx
);
...
...
@@ -1465,11 +1465,11 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
tColModelCompact
(
pDesc
->
pColumnModel
,
trsupport
->
localBuffer
,
pDesc
->
pColumnModel
->
capacity
);
#ifdef _DEBUG_VIEW
printf
(
"%"
PRIu64
" rows data flushed to disk:
\n
"
,
trsupport
->
localBuffer
->
num
OfElems
);
printf
(
"%"
PRIu64
" rows data flushed to disk:
\n
"
,
trsupport
->
localBuffer
->
num
);
SSrcColumnInfo
colInfo
[
256
]
=
{
0
};
tscGetSrcColumnInfo
(
colInfo
,
pQueryInfo
);
tColModelDisplayEx
(
pDesc
->
pColumnModel
,
trsupport
->
localBuffer
->
data
,
trsupport
->
localBuffer
->
num
OfElems
,
trsupport
->
localBuffer
->
num
OfElems
,
colInfo
);
tColModelDisplayEx
(
pDesc
->
pColumnModel
,
trsupport
->
localBuffer
->
data
,
trsupport
->
localBuffer
->
num
,
trsupport
->
localBuffer
->
num
,
colInfo
);
#endif
if
(
tsTotalTmpDirGB
!=
0
&&
tsAvailTmpDirGB
<
tsMinimalTmpDirGB
)
{
...
...
src/client/src/tscUtil.c
浏览文件 @
9376be5f
...
...
@@ -280,7 +280,7 @@ void tscClearInterpInfo(SQueryInfo* pQueryInfo) {
return
;
}
pQueryInfo
->
interpoType
=
TSDB_INTERPO
_NONE
;
pQueryInfo
->
fillType
=
TSDB_FILL
_NONE
;
tfree
(
pQueryInfo
->
defaultVal
);
}
...
...
@@ -1779,7 +1779,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
tscTagCondCopy
(
&
pNewQueryInfo
->
tagCond
,
&
pQueryInfo
->
tagCond
);
if
(
pQueryInfo
->
interpoType
!=
TSDB_INTERPO
_NONE
)
{
if
(
pQueryInfo
->
fillType
!=
TSDB_FILL
_NONE
)
{
pNewQueryInfo
->
defaultVal
=
malloc
(
pQueryInfo
->
fieldsInfo
.
numOfOutput
*
sizeof
(
int64_t
));
memcpy
(
pNewQueryInfo
->
defaultVal
,
pQueryInfo
->
defaultVal
,
pQueryInfo
->
fieldsInfo
.
numOfOutput
*
sizeof
(
int64_t
));
}
...
...
src/inc/taosmsg.h
浏览文件 @
9376be5f
...
...
@@ -140,19 +140,19 @@ enum _mgmt_table {
TSDB_MGMT_TABLE_MAX
,
};
#define TSDB_ALTER_TABLE_ADD_TAG_COLUMN 1
#define TSDB_ALTER_TABLE_DROP_TAG_COLUMN 2
#define TSDB_ALTER_TABLE_ADD_TAG_COLUMN
1
#define TSDB_ALTER_TABLE_DROP_TAG_COLUMN
2
#define TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN 3
#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL 4
#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL
4
#define TSDB_ALTER_TABLE_ADD_COLUMN 5
#define TSDB_ALTER_TABLE_DROP_COLUMN 6
#define TSDB_ALTER_TABLE_ADD_COLUMN
5
#define TSDB_ALTER_TABLE_DROP_COLUMN
6
#define TSDB_
INTERPO_NONE
0
#define TSDB_
INTERPO_NULL
1
#define TSDB_
INTERPO
_SET_VALUE 2
#define TSDB_
INTERPO_LINEAR
3
#define TSDB_
INTERPO_PREV
4
#define TSDB_
FILL_NONE
0
#define TSDB_
FILL_NULL
1
#define TSDB_
FILL
_SET_VALUE 2
#define TSDB_
FILL_LINEAR
3
#define TSDB_
FILL_PREV
4
#define TSDB_ALTER_USER_PASSWD 0x1
#define TSDB_ALTER_USER_PRIVILEGES 0x2
...
...
@@ -164,8 +164,8 @@ enum _mgmt_table {
#define TSDB_VN_ALL_ACCCESS (TSDB_VN_READ_ACCCESS | TSDB_VN_WRITE_ACCCESS)
#define TSDB_COL_NORMAL 0x0u
#define TSDB_COL_TAG 0x1u
#define TSDB_COL_JOIN 0x2u
#define TSDB_COL_TAG
0x1u
#define TSDB_COL_JOIN
0x2u
extern
char
*
taosMsg
[];
...
...
@@ -439,7 +439,7 @@ typedef struct {
uint16_t
queryType
;
// denote another query process
int16_t
numOfOutput
;
// final output columns numbers
int16_t
tagNameRelType
;
// relation of tag criteria and tbname criteria
int16_t
interpo
Type
;
// interpolate type
int16_t
fill
Type
;
// interpolate type
uint64_t
defaultVal
;
// default value array list
int32_t
tsOffset
;
// offset value in current msg body, NOTE: ts list is compressed
int32_t
tsLen
;
// total length of ts comp block
...
...
src/query/inc/qextbuffer.h
浏览文件 @
9376be5f
...
...
@@ -68,7 +68,7 @@ typedef struct SExtFileInfo {
}
SExtFileInfo
;
typedef
struct
tFilePage
{
uint64_t
num
OfElems
;
uint64_t
num
;
char
data
[];
}
tFilePage
;
...
...
src/query/inc/qinterpolation.h
浏览文件 @
9376be5f
...
...
@@ -24,18 +24,34 @@ extern "C" {
#include "taosdef.h"
#include "qextbuffer.h"
typedef
struct
SInterpolationInfo
{
int64_t
startTimestamp
;
int32_t
order
;
// order [asc/desc]
int32_t
numOfRawDataInRows
;
// number of points in pQuery->sdata
int32_t
rowIdx
;
// rowIdx in pQuery->sdata
int32_t
numOfTotalInterpo
;
// number of interpolated rows in one round
int32_t
numOfCurrentInterpo
;
// number of interpolated rows in current results
char
*
prevValues
;
// previous row of data
typedef
struct
{
STColumn
col
;
// column info
int16_t
functionId
;
// sql function id
int16_t
flag
;
// column flag: TAG COLUMN|NORMAL COLUMN
union
{
int64_t
i
;
double
d
;}
defaultVal
;
}
SFillColInfo
;
typedef
struct
SFillInfo
{
TSKEY
start
;
// start timestamp
TSKEY
endKey
;
// endKey for fill
int32_t
order
;
// order [TSDB_ORDER_ASC|TSDB_ORDER_DESC]
int32_t
fillType
;
// fill type
int32_t
numOfRows
;
// number of rows in the input data block
int32_t
rowIdx
;
// rowIdx
int32_t
numOfTotal
;
// number of filled rows in one round
int32_t
numOfCurrent
;
// number of filled rows in current results
int32_t
numOfTags
;
// number of tags
int32_t
numOfCols
;
// number of columns, including the tags columns
int32_t
rowSize
;
// size of each row
char
**
pTags
;
// tags value for current interpolation
int64_t
slidingTime
;
// sliding value to determine the number of result for a given time window
char
*
prevValues
;
// previous row of data, to generate the interpolation results
char
*
nextValues
;
// next row of data
int32_t
numOfTags
;
char
**
pTags
;
// tags value for current interoplation
}
S
Interpolation
Info
;
SFillColInfo
*
pFillCol
;
// column info for fill operations
char
**
pData
;
// original result data block involved in filling data
}
S
Fill
Info
;
typedef
struct
SPoint
{
int64_t
key
;
...
...
@@ -44,49 +60,31 @@ typedef struct SPoint {
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
);
SFillInfo
*
taosInitFillInfo
(
int32_t
order
,
TSKEY
skey
,
int32_t
numOfTags
,
int32_t
capacity
,
int32_t
numOfCols
,
int64_t
slidingTime
,
int32_t
fillType
,
SFillColInfo
*
pFillCol
);
void
taos
DestoryInterpoInfo
(
SInterpolationInfo
*
pInterpoInfo
);
void
taos
ResetFillInfo
(
SFillInfo
*
pFillInfo
,
TSKEY
startTimestamp
);
void
taos
InterpoSetStartInfo
(
SInterpolationInfo
*
pInterpoInfo
,
int32_t
numOfRawDataInRows
,
int32_t
type
);
void
taos
DestoryFillInfo
(
SFillInfo
*
pFillInfo
);
TSKEY
taosGetRevisedEndKey
(
TSKEY
ekey
,
int32_t
order
,
int32_t
timeInterval
,
int8_t
intervalTimeUnit
,
int8_t
precision
);
void
taosFillSetStartInfo
(
SFillInfo
*
pFillInfo
,
int32_t
numOfRows
,
TSKEY
endKey
);
/**
*
* @param pInterpoInfo
* @param pPrimaryKeyArray
* @param numOfRows
* @param nInterval
* @param ekey
* @param maxNumOfRows
* @return
*/
int32_t
taosGetNumOfResultWithInterpo
(
SInterpolationInfo
*
pInterpoInfo
,
int64_t
*
pPrimaryKeyArray
,
int32_t
numOfRows
,
int64_t
nInterval
,
int64_t
ekey
,
int32_t
maxNumOfRows
);
void
taosFillCopyInputDataFromFilePage
(
SFillInfo
*
pFillInfo
,
tFilePage
**
pInput
);
int32_t
taosGetNumOfResWithoutLimit
(
SInterpolationInfo
*
pInterpoInfo
,
int64_t
*
pPrimaryKeyArray
,
int32_t
numOfRawDataInRows
,
int64_t
nInterval
,
int64_t
ekey
);
/**
*
* @param pInterpoInfo
* @return
*/
bool
taosHasRemainsDataForInterpolation
(
SInterpolationInfo
*
pInterpoInfo
);
void
taosFillCopyInputDataFromOneFilePage
(
SFillInfo
*
pFillInfo
,
tFilePage
*
pInput
);
int32_t
taosNumOfRemainPoints
(
SInterpolationInfo
*
pInterpoInfo
);
TSKEY
taosGetRevisedEndKey
(
TSKEY
ekey
,
int32_t
order
,
int64_t
timeInterval
,
int8_t
slidingTimeUnit
,
int8_t
precision
);
/**
*
*/
int32_t
taosDoInterpoResult
(
SInterpolationInfo
*
pInterpoInfo
,
int16_t
interpoType
,
tFilePage
**
data
,
int32_t
numOfRawDataInRows
,
int32_t
outputRows
,
int64_t
nInterval
,
const
int64_t
*
pPrimaryKeyArray
,
SColumnModel
*
pModel
,
char
**
srcData
,
int64_t
*
defaultVal
,
const
int32_t
*
functionIDs
,
int32_t
bufSize
);
int32_t
taosGetNumOfResultWithFill
(
SFillInfo
*
pFillInfo
,
int32_t
numOfRows
,
int64_t
ekey
,
int32_t
maxNumOfRows
);
int32_t
taosNumOfRemainRows
(
SFillInfo
*
pFillInfo
);
int32_t
taosDoInterpoResult
(
SFillInfo
*
pFillInfo
,
tFilePage
**
data
,
int32_t
numOfRows
,
int32_t
outputRows
,
char
**
srcData
);
int
taosDoLinearInterpolation
(
int32_t
type
,
SPoint
*
point1
,
SPoint
*
point2
,
SPoint
*
point
);
void
taosGenerateDataBlock
(
SFillInfo
*
pFillInfo
,
tFilePage
**
output
,
int64_t
*
outputRows
,
int32_t
capacity
);
#ifdef __cplusplus
}
#endif
...
...
src/query/inc/queryExecutor.h
浏览文件 @
9376be5f
...
...
@@ -28,10 +28,10 @@
#include "tsqlfunction.h"
#include "tarray.h"
typedef
struct
SData
{
int32
_t
num
;
char
data
[];
}
SData
;
//typedef struct tFilePage
{
// int64
_t num;
//
char data[];
//} tFilePage
;
struct
SColumnFilterElem
;
typedef
bool
(
*
__filter_func_t
)(
struct
SColumnFilterElem
*
pFilter
,
char
*
val1
,
char
*
val2
);
...
...
@@ -129,7 +129,7 @@ typedef struct SQuery {
char
slidingTimeUnit
;
// interval data type, used for daytime revise
int8_t
precision
;
int16_t
numOfOutput
;
int16_t
interpo
Type
;
int16_t
fill
Type
;
int16_t
checkBuffer
;
// check if the buffer is full during scan each block
SLimitVal
limit
;
int32_t
rowSize
;
...
...
@@ -139,11 +139,10 @@ typedef struct SQuery {
SColumnInfo
*
tagColList
;
int32_t
numOfFilterCols
;
int64_t
*
defaultVal
;
// TSKEY lastKey;
uint32_t
status
;
// query status
SResultRec
rec
;
int32_t
pos
;
SData
**
sdata
;
tFilePage
**
sdata
;
STableQueryInfo
*
current
;
SSingleColumnFilterInfo
*
pFilterInfo
;
}
SQuery
;
...
...
@@ -151,12 +150,11 @@ typedef struct SQuery {
typedef
struct
SQueryRuntimeEnv
{
SResultInfo
*
resultInfo
;
// todo refactor to merge with SWindowResInfo
SQuery
*
pQuery
;
SData
**
pInterpoBuf
;
SQLFunctionCtx
*
pCtx
;
int16_t
numOfRowsPerPage
;
int16_t
offset
[
TSDB_MAX_COLUMNS
];
uint16_t
scanFlag
;
// denotes reversed scan of data or not
S
InterpolationInfo
interpo
Info
;
S
FillInfo
*
pFill
Info
;
SWindowResInfo
windowResInfo
;
STSBuf
*
pTSBuf
;
STSCursor
cur
;
...
...
src/query/src/qextbuffer.c
浏览文件 @
9376be5f
...
...
@@ -136,7 +136,7 @@ static bool tExtMemBufferAlloc(tExtMemBuffer *pMemBuffer) {
}
item
->
pNext
=
NULL
;
item
->
item
.
num
OfElems
=
0
;
item
->
item
.
num
=
0
;
if
(
pMemBuffer
->
pTail
!=
NULL
)
{
pMemBuffer
->
pTail
->
pNext
=
item
;
...
...
@@ -167,13 +167,13 @@ int16_t tExtMemBufferPut(tExtMemBuffer *pMemBuffer, void *data, int32_t numOfRow
pLast
=
pMemBuffer
->
pTail
;
}
if
(
pLast
->
item
.
num
OfElems
+
numOfRows
<=
pMemBuffer
->
numOfElemsPerPage
)
{
// enough space for records
if
(
pLast
->
item
.
num
+
numOfRows
<=
pMemBuffer
->
numOfElemsPerPage
)
{
// enough space for records
tColModelAppend
(
pMemBuffer
->
pColumnModel
,
&
pLast
->
item
,
data
,
0
,
numOfRows
,
numOfRows
);
pMemBuffer
->
numOfElemsInBuffer
+=
numOfRows
;
pMemBuffer
->
numOfTotalElems
+=
numOfRows
;
}
else
{
int32_t
numOfRemainEntries
=
pMemBuffer
->
numOfElemsPerPage
-
pLast
->
item
.
num
OfElems
;
int32_t
numOfRemainEntries
=
pMemBuffer
->
numOfElemsPerPage
-
pLast
->
item
.
num
;
tColModelAppend
(
pMemBuffer
->
pColumnModel
,
&
pLast
->
item
,
data
,
0
,
numOfRemainEntries
,
numOfRows
);
pMemBuffer
->
numOfElemsInBuffer
+=
numOfRemainEntries
;
...
...
@@ -271,7 +271,7 @@ bool tExtMemBufferFlush(tExtMemBuffer *pMemBuffer) {
ret
=
false
;
}
pMemBuffer
->
fileMeta
.
numOfElemsInFile
+=
first
->
item
.
num
OfElems
;
pMemBuffer
->
fileMeta
.
numOfElemsInFile
+=
first
->
item
.
num
;
pMemBuffer
->
fileMeta
.
nFileSize
+=
1
;
tFilePagesItem
*
ptmp
=
first
;
...
...
@@ -985,16 +985,16 @@ void tColModelDisplayEx(SColumnModel *pModel, void *pData, int32_t numOfRows, in
////////////////////////////////////////////////////////////////////////////////////////////
void
tColModelCompact
(
SColumnModel
*
pModel
,
tFilePage
*
inputBuffer
,
int32_t
maxElemsCapacity
)
{
if
(
inputBuffer
->
num
OfElems
==
0
||
maxElemsCapacity
==
inputBuffer
->
numOfElems
)
{
if
(
inputBuffer
->
num
==
0
||
maxElemsCapacity
==
inputBuffer
->
num
)
{
return
;
}
/* start from the second column */
for
(
int32_t
i
=
1
;
i
<
pModel
->
numOfCols
;
++
i
)
{
SSchemaEx
*
pSchemaEx
=
&
pModel
->
pFields
[
i
];
memmove
(
inputBuffer
->
data
+
pSchemaEx
->
offset
*
inputBuffer
->
num
OfElems
,
memmove
(
inputBuffer
->
data
+
pSchemaEx
->
offset
*
inputBuffer
->
num
,
inputBuffer
->
data
+
pSchemaEx
->
offset
*
maxElemsCapacity
,
pSchemaEx
->
field
.
bytes
*
inputBuffer
->
num
OfElems
);
pSchemaEx
->
field
.
bytes
*
inputBuffer
->
num
);
}
}
...
...
@@ -1009,13 +1009,13 @@ int16_t getColumnModelOffset(SColumnModel *pColumnModel, int32_t index) {
}
void
tColModelErase
(
SColumnModel
*
pModel
,
tFilePage
*
inputBuffer
,
int32_t
blockCapacity
,
int32_t
s
,
int32_t
e
)
{
if
(
inputBuffer
->
num
OfElems
==
0
||
(
e
-
s
+
1
)
<=
0
)
{
if
(
inputBuffer
->
num
==
0
||
(
e
-
s
+
1
)
<=
0
)
{
return
;
}
int32_t
removed
=
e
-
s
+
1
;
int32_t
remain
=
inputBuffer
->
num
OfElems
-
removed
;
int32_t
secPart
=
inputBuffer
->
num
OfElems
-
e
-
1
;
int32_t
remain
=
inputBuffer
->
num
-
removed
;
int32_t
secPart
=
inputBuffer
->
num
-
e
-
1
;
/* start from the second column */
for
(
int32_t
i
=
0
;
i
<
pModel
->
numOfCols
;
++
i
)
{
...
...
@@ -1028,7 +1028,7 @@ void tColModelErase(SColumnModel *pModel, tFilePage *inputBuffer, int32_t blockC
memmove
(
startPos
,
endPos
,
pSchema
->
bytes
*
secPart
);
}
inputBuffer
->
num
OfElems
=
remain
;
inputBuffer
->
num
=
remain
;
}
/*
...
...
@@ -1040,16 +1040,16 @@ void tColModelErase(SColumnModel *pModel, tFilePage *inputBuffer, int32_t blockC
*/
void
tColModelAppend
(
SColumnModel
*
dstModel
,
tFilePage
*
dstPage
,
void
*
srcData
,
int32_t
start
,
int32_t
numOfRows
,
int32_t
srcCapacity
)
{
assert
(
dstPage
->
num
OfElems
+
numOfRows
<=
dstModel
->
capacity
);
assert
(
dstPage
->
num
+
numOfRows
<=
dstModel
->
capacity
);
for
(
int32_t
col
=
0
;
col
<
dstModel
->
numOfCols
;
++
col
)
{
char
*
dst
=
COLMODEL_GET_VAL
(
dstPage
->
data
,
dstModel
,
dstModel
->
capacity
,
dstPage
->
num
OfElems
,
col
);
char
*
dst
=
COLMODEL_GET_VAL
(
dstPage
->
data
,
dstModel
,
dstModel
->
capacity
,
dstPage
->
num
,
col
);
char
*
src
=
COLMODEL_GET_VAL
((
char
*
)
srcData
,
dstModel
,
srcCapacity
,
start
,
col
);
memmove
(
dst
,
src
,
dstModel
->
pFields
[
col
].
field
.
bytes
*
numOfRows
);
}
dstPage
->
num
OfElems
+=
numOfRows
;
dstPage
->
num
+=
numOfRows
;
}
tOrderDescriptor
*
tOrderDesCreate
(
const
int32_t
*
orderColIdx
,
int32_t
numOfOrderCols
,
SColumnModel
*
pModel
,
...
...
src/query/src/qinterpolation.c
浏览文件 @
9376be5f
此差异已折叠。
点击以展开。
src/query/src/qpercentile.c
浏览文件 @
9376be5f
...
...
@@ -64,26 +64,26 @@ static tFilePage *loadIntoBucketFromDisk(tMemBucket *pMemBucket, int32_t segIdx,
for
(
uint32_t
j
=
0
;
j
<
pFlushInfo
->
numOfPages
;
++
j
)
{
ret
=
fread
(
pPage
,
pMemBuffer
->
pageSize
,
1
,
pMemBuffer
->
file
);
UNUSED
(
ret
);
assert
(
pPage
->
num
OfElems
>
0
);
assert
(
pPage
->
num
>
0
);
tColModelAppend
(
pDesc
->
pColumnModel
,
buffer
,
pPage
->
data
,
0
,
pPage
->
num
OfElems
,
pPage
->
numOfElems
);
printf
(
"id: %d count: %"
PRIu64
"
\n
"
,
j
,
buffer
->
num
OfElems
);
tColModelAppend
(
pDesc
->
pColumnModel
,
buffer
,
pPage
->
data
,
0
,
pPage
->
num
,
pPage
->
num
);
printf
(
"id: %d count: %"
PRIu64
"
\n
"
,
j
,
buffer
->
num
);
}
}
tfree
(
pPage
);
assert
(
buffer
->
num
OfElems
==
pMemBuffer
->
fileMeta
.
numOfElemsInFile
);
assert
(
buffer
->
num
==
pMemBuffer
->
fileMeta
.
numOfElemsInFile
);
}
// load data in pMemBuffer to buffer
tFilePagesItem
*
pListItem
=
pMemBuffer
->
pHead
;
while
(
pListItem
!=
NULL
)
{
tColModelAppend
(
pDesc
->
pColumnModel
,
buffer
,
pListItem
->
item
.
data
,
0
,
pListItem
->
item
.
num
OfElems
,
pListItem
->
item
.
num
OfElems
);
tColModelAppend
(
pDesc
->
pColumnModel
,
buffer
,
pListItem
->
item
.
data
,
0
,
pListItem
->
item
.
num
,
pListItem
->
item
.
num
);
pListItem
=
pListItem
->
pNext
;
}
tColDataQSort
(
pDesc
,
buffer
->
num
OfElems
,
0
,
buffer
->
numOfElems
-
1
,
buffer
->
data
,
TSDB_ORDER_ASC
);
tColDataQSort
(
pDesc
,
buffer
->
num
,
0
,
buffer
->
num
-
1
,
buffer
->
data
,
TSDB_ORDER_ASC
);
pDesc
->
pColumnModel
->
capacity
=
oldCapacity
;
// restore value
return
buffer
;
...
...
@@ -881,7 +881,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
for
(
uint32_t
jx
=
0
;
jx
<
pFlushInfo
->
numOfPages
;
++
jx
)
{
ret
=
fread
(
pPage
,
pMemBuffer
->
pageSize
,
1
,
pMemBuffer
->
file
);
UNUSED
(
ret
);
tMemBucketPut
(
pMemBucket
,
pPage
->
data
,
pPage
->
num
OfElems
);
tMemBucketPut
(
pMemBucket
,
pPage
->
data
,
pPage
->
num
);
}
fclose
(
pMemBuffer
->
file
);
...
...
src/query/src/queryExecutor.c
浏览文件 @
9376be5f
此差异已折叠。
点击以展开。
src/util/inc/talgo.h
浏览文件 @
9376be5f
...
...
@@ -26,6 +26,8 @@ extern "C" {
#define TD_GE (TD_EQ | TD_GT)
#define TD_LE (TD_EQ | TD_LT)
#define elePtrAt(base, size, idx) (void *)((char *)(base) + (size) * (idx))
typedef
int32_t
(
*
__ext_compar_fn_t
)(
const
void
*
p1
,
const
void
*
p2
,
const
void
*
param
);
/**
...
...
src/util/src/talgo.c
浏览文件 @
9376be5f
...
...
@@ -23,8 +23,6 @@
memcpy((__right), (__buf), (__size));\
} while (0);
#define elePtrAt(base, size, idx) (void *)((char *)(base) + (size) * (idx))
static
void
median
(
void
*
src
,
size_t
size
,
size_t
s
,
size_t
e
,
const
void
*
param
,
__ext_compar_fn_t
comparFn
,
void
*
buf
)
{
int32_t
mid
=
((
e
-
s
)
>>
1u
)
+
s
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录