Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5ea611f2
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
5ea611f2
编写于
9月 22, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1194
上级
724dbe86
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
17 deletion
+35
-17
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+0
-7
src/util/inc/tskiplist.h
src/util/inc/tskiplist.h
+2
-0
src/util/src/tskiplist.c
src/util/src/tskiplist.c
+33
-10
未找到文件。
src/tsdb/src/tsdbMemTable.c
浏览文件 @
5ea611f2
...
...
@@ -40,13 +40,6 @@ int tsdbInsertRowToMem(STsdbRepo *pRepo, SDataRow row, STable *pTable) {
TSKEY
key
=
dataRowKey
(
row
);
SMemTable
*
pMemTable
=
pRepo
->
mem
;
STableData
*
pTableData
=
NULL
;
// SSkipList * pSList = NULL;
// if (pMemTable != NULL && TABLE_TID(pTable) < pMemTable->maxTables && pMemTable->tData[TABLE_TID(pTable)] != NULL &&
// pMemTable->tData[TABLE_TID(pTable)]->uid == TABLE_UID(pTable)) {
// pTableData = pMemTable->tData[TABLE_TID(pTable)];
// pSList = pTableData->pData;
// }
void
*
pRow
=
tsdbAllocBytes
(
pRepo
,
dataRowLen
(
row
));
if
(
pRow
==
NULL
)
{
...
...
src/util/inc/tskiplist.h
浏览文件 @
5ea611f2
...
...
@@ -145,6 +145,8 @@ SSkipListNode * tSkipListIterGet(SSkipListIterator *iter);
void
*
tSkipListDestroyIter
(
SSkipListIterator
*
iter
);
uint32_t
tSkipListRemove
(
SSkipList
*
pSkipList
,
SSkipListKey
key
);
void
tSkipListRemoveNode
(
SSkipList
*
pSkipList
,
SSkipListNode
*
pNode
);
SSkipListKey
tSkipListGetMinKey
(
SSkipList
*
pSkipList
);
SSkipListKey
tSkipListGetMaxKey
(
SSkipList
*
pSkipList
);
#ifdef __cplusplus
}
...
...
src/util/src/tskiplist.c
浏览文件 @
5ea611f2
...
...
@@ -19,8 +19,6 @@
#include "tulog.h"
#include "tutil.h"
#define DO_MEMSET_PTR_AREA(n) memset((n)->forwards, 0, ((n)->level * 2))
static
int
initForwardBackwardPtr
(
SSkipList
*
pSkipList
);
static
SSkipListNode
*
getPriorNode
(
SSkipList
*
pSkipList
,
const
char
*
val
,
int32_t
order
);
static
void
tSkipListRemoveNodeImpl
(
SSkipList
*
pSkipList
,
SSkipListNode
*
pNode
);
...
...
@@ -117,7 +115,10 @@ SSkipListNode *tSkipListPut(SSkipList *pSkipList, void *pData) {
if
(
dupMode
==
SL_UPDATE_DUP_KEY
)
{
pNode
=
SL_NODE_GET_FORWARD_POINTER
(
forward
[
0
],
0
);
atomic_store_ptr
(
&
(
pNode
->
pData
),
pData
);
pNode
->
flags
&=
(
~
(
SL_NODE_DELETED_FLAG
));
if
(
SL_IS_NODE_DELETED
(
pNode
))
{
pNode
->
flags
&=
(
~
(
SL_NODE_DELETED_FLAG
));
pSkipList
->
size
++
;
}
}
}
else
{
pNode
=
tSkipListNewNode
(
getSkipListRandLevel
(
pSkipList
));
...
...
@@ -136,6 +137,8 @@ SSkipListNode *tSkipListPut(SSkipList *pSkipList, void *pData) {
uint32_t
tSkipListRemove
(
SSkipList
*
pSkipList
,
SSkipListKey
key
)
{
uint32_t
count
=
0
;
if
(
SL_DUP_MODE
(
pSkipList
)
==
SL_DISCARD_DUP_KEY
)
return
0
;
tSkipListWLock
(
pSkipList
);
SSkipListNode
*
pNode
=
getPriorNode
(
pSkipList
,
key
,
TSDB_ORDER_ASC
);
...
...
@@ -199,8 +202,8 @@ SSkipListIterator *tSkipListCreateIter(SSkipList *pSkipList) {
}
SSkipListIterator
*
tSkipListCreateIterFromVal
(
SSkipList
*
pSkipList
,
const
char
*
val
,
int32_t
type
,
int32_t
order
)
{
assert
(
order
==
TSDB_ORDER_ASC
||
order
==
TSDB_ORDER_DESC
);
assert
(
pSkipList
!=
NULL
);
ASSERT
(
order
==
TSDB_ORDER_ASC
||
order
==
TSDB_ORDER_DESC
);
ASSERT
(
pSkipList
!=
NULL
);
SSkipListIterator
*
iter
=
doCreateSkipListIterator
(
pSkipList
,
order
);
if
(
val
==
NULL
)
{
...
...
@@ -274,7 +277,7 @@ void tSkipListPrint(SSkipList *pSkipList, int16_t nlevel) {
while
(
p
!=
pSkipList
->
pTail
)
{
char
*
key
=
SL_GET_NODE_KEY
(
pSkipList
,
p
);
if
(
prev
!=
NULL
)
{
assert
(
pSkipList
->
comparFn
(
prev
,
key
)
<
0
);
ASSERT
(
pSkipList
->
comparFn
(
prev
,
key
)
<
0
);
}
switch
(
pSkipList
->
type
)
{
...
...
@@ -302,9 +305,29 @@ void tSkipListPrint(SSkipList *pSkipList, int16_t nlevel) {
}
}
static
void
tSkipListDoInsert
(
SSkipList
*
pSkipList
,
SSkipListNode
**
forward
,
SSkipListNode
*
pNode
)
{
DO_MEMSET_PTR_AREA
(
pNode
);
SSkipListKey
tSkipListGetMinKey
(
SSkipList
*
pSkipList
)
{
if
(
pSkipList
==
NULL
||
SL_SIZE
(
pSkipList
)
==
0
)
return
NULL
;
SSkipListNode
*
pNode
=
pSkipList
->
pHead
;
while
((
pNode
=
SL_NODE_GET_FORWARD_POINTER
(
pNode
,
0
))
!=
pSkipList
->
pTail
)
{
if
(
!
SL_IS_NODE_DELETED
(
pNode
))
return
pSkipList
->
keyFn
(
pNode
->
pData
);
}
return
NULL
;
}
SSkipListKey
tSkipListGetMaxKey
(
SSkipList
*
pSkipList
)
{
if
(
pSkipList
==
NULL
||
SL_SIZE
(
pSkipList
)
==
0
)
return
NULL
;
SSkipListNode
*
pNode
=
pSkipList
->
pTail
;
while
((
pNode
=
SL_NODE_GET_BACKWARD_POINTER
(
pNode
,
0
))
!=
pSkipList
->
pHead
)
{
if
(
!
SL_IS_NODE_DELETED
(
pNode
))
return
pSkipList
->
keyFn
(
pNode
->
pData
);
}
return
NULL
;
}
static
void
tSkipListDoInsert
(
SSkipList
*
pSkipList
,
SSkipListNode
**
forward
,
SSkipListNode
*
pNode
)
{
for
(
int32_t
i
=
0
;
i
<
pNode
->
level
;
++
i
)
{
if
(
i
>=
pSkipList
->
level
)
{
SL_NODE_GET_FORWARD_POINTER
(
pNode
,
i
)
=
pSkipList
->
pTail
;
...
...
@@ -365,7 +388,7 @@ static FORCE_INLINE int tSkipListUnlock(SSkipList *pSkipList) {
}
static
bool
tSkipListGetPosToPut
(
SSkipList
*
pSkipList
,
SSkipListNode
**
forward
,
void
*
pData
)
{
int
compare
=
1
;
int
compare
=
0
;
bool
hasDupKey
=
false
;
char
*
pDataKey
=
pSkipList
->
keyFn
(
pData
);
...
...
@@ -497,7 +520,7 @@ static FORCE_INLINE int32_t getSkipListRandLevel(SSkipList *pSkipList) {
}
}
assert
(
level
<=
pSkipList
->
maxLevel
);
ASSERT
(
level
<=
pSkipList
->
maxLevel
);
return
level
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录