Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7360a6b6
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看板
提交
7360a6b6
编写于
4月 24, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(query): opt hash.
上级
d73306f6
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
69 addition
and
67 deletion
+69
-67
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+2
-1
source/dnode/vnode/src/tsdb/tsdbMemTable.c
source/dnode/vnode/src/tsdb/tsdbMemTable.c
+3
-2
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+64
-60
source/util/src/tsimplehash.c
source/util/src/tsimplehash.c
+0
-4
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
7360a6b6
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#ifndef _TD_VNODE_TSDB_H_
#ifndef _TD_VNODE_TSDB_H_
#define _TD_VNODE_TSDB_H_
#define _TD_VNODE_TSDB_H_
#include "tsimplehash.h"
#include "vnodeInt.h"
#include "vnodeInt.h"
#ifdef __cplusplus
#ifdef __cplusplus
...
@@ -224,7 +225,7 @@ int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward,
...
@@ -224,7 +225,7 @@ int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward,
void
*
tsdbTbDataIterDestroy
(
STbDataIter
*
pIter
);
void
*
tsdbTbDataIterDestroy
(
STbDataIter
*
pIter
);
void
tsdbTbDataIterOpen
(
STbData
*
pTbData
,
TSDBKEY
*
pFrom
,
int8_t
backward
,
STbDataIter
*
pIter
);
void
tsdbTbDataIterOpen
(
STbData
*
pTbData
,
TSDBKEY
*
pFrom
,
int8_t
backward
,
STbDataIter
*
pIter
);
bool
tsdbTbDataIterNext
(
STbDataIter
*
pIter
);
bool
tsdbTbDataIterNext
(
STbDataIter
*
pIter
);
void
tsdbMemTableCountRows
(
SMemTable
*
pMemTable
,
SHashObj
*
pTableMap
,
int64_t
*
rowsNum
);
void
tsdbMemTableCountRows
(
SMemTable
*
pMemTable
,
S
S
HashObj
*
pTableMap
,
int64_t
*
rowsNum
);
// STbData
// STbData
int32_t
tsdbGetNRowsInTbData
(
STbData
*
pTbData
);
int32_t
tsdbGetNRowsInTbData
(
STbData
*
pTbData
);
...
...
source/dnode/vnode/src/tsdb/tsdbMemTable.c
浏览文件 @
7360a6b6
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <util/tsimplehash.h>
#include "tsdb.h"
#include "tsdb.h"
#define MEM_MIN_HASH 1024
#define MEM_MIN_HASH 1024
...
@@ -298,12 +299,12 @@ int64_t tsdbCountTbDataRows(STbData *pTbData) {
...
@@ -298,12 +299,12 @@ int64_t tsdbCountTbDataRows(STbData *pTbData) {
return
rowsNum
;
return
rowsNum
;
}
}
void
tsdbMemTableCountRows
(
SMemTable
*
pMemTable
,
S
HashObj
*
pTableMap
,
int64_t
*
rowsNum
)
{
void
tsdbMemTableCountRows
(
SMemTable
*
pMemTable
,
S
SHashObj
*
pTableMap
,
int64_t
*
rowsNum
)
{
taosRLockLatch
(
&
pMemTable
->
latch
);
taosRLockLatch
(
&
pMemTable
->
latch
);
for
(
int32_t
i
=
0
;
i
<
pMemTable
->
nBucket
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pMemTable
->
nBucket
;
++
i
)
{
STbData
*
pTbData
=
pMemTable
->
aBucket
[
i
];
STbData
*
pTbData
=
pMemTable
->
aBucket
[
i
];
while
(
pTbData
)
{
while
(
pTbData
)
{
void
*
p
=
t
aos
HashGet
(
pTableMap
,
&
pTbData
->
uid
,
sizeof
(
pTbData
->
uid
));
void
*
p
=
t
Simple
HashGet
(
pTableMap
,
&
pTbData
->
uid
,
sizeof
(
pTbData
->
uid
));
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
pTbData
=
pTbData
->
next
;
pTbData
=
pTbData
->
next
;
continue
;
continue
;
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
7360a6b6
...
@@ -130,7 +130,7 @@ typedef struct SDataBlockIter {
...
@@ -130,7 +130,7 @@ typedef struct SDataBlockIter {
SArray
*
blockList
;
// SArray<SFileDataBlockInfo>
SArray
*
blockList
;
// SArray<SFileDataBlockInfo>
int32_t
order
;
int32_t
order
;
SDataBlk
block
;
// current SDataBlk data
SDataBlk
block
;
// current SDataBlk data
SHashObj
*
pTableMap
;
S
S
HashObj
*
pTableMap
;
}
SDataBlockIter
;
}
SDataBlockIter
;
typedef
struct
SFileBlockDumpInfo
{
typedef
struct
SFileBlockDumpInfo
{
...
@@ -148,7 +148,7 @@ typedef struct STableUidList {
...
@@ -148,7 +148,7 @@ typedef struct STableUidList {
typedef
struct
SReaderStatus
{
typedef
struct
SReaderStatus
{
bool
loadFromFile
;
// check file stage
bool
loadFromFile
;
// check file stage
bool
composedDataBlock
;
// the returned data block is a composed block or not
bool
composedDataBlock
;
// the returned data block is a composed block or not
S
HashObj
*
pTableMap
;
// SHash<STableBlockScanInfo>
S
SHashObj
*
pTableMap
;
// SHash<STableBlockScanInfo>
STableBlockScanInfo
**
pTableIter
;
// table iterator used in building in-memory buffer data blocks.
STableBlockScanInfo
**
pTableIter
;
// table iterator used in building in-memory buffer data blocks.
STableUidList
uidList
;
// check tables in uid order, to avoid the repeatly load of blocks in STT.
STableUidList
uidList
;
// check tables in uid order, to avoid the repeatly load of blocks in STT.
SFileBlockDumpInfo
fBlockDumpInfo
;
SFileBlockDumpInfo
fBlockDumpInfo
;
...
@@ -233,7 +233,7 @@ static bool hasDataInFileBlock(const SBlockData* pBlockData, const SFil
...
@@ -233,7 +233,7 @@ static bool hasDataInFileBlock(const SBlockData* pBlockData, const SFil
static
void
initBlockDumpInfo
(
STsdbReader
*
pReader
,
SDataBlockIter
*
pBlockIter
);
static
void
initBlockDumpInfo
(
STsdbReader
*
pReader
,
SDataBlockIter
*
pBlockIter
);
static
int32_t
getInitialDelIndex
(
const
SArray
*
pDelSkyline
,
int32_t
order
);
static
int32_t
getInitialDelIndex
(
const
SArray
*
pDelSkyline
,
int32_t
order
);
static
STableBlockScanInfo
*
getTableBlockScanInfo
(
SHashObj
*
pTableMap
,
uint64_t
uid
,
const
char
*
id
);
static
STableBlockScanInfo
*
getTableBlockScanInfo
(
S
S
HashObj
*
pTableMap
,
uint64_t
uid
,
const
char
*
id
);
static
FORCE_INLINE
STSchema
*
getLatestTableSchema
(
STsdbReader
*
pReader
,
uint64_t
uid
);
static
FORCE_INLINE
STSchema
*
getLatestTableSchema
(
STsdbReader
*
pReader
,
uint64_t
uid
);
...
@@ -384,12 +384,11 @@ static int32_t uidComparFunc(const void* p1, const void* p2) {
...
@@ -384,12 +384,11 @@ static int32_t uidComparFunc(const void* p1, const void* p2) {
}
}
// NOTE: speedup the whole processing by preparing the buffer for STableBlockScanInfo in batch model
// NOTE: speedup the whole processing by preparing the buffer for STableBlockScanInfo in batch model
static
SHashObj
*
createDataBlockScanInfo
(
STsdbReader
*
pTsdbReader
,
SBlockInfoBuf
*
pBuf
,
const
STableKeyInfo
*
idList
,
static
S
S
HashObj
*
createDataBlockScanInfo
(
STsdbReader
*
pTsdbReader
,
SBlockInfoBuf
*
pBuf
,
const
STableKeyInfo
*
idList
,
STableUidList
*
pUidList
,
int32_t
numOfTables
)
{
STableUidList
*
pUidList
,
int32_t
numOfTables
)
{
// allocate buffer in order to load data blocks from file
// allocate buffer in order to load data blocks from file
// todo use simple hash instead, optimize the memory consumption
// todo use simple hash instead, optimize the memory consumption
SHashObj
*
pTableMap
=
SSHashObj
*
pTableMap
=
tSimpleHashInit
(
numOfTables
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
));
taosHashInit
(
numOfTables
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
if
(
pTableMap
==
NULL
)
{
if
(
pTableMap
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -399,7 +398,7 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf
...
@@ -399,7 +398,7 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf
pUidList
->
tableUidList
=
taosMemoryMalloc
(
numOfTables
*
sizeof
(
uint64_t
));
pUidList
->
tableUidList
=
taosMemoryMalloc
(
numOfTables
*
sizeof
(
uint64_t
));
if
(
pUidList
->
tableUidList
==
NULL
)
{
if
(
pUidList
->
tableUidList
==
NULL
)
{
t
aos
HashCleanup
(
pTableMap
);
t
Simple
HashCleanup
(
pTableMap
);
return
NULL
;
return
NULL
;
}
}
...
@@ -421,7 +420,7 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf
...
@@ -421,7 +420,7 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf
pScanInfo
->
lastKeyInStt
=
ekey
;
pScanInfo
->
lastKeyInStt
=
ekey
;
}
}
t
aos
HashPut
(
pTableMap
,
&
pScanInfo
->
uid
,
sizeof
(
uint64_t
),
&
pScanInfo
,
POINTER_BYTES
);
t
Simple
HashPut
(
pTableMap
,
&
pScanInfo
->
uid
,
sizeof
(
uint64_t
),
&
pScanInfo
,
POINTER_BYTES
);
tsdbTrace
(
"%p check table uid:%"
PRId64
" from lastKey:%"
PRId64
" %s"
,
pTsdbReader
,
pScanInfo
->
uid
,
tsdbTrace
(
"%p check table uid:%"
PRId64
" from lastKey:%"
PRId64
" %s"
,
pTsdbReader
,
pScanInfo
->
uid
,
pScanInfo
->
lastKey
,
pTsdbReader
->
idStr
);
pScanInfo
->
lastKey
,
pTsdbReader
->
idStr
);
}
}
...
@@ -436,9 +435,11 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf
...
@@ -436,9 +435,11 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf
return
pTableMap
;
return
pTableMap
;
}
}
static
void
resetAllDataBlockScanInfo
(
SHashObj
*
pTableMap
,
int64_t
ts
,
int32_t
step
)
{
static
void
resetAllDataBlockScanInfo
(
SSHashObj
*
pTableMap
,
int64_t
ts
,
int32_t
step
)
{
STableBlockScanInfo
**
p
=
NULL
;
void
*
p
=
NULL
;
while
((
p
=
taosHashIterate
(
pTableMap
,
p
))
!=
NULL
)
{
int32_t
iter
=
0
;
while
((
p
=
tSimpleHashIterate
(
pTableMap
,
p
,
&
iter
))
!=
NULL
)
{
STableBlockScanInfo
*
pInfo
=
*
(
STableBlockScanInfo
**
)
p
;
STableBlockScanInfo
*
pInfo
=
*
(
STableBlockScanInfo
**
)
p
;
pInfo
->
iterInit
=
false
;
pInfo
->
iterInit
=
false
;
...
@@ -478,13 +479,15 @@ static void clearBlockScanInfo(STableBlockScanInfo* p) {
...
@@ -478,13 +479,15 @@ static void clearBlockScanInfo(STableBlockScanInfo* p) {
tMapDataClear
(
&
p
->
mapData
);
tMapDataClear
(
&
p
->
mapData
);
}
}
static
void
destroyAllBlockScanInfo
(
SHashObj
*
pTableMap
)
{
static
void
destroyAllBlockScanInfo
(
S
S
HashObj
*
pTableMap
)
{
void
*
p
=
NULL
;
void
*
p
=
NULL
;
while
((
p
=
taosHashIterate
(
pTableMap
,
p
))
!=
NULL
)
{
int32_t
iter
=
0
;
while
((
p
=
tSimpleHashIterate
(
pTableMap
,
p
,
&
iter
))
!=
NULL
)
{
clearBlockScanInfo
(
*
(
STableBlockScanInfo
**
)
p
);
clearBlockScanInfo
(
*
(
STableBlockScanInfo
**
)
p
);
}
}
t
aos
HashCleanup
(
pTableMap
);
t
Simple
HashCleanup
(
pTableMap
);
}
}
static
bool
isEmptyQueryTimeWindow
(
STimeWindow
*
pWindow
)
{
return
pWindow
->
skey
>
pWindow
->
ekey
;
}
static
bool
isEmptyQueryTimeWindow
(
STimeWindow
*
pWindow
)
{
return
pWindow
->
skey
>
pWindow
->
ekey
;
}
...
@@ -800,7 +803,7 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFReader* pFileReader,
...
@@ -800,7 +803,7 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFReader* pFileReader,
goto
_end
;
goto
_end
;
}
}
int32_t
numOfTables
=
t
aos
HashGetSize
(
pReader
->
status
.
pTableMap
);
int32_t
numOfTables
=
t
Simple
HashGetSize
(
pReader
->
status
.
pTableMap
);
SArray
*
aBlockIdx
=
(
SArray
*
)
taosLRUCacheValue
(
pFileReader
->
pTsdb
->
biCache
,
handle
);
SArray
*
aBlockIdx
=
(
SArray
*
)
taosLRUCacheValue
(
pFileReader
->
pTsdb
->
biCache
,
handle
);
size_t
num
=
taosArrayGetSize
(
aBlockIdx
);
size_t
num
=
taosArrayGetSize
(
aBlockIdx
);
...
@@ -864,10 +867,12 @@ _end:
...
@@ -864,10 +867,12 @@ _end:
return
code
;
return
code
;
}
}
static
void
cleanupTableScanInfo
(
SHashObj
*
pTableMap
)
{
static
void
cleanupTableScanInfo
(
S
S
HashObj
*
pTableMap
)
{
STableBlockScanInfo
**
px
=
NULL
;
STableBlockScanInfo
**
px
=
NULL
;
int32_t
iter
=
0
;
while
(
1
)
{
while
(
1
)
{
px
=
t
aosHashIterate
(
pTableMap
,
px
);
px
=
t
SimpleHashIterate
(
pTableMap
,
px
,
&
iter
);
if
(
px
==
NULL
)
{
if
(
px
==
NULL
)
{
break
;
break
;
}
}
...
@@ -1439,7 +1444,7 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
...
@@ -1439,7 +1444,7 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
pBlockIter
->
pTableMap
=
pReader
->
status
.
pTableMap
;
pBlockIter
->
pTableMap
=
pReader
->
status
.
pTableMap
;
// access data blocks according to the offset of each block in asc/desc order.
// access data blocks according to the offset of each block in asc/desc order.
int32_t
numOfTables
=
(
int32_t
)
t
aos
HashGetSize
(
pReader
->
status
.
pTableMap
);
int32_t
numOfTables
=
(
int32_t
)
t
Simple
HashGetSize
(
pReader
->
status
.
pTableMap
);
int64_t
st
=
taosGetTimestampUs
();
int64_t
st
=
taosGetTimestampUs
();
int32_t
code
=
initBlockOrderSupporter
(
&
sup
,
numOfTables
);
int32_t
code
=
initBlockOrderSupporter
(
&
sup
,
numOfTables
);
...
@@ -1449,8 +1454,10 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
...
@@ -1449,8 +1454,10 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
int32_t
cnt
=
0
;
int32_t
cnt
=
0
;
void
*
ptr
=
NULL
;
void
*
ptr
=
NULL
;
int32_t
iter
=
0
;
while
(
1
)
{
while
(
1
)
{
ptr
=
t
aosHashIterate
(
pReader
->
status
.
pTableMap
,
pt
r
);
ptr
=
t
SimpleHashIterate
(
pReader
->
status
.
pTableMap
,
ptr
,
&
ite
r
);
if
(
ptr
==
NULL
)
{
if
(
ptr
==
NULL
)
{
break
;
break
;
}
}
...
@@ -2916,7 +2923,7 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) {
...
@@ -2916,7 +2923,7 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) {
pBlockNum
->
numOfBlocks
=
0
;
pBlockNum
->
numOfBlocks
=
0
;
pBlockNum
->
numOfLastFiles
=
0
;
pBlockNum
->
numOfLastFiles
=
0
;
size_t
numOfTables
=
t
aos
HashGetSize
(
pReader
->
status
.
pTableMap
);
size_t
numOfTables
=
t
Simple
HashGetSize
(
pReader
->
status
.
pTableMap
);
SArray
*
pIndexList
=
taosArrayInit
(
numOfTables
,
sizeof
(
SBlockIdx
));
SArray
*
pIndexList
=
taosArrayInit
(
numOfTables
,
sizeof
(
SBlockIdx
));
while
(
1
)
{
while
(
1
)
{
...
@@ -2985,18 +2992,18 @@ static void resetTableListIndex(SReaderStatus* pStatus) {
...
@@ -2985,18 +2992,18 @@ static void resetTableListIndex(SReaderStatus* pStatus) {
pList
->
currentIndex
=
0
;
pList
->
currentIndex
=
0
;
uint64_t
uid
=
pList
->
tableUidList
[
0
];
uint64_t
uid
=
pList
->
tableUidList
[
0
];
pStatus
->
pTableIter
=
t
aos
HashGet
(
pStatus
->
pTableMap
,
&
uid
,
sizeof
(
uid
));
pStatus
->
pTableIter
=
t
Simple
HashGet
(
pStatus
->
pTableMap
,
&
uid
,
sizeof
(
uid
));
}
}
static
bool
moveToNextTable
(
STableUidList
*
pOrderedCheckInfo
,
SReaderStatus
*
pStatus
)
{
static
bool
moveToNextTable
(
STableUidList
*
pOrderedCheckInfo
,
SReaderStatus
*
pStatus
)
{
pOrderedCheckInfo
->
currentIndex
+=
1
;
pOrderedCheckInfo
->
currentIndex
+=
1
;
if
(
pOrderedCheckInfo
->
currentIndex
>=
t
aos
HashGetSize
(
pStatus
->
pTableMap
))
{
if
(
pOrderedCheckInfo
->
currentIndex
>=
t
Simple
HashGetSize
(
pStatus
->
pTableMap
))
{
pStatus
->
pTableIter
=
NULL
;
pStatus
->
pTableIter
=
NULL
;
return
false
;
return
false
;
}
}
uint64_t
uid
=
pOrderedCheckInfo
->
tableUidList
[
pOrderedCheckInfo
->
currentIndex
];
uint64_t
uid
=
pOrderedCheckInfo
->
tableUidList
[
pOrderedCheckInfo
->
currentIndex
];
pStatus
->
pTableIter
=
t
aos
HashGet
(
pStatus
->
pTableMap
,
&
uid
,
sizeof
(
uid
));
pStatus
->
pTableIter
=
t
Simple
HashGet
(
pStatus
->
pTableMap
,
&
uid
,
sizeof
(
uid
));
return
(
pStatus
->
pTableIter
!=
NULL
);
return
(
pStatus
->
pTableIter
!=
NULL
);
}
}
...
@@ -3006,7 +3013,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
...
@@ -3006,7 +3013,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
STableUidList
*
pUidList
=
&
pStatus
->
uidList
;
STableUidList
*
pUidList
=
&
pStatus
->
uidList
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
t
aos
HashGetSize
(
pStatus
->
pTableMap
)
==
0
)
{
if
(
t
Simple
HashGetSize
(
pStatus
->
pTableMap
)
==
0
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -3168,7 +3175,7 @@ static int32_t doSumFileBlockRows(STsdbReader* pReader, SDataFReader* pFileReade
...
@@ -3168,7 +3175,7 @@ static int32_t doSumFileBlockRows(STsdbReader* pReader, SDataFReader* pFileReade
goto
_end
;
goto
_end
;
}
}
int32_t
numOfTables
=
t
aos
HashGetSize
(
pReader
->
status
.
pTableMap
);
int32_t
numOfTables
=
t
Simple
HashGetSize
(
pReader
->
status
.
pTableMap
);
SArray
*
aBlockIdx
=
(
SArray
*
)
taosLRUCacheValue
(
pFileReader
->
pTsdb
->
biCache
,
handle
);
SArray
*
aBlockIdx
=
(
SArray
*
)
taosLRUCacheValue
(
pFileReader
->
pTsdb
->
biCache
,
handle
);
size_t
num
=
taosArrayGetSize
(
aBlockIdx
);
size_t
num
=
taosArrayGetSize
(
aBlockIdx
);
...
@@ -3178,14 +3185,13 @@ static int32_t doSumFileBlockRows(STsdbReader* pReader, SDataFReader* pFileReade
...
@@ -3178,14 +3185,13 @@ static int32_t doSumFileBlockRows(STsdbReader* pReader, SDataFReader* pFileReade
}
}
SBlockIdx
*
pBlockIdx
=
NULL
;
SBlockIdx
*
pBlockIdx
=
NULL
;
int32_t
i
=
0
;
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
pBlockIdx
=
(
SBlockIdx
*
)
taosArrayGet
(
aBlockIdx
,
i
);
pBlockIdx
=
(
SBlockIdx
*
)
taosArrayGet
(
aBlockIdx
,
i
);
if
(
pBlockIdx
->
suid
!=
pReader
->
suid
)
{
if
(
pBlockIdx
->
suid
!=
pReader
->
suid
)
{
continue
;
continue
;
}
}
STableBlockScanInfo
**
p
=
t
aos
HashGet
(
pReader
->
status
.
pTableMap
,
&
pBlockIdx
->
uid
,
sizeof
(
pBlockIdx
->
uid
));
STableBlockScanInfo
**
p
=
t
Simple
HashGet
(
pReader
->
status
.
pTableMap
,
&
pBlockIdx
->
uid
,
sizeof
(
pBlockIdx
->
uid
));
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
continue
;
continue
;
}
}
...
@@ -3231,13 +3237,13 @@ static int32_t doSumSttBlockRows(STsdbReader* pReader) {
...
@@ -3231,13 +3237,13 @@ static int32_t doSumSttBlockRows(STsdbReader* pReader) {
taosArrayClear
(
pBlockLoadInfo
->
aSttBlk
);
taosArrayClear
(
pBlockLoadInfo
->
aSttBlk
);
continue
;
continue
;
}
}
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
j
=
0
;
j
<
size
;
++
j
)
{
SSttBlk
*
p
=
taosArrayGet
(
pBlockLoadInfo
->
aSttBlk
,
i
);
SSttBlk
*
p
=
taosArrayGet
(
pBlockLoadInfo
->
aSttBlk
,
j
);
pReader
->
rowsNum
+=
p
->
nRow
;
pReader
->
rowsNum
+=
p
->
nRow
;
}
}
}
else
{
}
else
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
j
=
0
;
j
<
size
;
++
j
)
{
SSttBlk
*
p
=
taosArrayGet
(
pBlockLoadInfo
->
aSttBlk
,
i
);
SSttBlk
*
p
=
taosArrayGet
(
pBlockLoadInfo
->
aSttBlk
,
j
);
uint64_t
s
=
p
->
suid
;
uint64_t
s
=
p
->
suid
;
if
(
s
<
pReader
->
suid
)
{
if
(
s
<
pReader
->
suid
)
{
continue
;
continue
;
...
@@ -3307,13 +3313,6 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) {
...
@@ -3307,13 +3313,6 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) {
STableUidList
*
pUidList
=
&
pStatus
->
uidList
;
STableUidList
*
pUidList
=
&
pStatus
->
uidList
;
while
(
1
)
{
while
(
1
)
{
// if (pStatus->pTableIter == NULL) {
// pStatus->pTableIter = taosHashIterate(pStatus->pTableMap, NULL);
// if (pStatus->pTableIter == NULL) {
// return TSDB_CODE_SUCCESS;
// }
// }
STableBlockScanInfo
**
pBlockScanInfo
=
pStatus
->
pTableIter
;
STableBlockScanInfo
**
pBlockScanInfo
=
pStatus
->
pTableIter
;
initMemDataIterator
(
*
pBlockScanInfo
,
pReader
);
initMemDataIterator
(
*
pBlockScanInfo
,
pReader
);
...
@@ -3341,7 +3340,7 @@ static void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter)
...
@@ -3341,7 +3340,7 @@ static void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter)
SDataBlk
*
pBlock
=
getCurrentBlock
(
pBlockIter
);
SDataBlk
*
pBlock
=
getCurrentBlock
(
pBlockIter
);
SFileDataBlockInfo
*
pBlockInfo
=
getCurrentBlockInfo
(
pBlockIter
);
SFileDataBlockInfo
*
pBlockInfo
=
getCurrentBlockInfo
(
pBlockIter
);
if
(
pBlockInfo
)
{
if
(
pBlockInfo
)
{
STableBlockScanInfo
*
pScanInfo
=
t
aos
HashGet
(
pBlockIter
->
pTableMap
,
&
pBlockInfo
->
uid
,
sizeof
(
pBlockInfo
->
uid
));
STableBlockScanInfo
*
pScanInfo
=
t
Simple
HashGet
(
pBlockIter
->
pTableMap
,
&
pBlockInfo
->
uid
,
sizeof
(
pBlockInfo
->
uid
));
if
(
pScanInfo
)
{
if
(
pScanInfo
)
{
lastKey
=
pScanInfo
->
lastKey
;
lastKey
=
pScanInfo
->
lastKey
;
}
}
...
@@ -4169,10 +4168,12 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e
...
@@ -4169,10 +4168,12 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e
// TODO refactor: with createDataBlockScanInfo
// TODO refactor: with createDataBlockScanInfo
int32_t
tsdbSetTableList
(
STsdbReader
*
pReader
,
const
void
*
pTableList
,
int32_t
num
)
{
int32_t
tsdbSetTableList
(
STsdbReader
*
pReader
,
const
void
*
pTableList
,
int32_t
num
)
{
int32_t
size
=
t
aos
HashGetSize
(
pReader
->
status
.
pTableMap
);
int32_t
size
=
t
Simple
HashGetSize
(
pReader
->
status
.
pTableMap
);
STableBlockScanInfo
**
p
=
NULL
;
STableBlockScanInfo
**
p
=
NULL
;
while
((
p
=
taosHashIterate
(
pReader
->
status
.
pTableMap
,
p
))
!=
NULL
)
{
int32_t
iter
=
0
;
while
((
p
=
tSimpleHashIterate
(
pReader
->
status
.
pTableMap
,
p
,
&
iter
))
!=
NULL
)
{
clearBlockScanInfo
(
*
p
);
clearBlockScanInfo
(
*
p
);
}
}
...
@@ -4190,7 +4191,7 @@ int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t n
...
@@ -4190,7 +4191,7 @@ int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t n
pReader
->
status
.
uidList
.
tableUidList
=
(
uint64_t
*
)
p1
;
pReader
->
status
.
uidList
.
tableUidList
=
(
uint64_t
*
)
p1
;
}
}
t
aos
HashClear
(
pReader
->
status
.
pTableMap
);
t
Simple
HashClear
(
pReader
->
status
.
pTableMap
);
STableUidList
*
pUidList
=
&
pReader
->
status
.
uidList
;
STableUidList
*
pUidList
=
&
pReader
->
status
.
uidList
;
pUidList
->
currentIndex
=
0
;
pUidList
->
currentIndex
=
0
;
...
@@ -4211,7 +4212,7 @@ int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t n
...
@@ -4211,7 +4212,7 @@ int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t n
pInfo
->
lastKeyInStt
=
ekey
;
pInfo
->
lastKeyInStt
=
ekey
;
}
}
t
aos
HashPut
(
pReader
->
status
.
pTableMap
,
&
pInfo
->
uid
,
sizeof
(
uint64_t
),
&
pInfo
,
POINTER_BYTES
);
t
Simple
HashPut
(
pReader
->
status
.
pTableMap
,
&
pInfo
->
uid
,
sizeof
(
uint64_t
),
&
pInfo
,
POINTER_BYTES
);
}
}
return
TDB_CODE_SUCCESS
;
return
TDB_CODE_SUCCESS
;
...
@@ -4428,7 +4429,7 @@ void tsdbReaderClose(STsdbReader* pReader) {
...
@@ -4428,7 +4429,7 @@ void tsdbReaderClose(STsdbReader* pReader) {
tBlockDataDestroy
(
&
pReader
->
status
.
fileBlockData
);
tBlockDataDestroy
(
&
pReader
->
status
.
fileBlockData
);
cleanupDataBlockIterator
(
&
pReader
->
status
.
blockIter
);
cleanupDataBlockIterator
(
&
pReader
->
status
.
blockIter
);
size_t
numOfTables
=
t
aos
HashGetSize
(
pReader
->
status
.
pTableMap
);
size_t
numOfTables
=
t
Simple
HashGetSize
(
pReader
->
status
.
pTableMap
);
if
(
pReader
->
status
.
pTableMap
!=
NULL
)
{
if
(
pReader
->
status
.
pTableMap
!=
NULL
)
{
destroyAllBlockScanInfo
(
pReader
->
status
.
pTableMap
);
destroyAllBlockScanInfo
(
pReader
->
status
.
pTableMap
);
clearBlockScanInfoBuf
(
&
pReader
->
blockInfoBuf
);
clearBlockScanInfoBuf
(
&
pReader
->
blockInfoBuf
);
...
@@ -4510,8 +4511,9 @@ int32_t tsdbReaderSuspend(STsdbReader* pReader) {
...
@@ -4510,8 +4511,9 @@ int32_t tsdbReaderSuspend(STsdbReader* pReader) {
// resetDataBlockScanInfo excluding lastKey
// resetDataBlockScanInfo excluding lastKey
STableBlockScanInfo
**
p
=
NULL
;
STableBlockScanInfo
**
p
=
NULL
;
int32_t
iter
=
0
;
while
((
p
=
t
aosHashIterate
(
pStatus
->
pTableMap
,
p
))
!=
NULL
)
{
while
((
p
=
t
SimpleHashIterate
(
pStatus
->
pTableMap
,
p
,
&
iter
))
!=
NULL
)
{
STableBlockScanInfo
*
pInfo
=
*
(
STableBlockScanInfo
**
)
p
;
STableBlockScanInfo
*
pInfo
=
*
(
STableBlockScanInfo
**
)
p
;
pInfo
->
iterInit
=
false
;
pInfo
->
iterInit
=
false
;
...
@@ -4532,8 +4534,9 @@ int32_t tsdbReaderSuspend(STsdbReader* pReader) {
...
@@ -4532,8 +4534,9 @@ int32_t tsdbReaderSuspend(STsdbReader* pReader) {
}
else
{
}
else
{
// resetDataBlockScanInfo excluding lastKey
// resetDataBlockScanInfo excluding lastKey
STableBlockScanInfo
**
p
=
NULL
;
STableBlockScanInfo
**
p
=
NULL
;
int32_t
iter
=
0
;
while
((
p
=
t
aosHashIterate
(
pStatus
->
pTableMap
,
p
))
!=
NULL
)
{
while
((
p
=
t
SimpleHashIterate
(
pStatus
->
pTableMap
,
p
,
&
iter
))
!=
NULL
)
{
STableBlockScanInfo
*
pInfo
=
*
(
STableBlockScanInfo
**
)
p
;
STableBlockScanInfo
*
pInfo
=
*
(
STableBlockScanInfo
**
)
p
;
pInfo
->
iterInit
=
false
;
pInfo
->
iterInit
=
false
;
...
@@ -4622,7 +4625,7 @@ int32_t tsdbReaderResume(STsdbReader* pReader) {
...
@@ -4622,7 +4625,7 @@ int32_t tsdbReaderResume(STsdbReader* pReader) {
// restore reader's state
// restore reader's state
// task snapshot
// task snapshot
int32_t
numOfTables
=
t
aos
HashGetSize
(
pReader
->
status
.
pTableMap
);
int32_t
numOfTables
=
t
Simple
HashGetSize
(
pReader
->
status
.
pTableMap
);
if
(
numOfTables
>
0
)
{
if
(
numOfTables
>
0
)
{
qTrace
(
"tsdb/reader: %p, take snapshot"
,
pReader
);
qTrace
(
"tsdb/reader: %p, take snapshot"
,
pReader
);
code
=
tsdbTakeReadSnap
(
pReader
,
tsdbSetQueryReseek
,
&
pReader
->
pReadSnap
);
code
=
tsdbTakeReadSnap
(
pReader
,
tsdbSetQueryReseek
,
&
pReader
->
pReadSnap
);
...
@@ -4701,7 +4704,7 @@ static int32_t doTsdbNextDataBlock(STsdbReader* pReader, bool* hasNext) {
...
@@ -4701,7 +4704,7 @@ static int32_t doTsdbNextDataBlock(STsdbReader* pReader, bool* hasNext) {
*
hasNext
=
false
;
*
hasNext
=
false
;
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
if
(
t
aos
HashGetSize
(
pStatus
->
pTableMap
)
==
0
)
{
if
(
t
Simple
HashGetSize
(
pStatus
->
pTableMap
)
==
0
)
{
return
code
;
return
code
;
}
}
...
@@ -4954,11 +4957,11 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock,
...
@@ -4954,11 +4957,11 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock,
return
code
;
return
code
;
}
}
STableBlockScanInfo
*
getTableBlockScanInfo
(
SHashObj
*
pTableMap
,
uint64_t
uid
,
const
char
*
id
)
{
STableBlockScanInfo
*
getTableBlockScanInfo
(
S
S
HashObj
*
pTableMap
,
uint64_t
uid
,
const
char
*
id
)
{
STableBlockScanInfo
**
p
=
t
aos
HashGet
(
pTableMap
,
&
uid
,
sizeof
(
uid
));
STableBlockScanInfo
**
p
=
t
Simple
HashGet
(
pTableMap
,
&
uid
,
sizeof
(
uid
));
if
(
p
==
NULL
||
*
p
==
NULL
)
{
if
(
p
==
NULL
||
*
p
==
NULL
)
{
terrno
=
TSDB_CODE_INVALID_PARA
;
terrno
=
TSDB_CODE_INVALID_PARA
;
int32_t
size
=
t
aos
HashGetSize
(
pTableMap
);
int32_t
size
=
t
Simple
HashGetSize
(
pTableMap
);
tsdbError
(
"failed to locate the uid:%"
PRIu64
" in query table uid list, total tables:%d, %s"
,
uid
,
size
,
id
);
tsdbError
(
"failed to locate the uid:%"
PRIu64
" in query table uid list, total tables:%d, %s"
,
uid
,
size
,
id
);
return
NULL
;
return
NULL
;
}
}
...
@@ -5044,7 +5047,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
...
@@ -5044,7 +5047,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
pReader
->
suppInfo
.
tsColAgg
.
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
pReader
->
suppInfo
.
tsColAgg
.
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
tsdbDataFReaderClose
(
&
pReader
->
pFileReader
);
tsdbDataFReaderClose
(
&
pReader
->
pFileReader
);
int32_t
numOfTables
=
t
aos
HashGetSize
(
pStatus
->
pTableMap
);
int32_t
numOfTables
=
t
Simple
HashGetSize
(
pStatus
->
pTableMap
);
initFilesetIterator
(
&
pStatus
->
fileIter
,
pReader
->
pReadSnap
->
fs
.
aDFileSet
,
pReader
);
initFilesetIterator
(
&
pStatus
->
fileIter
,
pReader
->
pReadSnap
->
fs
.
aDFileSet
,
pReader
);
resetDataBlockIterator
(
pBlockIter
,
pReader
->
order
);
resetDataBlockIterator
(
pBlockIter
,
pReader
->
order
);
...
@@ -5115,7 +5118,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
...
@@ -5115,7 +5118,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
pTableBlockInfo
->
numOfFiles
+=
1
;
pTableBlockInfo
->
numOfFiles
+=
1
;
int32_t
numOfTables
=
(
int32_t
)
t
aos
HashGetSize
(
pStatus
->
pTableMap
);
int32_t
numOfTables
=
(
int32_t
)
t
Simple
HashGetSize
(
pStatus
->
pTableMap
);
int
defaultRows
=
4096
;
int
defaultRows
=
4096
;
SDataBlockIter
*
pBlockIter
=
&
pStatus
->
blockIter
;
SDataBlockIter
*
pBlockIter
=
&
pStatus
->
blockIter
;
...
@@ -5179,7 +5182,8 @@ int64_t tsdbGetNumOfRowsInMemTable(STsdbReader* pReader) {
...
@@ -5179,7 +5182,8 @@ int64_t tsdbGetNumOfRowsInMemTable(STsdbReader* pReader) {
tsdbReaderResume
(
pReader
);
tsdbReaderResume
(
pReader
);
}
}
pStatus
->
pTableIter
=
taosHashIterate
(
pStatus
->
pTableMap
,
NULL
);
int32_t
iter
=
0
;
pStatus
->
pTableIter
=
tSimpleHashIterate
(
pStatus
->
pTableMap
,
NULL
,
&
iter
);
while
(
pStatus
->
pTableIter
!=
NULL
)
{
while
(
pStatus
->
pTableIter
!=
NULL
)
{
STableBlockScanInfo
*
pBlockScanInfo
=
*
(
STableBlockScanInfo
**
)
pStatus
->
pTableIter
;
STableBlockScanInfo
*
pBlockScanInfo
=
*
(
STableBlockScanInfo
**
)
pStatus
->
pTableIter
;
...
@@ -5201,7 +5205,7 @@ int64_t tsdbGetNumOfRowsInMemTable(STsdbReader* pReader) {
...
@@ -5201,7 +5205,7 @@ int64_t tsdbGetNumOfRowsInMemTable(STsdbReader* pReader) {
}
}
// current table is exhausted, let's try the next table
// current table is exhausted, let's try the next table
pStatus
->
pTableIter
=
t
aosHashIterate
(
pStatus
->
pTableMap
,
pStatus
->
pTableI
ter
);
pStatus
->
pTableIter
=
t
SimpleHashIterate
(
pStatus
->
pTableMap
,
pStatus
->
pTableIter
,
&
i
ter
);
}
}
tsdbReleaseReader
(
pReader
);
tsdbReleaseReader
(
pReader
);
...
...
source/util/src/tsimplehash.c
浏览文件 @
7360a6b6
...
@@ -361,10 +361,6 @@ int32_t tSimpleHashIterateRemove(SSHashObj *pHashObj, const void *key, size_t ke
...
@@ -361,10 +361,6 @@ int32_t tSimpleHashIterateRemove(SSHashObj *pHashObj, const void *key, size_t ke
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
destroyItems
(
void
*
pItem
)
{
taosMemoryFree
(
*
(
void
**
)
pItem
);
}
void
tSimpleHashClear
(
SSHashObj
*
pHashObj
)
{
void
tSimpleHashClear
(
SSHashObj
*
pHashObj
)
{
if
(
!
pHashObj
||
taosHashTableEmpty
(
pHashObj
))
{
if
(
!
pHashObj
||
taosHashTableEmpty
(
pHashObj
))
{
return
;
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录