Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b8753573
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b8753573
编写于
8月 24, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor:do some internal refactor.
上级
a23f5f59
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
6 deletion
+14
-6
source/libs/executor/src/tlinearhash.c
source/libs/executor/src/tlinearhash.c
+12
-6
source/util/src/tpagedbuf.c
source/util/src/tpagedbuf.c
+2
-0
未找到文件。
source/libs/executor/src/tlinearhash.c
浏览文件 @
b8753573
...
@@ -26,7 +26,7 @@ typedef struct SLHashBucket {
...
@@ -26,7 +26,7 @@ typedef struct SLHashBucket {
int32_t
size
;
// the number of element in this entry
int32_t
size
;
// the number of element in this entry
}
SLHashBucket
;
}
SLHashBucket
;
typedef
struct
SLHashObj
{
struct
SLHashObj
{
SDiskbasedBuf
*
pBuf
;
SDiskbasedBuf
*
pBuf
;
_hash_fn_t
hashFn
;
_hash_fn_t
hashFn
;
SLHashBucket
**
pBucket
;
// entry list
SLHashBucket
**
pBucket
;
// entry list
...
@@ -35,7 +35,7 @@ typedef struct SLHashObj {
...
@@ -35,7 +35,7 @@ typedef struct SLHashObj {
int32_t
bits
;
// the number of bits used in hash
int32_t
bits
;
// the number of bits used in hash
int32_t
numOfBuckets
;
// the number of buckets
int32_t
numOfBuckets
;
// the number of buckets
int64_t
size
;
// the number of total items
int64_t
size
;
// the number of total items
}
SLHashObj
;
};
/**
/**
* the data struct for each hash node
* the data struct for each hash node
...
@@ -99,7 +99,7 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t
...
@@ -99,7 +99,7 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t
int32_t
newPageId
=
-
1
;
int32_t
newPageId
=
-
1
;
SFilePage
*
pNewPage
=
getNewBufPage
(
pHashObj
->
pBuf
,
0
,
&
newPageId
);
SFilePage
*
pNewPage
=
getNewBufPage
(
pHashObj
->
pBuf
,
0
,
&
newPageId
);
if
(
pNewPage
==
NULL
)
{
if
(
pNewPage
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
terrno
;
}
}
taosArrayPush
(
pBucket
->
pPageIdList
,
&
newPageId
);
taosArrayPush
(
pBucket
->
pPageIdList
,
&
newPageId
);
...
@@ -138,7 +138,6 @@ static void doRemoveFromBucket(SFilePage* pPage, SLHashNode* pNode, SLHashBucket
...
@@ -138,7 +138,6 @@ static void doRemoveFromBucket(SFilePage* pPage, SLHashNode* pNode, SLHashBucket
}
}
setBufPageDirty
(
pPage
,
true
);
setBufPageDirty
(
pPage
,
true
);
pBucket
->
size
-=
1
;
pBucket
->
size
-=
1
;
}
}
...
@@ -229,6 +228,10 @@ static int32_t doAddNewBucket(SLHashObj* pHashObj) {
...
@@ -229,6 +228,10 @@ static int32_t doAddNewBucket(SLHashObj* pHashObj) {
int32_t
pageId
=
-
1
;
int32_t
pageId
=
-
1
;
SFilePage
*
p
=
getNewBufPage
(
pHashObj
->
pBuf
,
0
,
&
pageId
);
SFilePage
*
p
=
getNewBufPage
(
pHashObj
->
pBuf
,
0
,
&
pageId
);
if
(
p
==
NULL
)
{
return
terrno
;
}
p
->
num
=
sizeof
(
SFilePage
);
p
->
num
=
sizeof
(
SFilePage
);
setBufPageDirty
(
p
,
true
);
setBufPageDirty
(
p
,
true
);
...
@@ -252,7 +255,8 @@ SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_
...
@@ -252,7 +255,8 @@ SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_
printf
(
"tHash Init failed since %s"
,
terrstr
(
terrno
));
printf
(
"tHash Init failed since %s"
,
terrstr
(
terrno
));
return
NULL
;
return
NULL
;
}
}
int32_t
code
=
createDiskbasedBuf
(
&
pHashObj
->
pBuf
,
pageSize
,
inMemPages
*
pageSize
,
0
,
tsTempDir
);
int32_t
code
=
createDiskbasedBuf
(
&
pHashObj
->
pBuf
,
pageSize
,
inMemPages
*
pageSize
,
""
,
tsTempDir
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
terrno
=
code
;
terrno
=
code
;
return
NULL
;
return
NULL
;
...
@@ -389,7 +393,9 @@ char* tHashGet(SLHashObj* pHashObj, const void *key, size_t keyLen) {
...
@@ -389,7 +393,9 @@ char* tHashGet(SLHashObj* pHashObj, const void *key, size_t keyLen) {
}
}
SLHashBucket
*
pBucket
=
pHashObj
->
pBucket
[
bucketId
];
SLHashBucket
*
pBucket
=
pHashObj
->
pBucket
[
bucketId
];
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pBucket
->
pPageIdList
);
++
i
)
{
int32_t
num
=
taosArrayGetSize
(
pBucket
->
pPageIdList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
int32_t
pageId
=
*
(
int32_t
*
)
taosArrayGet
(
pBucket
->
pPageIdList
,
i
);
int32_t
pageId
=
*
(
int32_t
*
)
taosArrayGet
(
pBucket
->
pPageIdList
,
i
);
SFilePage
*
p
=
getBufPage
(
pHashObj
->
pBuf
,
pageId
);
SFilePage
*
p
=
getBufPage
(
pHashObj
->
pBuf
,
pageId
);
...
...
source/util/src/tpagedbuf.c
浏览文件 @
b8753573
...
@@ -309,6 +309,7 @@ static SListNode* getEldestUnrefedPage(SDiskbasedBuf* pBuf) {
...
@@ -309,6 +309,7 @@ static SListNode* getEldestUnrefedPage(SDiskbasedBuf* pBuf) {
static
char
*
evacOneDataPage
(
SDiskbasedBuf
*
pBuf
)
{
static
char
*
evacOneDataPage
(
SDiskbasedBuf
*
pBuf
)
{
char
*
bufPage
=
NULL
;
char
*
bufPage
=
NULL
;
SListNode
*
pn
=
getEldestUnrefedPage
(
pBuf
);
SListNode
*
pn
=
getEldestUnrefedPage
(
pBuf
);
terrno
=
0
;
// all pages are referenced by user, try to allocate new space
// all pages are referenced by user, try to allocate new space
if
(
pn
==
NULL
)
{
if
(
pn
==
NULL
)
{
...
@@ -332,6 +333,7 @@ static char* evacOneDataPage(SDiskbasedBuf* pBuf) {
...
@@ -332,6 +333,7 @@ static char* evacOneDataPage(SDiskbasedBuf* pBuf) {
bufPage
=
flushPageToDisk
(
pBuf
,
d
);
bufPage
=
flushPageToDisk
(
pBuf
,
d
);
}
}
ASSERT
((
bufPage
!=
NULL
)
||
terrno
!=
TSDB_CODE_SUCCESS
);
return
bufPage
;
return
bufPage
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录