Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
07cf336f
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
07cf336f
编写于
1月 17, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: add an array list api.
上级
e5ee9689
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
41 addition
and
20 deletion
+41
-20
include/util/tarray.h
include/util/tarray.h
+1
-0
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+1
-0
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+2
-2
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+6
-6
source/libs/catalog/src/ctgCache.c
source/libs/catalog/src/ctgCache.c
+8
-8
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+1
-1
source/libs/stream/src/streamData.c
source/libs/stream/src/streamData.c
+2
-3
source/util/src/tarray.c
source/util/src/tarray.c
+20
-0
未找到文件。
include/util/tarray.h
浏览文件 @
07cf336f
...
...
@@ -53,6 +53,7 @@ typedef struct SArray {
* @return
*/
SArray
*
taosArrayInit
(
size_t
size
,
size_t
elemSize
);
SArray
*
taosArrayInit_s
(
size_t
size
,
size_t
elemSize
,
size_t
initialSize
);
/**
*
...
...
source/common/src/tdatablock.c
浏览文件 @
07cf336f
...
...
@@ -2353,6 +2353,7 @@ const char* blockDecode(SSDataBlock* pBlock, const char* pData) {
if
(
pBlock
->
pDataBlock
==
NULL
)
{
pBlock
->
pDataBlock
=
taosArrayInit
(
numOfCols
,
sizeof
(
SColumnInfoData
));
taosArraySetSize
(
pBlock
->
pDataBlock
,
numOfCols
);
}
...
...
source/libs/catalog/inc/catalogInt.h
浏览文件 @
07cf336f
...
...
@@ -300,7 +300,7 @@ typedef struct SCtgSubRes {
ctgSubTaskCbFp
fp
;
}
SCtgSubRes
;
typedef
struct
SCtgTask
{
struct
SCtgTask
{
CTG_TASK_TYPE
type
;
int32_t
taskId
;
SCtgJob
*
pJob
;
...
...
@@ -313,7 +313,7 @@ typedef struct SCtgTask {
SRWLatch
lock
;
SArray
*
pParents
;
SCtgSubRes
subRes
;
}
SCtgTask
;
};
typedef
struct
SCtgTaskReq
{
SCtgTask
*
pTask
;
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
07cf336f
...
...
@@ -1705,9 +1705,7 @@ int32_t ctgLaunchGetTbMetasTask(SCtgTask* pTask) {
return
TSDB_CODE_SUCCESS
;
}
pTask
->
msgCtxs
=
taosArrayInit
(
pCtx
->
fetchNum
,
sizeof
(
SCtgMsgCtx
));
taosArraySetSize
(
pTask
->
msgCtxs
,
pCtx
->
fetchNum
);
pTask
->
msgCtxs
=
taosArrayInit_s
(
pCtx
->
fetchNum
,
sizeof
(
SCtgMsgCtx
),
pCtx
->
fetchNum
);
for
(
int32_t
i
=
0
;
i
<
pCtx
->
fetchNum
;
++
i
)
{
SCtgFetch
*
pFetch
=
taosArrayGet
(
pCtx
->
pFetchs
,
i
);
SName
*
pName
=
ctgGetFetchName
(
pCtx
->
pNames
,
pFetch
);
...
...
@@ -1842,7 +1840,10 @@ int32_t ctgLaunchGetTbHashsTask(SCtgTask* pTask) {
ctgAddFetch
(
&
pCtx
->
pFetchs
,
i
,
-
1
,
&
fetchIdx
,
baseResIdx
,
0
);
baseResIdx
+=
taosArrayGetSize
(
pReq
->
pTables
);
taosArraySetSize
(
pCtx
->
pResList
,
baseResIdx
);
int32_t
inc
=
baseResIdx
-
taosArrayGetSize
(
pCtx
->
pResList
);
for
(
int32_t
j
=
0
;
j
<
inc
;
++
j
)
{
taosArrayPush
(
pCtx
->
pResList
,
&
(
SMetaRes
){
0
});
}
}
}
...
...
@@ -1854,8 +1855,7 @@ int32_t ctgLaunchGetTbHashsTask(SCtgTask* pTask) {
return
TSDB_CODE_SUCCESS
;
}
pTask
->
msgCtxs
=
taosArrayInit
(
pCtx
->
fetchNum
,
sizeof
(
SCtgMsgCtx
));
taosArraySetSize
(
pTask
->
msgCtxs
,
pCtx
->
fetchNum
);
pTask
->
msgCtxs
=
taosArrayInit_s
(
pCtx
->
fetchNum
,
sizeof
(
SCtgMsgCtx
),
pCtx
->
fetchNum
);
for
(
int32_t
i
=
0
;
i
<
pCtx
->
fetchNum
;
++
i
)
{
SCtgFetch
*
pFetch
=
taosArrayGet
(
pCtx
->
pFetchs
,
i
);
...
...
source/libs/catalog/src/ctgCache.c
浏览文件 @
07cf336f
...
...
@@ -2480,20 +2480,20 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe
ctgDebug
(
"db %s not in cache"
,
dbFName
);
for
(
int32_t
i
=
0
;
i
<
tbNum
;
++
i
)
{
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArray
SetSize
(
ctx
->
pResList
,
taosArrayGetSize
(
ctx
->
pResList
)
+
1
);
taosArray
Push
(
ctx
->
pResList
,
&
(
SMetaData
){
0
}
);
}
return
TSDB_CODE_SUCCESS
;
}
for
(
int32_t
i
=
0
;
i
<
tbNum
;
++
i
)
{
SName
*
pName
=
taosArrayGet
(
pList
,
i
);
pName
=
taosArrayGet
(
pList
,
i
);
pCache
=
taosHashAcquire
(
dbCache
->
tbCache
,
pName
->
tname
,
strlen
(
pName
->
tname
));
if
(
NULL
==
pCache
)
{
ctgDebug
(
"tb %s not in cache, dbFName:%s"
,
pName
->
tname
,
dbFName
);
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArray
SetSize
(
ctx
->
pResList
,
taosArrayGetSize
(
ctx
->
pResList
)
+
1
);
taosArray
Push
(
ctx
->
pResList
,
&
(
SMetaRes
){
0
}
);
continue
;
}
...
...
@@ -2503,7 +2503,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe
CTG_UNLOCK
(
CTG_READ
,
&
pCache
->
metaLock
);
ctgDebug
(
"tb %s meta not in cache, dbFName:%s"
,
pName
->
tname
,
dbFName
);
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArray
SetSize
(
ctx
->
pResList
,
taosArrayGetSize
(
ctx
->
pResList
)
+
1
);
taosArray
Push
(
ctx
->
pResList
,
&
(
SMetaRes
){
0
}
);
continue
;
}
...
...
@@ -2576,7 +2576,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe
if
(
NULL
==
stName
)
{
ctgDebug
(
"stb 0x%"
PRIx64
" not in cache, dbFName:%s"
,
pTableMeta
->
suid
,
dbFName
);
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArray
SetSize
(
ctx
->
pResList
,
taosArrayGetSize
(
ctx
->
pResList
)
+
1
);
taosArray
Push
(
ctx
->
pResList
,
&
(
SMetaRes
){
0
}
);
taosMemoryFreeClear
(
pTableMeta
);
continue
;
...
...
@@ -2588,7 +2588,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe
taosHashRelease
(
dbCache
->
stbCache
,
stName
);
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArray
SetSize
(
ctx
->
pResList
,
taosArrayGetSize
(
ctx
->
pResList
)
+
1
);
taosArray
Push
(
ctx
->
pResList
,
&
(
SMetaRes
){
0
}
);
taosMemoryFreeClear
(
pTableMeta
);
continue
;
...
...
@@ -2603,7 +2603,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe
taosHashRelease
(
dbCache
->
tbCache
,
pCache
);
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArray
SetSize
(
ctx
->
pResList
,
taosArrayGetSize
(
ctx
->
pResList
)
+
1
);
taosArray
Push
(
ctx
->
pResList
,
&
(
SMetaRes
){
0
}
);
taosMemoryFreeClear
(
pTableMeta
);
...
...
@@ -2619,7 +2619,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe
nctx
.
tbInfo
.
suid
);
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArray
SetSize
(
ctx
->
pResList
,
taosArrayGetSize
(
ctx
->
pResList
)
+
1
);
taosArray
Push
(
ctx
->
pResList
,
&
(
SMetaRes
){
0
}
);
taosMemoryFreeClear
(
pTableMeta
);
...
...
source/libs/function/src/tudf.c
浏览文件 @
07cf336f
...
...
@@ -812,7 +812,7 @@ int32_t convertUdfColumnToDataBlock(SUdfColumn *udfCol, SSDataBlock *block) {
block
->
info
.
hasVarCol
=
IS_VAR_DATA_TYPE
(
udfCol
->
colMeta
.
type
);
block
->
pDataBlock
=
taosArrayInit
(
1
,
sizeof
(
SColumnInfoData
));
taosArray
SetSize
(
block
->
pDataBlock
,
1
);
taosArray
Push
(
block
->
pDataBlock
,
&
(
SColumnInfoData
){
0
}
);
SColumnInfoData
*
col
=
taosArrayGet
(
block
->
pDataBlock
,
0
);
SUdfColumnMeta
*
meta
=
&
udfCol
->
colMeta
;
col
->
info
.
precision
=
meta
->
precision
;
...
...
source/libs/stream/src/streamData.c
浏览文件 @
07cf336f
...
...
@@ -17,11 +17,10 @@
int32_t
streamDispatchReqToData
(
const
SStreamDispatchReq
*
pReq
,
SStreamDataBlock
*
pData
)
{
int32_t
blockNum
=
pReq
->
blockNum
;
SArray
*
pArray
=
taosArrayInit
(
blockNum
,
sizeof
(
SSDataBlock
)
);
SArray
*
pArray
=
taosArrayInit
_s
(
blockNum
,
sizeof
(
SSDataBlock
),
blockNum
);
if
(
pArray
==
NULL
)
{
return
-
1
;
}
taosArraySetSize
(
pArray
,
blockNum
);
ASSERT
(
pReq
->
blockNum
==
taosArrayGetSize
(
pReq
->
data
));
ASSERT
(
pReq
->
blockNum
==
taosArrayGetSize
(
pReq
->
dataLen
));
...
...
@@ -49,7 +48,7 @@ int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock
if
(
pArray
==
NULL
)
{
return
-
1
;
}
taosArray
SetSize
(
pArray
,
1
);
taosArray
Push
(
pArray
,
&
(
SSDataBlock
){
0
}
);
SRetrieveTableRsp
*
pRetrieve
=
pReq
->
pRetrieve
;
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
pArray
,
0
);
blockDecode
(
pDataBlock
,
pRetrieve
->
data
);
...
...
source/util/src/tarray.c
浏览文件 @
07cf336f
...
...
@@ -45,6 +45,26 @@ SArray* taosArrayInit(size_t size, size_t elemSize) {
return
pArray
;
}
SArray
*
taosArrayInit_s
(
size_t
size
,
size_t
elemSize
,
size_t
initialSize
)
{
SArray
*
pArray
=
taosMemoryMalloc
(
sizeof
(
SArray
));
if
(
pArray
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
pArray
->
size
=
0
;
pArray
->
pData
=
taosMemoryCalloc
(
initialSize
,
elemSize
);
if
(
pArray
->
pData
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
taosMemoryFree
(
pArray
);
return
NULL
;
}
pArray
->
capacity
=
initialSize
;
pArray
->
elemSize
=
elemSize
;
return
pArray
;
}
static
int32_t
taosArrayResize
(
SArray
*
pArray
)
{
assert
(
pArray
->
size
>=
pArray
->
capacity
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录