Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
aca8e364
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看板
提交
aca8e364
编写于
9月 16, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1439
上级
760b3087
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
9 deletion
+34
-9
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+34
-9
未找到文件。
src/tsdb/src/tsdbRead.c
浏览文件 @
aca8e364
...
...
@@ -432,7 +432,7 @@ static void destroyTableMemIterator(STableCheckInfo* pCheckInfo) {
tSkipListDestroyIter
(
pCheckInfo
->
iiter
);
}
static
SDataRow
getSDataRowInTableMem
(
STableCheckInfo
*
pCheckInfo
,
int32_t
order
)
{
static
SDataRow
getSDataRowInTableMem
(
STableCheckInfo
*
pCheckInfo
,
int32_t
order
,
int32_t
update
)
{
SDataRow
rmem
=
NULL
,
rimem
=
NULL
;
if
(
pCheckInfo
->
iter
)
{
SSkipListNode
*
node
=
tSkipListIterGet
(
pCheckInfo
->
iter
);
...
...
@@ -466,9 +466,15 @@ static SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo, int32_t order
TSKEY
r2
=
dataRowKey
(
rimem
);
if
(
r1
==
r2
)
{
// data ts are duplicated, ignore the data in mem
tSkipListIterNext
(
pCheckInfo
->
iter
);
pCheckInfo
->
chosen
=
1
;
return
rimem
;
if
(
!
update
)
{
tSkipListIterNext
(
pCheckInfo
->
iter
);
pCheckInfo
->
chosen
=
1
;
return
rimem
;
}
else
{
tSkipListIterNext
(
pCheckInfo
->
iiter
);
pCheckInfo
->
chosen
=
0
;
return
rmem
;
}
}
else
{
if
(
ASCENDING_TRAVERSE
(
order
))
{
if
(
r1
<
r2
)
{
...
...
@@ -522,6 +528,7 @@ static bool moveToNextRowInMem(STableCheckInfo* pCheckInfo) {
}
static
bool
hasMoreDataInCache
(
STsdbQueryHandle
*
pHandle
)
{
STsdbCfg
*
pCfg
=
&
pHandle
->
pTsdb
->
config
;
size_t
size
=
taosArrayGetSize
(
pHandle
->
pTableCheckInfo
);
assert
(
pHandle
->
activeIndex
<
size
&&
pHandle
->
activeIndex
>=
0
&&
size
>=
1
);
pHandle
->
cur
.
fid
=
-
1
;
...
...
@@ -535,7 +542,7 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) {
initTableMemIterator
(
pHandle
,
pCheckInfo
);
}
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
,
pHandle
->
order
);
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
,
pHandle
->
order
,
pCfg
->
update
);
if
(
row
==
NULL
)
{
return
false
;
}
...
...
@@ -741,11 +748,12 @@ static void copyAllRemainRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, STabl
static
int32_t
handleDataMergeIfNeeded
(
STsdbQueryHandle
*
pQueryHandle
,
SCompBlock
*
pBlock
,
STableCheckInfo
*
pCheckInfo
){
SQueryFilePos
*
cur
=
&
pQueryHandle
->
cur
;
STsdbCfg
*
pCfg
=
&
pQueryHandle
->
pTsdb
->
config
;
SDataBlockInfo
binfo
=
GET_FILE_DATA_BLOCK_INFO
(
pCheckInfo
,
pBlock
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
/*bool hasData = */
initTableMemIterator
(
pQueryHandle
,
pCheckInfo
);
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
,
pQueryHandle
->
order
);
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
,
pQueryHandle
->
order
,
pCfg
->
update
);
assert
(
cur
->
pos
>=
0
&&
cur
->
pos
<=
binfo
.
rows
);
...
...
@@ -1208,6 +1216,7 @@ static void copyAllRemainRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, STabl
static
void
doMergeTwoLevelData
(
STsdbQueryHandle
*
pQueryHandle
,
STableCheckInfo
*
pCheckInfo
,
SCompBlock
*
pBlock
)
{
SQueryFilePos
*
cur
=
&
pQueryHandle
->
cur
;
SDataBlockInfo
blockInfo
=
GET_FILE_DATA_BLOCK_INFO
(
pCheckInfo
,
pBlock
);
STsdbCfg
*
pCfg
=
&
pQueryHandle
->
pTsdb
->
config
;
initTableMemIterator
(
pQueryHandle
,
pCheckInfo
);
...
...
@@ -1256,7 +1265,7 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
}
else
if
(
pCheckInfo
->
iter
!=
NULL
||
pCheckInfo
->
iiter
!=
NULL
)
{
SSkipListNode
*
node
=
NULL
;
do
{
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
,
pQueryHandle
->
order
);
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
,
pQueryHandle
->
order
,
pCfg
->
update
);
if
(
row
==
NULL
)
{
break
;
}
...
...
@@ -1286,7 +1295,22 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
moveToNextRowInMem
(
pCheckInfo
);
}
else
if
(
key
==
tsArray
[
pos
])
{
// data in buffer has the same timestamp of data in file block, ignore it
moveToNextRowInMem
(
pCheckInfo
);
if
(
pCfg
->
update
)
{
copyOneRowFromMem
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
numOfRows
,
row
,
numOfCols
,
pTable
);
numOfRows
+=
1
;
if
(
cur
->
win
.
skey
==
TSKEY_INITIAL_VAL
)
{
cur
->
win
.
skey
=
key
;
}
cur
->
win
.
ekey
=
key
;
cur
->
lastKey
=
key
+
step
;
cur
->
mixBlock
=
true
;
moveToNextRowInMem
(
pCheckInfo
);
pos
+=
step
;
}
else
{
moveToNextRowInMem
(
pCheckInfo
);
}
}
else
if
((
key
>
tsArray
[
pos
]
&&
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
||
(
key
<
tsArray
[
pos
]
&&
!
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)))
{
if
(
cur
->
win
.
skey
==
TSKEY_INITIAL_VAL
)
{
...
...
@@ -1765,13 +1789,14 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
STsdbQueryHandle
*
pQueryHandle
)
{
int
numOfRows
=
0
;
int32_t
numOfCols
=
(
int32_t
)
taosArrayGetSize
(
pQueryHandle
->
pColumns
);
STsdbCfg
*
pCfg
=
&
pQueryHandle
->
pTsdb
->
config
;
win
->
skey
=
TSKEY_INITIAL_VAL
;
int64_t
st
=
taosGetTimestampUs
();
STable
*
pTable
=
pCheckInfo
->
pTableObj
;
do
{
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
,
pQueryHandle
->
order
);
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
,
pQueryHandle
->
order
,
pCfg
->
update
);
if
(
row
==
NULL
)
{
break
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录