Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2b21c5e0
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2b21c5e0
编写于
7月 17, 2023
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tsdb2: adapt cache with tsdb2 API
上级
145c43e3
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
405 addition
and
670 deletion
+405
-670
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+63
-57
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+315
-587
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
+16
-14
source/dnode/vnode/src/tsdb/tsdbFS2.h
source/dnode/vnode/src/tsdb/tsdbFS2.h
+2
-2
source/dnode/vnode/src/tsdb/tsdbRead2.c
source/dnode/vnode/src/tsdb/tsdbRead2.c
+8
-8
source/dnode/vnode/src/tsdb/tsdbReadUtil.h
source/dnode/vnode/src/tsdb/tsdbReadUtil.h
+1
-2
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
2b21c5e0
...
...
@@ -368,20 +368,20 @@ typedef struct {
}
SCacheFlushState
;
struct
STsdb
{
char
*
path
;
SVnode
*
pVnode
;
STsdbKeepCfg
keepCfg
;
TdThreadRwlock
rwLock
;
SMemTable
*
mem
;
SMemTable
*
imem
;
STsdbFS
fs
;
// old
SLRUCache
*
lruCache
;
SCacheFlushState
flushState
;
TdThreadMutex
lruMutex
;
SLRUCache
*
biCache
;
TdThreadMutex
biMutex
;
char
*
path
;
SVnode
*
pVnode
;
STsdbKeepCfg
keepCfg
;
TdThreadRwlock
rwLock
;
SMemTable
*
mem
;
SMemTable
*
imem
;
STsdbFS
fs
;
// old
SLRUCache
*
lruCache
;
SCacheFlushState
flushState
;
TdThreadMutex
lruMutex
;
SLRUCache
*
biCache
;
TdThreadMutex
biMutex
;
struct
STFileSystem
*
pFS
;
// new
SRocksCache
rCache
;
SRocksCache
rCache
;
};
struct
TSDBKEY
{
...
...
@@ -659,12 +659,19 @@ struct SDelFWriter {
uint8_t
*
aBuf
[
1
];
};
#include "tarray2.h"
//#include "tsdbFS2.h"
// struct STFileSet;
typedef
struct
STFileSet
STFileSet
;
typedef
TARRAY2
(
STFileSet
*
)
TFileSetArray
;
struct
STsdbReadSnap
{
SMemTable
*
pMem
;
SQueryNode
*
pNode
;
SMemTable
*
pIMem
;
SQueryNode
*
pINode
;
STsdbFS
fs
;
SMemTable
*
pMem
;
SQueryNode
*
pNode
;
SMemTable
*
pIMem
;
SQueryNode
*
pINode
;
TFileSetArray
*
pfSetArray
;
STsdbFS
fs
;
};
struct
SDataFWriter
{
...
...
@@ -777,7 +784,7 @@ struct SDiskDataBuilder {
typedef
struct
SLDataIter
{
SRBTreeNode
node
;
SSttBlk
*
pSttBlk
;
int32_t
iStt
;
// for debug purpose
int32_t
iStt
;
// for debug purpose
int8_t
backward
;
int32_t
iSttBlk
;
int32_t
iRow
;
...
...
@@ -796,22 +803,22 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead
bool
destroyLoadInfo
,
const
char
*
idStr
,
bool
strictTimeRange
,
SLDataIter
*
pLDataIter
);
typedef
struct
{
int8_t
backward
;
STsdb
*
pTsdb
;
uint64_t
suid
;
uint64_t
uid
;
STimeWindow
timewindow
;
SVersionRange
verRange
;
bool
strictTimeRange
;
SArray
*
pSttFileBlockIterArray
;
void
*
pCurrentFileset
;
STSchema
*
pSchema
;
int16_t
*
pCols
;
int32_t
numOfCols
;
void
*
pReader
;
void
*
idstr
;
int8_t
backward
;
STsdb
*
pTsdb
;
uint64_t
suid
;
uint64_t
uid
;
STimeWindow
timewindow
;
SVersionRange
verRange
;
bool
strictTimeRange
;
SArray
*
pSttFileBlockIterArray
;
void
*
pCurrentFileset
;
STSchema
*
pSchema
;
int16_t
*
pCols
;
int32_t
numOfCols
;
void
*
pReader
;
void
*
idstr
;
}
SMergeTreeConf
;
int32_t
tMergeTreeOpen2
(
SMergeTree
*
pMTree
,
SMergeTreeConf
*
pConf
);
int32_t
tMergeTreeOpen2
(
SMergeTree
*
pMTree
,
SMergeTreeConf
*
pConf
);
void
tMergeTreeAddIter
(
SMergeTree
*
pMTree
,
SLDataIter
*
pIter
);
bool
tMergeTreeNext
(
SMergeTree
*
pMTree
);
...
...
@@ -827,29 +834,28 @@ void *destroySttBlockReader(SArray *pLDataIterArray, int64_t *block
// tsdbCache ==============================================================================================
typedef
struct
SCacheRowsReader
{
STsdb
*
pTsdb
;
SVersionRange
verRange
;
TdThreadMutex
readerMutex
;
SVnode
*
pVnode
;
STSchema
*
pSchema
;
STSchema
*
pCurrSchema
;
uint64_t
uid
;
uint64_t
suid
;
char
**
transferBuf
;
// todo remove it soon
int32_t
numOfCols
;
SArray
*
pCidList
;
int32_t
*
pSlotIds
;
int32_t
type
;
int32_t
tableIndex
;
// currently returned result tables
STableKeyInfo
*
pTableList
;
// table id list
int32_t
numOfTables
;
SSttBlockLoadInfo
*
pLoadInfo
;
SLDataIter
*
pDataIter
;
STsdbReadSnap
*
pReadSnap
;
SDataFReader
*
pDataFReader
;
SDataFReader
*
pDataFReaderLast
;
const
char
*
idstr
;
int64_t
lastTs
;
STsdb
*
pTsdb
;
SVersionRange
verRange
;
TdThreadMutex
readerMutex
;
SVnode
*
pVnode
;
STSchema
*
pSchema
;
STSchema
*
pCurrSchema
;
uint64_t
uid
;
uint64_t
suid
;
char
**
transferBuf
;
// todo remove it soon
int32_t
numOfCols
;
SArray
*
pCidList
;
int32_t
*
pSlotIds
;
int32_t
type
;
int32_t
tableIndex
;
// currently returned result tables
STableKeyInfo
*
pTableList
;
// table id list
int32_t
numOfTables
;
SArray
*
pLDataIterArray
;
STsdbReadSnap
*
pReadSnap
;
SDataFReader
*
pDataFReader
;
SDataFReader
*
pDataFReaderLast
;
char
*
idstr
;
int64_t
lastTs
;
}
SCacheRowsReader
;
typedef
struct
{
...
...
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
2b21c5e0
此差异已折叠。
点击以展开。
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
浏览文件 @
2b21c5e0
...
...
@@ -124,7 +124,10 @@ int32_t tsdbReuseCacherowsReader(void* reader, void* pTableIdList, int32_t numOf
pReader
->
numOfTables
=
numOfTables
;
pReader
->
lastTs
=
INT64_MIN
;
resetLastBlockLoadInfo
(
pReader
->
pLoadInfo
);
int64_t
blocks
;
double
elapse
;
pReader
->
pLDataIterArray
=
destroySttBlockReader
(
pReader
->
pLDataIterArray
,
&
blocks
,
&
elapse
);
pReader
->
pLDataIterArray
=
taosArrayInit
(
4
,
POINTER_BYTES
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -178,14 +181,8 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList,
SVnodeCfg
*
pCfg
=
&
((
SVnode
*
)
pVnode
)
->
config
;
int32_t
numOfStt
=
pCfg
->
sttTrigger
;
p
->
pLoadInfo
=
tCreateLastBlockLoadInfo
(
p
->
pSchema
,
NULL
,
0
,
numOfStt
);
if
(
p
->
pLoadInfo
==
NULL
)
{
tsdbCacherowsReaderClose
(
p
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
p
->
pDataIter
=
taosMemoryCalloc
(
pCfg
->
sttTrigger
,
sizeof
(
SLDataIter
));
if
(
p
->
pDataIter
==
NULL
)
{
p
->
pLDataIterArray
=
taosArrayInit
(
4
,
POINTER_BYTES
);
if
(
p
->
pLDataIterArray
==
NULL
)
{
tsdbCacherowsReaderClose
(
p
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
...
...
@@ -214,10 +211,11 @@ void* tsdbCacherowsReaderClose(void* pReader) {
taosMemoryFree
(
p
->
pSchema
);
}
taosMemoryFree
(
p
->
pDataIter
);
taosMemoryFree
(
p
->
pCurrSchema
);
destroyLastBlockLoadInfo
(
p
->
pLoadInfo
);
int64_t
loadBlocks
=
0
;
double
elapse
=
0
;
destroySttBlockReader
(
p
->
pLDataIterArray
,
&
loadBlocks
,
&
elapse
);
taosMemoryFree
((
void
*
)
p
->
idstr
);
taosThreadMutexDestroy
(
&
p
->
readerMutex
);
...
...
@@ -298,7 +296,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
}
taosThreadMutexLock
(
&
pr
->
readerMutex
);
code
=
tsdbTakeReadSnap
((
STsdbReader
*
)
pr
,
tsdbCacheQueryReseek
,
&
pr
->
pReadSnap
);
code
=
tsdbTakeReadSnap
2
((
STsdbReader
*
)
pr
,
tsdbCacheQueryReseek
,
&
pr
->
pReadSnap
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_end
;
}
...
...
@@ -427,8 +425,12 @@ _end:
tsdbDataFReaderClose
(
&
pr
->
pDataFReaderLast
);
tsdbDataFReaderClose
(
&
pr
->
pDataFReader
);
resetLastBlockLoadInfo
(
pr
->
pLoadInfo
);
tsdbUntakeReadSnap
((
STsdbReader
*
)
pr
,
pr
->
pReadSnap
,
true
);
int64_t
loadBlocks
=
0
;
double
elapse
=
0
;
pr
->
pLDataIterArray
=
destroySttBlockReader
(
pr
->
pLDataIterArray
,
&
loadBlocks
,
&
elapse
);
pr
->
pLDataIterArray
=
taosArrayInit
(
4
,
POINTER_BYTES
);
tsdbUntakeReadSnap2
((
STsdbReader
*
)
pr
,
pr
->
pReadSnap
,
true
);
taosThreadMutexUnlock
(
&
pr
->
readerMutex
);
if
(
pRes
!=
NULL
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbFS2.h
浏览文件 @
2b21c5e0
...
...
@@ -25,7 +25,7 @@ extern "C" {
/* Exposed Handle */
typedef
struct
STFileSystem
STFileSystem
;
typedef
struct
STFSBgTask
STFSBgTask
;
typedef
TARRAY2
(
STFileSet
*
)
TFileSetArray
;
//
typedef TARRAY2(STFileSet *) TFileSetArray;
typedef
enum
{
TSDB_FEDIT_COMMIT
=
1
,
//
...
...
@@ -107,4 +107,4 @@ struct STFileSystem {
}
#endif
#endif
/*_TSDB_FILE_SYSTEM_H*/
\ No newline at end of file
#endif
/*_TSDB_FILE_SYSTEM_H*/
source/dnode/vnode/src/tsdb/tsdbRead2.c
浏览文件 @
2b21c5e0
...
...
@@ -18,9 +18,9 @@
#include "tsdbDataFileRW.h"
#include "tsdbFS2.h"
#include "tsdbMerge.h"
#include "tsdbReadUtil.h"
#include "tsdbUtil2.h"
#include "tsimplehash.h"
#include "tsdbReadUtil.h"
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
#define getCurrentKeyInLastBlock(_r) ((_r)->currentKey)
...
...
@@ -100,7 +100,7 @@ static int32_t updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInf
i
+=
1
;
j
+=
1
;
}
else
if
(
pTCol
->
colId
<
pSupInfo
->
colId
[
j
])
{
// do nothing
}
else
if
(
pTCol
->
colId
<
pSupInfo
->
colId
[
j
])
{
// do nothing
i
+=
1
;
}
else
{
return
TSDB_CODE_INVALID_PARA
;
...
...
@@ -3815,7 +3815,7 @@ static int32_t doOpenReaderImpl(STsdbReader* pReader) {
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SDataBlockIter
*
pBlockIter
=
&
pStatus
->
blockIter
;
initFilesetIterator
(
&
pStatus
->
fileIter
,
pReader
->
status
.
pfSetArray
,
pReader
);
initFilesetIterator
(
&
pStatus
->
fileIter
,
pReader
->
pReadSnap
->
pfSetArray
,
pReader
);
resetDataBlockIterator
(
&
pStatus
->
blockIter
,
pReader
->
info
.
order
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
...
@@ -3842,7 +3842,6 @@ static void freeSchemaFunc(void* param) {
static
void
clearSharedPtr
(
STsdbReader
*
p
)
{
p
->
status
.
pTableMap
=
NULL
;
p
->
status
.
uidList
.
tableUidList
=
NULL
;
p
->
status
.
pfSetArray
=
NULL
;
p
->
info
.
pSchema
=
NULL
;
p
->
pReadSnap
=
NULL
;
p
->
pSchemaMap
=
NULL
;
...
...
@@ -3851,7 +3850,8 @@ static void clearSharedPtr(STsdbReader* p) {
static
void
setSharedPtr
(
STsdbReader
*
pDst
,
const
STsdbReader
*
pSrc
)
{
pDst
->
status
.
pTableMap
=
pSrc
->
status
.
pTableMap
;
pDst
->
status
.
uidList
=
pSrc
->
status
.
uidList
;
pDst
->
status
.
pfSetArray
=
pSrc
->
status
.
pfSetArray
;
// pDst->status.pfSetArray = pSrc->status.pfSetArray;
pDst
->
pReadSnap
->
pfSetArray
=
pSrc
->
pReadSnap
->
pfSetArray
;
pDst
->
info
.
pSchema
=
pSrc
->
info
.
pSchema
;
pDst
->
pSchemaMap
=
pSrc
->
pSchemaMap
;
pDst
->
pReadSnap
=
pSrc
->
pReadSnap
;
...
...
@@ -4633,7 +4633,7 @@ int32_t tsdbReaderReset2(STsdbReader* pReader, SQueryTableDataCond* pCond) {
int32_t
numOfTables
=
tSimpleHashGetSize
(
pStatus
->
pTableMap
);
initFilesetIterator
(
&
pStatus
->
fileIter
,
pReader
->
status
.
pfSetArray
,
pReader
);
initFilesetIterator
(
&
pStatus
->
fileIter
,
pReader
->
pReadSnap
->
pfSetArray
,
pReader
);
resetDataBlockIterator
(
pBlockIter
,
pReader
->
info
.
order
);
resetTableListIndex
(
&
pReader
->
status
);
...
...
@@ -4886,7 +4886,7 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
}
// fs
code
=
tsdbFSCreateRefSnapshot
(
pTsdb
->
pFS
,
&
p
Reader
->
status
.
pfSetArray
);
code
=
tsdbFSCreateRefSnapshot
(
pTsdb
->
pFS
,
&
p
Snap
->
pfSetArray
);
if
(
code
)
{
taosThreadRwlockUnlock
(
&
pTsdb
->
rwLock
);
goto
_exit
;
...
...
@@ -4929,7 +4929,7 @@ void tsdbUntakeReadSnap2(STsdbReader* pReader, STsdbReadSnap* pSnap, bool proact
if
(
pSnap
->
pINode
)
taosMemoryFree
(
pSnap
->
pINode
);
taosMemoryFree
(
pSnap
);
tsdbFSDestroyRefSnapshot
(
&
p
Reader
->
status
.
pfSetArray
);
tsdbFSDestroyRefSnapshot
(
&
p
Snap
->
pfSetArray
);
}
tsdbTrace
(
"vgId:%d, untake read snapshot"
,
TD_VID
(
pTsdb
->
pVnode
));
}
...
...
source/dnode/vnode/src/tsdb/tsdbReadUtil.h
浏览文件 @
2b21c5e0
...
...
@@ -20,8 +20,8 @@
extern
"C"
{
#endif
#include "tsdbUtil2.h"
#include "tsdbDataFileRW.h"
#include "tsdbUtil2.h"
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
...
...
@@ -196,7 +196,6 @@ typedef struct SReaderStatus {
SArray
*
pLDataIterArray
;
SRowMerger
merger
;
SColumnInfoData
*
pPrimaryTsCol
;
// primary time stamp output col info data
TFileSetArray
*
pfSetArray
;
}
SReaderStatus
;
struct
STsdbReader
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录