Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5e793c2f
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5e793c2f
编写于
6月 29, 2022
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tsdbCacheRead: use new H version api of last_row
上级
ac7f5190
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
24 deletion
+35
-24
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+4
-2
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
+31
-22
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
5e793c2f
...
...
@@ -1087,7 +1087,8 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUH
code
=
mergeLastRow
(
uid
,
pTsdb
,
&
pRow
);
// if table's empty or error, return code of -1
if
(
code
<
0
||
pRow
==
NULL
)
{
return
-
1
;
*
handle
=
NULL
;
return
0
;
}
tsdbCacheInsertLastrow
(
pCache
,
uid
,
pRow
);
...
...
@@ -1116,7 +1117,8 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUHand
code
=
mergeLast
(
uid
,
pTsdb
,
&
pRow
);
// if table's empty or error, return code of -1
if
(
code
<
0
||
pRow
==
NULL
)
{
return
-
1
;
*
handle
=
NULL
;
return
0
;
}
tsdbCacheInsertLast
(
pCache
,
uid
,
pRow
);
...
...
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
浏览文件 @
5e793c2f
...
...
@@ -22,15 +22,15 @@ typedef struct SLastrowReader {
SVnode
*
pVnode
;
STSchema
*
pSchema
;
uint64_t
uid
;
// int32_t* pSlotIds;
char
**
transferBuf
;
// todo remove it soon
int32_t
numOfCols
;
int32_t
type
;
int32_t
tableIndex
;
// currently returned result tables
SArray
*
pTableList
;
// table id list
// int32_t* pSlotIds;
char
**
transferBuf
;
// todo remove it soon
int32_t
numOfCols
;
int32_t
type
;
int32_t
tableIndex
;
// currently returned result tables
SArray
*
pTableList
;
// table id list
}
SLastrowReader
;
static
void
saveOneRow
(
STSRow
*
pRow
,
SSDataBlock
*
pBlock
,
SLastrowReader
*
pReader
,
const
int32_t
*
slotIds
)
{
static
void
saveOneRow
(
STSRow
*
pRow
,
SSDataBlock
*
pBlock
,
SLastrowReader
*
pReader
,
const
int32_t
*
slotIds
)
{
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
size_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
...
...
@@ -60,21 +60,21 @@ static void saveOneRow(STSRow* pRow, SSDataBlock* pBlock, SLastrowReader* pReade
pBlock
->
info
.
rows
+=
1
;
}
int32_t
tsdbLastRowReaderOpen
(
void
*
pVnode
,
int32_t
type
,
SArray
*
pTableIdList
,
int32_t
*
colId
,
int32_t
numOfCols
,
void
**
pReader
)
{
int32_t
tsdbLastRowReaderOpen
(
void
*
pVnode
,
int32_t
type
,
SArray
*
pTableIdList
,
int32_t
*
colId
,
int32_t
numOfCols
,
void
**
pReader
)
{
SLastrowReader
*
p
=
taosMemoryCalloc
(
1
,
sizeof
(
SLastrowReader
));
if
(
p
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
p
->
type
=
type
;
p
->
pVnode
=
pVnode
;
p
->
numOfCols
=
numOfCols
;
p
->
type
=
type
;
p
->
pVnode
=
pVnode
;
p
->
numOfCols
=
numOfCols
;
p
->
transferBuf
=
taosMemoryCalloc
(
p
->
numOfCols
,
POINTER_BYTES
);
STableKeyInfo
*
pKeyInfo
=
taosArrayGet
(
pTableIdList
,
0
);
p
->
pSchema
=
metaGetTbTSchema
(
p
->
pVnode
->
pMeta
,
pKeyInfo
->
uid
,
-
1
);
p
->
pTableList
=
pTableIdList
;
p
->
pSchema
=
metaGetTbTSchema
(
p
->
pVnode
->
pMeta
,
pKeyInfo
->
uid
,
-
1
);
p
->
pTableList
=
pTableIdList
;
#if 0
for(int32_t i = 0; i < p->numOfCols; ++i) {
for(int32_t j = 0; j < p->pSchema->numOfCols; ++j) {
...
...
@@ -101,7 +101,7 @@ int32_t tsdbLastRowReaderOpen(void* pVnode, int32_t type, SArray* pTableIdList,
int32_t
tsdbLastrowReaderClose
(
void
*
pReader
)
{
SLastrowReader
*
p
=
pReader
;
for
(
int32_t
i
=
0
;
i
<
p
->
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
p
->
numOfCols
;
++
i
)
{
taosMemoryFreeClear
(
p
->
transferBuf
[
i
]);
}
...
...
@@ -117,8 +117,9 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t
SLastrowReader
*
pr
=
pReader
;
STSRow
*
pRow
=
NULL
;
size_t
numOfTables
=
taosArrayGetSize
(
pr
->
pTableList
);
LRUHandle
*
h
=
NULL
;
STSRow
*
pRow
=
NULL
;
size_t
numOfTables
=
taosArrayGetSize
(
pr
->
pTableList
);
// retrieve the only one last row of all tables in the uid list.
if
(
pr
->
type
==
LASTROW_RETRIEVE_TYPE_SINGLE
)
{
...
...
@@ -126,16 +127,18 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t
bool
internalResult
=
false
;
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
STableKeyInfo
*
pKeyInfo
=
taosArrayGet
(
pr
->
pTableList
,
i
);
int32_t
code
=
tsdbCacheGetLastrow
(
pr
->
pVnode
->
pTsdb
->
lruCache
,
pKeyInfo
->
uid
,
pr
->
pVnode
->
pTsdb
,
&
pRow
);
/* int32_t code = tsdbCacheGetLastrow(pr->pVnode->pTsdb->lruCache, pKeyInfo->uid, pr->pVnode->pTsdb, &pRow); */
int32_t
code
=
tsdbCacheGetLastrowH
(
pr
->
pVnode
->
pTsdb
->
lruCache
,
pKeyInfo
->
uid
,
pr
->
pVnode
->
pTsdb
,
&
h
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
if
(
pRow
==
NULL
)
{
if
(
h
==
NULL
)
{
continue
;
}
pRow
=
(
STSRow
*
)
taosLRUCacheValue
(
pr
->
pVnode
->
pTsdb
->
lruCache
,
h
);
if
(
pRow
->
ts
>
lastKey
)
{
// Set result row into the same rowIndex repeatly, so we need to check if the internal result row has already
// appended or not.
...
...
@@ -147,23 +150,29 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t
internalResult
=
true
;
lastKey
=
pRow
->
ts
;
}
tsdbCacheRelease
(
pr
->
pVnode
->
pTsdb
->
lruCache
,
h
);
}
}
else
if
(
pr
->
type
==
LASTROW_RETRIEVE_TYPE_ALL
)
{
for
(
int32_t
i
=
pr
->
tableIndex
;
i
<
numOfTables
;
++
i
)
{
STableKeyInfo
*
pKeyInfo
=
taosArrayGet
(
pr
->
pTableList
,
i
);
int32_t
code
=
tsdbCacheGetLastrow
(
pr
->
pVnode
->
pTsdb
->
lruCache
,
pKeyInfo
->
uid
,
pr
->
pVnode
->
pTsdb
,
&
pRow
);
/* int32_t code = tsdbCacheGetLastrow(pr->pVnode->pTsdb->lruCache, pKeyInfo->uid, pr->pVnode->pTsdb, &pRow); */
int32_t
code
=
tsdbCacheGetLastrowH
(
pr
->
pVnode
->
pTsdb
->
lruCache
,
pKeyInfo
->
uid
,
pr
->
pVnode
->
pTsdb
,
&
h
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
// no data in the table of Uid
if
(
pRow
==
NULL
)
{
if
(
h
==
NULL
)
{
continue
;
}
pRow
=
(
STSRow
*
)
taosLRUCacheValue
(
pr
->
pVnode
->
pTsdb
->
lruCache
,
h
);
saveOneRow
(
pRow
,
pResBlock
,
pr
,
slotIds
);
tsdbCacheRelease
(
pr
->
pVnode
->
pTsdb
->
lruCache
,
h
);
pr
->
tableIndex
+=
1
;
if
(
pResBlock
->
info
.
rows
>=
pResBlock
->
info
.
capacity
)
{
return
TSDB_CODE_SUCCESS
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录