Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
codyshao
TDengine
提交
9fa4fa30
T
TDengine
项目概览
codyshao
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
2
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9fa4fa30
编写于
5月 03, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-168] support the last_row query for super table,
上级
d226214f
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
80 addition
and
70 deletion
+80
-70
src/client/inc/tscSecondaryMerge.h
src/client/inc/tscSecondaryMerge.h
+1
-1
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+18
-1
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+1
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/common/src/ttypes.c
src/common/src/ttypes.c
+1
-1
src/inc/taosdef.h
src/inc/taosdef.h
+5
-3
src/query/src/qextbuffer.c
src/query/src/qextbuffer.c
+13
-5
src/query/src/queryExecutor.c
src/query/src/queryExecutor.c
+37
-54
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+3
-3
未找到文件。
src/client/inc/tscSecondaryMerge.h
浏览文件 @
9fa4fa30
...
...
@@ -120,7 +120,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
void
tscDestroyLocalReducer
(
SSqlObj
*
pSql
);
int32_t
tscDoLocal
reduc
e
(
SSqlObj
*
pSql
);
int32_t
tscDoLocal
Merg
e
(
SSqlObj
*
pSql
);
#ifdef __cplusplus
}
...
...
src/client/src/tscFunctionImpl.c
浏览文件 @
9fa4fa30
...
...
@@ -2981,11 +2981,28 @@ static void tag_project_function_f(SQLFunctionCtx *pCtx, int32_t index) {
*/
static
void
tag_function
(
SQLFunctionCtx
*
pCtx
)
{
SET_VAL
(
pCtx
,
1
,
1
);
tVariantDump
(
&
pCtx
->
tag
,
pCtx
->
aOutputBuf
,
pCtx
->
tag
.
nType
);
char
*
output
=
pCtx
->
aOutputBuf
;
// todo refactor to dump length presented string(var string)
if
(
pCtx
->
tag
.
nType
==
TSDB_DATA_TYPE_BINARY
||
pCtx
->
tag
.
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
*
(
int16_t
*
)
output
=
pCtx
->
tag
.
nLen
;
output
+=
VARSTR_HEADER_SIZE
;
}
tVariantDump
(
&
pCtx
->
tag
,
output
,
pCtx
->
tag
.
nType
);
}
static
void
tag_function_f
(
SQLFunctionCtx
*
pCtx
,
int32_t
index
)
{
SET_VAL
(
pCtx
,
1
,
1
);
char
*
output
=
pCtx
->
aOutputBuf
;
// todo refactor to dump length presented string(var string)
if
(
pCtx
->
tag
.
nType
==
TSDB_DATA_TYPE_BINARY
||
pCtx
->
tag
.
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
*
(
int16_t
*
)
output
=
pCtx
->
tag
.
nLen
;
output
+=
VARSTR_HEADER_SIZE
;
}
tVariantDump
(
&
pCtx
->
tag
,
pCtx
->
aOutputBuf
,
pCtx
->
tag
.
nType
);
}
...
...
src/client/src/tscSecondaryMerge.c
浏览文件 @
9fa4fa30
...
...
@@ -1422,7 +1422,7 @@ static void doProcessResultInNextWindow(SSqlObj *pSql, int32_t numOfRes) {
doExecuteSecondaryMerge
(
pCmd
,
pLocalReducer
,
true
);
}
int32_t
tscDoLocal
reduc
e
(
SSqlObj
*
pSql
)
{
int32_t
tscDoLocal
Merg
e
(
SSqlObj
*
pSql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
...
...
src/client/src/tscServer.c
浏览文件 @
9fa4fa30
...
...
@@ -1470,7 +1470,7 @@ int tscProcessRetrieveLocalMergeRsp(SSqlObj *pSql) {
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pRes
->
code
=
tscDoLocal
reduc
e
(
pSql
);
pRes
->
code
=
tscDoLocal
Merg
e
(
pSql
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
if
(
pRes
->
code
==
TSDB_CODE_SUCCESS
&&
pRes
->
numOfRows
>
0
)
{
...
...
src/common/src/ttypes.c
浏览文件 @
9fa4fa30
...
...
@@ -198,7 +198,7 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) {
break
;
};
case
TSDB_DATA_TYPE_BINARY
:
{
strncpy
(
val
,
src
,
len
);
varDataCopy
(
val
,
src
);
break
;
};
case
TSDB_DATA_TYPE_NCHAR
:
{
...
...
src/inc/taosdef.h
浏览文件 @
9fa4fa30
...
...
@@ -35,9 +35,11 @@ extern "C" {
// ----------------- For variable data types such as TSDB_DATA_TYPE_BINARY and TSDB_DATA_TYPE_NCHAR
typedef
int32_t
VarDataOffsetT
;
typedef
int16_t
VarDataLenT
;
#define varDataLen(v) ((VarDataLenT *)(v))[0]
#define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v))
#define varDataVal(v) ((void *)((char *)v + sizeof(VarDataLenT)))
#define varDataLen(v) ((VarDataLenT *)(v))[0]
#define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v))
#define varDataVal(v) ((void *)((char *)v + sizeof(VarDataLenT)))
#define varDataCopy(dst, v) memcpy((dst), (void*) (v), varDataTLen(v))
// this data type is internally used only in 'in' query to hold the values
#define TSDB_DATA_TYPE_ARRAY (TSDB_DATA_TYPE_NCHAR + 1)
...
...
src/query/src/qextbuffer.c
浏览文件 @
9fa4fa30
...
...
@@ -409,13 +409,21 @@ static FORCE_INLINE int32_t columnValueAscendingComparator(char *f1, char *f2, i
return
(
first
<
second
)
?
-
1
:
1
;
};
case
TSDB_DATA_TYPE_BINARY
:
{
int32_t
ret
=
strncmp
(
f1
,
f2
,
bytes
);
if
(
ret
==
0
)
{
return
0
;
int32_t
len1
=
varDataLen
(
f1
);
int32_t
len2
=
varDataLen
(
f2
);
if
(
len1
!=
len2
)
{
return
len1
>
len2
?
1
:-
1
;
}
else
{
int32_t
ret
=
strncmp
(
varDataVal
(
f1
),
varDataVal
(
f2
),
len1
);
if
(
ret
==
0
)
{
return
0
;
}
return
(
ret
<
0
)
?
-
1
:
1
;
}
return
(
ret
<
0
)
?
-
1
:
1
;
};
case
TSDB_DATA_TYPE_NCHAR
:
{
case
TSDB_DATA_TYPE_NCHAR
:
{
// todo handle the var string compare
int32_t
ret
=
tasoUcs4Compare
(
f1
,
f2
,
bytes
);
if
(
ret
==
0
)
{
return
0
;
...
...
src/query/src/queryExecutor.c
浏览文件 @
9fa4fa30
...
...
@@ -2555,7 +2555,7 @@ static void doSetTagValueInParam(void *tsdb, STableId* pTableId, int32_t tagColI
if
(
tagColId
==
TSDB_TBNAME_COLUMN_INDEX
)
{
tsdbGetTableName
(
tsdb
,
pTableId
,
&
val
);
bytes
=
TSDB_TABLE_NAME_LEN
;
bytes
=
strnlen
(
val
,
TSDB_TABLE_NAME_LEN
)
;
type
=
TSDB_DATA_TYPE_BINARY
;
}
else
{
tsdbGetTableTagVal
(
tsdb
,
pTableId
,
tagColId
,
&
type
,
&
bytes
,
&
val
);
...
...
@@ -4232,7 +4232,7 @@ int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool
// normal query setup the queryhandle here
if
(
isFirstLastRowQuery
(
pQuery
))
{
// in case of last_row query, invoke a different API.
if
(
isFirstLastRowQuery
(
pQuery
)
&&
!
isSTableQuery
)
{
// in case of last_row query, invoke a different API.
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryLastRow
(
tsdb
,
&
cond
,
&
pQInfo
->
tableIdGroupInfo
);
}
else
if
(
!
isSTableQuery
||
isIntervalQuery
(
pQuery
)
||
isFixedOutputQuery
(
pQuery
))
{
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryTables
(
tsdb
,
&
cond
,
&
pQInfo
->
tableIdGroupInfo
);
...
...
@@ -4478,22 +4478,16 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
return
true
;
}
static
UNUSED_FUNC
int64_t
doCheck
MetersInGroup
(
SQInfo
*
pQInfo
,
int32_t
index
,
int32_t
star
t
)
{
static
UNUSED_FUNC
int64_t
doCheck
Tables
(
SQInfo
*
pQInfo
,
SArray
*
pTableLis
t
)
{
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
if
(
!
multiTableMultioutputHelper
(
pQInfo
,
index
))
{
if
(
!
multiTableMultioutputHelper
(
pQInfo
,
0
))
{
return
0
;
}
SPointInterpoSupporter
pointInterpSupporter
=
{
0
};
pointInterpSupporterInit
(
pQuery
,
&
pointInterpSupporter
);
assert
(
0
);
// if (!normalizedFirstQueryRange(dataInDisk, dataInCache, pSupporter, &pointInterpSupporter, NULL)) {
// pointInterpSupporterDestroy(&pointInterpSupporter);
// return 0;
// }
/*
* here we set the value for before and after the specified time into the
...
...
@@ -4537,62 +4531,51 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
resetCtxOutputBuf
(
pRuntimeEnv
);
assert
(
pQuery
->
limit
.
offset
==
0
&&
pQuery
->
limit
.
limit
!=
0
);
#if 0
while
(
pQInfo
->
groupIndex
<
numOfGroups
)
{
SArray
*
group
=
taosArrayGetP
(
pQInfo
->
groupInfo
.
pGroupList
,
pQInfo
->
groupIndex
);
size_t numOfTable = taosArrayGetSize(group);
if
(
isFirstLastRowQuery
(
pQuery
))
{
qTrace("QInfo:%p last_row query on vid:%d, numOfGroups:%d, current group:%d", pQInfo, vid, pTableIdList->numOfSubSet,
pQInfo->groupIndex);
TSKEY key = -1;
int32_t index = -1;
// choose the last key for one group
pQInfo->tableIndex = 0;
qTrace
(
"QInfo:%p last_row query on group:%d, total group:%d, current group:%d"
,
pQInfo
,
pQInfo
->
groupIndex
,
numOfGroups
);
STsdbQueryCond
cond
=
{
.
twindow
=
pQuery
->
window
,
.
colList
=
pQuery
->
colList
,
.
order
=
pQuery
->
order
.
order
,
.
numOfCols
=
pQuery
->
numOfCols
,
};
SArray
*
g1
=
taosArrayInit
(
1
,
POINTER_BYTES
);
SArray
*
tx
=
taosArrayClone
(
group
);
taosArrayPush
(
g1
,
&
tx
);
for (int32_t k = 0; k < numOfTable; ++k, pQInfo->tableIndex++) {
if (isQueryKilled(pQInfo)) {
return;
}
STableGroupInfo
gp
=
{.
numOfTables
=
taosArrayGetSize
(
tx
),
.
pGroupList
=
g1
};
// include only current table
if
(
pRuntimeEnv
->
pQueryHandle
!=
NULL
)
{
tsdbCleanupQueryHandle
(
pRuntimeEnv
->
pQueryHandle
);
pRuntimeEnv
->
pQueryHandle
=
NULL
;
}
pQuery->window.skey = key;
pQuery->window.ekey = key;
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryLastRow
(
pQInfo
->
tsdb
,
&
cond
,
&
gp
);
// int64_t num = doCheckMetersInGroup(pQInfo, index, start);
// assert(num >= 0);
} else {
qTrace("QInfo:%p interp query on vid:%d, numOfGroups:%d, current group:%d", pQInfo, vid, pTableIdList->numOfSubSet,
pQInfo->groupIndex);
initCtxOutputBuf
(
pRuntimeEnv
);
setTagVal
(
pRuntimeEnv
,
(
STableId
*
)
taosArrayGet
(
tx
,
0
),
pQInfo
->
tsdb
);
scanAllDataBlocks
(
pRuntimeEnv
);
for (int32_t k = start; k <= end; ++k) {
if (isQueryKilled(pQInfo)) {
setQueryStatus(pQuery, QUERY_NO_DATA_TO_CHECK);
return;
}
pQuery->skey = pSupporter->rawSKey;
pQuery->ekey = pSupporter->rawEKey;
int64_t num = doCheckMetersInGroup(pQInfo, k, start);
if (num == 1) {
break;
}
int64_t
numOfRes
=
getNumOfResult
(
pRuntimeEnv
);
if
(
numOfRes
>
0
)
{
pQuery
->
rec
.
rows
+=
numOfRes
;
forwardCtxOutputBuf
(
pRuntimeEnv
,
numOfRes
);
}
}
pSupporter->groupIndex++;
// output buffer is full, return to client
if (pQuery->size >= pQuery->pointsToRead) {
break;
skipResults
(
pRuntimeEnv
);
pQInfo
->
groupIndex
+=
1
;
// enable execution for next table, when handling the projection query
enableExecutionForNextTable
(
pRuntimeEnv
);
}
}
#endif
}
else
{
createTableQueryInfo
(
pQInfo
);
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
9fa4fa30
...
...
@@ -122,7 +122,7 @@ typedef struct STsdbQueryHandle {
SRWHelper
rhelper
;
}
STsdbQueryHandle
;
static
void
changeQueryHandleForQuery
(
TsdbQueryHandleT
pqHandle
);
static
void
changeQueryHandleFor
Lastrow
Query
(
TsdbQueryHandleT
pqHandle
);
static
void
tsdbInitDataBlockLoadInfo
(
SDataBlockLoadInfo
*
pBlockLoadInfo
)
{
pBlockLoadInfo
->
slot
=
-
1
;
...
...
@@ -207,7 +207,7 @@ TsdbQueryHandleT tsdbQueryLastRow(TsdbRepoT *tsdb, STsdbQueryCond *pCond, STable
pQueryHandle
->
type
=
TSDB_QUERY_TYPE_LAST_ROW
;
pQueryHandle
->
order
=
TSDB_ORDER_DESC
;
changeQueryHandleForQuery
(
pQueryHandle
);
changeQueryHandleFor
Lastrow
Query
(
pQueryHandle
);
return
pQueryHandle
;
}
...
...
@@ -957,7 +957,7 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pqHandle) {
}
}
void
changeQueryHandleForQuery
(
TsdbQueryHandleT
pqHandle
)
{
void
changeQueryHandleFor
Lastrow
Query
(
TsdbQueryHandleT
pqHandle
)
{
STsdbQueryHandle
*
pQueryHandle
=
(
STsdbQueryHandle
*
)
pqHandle
;
assert
(
!
ASCENDING_ORDER_TRAVERSE
(
pQueryHandle
->
order
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录