提交 f9bc8ff3 编写于 作者: H hjxilinx

support the interpolation of query time window

上级 f232dd2a
...@@ -1636,13 +1636,16 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt ...@@ -1636,13 +1636,16 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
// set the first column ts for diff query // set the first column ts for diff query
if (optr == TK_DIFF) { if (optr == TK_DIFF) {
colIdx += 1; colIdx += 1;
SColumnIndex indexTS = {.tableIndex = index.tableIndex, .columnIndex = 0}; SColumnIndex indexTS = {.tableIndex = index.tableIndex, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
SSqlExpr* pExpr = tscSqlExprInsert(pQueryInfo, 0, TSDB_FUNC_TS_DUMMY, &indexTS, TSDB_DATA_TYPE_TIMESTAMP, SSqlExpr* pExpr = tscSqlExprInsert(pQueryInfo, 0, TSDB_FUNC_TS_DUMMY, &indexTS, TSDB_DATA_TYPE_TIMESTAMP,
TSDB_KEYSIZE, TSDB_KEYSIZE); TSDB_KEYSIZE, TSDB_KEYSIZE);
SColumnList ids = getColumnList(1, 0, 0); SColumnList ids = getColumnList(1, 0, 0);
insertResultField(pQueryInfo, 0, &ids, TSDB_KEYSIZE, TSDB_DATA_TYPE_TIMESTAMP, aAggs[TSDB_FUNC_TS_DUMMY].aName, insertResultField(pQueryInfo, 0, &ids, TSDB_KEYSIZE, TSDB_DATA_TYPE_TIMESTAMP, aAggs[TSDB_FUNC_TS_DUMMY].aName,
pExpr); pExpr);
} else if (optr == TK_RATE) {
SColumnIndex index1 = {.tableIndex = index.tableIndex, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
tscColumnBaseInfoInsert(pQueryInfo, &index1);
} }
// functions can not be applied to tags // functions can not be applied to tags
......
...@@ -30,7 +30,7 @@ typedef struct SInterpolationInfo { ...@@ -30,7 +30,7 @@ typedef struct SInterpolationInfo {
char * prevValues; // previous row of data char * prevValues; // previous row of data
char * nextValues; // next row of data char * nextValues; // next row of data
int32_t numOfTags; int32_t numOfTags;
char ** pTags; // tags value for current interoplation char ** pTags; // tags value for current interpolation
} SInterpolationInfo; } SInterpolationInfo;
typedef struct SPoint { typedef struct SPoint {
......
...@@ -167,6 +167,11 @@ typedef struct SExtTagsInfo { ...@@ -167,6 +167,11 @@ typedef struct SExtTagsInfo {
struct SQLFunctionCtx **pTagCtxList; struct SQLFunctionCtx **pTagCtxList;
} SExtTagsInfo; } SExtTagsInfo;
typedef struct SBoundaryData {
TSKEY key;
char* data;
} SBoundaryData;
// sql function runtime context // sql function runtime context
typedef struct SQLFunctionCtx { typedef struct SQLFunctionCtx {
int32_t startOffset; int32_t startOffset;
...@@ -195,6 +200,8 @@ typedef struct SQLFunctionCtx { ...@@ -195,6 +200,8 @@ typedef struct SQLFunctionCtx {
SResultInfo *resultInfo; SResultInfo *resultInfo;
SExtTagsInfo tagInfo; SExtTagsInfo tagInfo;
SBoundaryData beforeRow; // this value may be less or equalled to the start time of time window
SBoundaryData afterRow; // this value may be greater or equalled to the end time of time window
} SQLFunctionCtx; } SQLFunctionCtx;
typedef struct SQLAggFuncElem { typedef struct SQLAggFuncElem {
......
...@@ -85,12 +85,6 @@ typedef enum { ...@@ -85,12 +85,6 @@ typedef enum {
QUERY_NO_DATA_TO_CHECK = 0x8u, QUERY_NO_DATA_TO_CHECK = 0x8u,
} vnodeQueryStatus; } vnodeQueryStatus;
typedef struct SPointInterpoSupporter {
int32_t numOfCols;
char** pPrevPoint;
char** pNextPoint;
} SPointInterpoSupporter;
typedef struct SBlockInfo { typedef struct SBlockInfo {
TSKEY keyFirst; TSKEY keyFirst;
TSKEY keyLast; TSKEY keyLast;
......
...@@ -141,6 +141,12 @@ typedef struct SWindowResInfo { ...@@ -141,6 +141,12 @@ typedef struct SWindowResInfo {
int64_t threshold; // threshold for return completed results. int64_t threshold; // threshold for return completed results.
} SWindowResInfo; } SWindowResInfo;
typedef struct SPointInterpoSupporter {
int32_t numOfCols;
char** pPrevPoint;
char** pNextPoint;
} SPointInterpoSupporter;
typedef struct SQueryRuntimeEnv { typedef struct SQueryRuntimeEnv {
SPositionInfo startPos; /* the start position, used for secondary/third iteration */ SPositionInfo startPos; /* the start position, used for secondary/third iteration */
SPositionInfo endPos; /* the last access position in query, served as the start pos of reversed order query */ SPositionInfo endPos; /* the last access position in query, served as the start pos of reversed order query */
...@@ -166,6 +172,9 @@ typedef struct SQueryRuntimeEnv { ...@@ -166,6 +172,9 @@ typedef struct SQueryRuntimeEnv {
SWindowResInfo windowResInfo; SWindowResInfo windowResInfo;
// require time stamp that are direct before/after query time window
bool boundaryExternalTS;
STSBuf* pTSBuf; STSBuf* pTSBuf;
STSCursor cur; STSCursor cur;
SQueryCostSummary summary; SQueryCostSummary summary;
...@@ -179,6 +188,9 @@ typedef struct SQueryRuntimeEnv { ...@@ -179,6 +188,9 @@ typedef struct SQueryRuntimeEnv {
* So we keep a copy of the support structure as well as the cache block data itself. * So we keep a copy of the support structure as well as the cache block data itself.
*/ */
SCacheBlock cacheBlock; SCacheBlock cacheBlock;
SPointInterpoSupporter* pInterpoSupporter;
bool hasTimeWindow;
} SQueryRuntimeEnv; } SQueryRuntimeEnv;
/* intermediate pos during multimeter query involves interval */ /* intermediate pos during multimeter query involves interval */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册