Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
2ba89e21
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
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看板
提交
2ba89e21
编写于
7月 17, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] fix error in calculate the qualified block
上级
14a86b4b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
51 addition
and
44 deletion
+51
-44
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+2
-3
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+49
-41
未找到文件。
src/query/src/qExecutor.c
浏览文件 @
2ba89e21
...
...
@@ -26,7 +26,6 @@
#include "query.h"
#include "queryLog.h"
#include "qast.h"
#include "tfile.h"
#include "tlosertree.h"
#include "tscompression.h"
#include "ttime.h"
...
...
@@ -35,8 +34,8 @@
* check if the primary column is load by default, otherwise, the program will
* forced to load primary column explicitly.
*/
#define Q_STATUS_EQUAL(p, s) (((p) & (s)) != 0)
#define TSDB_COL_IS_TAG(f) (((f)&TSDB_COL_TAG) != 0)
#define Q_STATUS_EQUAL(p, s)
(((p) & (s)) != 0)
#define TSDB_COL_IS_TAG(f)
(((f)&TSDB_COL_TAG) != 0)
#define QUERY_IS_ASC_QUERY(q) (GET_FORWARD_DIRECTION_FACTOR((q)->order.order) == QUERY_ASC_FORWARD_STEP)
#define IS_MASTER_SCAN(runtime) ((runtime)->scanFlag == MASTER_SCAN)
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
2ba89e21
...
...
@@ -515,7 +515,7 @@ static int32_t binarySearchForBlock(SCompBlock* pBlock, int32_t numOfBlocks, TSK
return
midSlot
;
}
static
int32_t
getFileCompInfo
(
STsdbQueryHandle
*
pQueryHandle
,
int32_t
*
numOfBlocks
,
int32_t
type
)
{
static
int32_t
getFileCompInfo
(
STsdbQueryHandle
*
pQueryHandle
,
int32_t
*
numOfBlocks
)
{
SFileGroup
*
fileGroup
=
pQueryHandle
->
pFileGroup
;
assert
(
fileGroup
->
files
[
TSDB_FILE_TYPE_HEAD
].
fname
>
0
);
...
...
@@ -532,52 +532,61 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
STableCheckInfo
*
pCheckInfo
=
taosArrayGet
(
pQueryHandle
->
pTableCheckInfo
,
i
);
pCheckInfo
->
numOfBlocks
=
0
;
SCompIdx
*
compIndex
=
&
pQueryHandle
->
rhelper
.
pCompIdx
[
pCheckInfo
->
tableId
.
tid
];
if
(
compIndex
->
len
==
0
||
compIndex
->
numOfBlocks
==
0
||
compIndex
->
uid
!=
pCheckInfo
->
tableId
.
uid
)
{
// no data block in this file, try next file
pCheckInfo
->
numOfBlocks
=
0
;
continue
;
// no data blocks in the file belongs to pCheckInfo->pTable
// no data block in this file, try next file
if
(
compIndex
->
len
==
0
||
compIndex
->
numOfBlocks
==
0
||
compIndex
->
uid
!=
pCheckInfo
->
tableId
.
uid
)
{
continue
;
// no data blocks in the file belongs to pCheckInfo->pTable
}
if
(
pCheckInfo
->
compSize
<
compIndex
->
len
)
{
assert
(
compIndex
->
len
>
0
);
char
*
t
=
realloc
(
pCheckInfo
->
pCompInfo
,
compIndex
->
len
);
assert
(
t
!=
NULL
);
pCheckInfo
->
pCompInfo
=
(
SCompInfo
*
)
t
;
pCheckInfo
->
compSize
=
compIndex
->
len
;
}
tsdbSetHelperTable
(
&
pQueryHandle
->
rhelper
,
pCheckInfo
->
pTableObj
,
pQueryHandle
->
pTsdb
);
tsdbLoadCompInfo
(
&
(
pQueryHandle
->
rhelper
),
(
void
*
)(
pCheckInfo
->
pCompInfo
));
SCompInfo
*
pCompInfo
=
pCheckInfo
->
pCompInfo
;
TSKEY
s
=
TSKEY_INITIAL_VAL
,
e
=
TSKEY_INITIAL_VAL
;
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
assert
(
pCheckInfo
->
lastKey
>=
pQueryHandle
->
window
.
ekey
&&
pQueryHandle
->
window
.
skey
<=
pQueryHandle
->
window
.
ekey
);
}
else
{
if
(
pCheckInfo
->
compSize
<
compIndex
->
len
)
{
assert
(
compIndex
->
len
>
0
);
char
*
t
=
realloc
(
pCheckInfo
->
pCompInfo
,
compIndex
->
len
);
assert
(
t
!=
NULL
);
pCheckInfo
->
pCompInfo
=
(
SCompInfo
*
)
t
;
pCheckInfo
->
compSize
=
compIndex
->
len
;
}
tsdbSetHelperTable
(
&
pQueryHandle
->
rhelper
,
pCheckInfo
->
pTableObj
,
pQueryHandle
->
pTsdb
);
assert
(
pCheckInfo
->
lastKey
<=
pQueryHandle
->
window
.
ekey
&&
pQueryHandle
->
window
.
skey
>=
pQueryHandle
->
window
.
ekey
);
}
tsdbLoadCompInfo
(
&
(
pQueryHandle
->
rhelper
),
(
void
*
)(
pCheckInfo
->
pCompInfo
));
SCompInfo
*
pCompInfo
=
pCheckInfo
->
pCompInfo
;
TSKEY
s
=
MIN
(
pCheckInfo
->
lastKey
,
pQueryHandle
->
window
.
ekey
);
TSKEY
e
=
MAX
(
pCheckInfo
->
lastKey
,
pQueryHandle
->
window
.
ekey
);
// discard the unqualified data block based on the query time window
int32_t
start
=
binarySearchForBlock
(
pCompInfo
->
blocks
,
compIndex
->
numOfBlocks
,
s
,
TSDB_ORDER_ASC
);
int32_t
end
=
start
;
if
(
s
>
pCompInfo
->
blocks
[
start
].
keyLast
)
{
continue
;
}
s
=
MIN
(
pCheckInfo
->
lastKey
,
pQueryHandle
->
window
.
ekey
);
e
=
MAX
(
pCheckInfo
->
lastKey
,
pQueryHandle
->
window
.
ekey
);
// todo speedup the procedure of located end block
while
(
end
<
compIndex
->
numOfBlocks
&&
(
pCompInfo
->
blocks
[
end
].
keyFirst
<=
e
))
{
end
+=
1
;
}
// discard the unqualified data block based on the query time window
int32_t
start
=
binarySearchForBlock
(
pCompInfo
->
blocks
,
compIndex
->
numOfBlocks
,
s
,
TSDB_ORDER_ASC
);
int32_t
end
=
start
;
pCheckInfo
->
numOfBlocks
=
(
end
-
start
);
if
(
start
>
0
)
{
memmove
(
pCompInfo
->
blocks
,
&
pCompInfo
->
blocks
[
start
],
pCheckInfo
->
numOfBlocks
*
sizeof
(
SCompBlock
));
}
if
(
s
>
pCompInfo
->
blocks
[
start
].
keyLast
)
{
continue
;
}
(
*
numOfBlocks
)
+=
pCheckInfo
->
numOfBlocks
;
// todo speedup the procedure of located end block
while
(
end
<
compIndex
->
numOfBlocks
&&
(
pCompInfo
->
blocks
[
end
].
keyFirst
<=
e
))
{
end
+=
1
;
}
pCheckInfo
->
numOfBlocks
=
(
end
-
start
);
if
(
start
>
0
)
{
memmove
(
pCompInfo
->
blocks
,
&
pCompInfo
->
blocks
[
start
],
pCheckInfo
->
numOfBlocks
*
sizeof
(
SCompBlock
));
}
(
*
numOfBlocks
)
+=
pCheckInfo
->
numOfBlocks
;
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1378,8 +1387,7 @@ static int32_t getDataBlocksInFilesImpl(STsdbQueryHandle* pQueryHandle, bool* ex
int32_t
numOfTables
=
taosArrayGetSize
(
pQueryHandle
->
pTableCheckInfo
);
while
((
pQueryHandle
->
pFileGroup
=
tsdbGetFileGroupNext
(
&
pQueryHandle
->
fileIter
))
!=
NULL
)
{
int32_t
type
=
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
?
QUERY_RANGE_GREATER_EQUAL
:
QUERY_RANGE_LESS_EQUAL
;
if
((
code
=
getFileCompInfo
(
pQueryHandle
,
&
numOfBlocks
,
type
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
getFileCompInfo
(
pQueryHandle
,
&
numOfBlocks
))
!=
TSDB_CODE_SUCCESS
)
{
break
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录