Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
379d574d
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
379d574d
编写于
9月 04, 2020
作者:
B
Bomin Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix TD-1334: select count(*) returns wrong result
github #3334
上级
e9c0e7d2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
52 addition
and
7 deletion
+52
-7
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+52
-7
未找到文件。
src/tsdb/src/tsdbRead.c
浏览文件 @
379d574d
...
...
@@ -734,6 +734,10 @@ static int32_t doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* p
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
copyDataFromFileBlock
(
STsdbQueryHandle
*
pQueryHandle
,
int32_t
capacity
,
int32_t
numOfRows
,
int32_t
start
,
int32_t
end
);
static
void
moveDataToFront
(
STsdbQueryHandle
*
pQueryHandle
,
int32_t
numOfRows
,
int32_t
numOfCols
);
static
void
doCheckGeneratedBlockRange
(
STsdbQueryHandle
*
pQueryHandle
);
static
int32_t
handleDataMergeIfNeeded
(
STsdbQueryHandle
*
pQueryHandle
,
SCompBlock
*
pBlock
,
STableCheckInfo
*
pCheckInfo
){
SQueryFilePos
*
cur
=
&
pQueryHandle
->
cur
;
SDataBlockInfo
binfo
=
GET_FILE_DATA_BLOCK_INFO
(
pCheckInfo
,
pBlock
);
...
...
@@ -745,7 +749,6 @@ static int32_t handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBloc
TSKEY
key
=
(
row
!=
NULL
)
?
dataRowKey
(
row
)
:
TSKEY_INITIAL_VAL
;
tsdbDebug
(
"%p key in mem:%"
PRId64
", %p"
,
pQueryHandle
,
key
,
pQueryHandle
->
qinfo
);
cur
->
pos
=
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
?
0
:
(
binfo
.
rows
-
1
);
if
((
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
&&
(
key
!=
TSKEY_INITIAL_VAL
&&
key
<=
binfo
.
window
.
ekey
))
||
(
!
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
&&
(
key
!=
TSKEY_INITIAL_VAL
&&
key
>=
binfo
.
window
.
skey
)))
{
...
...
@@ -784,14 +787,54 @@ static int32_t handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBloc
*
* Here the buffer is not enough, so only part of file block can be loaded into memory buffer
*/
assert
(
pQueryHandle
->
outputCapacity
>=
binfo
.
rows
);
pQueryHandle
->
realNumOfRows
=
binfo
.
rows
;
assert
(
pQueryHandle
->
outputCapacity
>=
binfo
.
rows
);
if
((
cur
->
pos
==
0
&&
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
||
(
cur
->
pos
==
(
binfo
.
rows
-
1
)
&&
(
!
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))))
{
pQueryHandle
->
realNumOfRows
=
binfo
.
rows
;
cur
->
rows
=
binfo
.
rows
;
cur
->
win
=
binfo
.
window
;
cur
->
mixBlock
=
false
;
cur
->
lastKey
=
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
?
(
binfo
.
window
.
ekey
+
1
)
:
(
binfo
.
window
.
skey
-
1
);
}
else
{
SDataCols
*
pCols
=
pQueryHandle
->
rhelper
.
pDataCols
[
0
];
TSKEY
*
tsArray
=
pCols
->
cols
[
0
].
pData
;
assert
(
pCols
->
cols
[
0
].
type
==
TSDB_DATA_TYPE_TIMESTAMP
&&
pCols
->
cols
[
0
].
colId
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
&&
cur
->
pos
>=
0
&&
cur
->
pos
<
pBlock
->
numOfRows
&&
(
tsArray
[
0
]
==
binfo
.
window
.
skey
&&
tsArray
[
binfo
.
rows
-
1
]
==
binfo
.
window
.
ekey
));
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
cur
->
rows
=
binfo
.
rows
-
cur
->
pos
;
cur
->
win
.
skey
=
tsArray
[
cur
->
pos
];
cur
->
win
.
ekey
=
binfo
.
window
.
ekey
;
cur
->
lastKey
=
binfo
.
window
.
ekey
+
1
;
int32_t
numOfRows
=
copyDataFromFileBlock
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
0
,
cur
->
pos
,
binfo
.
rows
-
1
);
assert
(
numOfRows
==
cur
->
rows
);
}
else
{
cur
->
rows
=
cur
->
pos
+
1
;
cur
->
win
.
skey
=
binfo
.
window
.
skey
;
cur
->
win
.
ekey
=
tsArray
[
cur
->
pos
];
cur
->
lastKey
=
binfo
.
window
.
skey
-
1
;
int32_t
numOfRows
=
copyDataFromFileBlock
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
0
,
0
,
cur
->
pos
);
assert
(
numOfRows
==
cur
->
rows
);
int32_t
numOfCols
=
(
int32_t
)(
QH_GET_NUM_OF_COLS
(
pQueryHandle
));
moveDataToFront
(
pQueryHandle
,
numOfRows
,
numOfCols
);
doCheckGeneratedBlockRange
(
pQueryHandle
);
}
pQueryHandle
->
realNumOfRows
=
cur
->
rows
;
cur
->
mixBlock
=
true
;
}
cur
->
rows
=
binfo
.
rows
;
cur
->
win
=
binfo
.
window
;
cur
->
mixBlock
=
false
;
cur
->
blockCompleted
=
true
;
cur
->
lastKey
=
binfo
.
window
.
ekey
+
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
?
1
:-
1
);
pCheckInfo
->
lastKey
=
cur
->
lastKey
;
}
...
...
@@ -823,6 +866,7 @@ static int32_t loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBl
assert
(
pCheckInfo
->
lastKey
<=
pBlock
->
keyLast
);
doMergeTwoLevelData
(
pQueryHandle
,
pCheckInfo
,
pBlock
);
}
else
{
// the whole block is loaded in to buffer
cur
->
pos
=
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
?
0
:
(
pBlock
->
numOfRows
-
1
);
code
=
handleDataMergeIfNeeded
(
pQueryHandle
,
pBlock
,
pCheckInfo
);
}
}
else
{
//desc order, query ended in current block
...
...
@@ -842,6 +886,7 @@ static int32_t loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBl
assert
(
pCheckInfo
->
lastKey
>=
pBlock
->
keyFirst
);
doMergeTwoLevelData
(
pQueryHandle
,
pCheckInfo
,
pBlock
);
}
else
{
cur
->
pos
=
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
?
0
:
(
pBlock
->
numOfRows
-
1
);
code
=
handleDataMergeIfNeeded
(
pQueryHandle
,
pBlock
,
pCheckInfo
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录