Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bc1af6de
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看板
提交
bc1af6de
编写于
7月 19, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(stream): batch optimization for submit msg
上级
159f1c7b
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
123 addition
and
39 deletion
+123
-39
include/util/tarray.h
include/util/tarray.h
+8
-0
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+1
-1
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+1
-0
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+13
-4
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+50
-26
source/libs/stream/src/streamData.c
source/libs/stream/src/streamData.c
+3
-3
source/libs/wal/src/walRead.c
source/libs/wal/src/walRead.c
+7
-5
source/util/src/tarray.c
source/util/src/tarray.c
+40
-0
未找到文件。
include/util/tarray.h
浏览文件 @
bc1af6de
...
@@ -87,6 +87,14 @@ void taosArrayRemoveBatch(SArray* pArray, const int32_t* pData, int32_t numOfEle
...
@@ -87,6 +87,14 @@ void taosArrayRemoveBatch(SArray* pArray, const int32_t* pData, int32_t numOfEle
*/
*/
void
taosArrayRemoveDuplicate
(
SArray
*
pArray
,
__compar_fn_t
comparFn
,
void
(
*
fp
)(
void
*
));
void
taosArrayRemoveDuplicate
(
SArray
*
pArray
,
__compar_fn_t
comparFn
,
void
(
*
fp
)(
void
*
));
/**
*
* @param pArray
* @param comparFn
* @param fp
*/
void
taosArrayRemoveDuplicateP
(
SArray
*
pArray
,
__compar_fn_t
comparFn
,
void
(
*
fp
)(
void
*
));
/**
/**
* add all element from the source array list into the destination
* add all element from the source array list into the destination
* @param pArray
* @param pArray
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
bc1af6de
...
@@ -452,7 +452,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
...
@@ -452,7 +452,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
SArray
*
newSub
=
subscribe
.
topicNames
;
SArray
*
newSub
=
subscribe
.
topicNames
;
taosArraySortString
(
newSub
,
taosArrayCompareString
);
taosArraySortString
(
newSub
,
taosArrayCompareString
);
taosArrayRemoveDuplicate
(
newSub
,
taosArrayCompareString
,
taosMemoryFree
);
taosArrayRemoveDuplicate
P
(
newSub
,
taosArrayCompareString
,
taosMemoryFree
);
int32_t
newTopicNum
=
taosArrayGetSize
(
newSub
);
int32_t
newTopicNum
=
taosArrayGetSize
(
newSub
);
// check topic existance
// check topic existance
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
bc1af6de
...
@@ -299,6 +299,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) {
...
@@ -299,6 +299,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) {
}
}
if
(
blockDataEnsureCapacity
(
pBlock
,
pReader
->
msgIter
.
numOfRows
)
<
0
)
{
if
(
blockDataEnsureCapacity
(
pBlock
,
pReader
->
msgIter
.
numOfRows
)
<
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
FAIL
;
goto
FAIL
;
}
}
...
...
source/libs/executor/src/executor.c
浏览文件 @
bc1af6de
...
@@ -43,16 +43,24 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
...
@@ -43,16 +43,24 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
// TODO: if a block was set but not consumed,
// TODO: if a block was set but not consumed,
// prevent setting a different type of block
// prevent setting a different type of block
pInfo
->
blockType
=
type
;
pInfo
->
blockType
=
type
;
pInfo
->
validBlockIndex
=
0
;
taosArrayClear
(
pInfo
->
pBlockLists
);
if
(
type
==
STREAM_INPUT__DATA_SUBMIT
)
{
if
(
type
==
STREAM_INPUT__DATA_SUBMIT
)
{
if
(
tqReaderSetDataMsg
(
pInfo
->
tqReader
,
input
,
0
)
<
0
)
{
/*if (tqReaderSetDataMsg(pInfo->tqReader, input, 0) < 0) {*/
qError
(
"submit msg messed up when initing stream block, %s"
PRIx64
,
id
);
/*qError("submit msg messed up when initing stream block, %s" PRIx64, id);*/
return
TSDB_CODE_QRY_APP_ERROR
;
/*return TSDB_CODE_QRY_APP_ERROR;*/
/*}*/
taosArrayClear
(
pInfo
->
pBlockLists
);
for
(
int32_t
i
=
0
;
i
<
numOfBlocks
;
i
++
)
{
SSubmitReq
*
pReq
=
POINTER_SHIFT
(
input
,
i
*
sizeof
(
void
*
));
taosArrayPush
(
pInfo
->
pBlockLists
,
&
pReq
);
}
}
}
else
if
(
type
==
STREAM_INPUT__DATA_BLOCK
)
{
}
else
if
(
type
==
STREAM_INPUT__DATA_BLOCK
)
{
for
(
int32_t
i
=
0
;
i
<
numOfBlocks
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfBlocks
;
++
i
)
{
SSDataBlock
*
pDataBlock
=
&
((
SSDataBlock
*
)
input
)[
i
];
SSDataBlock
*
pDataBlock
=
&
((
SSDataBlock
*
)
input
)[
i
];
// TODO optimize
SSDataBlock
*
p
=
createOneDataBlock
(
pDataBlock
,
false
);
SSDataBlock
*
p
=
createOneDataBlock
(
pDataBlock
,
false
);
p
->
info
=
pDataBlock
->
info
;
p
->
info
=
pDataBlock
->
info
;
...
@@ -153,7 +161,8 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers) {
...
@@ -153,7 +161,8 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers) {
return
pTaskInfo
;
return
pTaskInfo
;
}
}
static
SArray
*
filterQualifiedChildTables
(
const
SStreamScanInfo
*
pScanInfo
,
const
SArray
*
tableIdList
,
const
char
*
idstr
)
{
static
SArray
*
filterQualifiedChildTables
(
const
SStreamScanInfo
*
pScanInfo
,
const
SArray
*
tableIdList
,
const
char
*
idstr
)
{
SArray
*
qa
=
taosArrayInit
(
4
,
sizeof
(
tb_uid_t
));
SArray
*
qa
=
taosArrayInit
(
4
,
sizeof
(
tb_uid_t
));
// let's discard the tables those are not created according to the queried super table.
// let's discard the tables those are not created according to the queried super table.
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
bc1af6de
...
@@ -1393,24 +1393,47 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
...
@@ -1393,24 +1393,47 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
}
}
SDataBlockInfo
*
pBlockInfo
=
&
pInfo
->
pRes
->
info
;
SDataBlockInfo
*
pBlockInfo
=
&
pInfo
->
pRes
->
info
;
blockDataCleanup
(
pInfo
->
pRes
);
while
(
tqNextDataBlock
(
pInfo
->
tqReader
))
{
int32_t
totBlockNum
=
taosArrayGetSize
(
pInfo
->
pBlockLists
);
SSDataBlock
block
=
{
0
};
// todo refactor
while
(
1
)
{
int32_t
code
=
tqRetrieveDataBlock
(
&
block
,
pInfo
->
tqReader
);
if
(
pInfo
->
tqReader
->
pMsg
==
NULL
)
{
if
(
pInfo
->
validBlockIndex
>=
totBlockNum
)
{
return
NULL
;
}
if
(
code
!=
TSDB_CODE_SUCCESS
||
block
.
info
.
rows
==
0
)
{
int32_t
current
=
pInfo
->
validBlockIndex
++
;
pTaskInfo
->
code
=
code
;
SSubmitReq
*
pSubmit
=
taosArrayGetP
(
pInfo
->
pBlockLists
,
current
);
return
NULL
;
if
(
tqReaderSetDataMsg
(
pInfo
->
tqReader
,
pSubmit
,
0
)
<
0
)
{
qError
(
"submit msg messed up when initing stream submit block %p, current %d, total %d"
,
pSubmit
,
current
,
totBlockNum
);
pInfo
->
tqReader
->
pMsg
=
NULL
;
continue
;
}
}
}
setBlockIntoRes
(
pInfo
,
&
block
);
blockDataCleanup
(
pInfo
->
pRes
);
while
(
tqNextDataBlock
(
pInfo
->
tqReader
))
{
SSDataBlock
block
=
{
0
};
int32_t
code
=
tqRetrieveDataBlock
(
&
block
,
pInfo
->
tqReader
);
if
(
code
!=
TSDB_CODE_SUCCESS
||
block
.
info
.
rows
==
0
)
{
continue
;
}
setBlockIntoRes
(
pInfo
,
&
block
);
if
(
pBlockInfo
->
rows
>
0
)
{
break
;
}
}
if
(
pBlockInfo
->
rows
>
0
)
{
if
(
pBlockInfo
->
rows
>
0
)
{
break
;
break
;
}
}
/*blockDataCleanup(pInfo->pRes);*/
pInfo
->
tqReader
->
pMsg
=
NULL
;
}
}
// record the scan action.
// record the scan action.
...
@@ -2558,30 +2581,30 @@ typedef struct STableMergeScanInfo {
...
@@ -2558,30 +2581,30 @@ typedef struct STableMergeScanInfo {
SArray
*
pSortInfo
;
SArray
*
pSortInfo
;
SSortHandle
*
pSortHandle
;
SSortHandle
*
pSortHandle
;
SSDataBlock
*
pSortInputBlock
;
SSDataBlock
*
pSortInputBlock
;
int64_t
startTs
;
// sort start time
int64_t
startTs
;
// sort start time
SArray
*
sortSourceParams
;
SArray
*
sortSourceParams
;
SFileBlockLoadRecorder
readRecorder
;
SFileBlockLoadRecorder
readRecorder
;
int64_t
numOfRows
;
int64_t
numOfRows
;
SScanInfo
scanInfo
;
SScanInfo
scanInfo
;
int32_t
scanTimes
;
int32_t
scanTimes
;
SNode
*
pFilterNode
;
// filter info, which is push down by optimizer
SNode
*
pFilterNode
;
// filter info, which is push down by optimizer
SqlFunctionCtx
*
pCtx
;
// which belongs to the direct upstream operator operator query context
SqlFunctionCtx
*
pCtx
;
// which belongs to the direct upstream operator operator query context
SResultRowInfo
*
pResultRowInfo
;
SResultRowInfo
*
pResultRowInfo
;
int32_t
*
rowEntryInfoOffset
;
int32_t
*
rowEntryInfoOffset
;
SExprInfo
*
pExpr
;
SExprInfo
*
pExpr
;
SSDataBlock
*
pResBlock
;
SSDataBlock
*
pResBlock
;
SArray
*
pColMatchInfo
;
SArray
*
pColMatchInfo
;
int32_t
numOfOutput
;
int32_t
numOfOutput
;
SExprInfo
*
pPseudoExpr
;
SExprInfo
*
pPseudoExpr
;
int32_t
numOfPseudoExpr
;
int32_t
numOfPseudoExpr
;
SqlFunctionCtx
*
pPseudoCtx
;
SqlFunctionCtx
*
pPseudoCtx
;
SQueryTableDataCond
cond
;
SQueryTableDataCond
cond
;
int32_t
scanFlag
;
// table scan flag to denote if it is a repeat/reverse/main scan
int32_t
scanFlag
;
// table scan flag to denote if it is a repeat/reverse/main scan
int32_t
dataBlockLoadFlag
;
int32_t
dataBlockLoadFlag
;
// if the upstream is an interval operator, the interval info is also kept here to get the time
// if the upstream is an interval operator, the interval info is also kept here to get the time
// window to check if current data block needs to be loaded.
// window to check if current data block needs to be loaded.
SInterval
interval
;
SInterval
interval
;
...
@@ -2589,7 +2612,8 @@ typedef struct STableMergeScanInfo {
...
@@ -2589,7 +2612,8 @@ typedef struct STableMergeScanInfo {
}
STableMergeScanInfo
;
}
STableMergeScanInfo
;
int32_t
createScanTableListInfo
(
SScanPhysiNode
*
pScanNode
,
SNodeList
*
pGroupTags
,
bool
groupSort
,
SReadHandle
*
pHandle
,
int32_t
createScanTableListInfo
(
SScanPhysiNode
*
pScanNode
,
SNodeList
*
pGroupTags
,
bool
groupSort
,
SReadHandle
*
pHandle
,
STableListInfo
*
pTableListInfo
,
SNode
*
pTagCond
,
SNode
*
pTagIndexCond
,
const
char
*
idStr
)
{
STableListInfo
*
pTableListInfo
,
SNode
*
pTagCond
,
SNode
*
pTagIndexCond
,
const
char
*
idStr
)
{
int32_t
code
=
getTableList
(
pHandle
->
meta
,
pHandle
->
vnode
,
pScanNode
,
pTagCond
,
pTagIndexCond
,
pTableListInfo
);
int32_t
code
=
getTableList
(
pHandle
->
meta
,
pHandle
->
vnode
,
pScanNode
,
pTagCond
,
pTagIndexCond
,
pTableListInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
...
source/libs/stream/src/streamData.c
浏览文件 @
bc1af6de
...
@@ -81,7 +81,7 @@ SStreamMergedSubmit* streamMergedSubmitNew() {
...
@@ -81,7 +81,7 @@ SStreamMergedSubmit* streamMergedSubmitNew() {
SStreamMergedSubmit
*
pMerged
=
(
SStreamMergedSubmit
*
)
taosAllocateQitem
(
sizeof
(
SStreamMergedSubmit
),
DEF_QITEM
);
SStreamMergedSubmit
*
pMerged
=
(
SStreamMergedSubmit
*
)
taosAllocateQitem
(
sizeof
(
SStreamMergedSubmit
),
DEF_QITEM
);
if
(
pMerged
==
NULL
)
return
NULL
;
if
(
pMerged
==
NULL
)
return
NULL
;
pMerged
->
reqs
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
pMerged
->
reqs
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
pMerged
->
dataRefs
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
pMerged
->
dataRefs
=
taosArrayInit
(
0
,
sizeof
(
int32_t
*
));
if
(
pMerged
->
dataRefs
==
NULL
||
pMerged
->
reqs
==
NULL
)
goto
FAIL
;
if
(
pMerged
->
dataRefs
==
NULL
||
pMerged
->
reqs
==
NULL
)
goto
FAIL
;
return
pMerged
;
return
pMerged
;
FAIL:
FAIL:
...
@@ -93,7 +93,7 @@ FAIL:
...
@@ -93,7 +93,7 @@ FAIL:
int32_t
streamMergeSubmit
(
SStreamMergedSubmit
*
pMerged
,
SStreamDataSubmit
*
pSubmit
)
{
int32_t
streamMergeSubmit
(
SStreamMergedSubmit
*
pMerged
,
SStreamDataSubmit
*
pSubmit
)
{
taosArrayPush
(
pMerged
->
dataRefs
,
pSubmit
->
dataRef
);
taosArrayPush
(
pMerged
->
dataRefs
,
pSubmit
->
dataRef
);
taosArrayPush
(
pMerged
->
reqs
,
pSubmit
->
data
);
taosArrayPush
(
pMerged
->
reqs
,
&
pSubmit
->
data
);
pMerged
->
ver
=
pSubmit
->
ver
;
pMerged
->
ver
=
pSubmit
->
ver
;
return
0
;
return
0
;
}
}
...
@@ -167,7 +167,7 @@ void streamFreeQitem(SStreamQueueItem* data) {
...
@@ -167,7 +167,7 @@ void streamFreeQitem(SStreamQueueItem* data) {
int32_t
*
ref
=
taosArrayGet
(
pMerge
->
dataRefs
,
i
);
int32_t
*
ref
=
taosArrayGet
(
pMerge
->
dataRefs
,
i
);
(
*
ref
)
--
;
(
*
ref
)
--
;
if
(
*
ref
==
0
)
{
if
(
*
ref
==
0
)
{
void
*
data
=
taosArrayGet
(
pMerge
->
reqs
,
i
);
void
*
data
=
taosArrayGet
P
(
pMerge
->
reqs
,
i
);
taosMemoryFree
(
data
);
taosMemoryFree
(
data
);
taosMemoryFree
(
ref
);
taosMemoryFree
(
ref
);
}
}
...
...
source/libs/wal/src/walRead.c
浏览文件 @
bc1af6de
...
@@ -417,7 +417,7 @@ int32_t walReadVer(SWalReader *pRead, int64_t ver) {
...
@@ -417,7 +417,7 @@ int32_t walReadVer(SWalReader *pRead, int64_t ver) {
}
}
if
(
ver
>
pRead
->
pWal
->
vers
.
lastVer
||
ver
<
pRead
->
pWal
->
vers
.
firstVer
)
{
if
(
ver
>
pRead
->
pWal
->
vers
.
lastVer
||
ver
<
pRead
->
pWal
->
vers
.
firstVer
)
{
w
Error
(
"vgId:%d, invalid index:%"
PRId64
", first index:%"
PRId64
", last index:%"
PRId64
,
pRead
->
pWal
->
cfg
.
vgId
,
w
Debug
(
"vgId:%d, invalid index:%"
PRId64
", first index:%"
PRId64
", last index:%"
PRId64
,
pRead
->
pWal
->
cfg
.
vgId
,
ver
,
pRead
->
pWal
->
vers
.
firstVer
,
pRead
->
pWal
->
vers
.
lastVer
);
ver
,
pRead
->
pWal
->
vers
.
firstVer
,
pRead
->
pWal
->
vers
.
lastVer
);
terrno
=
TSDB_CODE_WAL_LOG_NOT_EXIST
;
terrno
=
TSDB_CODE_WAL_LOG_NOT_EXIST
;
return
-
1
;
return
-
1
;
...
@@ -425,7 +425,7 @@ int32_t walReadVer(SWalReader *pRead, int64_t ver) {
...
@@ -425,7 +425,7 @@ int32_t walReadVer(SWalReader *pRead, int64_t ver) {
if
(
pRead
->
curInvalid
||
pRead
->
curVersion
!=
ver
)
{
if
(
pRead
->
curInvalid
||
pRead
->
curVersion
!=
ver
)
{
if
(
walReadSeekVer
(
pRead
,
ver
)
<
0
)
{
if
(
walReadSeekVer
(
pRead
,
ver
)
<
0
)
{
wError
(
"vgId:%d, unexpected wal log index:%"
PRId64
", since %s"
,
pRead
->
pWal
->
cfg
.
vgId
,
ver
,
terrstr
());
wError
(
"vgId:%d, unexpected wal log
,
index:%"
PRId64
", since %s"
,
pRead
->
pWal
->
cfg
.
vgId
,
ver
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
seeked
=
true
;
seeked
=
true
;
...
@@ -452,7 +452,8 @@ int32_t walReadVer(SWalReader *pRead, int64_t ver) {
...
@@ -452,7 +452,8 @@ int32_t walReadVer(SWalReader *pRead, int64_t ver) {
contLen
=
walValidHeadCksum
(
pRead
->
pHead
);
contLen
=
walValidHeadCksum
(
pRead
->
pHead
);
if
(
contLen
!=
0
)
{
if
(
contLen
!=
0
)
{
wError
(
"vgId:%d, unexpected wal log index:%"
PRId64
", since head checksum not passed"
,
pRead
->
pWal
->
cfg
.
vgId
,
ver
);
wError
(
"vgId:%d, unexpected wal log, index:%"
PRId64
", since head checksum not passed"
,
pRead
->
pWal
->
cfg
.
vgId
,
ver
);
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
return
-
1
;
return
-
1
;
}
}
...
@@ -479,7 +480,7 @@ int32_t walReadVer(SWalReader *pRead, int64_t ver) {
...
@@ -479,7 +480,7 @@ int32_t walReadVer(SWalReader *pRead, int64_t ver) {
}
}
if
(
pRead
->
pHead
->
head
.
version
!=
ver
)
{
if
(
pRead
->
pHead
->
head
.
version
!=
ver
)
{
wError
(
"vgId:%d, unexpected wal log index:%"
PRId64
", read request index:%"
PRId64
,
pRead
->
pWal
->
cfg
.
vgId
,
wError
(
"vgId:%d, unexpected wal log
,
index:%"
PRId64
", read request index:%"
PRId64
,
pRead
->
pWal
->
cfg
.
vgId
,
pRead
->
pHead
->
head
.
version
,
ver
);
pRead
->
pHead
->
head
.
version
,
ver
);
pRead
->
curInvalid
=
1
;
pRead
->
curInvalid
=
1
;
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
...
@@ -489,7 +490,8 @@ int32_t walReadVer(SWalReader *pRead, int64_t ver) {
...
@@ -489,7 +490,8 @@ int32_t walReadVer(SWalReader *pRead, int64_t ver) {
contLen
=
walValidBodyCksum
(
pRead
->
pHead
);
contLen
=
walValidBodyCksum
(
pRead
->
pHead
);
if
(
contLen
!=
0
)
{
if
(
contLen
!=
0
)
{
wError
(
"vgId:%d, unexpected wal log index:%"
PRId64
", since body checksum not passed"
,
pRead
->
pWal
->
cfg
.
vgId
,
ver
);
wError
(
"vgId:%d, unexpected wal log, index:%"
PRId64
", since body checksum not passed"
,
pRead
->
pWal
->
cfg
.
vgId
,
ver
);
pRead
->
curInvalid
=
1
;
pRead
->
curInvalid
=
1
;
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
ASSERT
(
0
);
ASSERT
(
0
);
...
...
source/util/src/tarray.c
浏览文件 @
bc1af6de
...
@@ -173,6 +173,46 @@ void taosArrayRemoveDuplicate(SArray* pArray, __compar_fn_t comparFn, void (*fp)
...
@@ -173,6 +173,46 @@ void taosArrayRemoveDuplicate(SArray* pArray, __compar_fn_t comparFn, void (*fp)
pArray
->
size
=
pos
+
1
;
pArray
->
size
=
pos
+
1
;
}
}
void
taosArrayRemoveDuplicateP
(
SArray
*
pArray
,
__compar_fn_t
comparFn
,
void
(
*
fp
)(
void
*
))
{
assert
(
pArray
);
size_t
size
=
pArray
->
size
;
if
(
size
<=
1
)
{
return
;
}
int32_t
pos
=
0
;
for
(
int32_t
i
=
1
;
i
<
size
;
++
i
)
{
char
*
p1
=
taosArrayGet
(
pArray
,
pos
);
char
*
p2
=
taosArrayGet
(
pArray
,
i
);
if
(
comparFn
(
p1
,
p2
)
==
0
)
{
// do nothing
}
else
{
if
(
pos
+
1
!=
i
)
{
void
*
p
=
taosArrayGet
(
pArray
,
pos
+
1
);
if
(
fp
!=
NULL
)
{
fp
(
p
);
}
taosArraySet
(
pArray
,
pos
+
1
,
p2
);
pos
+=
1
;
}
else
{
pos
+=
1
;
}
}
}
if
(
fp
!=
NULL
)
{
for
(
int32_t
i
=
pos
+
1
;
i
<
pArray
->
size
;
++
i
)
{
void
*
p
=
taosArrayGetP
(
pArray
,
i
);
fp
(
p
);
}
}
pArray
->
size
=
pos
+
1
;
}
void
*
taosArrayAddAll
(
SArray
*
pArray
,
const
SArray
*
pInput
)
{
void
*
taosArrayAddAll
(
SArray
*
pArray
,
const
SArray
*
pInput
)
{
if
(
pInput
)
{
if
(
pInput
)
{
return
taosArrayAddBatch
(
pArray
,
pInput
->
pData
,
(
int32_t
)
taosArrayGetSize
(
pInput
));
return
taosArrayAddBatch
(
pArray
,
pInput
->
pData
,
(
int32_t
)
taosArrayGetSize
(
pInput
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录