Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8d6e6d2f
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1181
Star
22014
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,发现更多精彩内容 >>
提交
8d6e6d2f
编写于
2月 08, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
c398f9d2
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
120 addition
and
55 deletion
+120
-55
include/util/trbtree.h
include/util/trbtree.h
+3
-0
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+2
-0
source/dnode/vnode/src/tsdb/tsdbCompact.c
source/dnode/vnode/src/tsdb/tsdbCompact.c
+48
-24
source/dnode/vnode/src/tsdb/tsdbDataIter.c
source/dnode/vnode/src/tsdb/tsdbDataIter.c
+45
-2
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+2
-29
source/util/src/trbtree.c
source/util/src/trbtree.c
+20
-0
未找到文件。
include/util/trbtree.h
浏览文件 @
8d6e6d2f
...
@@ -33,9 +33,12 @@ typedef int32_t (*tRBTreeCmprFn)(const SRBTreeNode *, const SRBTreeNode *);
...
@@ -33,9 +33,12 @@ typedef int32_t (*tRBTreeCmprFn)(const SRBTreeNode *, const SRBTreeNode *);
#define tRBTreeMax(T) ((T)->max == ((T)->NIL) ? NULL : (T)->max)
#define tRBTreeMax(T) ((T)->max == ((T)->NIL) ? NULL : (T)->max)
void
tRBTreeCreate
(
SRBTree
*
pTree
,
tRBTreeCmprFn
cmprFn
);
void
tRBTreeCreate
(
SRBTree
*
pTree
,
tRBTreeCmprFn
cmprFn
);
void
tRBTreeClear
(
SRBTree
*
pTree
);
SRBTreeNode
*
tRBTreePut
(
SRBTree
*
pTree
,
SRBTreeNode
*
z
);
SRBTreeNode
*
tRBTreePut
(
SRBTree
*
pTree
,
SRBTreeNode
*
z
);
void
tRBTreeDrop
(
SRBTree
*
pTree
,
SRBTreeNode
*
z
);
void
tRBTreeDrop
(
SRBTree
*
pTree
,
SRBTreeNode
*
z
);
SRBTreeNode
*
tRBTreeDropByKey
(
SRBTree
*
pTree
,
void
*
pKey
);
SRBTreeNode
*
tRBTreeDropByKey
(
SRBTree
*
pTree
,
void
*
pKey
);
SRBTreeNode
*
tRBTreeDropMin
(
SRBTree
*
pTree
);
SRBTreeNode
*
tRBTreeDropMax
(
SRBTree
*
pTree
);
SRBTreeNode
*
tRBTreeGet
(
SRBTree
*
pTree
,
const
SRBTreeNode
*
pKeyNode
);
SRBTreeNode
*
tRBTreeGet
(
SRBTree
*
pTree
,
const
SRBTreeNode
*
pKeyNode
);
// SRBTreeIter =============================================
// SRBTreeIter =============================================
...
...
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
8d6e6d2f
...
@@ -320,6 +320,7 @@ int32_t tGnrtDiskData(SDiskDataBuilder *pBuilder, const SDiskData **ppDiskData,
...
@@ -320,6 +320,7 @@ int32_t tGnrtDiskData(SDiskDataBuilder *pBuilder, const SDiskData **ppDiskData,
#define TSDB_TOMB_FILE_DATA_ITER 3
#define TSDB_TOMB_FILE_DATA_ITER 3
#define TSDB_FILTER_FLAG_BY_VERSION 0x1
#define TSDB_FILTER_FLAG_BY_VERSION 0x1
#define TSDB_FILTER_FLAG_BY_TABLEID 0x2
#define TSDB_RBTN_TO_DATA_ITER(pNode) ((STsdbDataIter2 *)(((char *)pNode) - offsetof(STsdbDataIter2, rbtn)))
#define TSDB_RBTN_TO_DATA_ITER(pNode) ((STsdbDataIter2 *)(((char *)pNode) - offsetof(STsdbDataIter2, rbtn)))
/* open */
/* open */
...
@@ -906,6 +907,7 @@ struct STsdbFilterInfo {
...
@@ -906,6 +907,7 @@ struct STsdbFilterInfo {
int32_t
flag
;
int32_t
flag
;
int64_t
sver
;
int64_t
sver
;
int64_t
ever
;
int64_t
ever
;
TABLEID
tbid
;
};
};
#ifdef __cplusplus
#ifdef __cplusplus
...
...
source/dnode/vnode/src/tsdb/tsdbCompact.c
浏览文件 @
8d6e6d2f
...
@@ -310,43 +310,67 @@ _exit:
...
@@ -310,43 +310,67 @@ _exit:
return
code
;
return
code
;
}
}
static
bool
tsdbCompactTableIsDropped
(
STsdbCompactor
*
pCompactor
)
{
SMetaInfo
info
;
if
(
pCompactor
->
pIter
->
rowInfo
.
uid
==
pCompactor
->
tbid
.
uid
)
return
false
;
if
(
metaGetInfo
(
pCompactor
->
pTsdb
->
pVnode
->
pMeta
,
pCompactor
->
tbid
.
uid
,
&
info
,
NULL
))
{
return
true
;
}
return
false
;
}
static
int32_t
tsdbCompactNextRow
(
STsdbCompactor
*
pCompactor
,
SRowInfo
**
ppRowInfo
)
{
static
int32_t
tsdbCompactNextRow
(
STsdbCompactor
*
pCompactor
,
SRowInfo
**
ppRowInfo
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
int32_t
lino
=
0
;
int32_t
lino
=
0
;
if
(
pCompactor
->
pIter
)
{
for
(;;)
{
code
=
tsdbDataIterNext2
(
pCompactor
->
pIter
,
NULL
/* TODO */
);
if
(
pCompactor
->
pIter
)
{
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
tsdbDataIterNext2
(
pCompactor
->
pIter
,
NULL
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
pCompactor
->
pIter
->
rowInfo
.
suid
==
0
&&
pCompactor
->
pIter
->
rowInfo
.
uid
==
0
)
{
if
(
pCompactor
->
pIter
->
rowInfo
.
suid
==
0
&&
pCompactor
->
pIter
->
rowInfo
.
uid
==
0
)
{
pCompactor
->
pIter
=
NULL
;
pCompactor
->
pIter
=
NULL
;
}
else
{
}
else
{
SRBTreeNode
*
pNode
=
tRBTreeMin
(
&
pCompactor
->
rbt
);
SRBTreeNode
*
pNode
=
tRBTreeMin
(
&
pCompactor
->
rbt
);
if
(
pNode
)
{
if
(
pNode
)
{
int32_t
c
=
tsdbDataIterCmprFn
(
&
pCompactor
->
pIter
->
rbtn
,
pNode
);
int32_t
c
=
tsdbDataIterCmprFn
(
&
pCompactor
->
pIter
->
rbtn
,
pNode
);
if
(
c
>
0
)
{
if
(
c
>
0
)
{
tRBTreePut
(
&
pCompactor
->
rbt
,
&
pCompactor
->
pIter
->
rbtn
);
tRBTreePut
(
&
pCompactor
->
rbt
,
&
pCompactor
->
pIter
->
rbtn
);
pCompactor
->
pIter
=
NULL
;
pCompactor
->
pIter
=
NULL
;
}
else
if
(
c
==
0
)
{
}
else
if
(
c
==
0
)
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
}
}
}
}
}
}
if
(
pCompactor
->
pIter
==
NULL
)
{
if
(
pCompactor
->
pIter
==
NULL
)
{
SRBTreeNode
*
pNode
=
tRBTree
Min
(
&
pCompactor
->
rbt
);
SRBTreeNode
*
pNode
=
tRBTreeDrop
Min
(
&
pCompactor
->
rbt
);
if
(
pNode
)
{
if
(
pNode
)
{
tRBTreeDrop
(
&
pCompactor
->
rbt
,
pNode
);
pCompactor
->
pIter
=
TSDB_RBTN_TO_DATA_ITER
(
pNode
);
pCompactor
->
pIter
=
TSDB_RBTN_TO_DATA_ITER
(
pNode
);
}
}
}
}
if
(
ppRowInfo
)
{
if
(
pCompactor
->
pIter
)
{
if
(
pCompactor
->
pIter
)
{
*
ppRowInfo
=
&
pCompactor
->
pIter
->
rowInfo
;
if
(
tsdbCompactTableIsDropped
(
pCompactor
))
{
TABLEID
tbid
=
{.
suid
=
pCompactor
->
pIter
->
rowInfo
.
suid
,
.
uid
=
pCompactor
->
pIter
->
rowInfo
.
uid
};
tRBTreeClear
(
&
pCompactor
->
rbt
);
for
(
pCompactor
->
pIter
=
pCompactor
->
iterList
;
pCompactor
->
pIter
;
pCompactor
->
pIter
=
pCompactor
->
pIter
->
next
)
{
code
=
tsdbDataIterNext2
(
pCompactor
->
pIter
,
&
(
STsdbFilterInfo
){.
flag
=
TSDB_FILTER_FLAG_BY_TABLEID
,
.
tbid
=
tbid
});
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
pCompactor
->
pIter
->
rowInfo
.
suid
||
pCompactor
->
pIter
->
rowInfo
.
uid
)
{
tRBTreePut
(
&
pCompactor
->
rbt
,
&
pCompactor
->
pIter
->
rbtn
);
}
}
}
else
{
*
ppRowInfo
=
&
pCompactor
->
pIter
->
rowInfo
;
break
;
}
}
else
{
}
else
{
*
ppRowInfo
=
NULL
;
*
ppRowInfo
=
NULL
;
break
;
}
}
}
}
...
@@ -497,7 +521,7 @@ static int32_t tsdbCompactFileSet(STsdbCompactor *pCompactor, SDFileSet *pSet) {
...
@@ -497,7 +521,7 @@ static int32_t tsdbCompactFileSet(STsdbCompactor *pCompactor, SDFileSet *pSet) {
code
=
tsdbCompactFileSetStart
(
pCompactor
,
pSet
);
code
=
tsdbCompactFileSetStart
(
pCompactor
,
pSet
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
// do compact
// do compact
, end with a NULL row
SRowInfo
*
pRowInfo
;
SRowInfo
*
pRowInfo
;
do
{
do
{
code
=
tsdbCompactNextRow
(
pCompactor
,
&
pRowInfo
);
code
=
tsdbCompactNextRow
(
pCompactor
,
&
pRowInfo
);
...
...
source/dnode/vnode/src/tsdb/tsdbDataIter.c
浏览文件 @
8d6e6d2f
...
@@ -202,6 +202,13 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
...
@@ -202,6 +202,13 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
for
(;;)
{
for
(;;)
{
while
(
pIter
->
dIter
.
iRow
<
pIter
->
dIter
.
bData
.
nRow
)
{
while
(
pIter
->
dIter
.
iRow
<
pIter
->
dIter
.
bData
.
nRow
)
{
if
(
pFilterInfo
)
{
if
(
pFilterInfo
)
{
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_TABLEID
)
{
if
(
pFilterInfo
->
tbid
.
uid
==
pIter
->
dIter
.
bData
.
uid
)
{
pIter
->
dIter
.
iRow
=
pIter
->
dIter
.
bData
.
nRow
;
continue
;
}
}
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_VERSION
)
{
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_VERSION
)
{
if
(
pIter
->
dIter
.
bData
.
aVersion
[
pIter
->
dIter
.
iRow
]
<
pFilterInfo
->
sver
||
if
(
pIter
->
dIter
.
bData
.
aVersion
[
pIter
->
dIter
.
iRow
]
<
pFilterInfo
->
sver
||
pIter
->
dIter
.
bData
.
aVersion
[
pIter
->
dIter
.
iRow
]
>
pFilterInfo
->
ever
)
{
pIter
->
dIter
.
bData
.
aVersion
[
pIter
->
dIter
.
iRow
]
>
pFilterInfo
->
ever
)
{
...
@@ -211,8 +218,8 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
...
@@ -211,8 +218,8 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
}
}
}
}
pIter
->
rowInfo
.
suid
=
pIter
->
dIter
.
bData
.
suid
;
ASSERT
(
pIter
->
rowInfo
.
suid
==
pIter
->
dIter
.
bData
.
suid
)
;
pIter
->
rowInfo
.
uid
=
pIter
->
dIter
.
bData
.
uid
;
ASSERT
(
pIter
->
rowInfo
.
uid
=
pIter
->
dIter
.
bData
.
uid
)
;
pIter
->
rowInfo
.
row
=
tsdbRowFromBlockData
(
&
pIter
->
dIter
.
bData
,
pIter
->
dIter
.
iRow
);
pIter
->
rowInfo
.
row
=
tsdbRowFromBlockData
(
&
pIter
->
dIter
.
bData
,
pIter
->
dIter
.
iRow
);
pIter
->
dIter
.
iRow
++
;
pIter
->
dIter
.
iRow
++
;
goto
_exit
;
goto
_exit
;
...
@@ -225,6 +232,13 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
...
@@ -225,6 +232,13 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
// filter
// filter
if
(
pFilterInfo
)
{
if
(
pFilterInfo
)
{
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_TABLEID
)
{
if
(
tTABLEIDCmprFn
(
&
pFilterInfo
->
tbid
,
&
pIter
->
rowInfo
)
==
0
)
{
pIter
->
dIter
.
iDataBlk
=
pIter
->
dIter
.
mDataBlk
.
nItem
;
continue
;
}
}
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_VERSION
)
{
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_VERSION
)
{
if
(
pFilterInfo
->
sver
>
dataBlk
.
maxVer
||
pFilterInfo
->
ever
<
dataBlk
.
minVer
)
{
if
(
pFilterInfo
->
sver
>
dataBlk
.
maxVer
||
pFilterInfo
->
ever
<
dataBlk
.
minVer
)
{
pIter
->
dIter
.
iDataBlk
++
;
pIter
->
dIter
.
iDataBlk
++
;
...
@@ -248,9 +262,22 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
...
@@ -248,9 +262,22 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
if
(
pIter
->
dIter
.
iBlockIdx
<
taosArrayGetSize
(
pIter
->
dIter
.
aBlockIdx
))
{
if
(
pIter
->
dIter
.
iBlockIdx
<
taosArrayGetSize
(
pIter
->
dIter
.
aBlockIdx
))
{
SBlockIdx
*
pBlockIdx
=
taosArrayGet
(
pIter
->
dIter
.
aBlockIdx
,
pIter
->
dIter
.
iBlockIdx
);
SBlockIdx
*
pBlockIdx
=
taosArrayGet
(
pIter
->
dIter
.
aBlockIdx
,
pIter
->
dIter
.
iBlockIdx
);
if
(
pFilterInfo
&&
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_TABLEID
))
{
int32_t
c
=
tTABLEIDCmprFn
(
pBlockIdx
,
&
pFilterInfo
->
tbid
);
if
(
c
==
0
)
{
pIter
->
dIter
.
iBlockIdx
++
;
continue
;
}
else
if
(
c
<
0
)
{
ASSERT
(
0
);
}
}
code
=
tsdbReadDataBlk
(
pIter
->
dIter
.
pReader
,
pBlockIdx
,
&
pIter
->
dIter
.
mDataBlk
);
code
=
tsdbReadDataBlk
(
pIter
->
dIter
.
pReader
,
pBlockIdx
,
&
pIter
->
dIter
.
mDataBlk
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
pIter
->
rowInfo
.
suid
=
pBlockIdx
->
suid
;
pIter
->
rowInfo
.
uid
=
pBlockIdx
->
uid
;
pIter
->
dIter
.
iBlockIdx
++
;
pIter
->
dIter
.
iBlockIdx
++
;
pIter
->
dIter
.
iDataBlk
=
0
;
pIter
->
dIter
.
iDataBlk
=
0
;
...
@@ -277,6 +304,14 @@ static int32_t tsdbSttFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo* p
...
@@ -277,6 +304,14 @@ static int32_t tsdbSttFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo* p
for
(;;)
{
for
(;;)
{
while
(
pIter
->
sIter
.
iRow
<
pIter
->
sIter
.
bData
.
nRow
)
{
while
(
pIter
->
sIter
.
iRow
<
pIter
->
sIter
.
bData
.
nRow
)
{
if
(
pFilterInfo
)
{
if
(
pFilterInfo
)
{
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_TABLEID
)
{
int64_t
uid
=
pIter
->
sIter
.
bData
.
uid
?
pIter
->
sIter
.
bData
.
uid
:
pIter
->
sIter
.
bData
.
aUid
[
pIter
->
sIter
.
iRow
];
if
(
pFilterInfo
->
tbid
.
uid
==
uid
)
{
pIter
->
sIter
.
iRow
++
;
continue
;
}
}
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_VERSION
)
{
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_VERSION
)
{
if
(
pFilterInfo
->
sver
>
pIter
->
sIter
.
bData
.
aVersion
[
pIter
->
sIter
.
iRow
]
||
if
(
pFilterInfo
->
sver
>
pIter
->
sIter
.
bData
.
aVersion
[
pIter
->
sIter
.
iRow
]
||
pFilterInfo
->
ever
<
pIter
->
sIter
.
bData
.
aVersion
[
pIter
->
sIter
.
iRow
])
{
pFilterInfo
->
ever
<
pIter
->
sIter
.
bData
.
aVersion
[
pIter
->
sIter
.
iRow
])
{
...
@@ -298,6 +333,14 @@ static int32_t tsdbSttFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo* p
...
@@ -298,6 +333,14 @@ static int32_t tsdbSttFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo* p
SSttBlk
*
pSttBlk
=
taosArrayGet
(
pIter
->
sIter
.
aSttBlk
,
pIter
->
sIter
.
iSttBlk
);
SSttBlk
*
pSttBlk
=
taosArrayGet
(
pIter
->
sIter
.
aSttBlk
,
pIter
->
sIter
.
iSttBlk
);
if
(
pFilterInfo
)
{
if
(
pFilterInfo
)
{
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_TABLEID
)
{
if
(
pSttBlk
->
suid
==
pFilterInfo
->
tbid
.
suid
&&
pSttBlk
->
minUid
==
pFilterInfo
->
tbid
.
uid
&&
pSttBlk
->
maxUid
==
pFilterInfo
->
tbid
.
uid
)
{
pIter
->
sIter
.
iSttBlk
++
;
continue
;
}
}
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_VERSION
)
{
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_VERSION
)
{
if
(
pFilterInfo
->
sver
>
pSttBlk
->
maxVer
||
pFilterInfo
->
ever
<
pSttBlk
->
minVer
)
{
if
(
pFilterInfo
->
sver
>
pSttBlk
->
maxVer
||
pFilterInfo
->
ever
<
pSttBlk
->
minVer
)
{
pIter
->
sIter
.
iSttBlk
++
;
pIter
->
sIter
.
iSttBlk
++
;
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
8d6e6d2f
...
@@ -1250,10 +1250,7 @@ _exit:
...
@@ -1250,10 +1250,7 @@ _exit:
int32_t
tBlockDataTryUpsertRow
(
SBlockData
*
pBlockData
,
TSDBROW
*
pRow
,
int64_t
uid
)
{
int32_t
tBlockDataTryUpsertRow
(
SBlockData
*
pBlockData
,
TSDBROW
*
pRow
,
int64_t
uid
)
{
if
(
pBlockData
->
nRow
==
0
)
{
if
(
pBlockData
->
nRow
==
0
)
{
return
1
;
return
1
;
}
}
else
if
(
pBlockData
->
aTSKEY
[
pBlockData
->
nRow
-
1
]
==
TSDBROW_TS
(
pRow
))
{
int64_t
luid
=
pBlockData
->
uid
?
pBlockData
->
uid
:
pBlockData
->
aUid
[
pBlockData
->
nRow
-
1
];
if
(
luid
==
uid
&&
pBlockData
->
aTSKEY
[
pBlockData
->
nRow
-
1
]
==
TSDBROW_TS
(
pRow
))
{
return
pBlockData
->
nRow
;
return
pBlockData
->
nRow
;
}
else
{
}
else
{
return
pBlockData
->
nRow
+
1
;
return
pBlockData
->
nRow
+
1
;
...
@@ -1261,31 +1258,7 @@ int32_t tBlockDataTryUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, int64_t ui
...
@@ -1261,31 +1258,7 @@ int32_t tBlockDataTryUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, int64_t ui
}
}
int32_t
tBlockDataUpsertRow
(
SBlockData
*
pBlockData
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
,
int64_t
uid
)
{
int32_t
tBlockDataUpsertRow
(
SBlockData
*
pBlockData
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
,
int64_t
uid
)
{
int32_t
code
=
0
;
if
(
pBlockData
->
aTSKEY
[
pBlockData
->
nRow
-
1
]
==
TSDBROW_TS
(
pRow
))
{
ASSERT
(
pBlockData
->
suid
||
pBlockData
->
uid
);
if
(
pBlockData
->
nRow
==
0
)
{
pBlockData
->
uid
=
uid
;
return
tBlockDataAppendRow
(
pBlockData
,
pRow
,
pTSchema
,
uid
);
}
if
(
pBlockData
->
uid
&&
pBlockData
->
uid
!=
uid
)
{
ASSERT
(
pBlockData
->
suid
);
code
=
tRealloc
((
uint8_t
**
)
&
pBlockData
->
aUid
,
sizeof
(
int64_t
)
*
(
pBlockData
->
nRow
+
1
));
if
(
code
)
return
code
;
for
(
int32_t
iRow
=
0
;
iRow
<
pBlockData
->
nRow
;
iRow
++
)
{
pBlockData
->
aUid
[
iRow
]
=
pBlockData
->
uid
;
}
pBlockData
->
uid
=
0
;
}
// decide append/update row
int64_t
luid
=
pBlockData
->
uid
?
pBlockData
->
uid
:
pBlockData
->
aUid
[
pBlockData
->
nRow
-
1
];
if
(
luid
==
uid
&&
pBlockData
->
aTSKEY
[
pBlockData
->
nRow
-
1
]
==
TSDBROW_TS
(
pRow
))
{
return
tBlockDataUpdateRow
(
pBlockData
,
pRow
,
pTSchema
);
return
tBlockDataUpdateRow
(
pBlockData
,
pRow
,
pTSchema
);
}
else
{
}
else
{
return
tBlockDataAppendRow
(
pBlockData
,
pRow
,
pTSchema
,
uid
);
return
tBlockDataAppendRow
(
pBlockData
,
pRow
,
pTSchema
,
uid
);
...
...
source/util/src/trbtree.c
浏览文件 @
8d6e6d2f
...
@@ -147,6 +147,10 @@ static SRBTreeNode *tRBTreePredecessor(SRBTree *pTree, SRBTreeNode *pNode) {
...
@@ -147,6 +147,10 @@ static SRBTreeNode *tRBTreePredecessor(SRBTree *pTree, SRBTreeNode *pNode) {
void
tRBTreeCreate
(
SRBTree
*
pTree
,
tRBTreeCmprFn
cmprFn
)
{
void
tRBTreeCreate
(
SRBTree
*
pTree
,
tRBTreeCmprFn
cmprFn
)
{
pTree
->
cmprFn
=
cmprFn
;
pTree
->
cmprFn
=
cmprFn
;
tRBTreeClear
(
pTree
);
}
void
tRBTreeClear
(
SRBTree
*
pTree
)
{
pTree
->
n
=
0
;
pTree
->
n
=
0
;
pTree
->
NIL
=
&
pTree
->
NILNODE
;
pTree
->
NIL
=
&
pTree
->
NILNODE
;
pTree
->
NIL
->
color
=
BLACK
;
pTree
->
NIL
->
color
=
BLACK
;
...
@@ -423,6 +427,22 @@ SRBTreeNode *tRBTreeDropByKey(SRBTree *pTree, void *pKey) {
...
@@ -423,6 +427,22 @@ SRBTreeNode *tRBTreeDropByKey(SRBTree *pTree, void *pKey) {
return
pNode
;
return
pNode
;
}
}
SRBTreeNode
*
tRBTreeDropMin
(
SRBTree
*
pTree
)
{
SRBTreeNode
*
pNode
=
tRBTreeMin
(
pTree
);
if
(
pNode
)
{
tRBTreeDrop
(
pTree
,
pNode
);
}
return
pNode
;
}
SRBTreeNode
*
tRBTreeDropMax
(
SRBTree
*
pTree
)
{
SRBTreeNode
*
pNode
=
tRBTreeMax
(
pTree
);
if
(
pNode
)
{
tRBTreeDrop
(
pTree
,
pNode
);
}
return
pNode
;
}
SRBTreeNode
*
tRBTreeGet
(
SRBTree
*
pTree
,
const
SRBTreeNode
*
pKeyNode
)
{
SRBTreeNode
*
tRBTreeGet
(
SRBTree
*
pTree
,
const
SRBTreeNode
*
pKeyNode
)
{
SRBTreeNode
*
pNode
=
pTree
->
root
;
SRBTreeNode
*
pNode
=
pTree
->
root
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录