Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d5255f1e
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看板
提交
d5255f1e
编写于
10月 13, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more format
上级
3950c8fc
变更
30
展开全部
显示空白变更内容
内联
并排
Showing
30 changed file
with
1237 addition
and
1200 deletion
+1237
-1200
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+382
-325
source/libs/catalog/inc/ctgRemote.h
source/libs/catalog/inc/ctgRemote.h
+0
-2
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+88
-83
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+1
-1
source/libs/catalog/src/ctgDbg.c
source/libs/catalog/src/ctgDbg.c
+65
-61
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+179
-221
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+149
-166
source/libs/command/test/commandTest.cpp
source/libs/command/test/commandTest.cpp
+2
-2
source/libs/executor/inc/dataSinkInt.h
source/libs/executor/inc/dataSinkInt.h
+11
-9
source/libs/executor/inc/executorInt.h
source/libs/executor/inc/executorInt.h
+4
-4
source/libs/executor/inc/tlinearhash.h
source/libs/executor/inc/tlinearhash.h
+5
-5
source/libs/executor/inc/tsimplehash.h
source/libs/executor/inc/tsimplehash.h
+1
-1
source/libs/executor/inc/tsort.h
source/libs/executor/inc/tsort.h
+16
-14
source/libs/executor/src/cachescanoperator.c
source/libs/executor/src/cachescanoperator.c
+29
-27
source/libs/executor/src/dataDispatcher.c
source/libs/executor/src/dataDispatcher.c
+16
-15
source/libs/executor/src/dataInserter.c
source/libs/executor/src/dataInserter.c
+40
-40
source/libs/executor/src/dataSinkMgt.c
source/libs/executor/src/dataSinkMgt.c
+7
-9
source/libs/executor/src/joinoperator.c
source/libs/executor/src/joinoperator.c
+10
-9
source/libs/executor/src/sortoperator.c
source/libs/executor/src/sortoperator.c
+2
-1
source/libs/executor/src/tfill.c
source/libs/executor/src/tfill.c
+1
-1
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+2
-2
source/libs/executor/src/tlinearhash.c
source/libs/executor/src/tlinearhash.c
+46
-48
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+88
-78
source/libs/executor/test/lhashTests.cpp
source/libs/executor/test/lhashTests.cpp
+11
-10
source/libs/executor/test/sortTests.cpp
source/libs/executor/test/sortTests.cpp
+40
-40
source/libs/executor/test/tSimpleHashTests.cpp
source/libs/executor/test/tSimpleHashTests.cpp
+3
-7
source/libs/tfs/inc/tfsInt.h
source/libs/tfs/inc/tfsInt.h
+16
-14
source/libs/tfs/src/tfs.c
source/libs/tfs/src/tfs.c
+2
-2
source/libs/tfs/test/tfsTest.cpp
source/libs/tfs/test/tfsTest.cpp
+2
-2
tools/scripts/codeFormat.sh
tools/scripts/codeFormat.sh
+19
-1
未找到文件。
source/libs/catalog/inc/catalogInt.h
浏览文件 @
d5255f1e
此差异已折叠。
点击以展开。
source/libs/catalog/inc/ctgRemote.h
浏览文件 @
d5255f1e
...
@@ -20,8 +20,6 @@
...
@@ -20,8 +20,6 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
d5255f1e
...
@@ -22,7 +22,8 @@
...
@@ -22,7 +22,8 @@
SCatalogMgmt
gCtgMgmt
=
{
0
};
SCatalogMgmt
gCtgMgmt
=
{
0
};
int32_t
ctgGetDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SCtgDBCache
**
dbCache
,
SDBVgInfo
**
pInfo
)
{
int32_t
ctgGetDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SCtgDBCache
**
dbCache
,
SDBVgInfo
**
pInfo
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
CTG_ERR_RET
(
ctgAcquireVgInfoFromCache
(
pCtg
,
dbFName
,
dbCache
));
CTG_ERR_RET
(
ctgAcquireVgInfoFromCache
(
pCtg
,
dbFName
,
dbCache
));
...
@@ -53,7 +54,7 @@ _return:
...
@@ -53,7 +54,7 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgRefreshDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
)
{
int32_t
ctgRefreshDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDBCache
*
dbCache
=
NULL
;
...
@@ -87,7 +88,8 @@ int32_t ctgRefreshDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
...
@@ -87,7 +88,8 @@ int32_t ctgRefreshDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgRefreshTbMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetaCtx
*
ctx
,
STableMetaOutput
**
pOutput
,
bool
syncReq
)
{
int32_t
ctgRefreshTbMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetaCtx
*
ctx
,
STableMetaOutput
**
pOutput
,
bool
syncReq
)
{
SVgroupInfo
vgroupInfo
=
{
0
};
SVgroupInfo
vgroupInfo
=
{
0
};
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -105,7 +107,8 @@ int32_t ctgRefreshTbMeta(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetaCtx*
...
@@ -105,7 +107,8 @@ int32_t ctgRefreshTbMeta(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetaCtx*
if
(
CTG_FLAG_IS_SYS_DB
(
ctx
->
flag
))
{
if
(
CTG_FLAG_IS_SYS_DB
(
ctx
->
flag
))
{
ctgDebug
(
"will refresh tbmeta, supposed in information_schema, tbName:%s"
,
tNameGetTableName
(
ctx
->
pName
));
ctgDebug
(
"will refresh tbmeta, supposed in information_schema, tbName:%s"
,
tNameGetTableName
(
ctx
->
pName
));
CTG_ERR_JRET
(
ctgGetTbMetaFromMnodeImpl
(
pCtg
,
pConn
,
(
char
*
)
ctx
->
pName
->
dbname
,
(
char
*
)
ctx
->
pName
->
tname
,
output
,
NULL
));
CTG_ERR_JRET
(
ctgGetTbMetaFromMnodeImpl
(
pCtg
,
pConn
,
(
char
*
)
ctx
->
pName
->
dbname
,
(
char
*
)
ctx
->
pName
->
tname
,
output
,
NULL
));
}
else
if
(
CTG_FLAG_IS_STB
(
ctx
->
flag
))
{
}
else
if
(
CTG_FLAG_IS_STB
(
ctx
->
flag
))
{
ctgDebug
(
"will refresh tbmeta, supposed to be stb, tbName:%s"
,
tNameGetTableName
(
ctx
->
pName
));
ctgDebug
(
"will refresh tbmeta, supposed to be stb, tbName:%s"
,
tNameGetTableName
(
ctx
->
pName
));
...
@@ -182,9 +185,9 @@ _return:
...
@@ -182,9 +185,9 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgGetTbMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
)
{
int32_t
ctgGetTbMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
STableMetaOutput
*
output
=
NULL
;
STableMetaOutput
*
output
=
NULL
;
CTG_ERR_RET
(
ctgGetTbMetaFromCache
(
pCtg
,
pConn
,
ctx
,
pTableMeta
));
CTG_ERR_RET
(
ctgGetTbMetaFromCache
(
pCtg
,
pConn
,
ctx
,
pTableMeta
));
if
(
*
pTableMeta
)
{
if
(
*
pTableMeta
)
{
...
@@ -299,7 +302,8 @@ _return:
...
@@ -299,7 +302,8 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
)
{
int32_t
ctgChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
)
{
bool
inCache
=
false
;
bool
inCache
=
false
;
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -337,7 +341,7 @@ _return:
...
@@ -337,7 +341,7 @@ _return:
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgGetTbType
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
int32_t
*
tbType
)
{
int32_t
ctgGetTbType
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
int32_t
*
tbType
)
{
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
tNameGetFullDbName
(
pTableName
,
dbFName
);
tNameGetFullDbName
(
pTableName
,
dbFName
);
CTG_ERR_RET
(
ctgReadTbTypeFromCache
(
pCtg
,
dbFName
,
pTableName
->
tname
,
tbType
));
CTG_ERR_RET
(
ctgReadTbTypeFromCache
(
pCtg
,
dbFName
,
pTableName
->
tname
,
tbType
));
...
@@ -357,13 +361,13 @@ int32_t ctgGetTbType(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName,
...
@@ -357,13 +361,13 @@ int32_t ctgGetTbType(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName,
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgGetTbIndex
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
SArray
**
pRes
)
{
int32_t
ctgGetTbIndex
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
SArray
**
pRes
)
{
CTG_ERR_RET
(
ctgReadTbIndexFromCache
(
pCtg
,
pTableName
,
pRes
));
CTG_ERR_RET
(
ctgReadTbIndexFromCache
(
pCtg
,
pTableName
,
pRes
));
if
(
*
pRes
)
{
if
(
*
pRes
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
STableIndex
*
pIndex
=
taosMemoryCalloc
(
1
,
sizeof
(
STableIndex
));
STableIndex
*
pIndex
=
taosMemoryCalloc
(
1
,
sizeof
(
STableIndex
));
if
(
NULL
==
pIndex
)
{
if
(
NULL
==
pIndex
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
}
...
@@ -395,7 +399,7 @@ _return:
...
@@ -395,7 +399,7 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgGetTbCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
STableCfg
**
pCfg
)
{
int32_t
ctgGetTbCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
STableCfg
**
pCfg
)
{
int32_t
tbType
=
0
;
int32_t
tbType
=
0
;
CTG_ERR_RET
(
ctgGetTbType
(
pCtg
,
pConn
,
pTableName
,
&
tbType
));
CTG_ERR_RET
(
ctgGetTbType
(
pCtg
,
pConn
,
pTableName
,
&
tbType
));
...
@@ -410,13 +414,13 @@ int32_t ctgGetTbCfg(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName,
...
@@ -410,13 +414,13 @@ int32_t ctgGetTbCfg(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName,
CTG_RET
(
TSDB_CODE_SUCCESS
);
CTG_RET
(
TSDB_CODE_SUCCESS
);
}
}
int32_t
ctgGetTbDistVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
SArray
**
pVgList
)
{
int32_t
ctgGetTbDistVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
SArray
**
pVgList
)
{
STableMeta
*
tbMeta
=
NULL
;
STableMeta
*
tbMeta
=
NULL
;
int32_t
code
=
0
;
int32_t
code
=
0
;
SVgroupInfo
vgroupInfo
=
{
0
};
SVgroupInfo
vgroupInfo
=
{
0
};
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDBCache
*
dbCache
=
NULL
;
SArray
*
vgList
=
NULL
;
SArray
*
vgList
=
NULL
;
SDBVgInfo
*
vgInfo
=
NULL
;
SDBVgInfo
*
vgInfo
=
NULL
;
SCtgTbMetaCtx
ctx
=
{
0
};
SCtgTbMetaCtx
ctx
=
{
0
};
ctx
.
pName
=
pTableName
;
ctx
.
pName
=
pTableName
;
ctx
.
flag
=
CTG_FLAG_UNKNOWN_STB
;
ctx
.
flag
=
CTG_FLAG_UNKNOWN_STB
;
...
@@ -428,7 +432,7 @@ int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTabl
...
@@ -428,7 +432,7 @@ int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTabl
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
pTableName
,
db
);
tNameGetFullDbName
(
pTableName
,
db
);
SHashObj
*
vgHash
=
NULL
;
SHashObj
*
vgHash
=
NULL
;
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
db
,
&
dbCache
,
&
vgInfo
));
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
db
,
&
dbCache
,
&
vgInfo
));
if
(
dbCache
)
{
if
(
dbCache
)
{
...
@@ -489,8 +493,7 @@ _return:
...
@@ -489,8 +493,7 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgGetTbHashVgroup
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
)
{
int32_t
ctgGetTbHashVgroup
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
)
{
if
(
IS_SYS_DBNAME
(
pTableName
->
dbname
))
{
if
(
IS_SYS_DBNAME
(
pTableName
->
dbname
))
{
ctgError
(
"no valid vgInfo for db, dbname:%s"
,
pTableName
->
dbname
);
ctgError
(
"no valid vgInfo for db, dbname:%s"
,
pTableName
->
dbname
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
...
@@ -501,7 +504,7 @@ int32_t ctgGetTbHashVgroup(SCatalog *pCtg, SRequestConnInfo *pConn, const SName
...
@@ -501,7 +504,7 @@ int32_t ctgGetTbHashVgroup(SCatalog *pCtg, SRequestConnInfo *pConn, const SName
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
pTableName
,
db
);
tNameGetFullDbName
(
pTableName
,
db
);
SDBVgInfo
*
vgInfo
=
NULL
;
SDBVgInfo
*
vgInfo
=
NULL
;
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
db
,
&
dbCache
,
&
vgInfo
));
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
db
,
&
dbCache
,
&
vgInfo
));
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pCtg
,
vgInfo
?
vgInfo
:
dbCache
->
vgCache
.
vgInfo
,
pTableName
,
pVgroup
));
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pCtg
,
vgInfo
?
vgInfo
:
dbCache
->
vgCache
.
vgInfo
,
pTableName
,
pVgroup
));
...
@@ -539,7 +542,6 @@ _return:
...
@@ -539,7 +542,6 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
catalogInit
(
SCatalogCfg
*
cfg
)
{
int32_t
catalogInit
(
SCatalogCfg
*
cfg
)
{
if
(
gCtgMgmt
.
pCluster
)
{
if
(
gCtgMgmt
.
pCluster
)
{
qError
(
"catalog already initialized"
);
qError
(
"catalog already initialized"
);
...
@@ -648,7 +650,8 @@ int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) {
...
@@ -648,7 +650,8 @@ int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) {
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
}
clusterCtg
->
userCache
=
taosHashInit
(
gCtgMgmt
.
cfg
.
maxUserCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_ENTRY_LOCK
);
clusterCtg
->
userCache
=
taosHashInit
(
gCtgMgmt
.
cfg
.
maxUserCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
clusterCtg
->
userCache
)
{
if
(
NULL
==
clusterCtg
->
userCache
)
{
qError
(
"taosHashInit %d user cache failed"
,
gCtgMgmt
.
cfg
.
maxUserCacheNum
);
qError
(
"taosHashInit %d user cache failed"
,
gCtgMgmt
.
cfg
.
maxUserCacheNum
);
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
...
@@ -714,7 +717,7 @@ _return:
...
@@ -714,7 +717,7 @@ _return:
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogGetDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SArray
**
vgroupList
)
{
int32_t
catalogGetDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SArray
**
vgroupList
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
dbFName
||
NULL
==
pConn
||
NULL
==
vgroupList
)
{
if
(
NULL
==
pCtg
||
NULL
==
dbFName
||
NULL
==
pConn
||
NULL
==
vgroupList
)
{
...
@@ -723,9 +726,9 @@ int32_t catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
...
@@ -723,9 +726,9 @@ int32_t catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDBCache
*
dbCache
=
NULL
;
int32_t
code
=
0
;
int32_t
code
=
0
;
SArray
*
vgList
=
NULL
;
SArray
*
vgList
=
NULL
;
SHashObj
*
vgHash
=
NULL
;
SHashObj
*
vgHash
=
NULL
;
SDBVgInfo
*
vgInfo
=
NULL
;
SDBVgInfo
*
vgInfo
=
NULL
;
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
dbFName
,
&
dbCache
,
&
vgInfo
));
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
dbFName
,
&
dbCache
,
&
vgInfo
));
if
(
dbCache
)
{
if
(
dbCache
)
{
vgHash
=
dbCache
->
vgCache
.
vgInfo
->
vgHash
;
vgHash
=
dbCache
->
vgCache
.
vgInfo
->
vgHash
;
...
@@ -808,7 +811,7 @@ _return:
...
@@ -808,7 +811,7 @@ _return:
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogUpdateTableIndex
(
SCatalog
*
pCtg
,
STableIndexRsp
*
pRsp
)
{
int32_t
catalogUpdateTableIndex
(
SCatalog
*
pCtg
,
STableIndexRsp
*
pRsp
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -831,7 +834,6 @@ _return:
...
@@ -831,7 +834,6 @@ _return:
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogRemoveTableMeta
(
SCatalog
*
pCtg
,
SName
*
pTableName
)
{
int32_t
catalogRemoveTableMeta
(
SCatalog
*
pCtg
,
SName
*
pTableName
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
...
@@ -860,7 +862,7 @@ _return:
...
@@ -860,7 +862,7 @@ _return:
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogGetTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
int32_t
catalogGetTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
SCtgTbMetaCtx
ctx
=
{
0
};
SCtgTbMetaCtx
ctx
=
{
0
};
...
@@ -870,7 +872,8 @@ int32_t catalogGetTableMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const SName
...
@@ -870,7 +872,8 @@ int32_t catalogGetTableMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const SName
CTG_API_LEAVE
(
ctgGetTbMeta
(
pCtg
,
pConn
,
&
ctx
,
pTableMeta
));
CTG_API_LEAVE
(
ctgGetTbMeta
(
pCtg
,
pConn
,
&
ctx
,
pTableMeta
));
}
}
int32_t
catalogGetSTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
int32_t
catalogGetSTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
SCtgTbMetaCtx
ctx
=
{
0
};
SCtgTbMetaCtx
ctx
=
{
0
};
...
@@ -895,7 +898,7 @@ _return:
...
@@ -895,7 +898,7 @@ _return:
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogChkTbMetaVersion
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SArray
*
pTables
)
{
int32_t
catalogChkTbMetaVersion
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SArray
*
pTables
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTables
)
{
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTables
)
{
...
@@ -944,7 +947,7 @@ int32_t catalogChkTbMetaVersion(SCatalog* pCtg, SRequestConnInfo *pConn, SArray*
...
@@ -944,7 +947,7 @@ int32_t catalogChkTbMetaVersion(SCatalog* pCtg, SRequestConnInfo *pConn, SArray*
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
}
}
int32_t
catalogRefreshDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
)
{
int32_t
catalogRefreshDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
dbFName
)
{
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
dbFName
)
{
...
@@ -954,7 +957,7 @@ int32_t catalogRefreshDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const ch
...
@@ -954,7 +957,7 @@ int32_t catalogRefreshDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const ch
CTG_API_LEAVE
(
ctgRefreshDBVgInfo
(
pCtg
,
pConn
,
dbFName
));
CTG_API_LEAVE
(
ctgRefreshDBVgInfo
(
pCtg
,
pConn
,
dbFName
));
}
}
int32_t
catalogRefreshTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
int32_t
isSTable
)
{
int32_t
catalogRefreshTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
int32_t
isSTable
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTableName
)
{
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTableName
)
{
...
@@ -968,7 +971,8 @@ int32_t catalogRefreshTableMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const S
...
@@ -968,7 +971,8 @@ int32_t catalogRefreshTableMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const S
CTG_API_LEAVE
(
ctgRefreshTbMeta
(
pCtg
,
pConn
,
&
ctx
,
NULL
,
true
));
CTG_API_LEAVE
(
ctgRefreshTbMeta
(
pCtg
,
pConn
,
&
ctx
,
NULL
,
true
));
}
}
int32_t
catalogRefreshGetTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
isSTable
)
{
int32_t
catalogRefreshGetTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
isSTable
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
SCtgTbMetaCtx
ctx
=
{
0
};
SCtgTbMetaCtx
ctx
=
{
0
};
...
@@ -978,7 +982,7 @@ int32_t catalogRefreshGetTableMeta(SCatalog* pCtg, SRequestConnInfo *pConn, cons
...
@@ -978,7 +982,7 @@ int32_t catalogRefreshGetTableMeta(SCatalog* pCtg, SRequestConnInfo *pConn, cons
CTG_API_LEAVE
(
ctgGetTbMeta
(
pCtg
,
pConn
,
&
ctx
,
pTableMeta
));
CTG_API_LEAVE
(
ctgGetTbMeta
(
pCtg
,
pConn
,
&
ctx
,
pTableMeta
));
}
}
int32_t
catalogGetTableDistVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pVgList
)
{
int32_t
catalogGetTableDistVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pVgList
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTableName
||
NULL
==
pVgList
)
{
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTableName
||
NULL
==
pVgList
)
{
...
@@ -993,13 +997,14 @@ int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const
...
@@ -993,13 +997,14 @@ int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const
CTG_API_LEAVE
(
ctgGetTbDistVgInfo
(
pCtg
,
pConn
,
(
SName
*
)
pTableName
,
pVgList
));
CTG_API_LEAVE
(
ctgGetTbDistVgInfo
(
pCtg
,
pConn
,
(
SName
*
)
pTableName
,
pVgList
));
}
}
int32_t
catalogGetTableHashVgroup
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
)
{
int32_t
catalogGetTableHashVgroup
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
CTG_API_LEAVE
(
ctgGetTbHashVgroup
(
pCtg
,
pConn
,
pTableName
,
pVgroup
));
CTG_API_LEAVE
(
ctgGetTbHashVgroup
(
pCtg
,
pConn
,
pTableName
,
pVgroup
));
}
}
int32_t
catalogGetAllMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SCatalogReq
*
pReq
,
SMetaData
*
pRsp
)
{
int32_t
catalogGetAllMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SCatalogReq
*
pReq
,
SMetaData
*
pRsp
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pReq
||
NULL
==
pRsp
)
{
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pReq
||
NULL
==
pRsp
)
{
...
@@ -1062,7 +1067,8 @@ _return:
...
@@ -1062,7 +1067,8 @@ _return:
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogAsyncGetAllMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SCatalogReq
*
pReq
,
catalogCallback
fp
,
void
*
param
,
int64_t
*
jobId
)
{
int32_t
catalogAsyncGetAllMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SCatalogReq
*
pReq
,
catalogCallback
fp
,
void
*
param
,
int64_t
*
jobId
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pReq
||
NULL
==
fp
||
NULL
==
param
)
{
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pReq
||
NULL
==
fp
||
NULL
==
param
)
{
...
@@ -1070,7 +1076,7 @@ int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const SC
...
@@ -1070,7 +1076,7 @@ int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const SC
}
}
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtgJob
*
pJob
=
NULL
;
SCtgJob
*
pJob
=
NULL
;
CTG_ERR_JRET
(
ctgInitJob
(
pCtg
,
pConn
,
&
pJob
,
pReq
,
fp
,
param
));
CTG_ERR_JRET
(
ctgInitJob
(
pCtg
,
pConn
,
&
pJob
,
pReq
,
fp
,
param
));
CTG_ERR_JRET
(
ctgLaunchJob
(
pJob
));
CTG_ERR_JRET
(
ctgLaunchJob
(
pJob
));
...
@@ -1091,7 +1097,7 @@ _return:
...
@@ -1091,7 +1097,7 @@ _return:
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogGetQnodeList
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SArray
*
pQnodeList
)
{
int32_t
catalogGetQnodeList
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SArray
*
pQnodeList
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -1121,14 +1127,14 @@ _return:
...
@@ -1121,14 +1127,14 @@ _return:
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
}
}
int32_t
catalogGetExpiredSTables
(
SCatalog
*
pCtg
,
SSTableVersion
**
stables
,
uint32_t
*
num
)
{
int32_t
catalogGetExpiredSTables
(
SCatalog
*
pCtg
,
SSTableVersion
**
stables
,
uint32_t
*
num
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
stables
||
NULL
==
num
)
{
if
(
NULL
==
pCtg
||
NULL
==
stables
||
NULL
==
num
)
{
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
CTG_API_LEAVE
(
ctgMetaRentGet
(
&
pCtg
->
stbRent
,
(
void
**
)
stables
,
num
,
sizeof
(
SSTableVersion
)));
CTG_API_LEAVE
(
ctgMetaRentGet
(
&
pCtg
->
stbRent
,
(
void
**
)
stables
,
num
,
sizeof
(
SSTableVersion
)));
}
}
int32_t
catalogGetExpiredDBs
(
SCatalog
*
pCtg
,
SDbVgVersion
**
dbs
,
uint32_t
*
num
)
{
int32_t
catalogGetExpiredDBs
(
SCatalog
*
pCtg
,
SDbVgVersion
**
dbs
,
uint32_t
*
num
)
{
...
@@ -1179,7 +1185,7 @@ int32_t catalogGetExpiredUsers(SCatalog* pCtg, SUserAuthVersion** users, uint32_
...
@@ -1179,7 +1185,7 @@ int32_t catalogGetExpiredUsers(SCatalog* pCtg, SUserAuthVersion** users, uint32_
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
}
}
int32_t
catalogGetDBCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SDbCfgInfo
*
pDbCfg
)
{
int32_t
catalogGetDBCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SDbCfgInfo
*
pDbCfg
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
dbFName
||
NULL
==
pDbCfg
)
{
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
dbFName
||
NULL
==
pDbCfg
)
{
...
@@ -1189,7 +1195,7 @@ int32_t catalogGetDBCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const char* dbF
...
@@ -1189,7 +1195,7 @@ int32_t catalogGetDBCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const char* dbF
CTG_API_LEAVE
(
ctgGetDBCfgFromMnode
(
pCtg
,
pConn
,
dbFName
,
pDbCfg
,
NULL
));
CTG_API_LEAVE
(
ctgGetDBCfgFromMnode
(
pCtg
,
pConn
,
dbFName
,
pDbCfg
,
NULL
));
}
}
int32_t
catalogGetIndexMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
indexName
,
SIndexInfo
*
pInfo
)
{
int32_t
catalogGetIndexMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
indexName
,
SIndexInfo
*
pInfo
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
indexName
||
NULL
==
pInfo
)
{
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
indexName
||
NULL
==
pInfo
)
{
...
@@ -1199,7 +1205,7 @@ int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
...
@@ -1199,7 +1205,7 @@ int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
CTG_API_LEAVE
(
ctgGetIndexInfoFromMnode
(
pCtg
,
pConn
,
indexName
,
pInfo
,
NULL
));
CTG_API_LEAVE
(
ctgGetIndexInfoFromMnode
(
pCtg
,
pConn
,
indexName
,
pInfo
,
NULL
));
}
}
int32_t
catalogGetTableIndex
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pRes
)
{
int32_t
catalogGetTableIndex
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pRes
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTableName
||
NULL
==
pRes
)
{
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTableName
||
NULL
==
pRes
)
{
...
@@ -1214,7 +1220,7 @@ _return:
...
@@ -1214,7 +1220,7 @@ _return:
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogRefreshGetTableCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableCfg
**
pCfg
)
{
int32_t
catalogRefreshGetTableCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableCfg
**
pCfg
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTableName
||
NULL
==
pCfg
)
{
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTableName
||
NULL
==
pCfg
)
{
...
@@ -1231,7 +1237,7 @@ _return:
...
@@ -1231,7 +1237,7 @@ _return:
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogGetUdfInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
pInfo
)
{
int32_t
catalogGetUdfInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
pInfo
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
funcName
||
NULL
==
pInfo
)
{
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
funcName
||
NULL
==
pInfo
)
{
...
@@ -1246,7 +1252,8 @@ _return:
...
@@ -1246,7 +1252,8 @@ _return:
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
)
{
int32_t
catalogChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
user
||
NULL
==
dbFName
||
NULL
==
pass
)
{
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
user
||
NULL
==
dbFName
||
NULL
==
pass
)
{
...
@@ -1261,7 +1268,7 @@ _return:
...
@@ -1261,7 +1268,7 @@ _return:
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogGetServerVersion
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
char
**
pVersion
)
{
int32_t
catalogGetServerVersion
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
char
**
pVersion
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pVersion
)
{
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pVersion
)
{
...
@@ -1276,7 +1283,6 @@ _return:
...
@@ -1276,7 +1283,6 @@ _return:
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogUpdateUserAuthInfo
(
SCatalog
*
pCtg
,
SGetUserAuthRsp
*
pAuth
)
{
int32_t
catalogUpdateUserAuthInfo
(
SCatalog
*
pCtg
,
SGetUserAuthRsp
*
pAuth
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
...
@@ -1303,7 +1309,6 @@ int32_t catalogClearCache(void) {
...
@@ -1303,7 +1309,6 @@ int32_t catalogClearCache(void) {
CTG_API_LEAVE_NOLOCK
(
code
);
CTG_API_LEAVE_NOLOCK
(
code
);
}
}
void
catalogDestroy
(
void
)
{
void
catalogDestroy
(
void
)
{
qInfo
(
"start to destroy catalog"
);
qInfo
(
"start to destroy catalog"
);
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
d5255f1e
...
@@ -636,7 +636,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
...
@@ -636,7 +636,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
taosAcquireRef
(
gCtgMgmt
.
jobPool
,
pJob
->
refId
);
taosAcquireRef
(
gCtgMgmt
.
jobPool
,
pJob
->
refId
);
double
el
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
double
el
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
qDebug
(
"QID:0x%"
PRIx64
", jobId: 0x%"
PRIx64
" initialized, task num %d, forceUpdate %d, elapsed time:%.2f ms"
,
qDebug
(
"QID:0x%"
PRIx64
", jobId: 0x%"
PRIx64
" initialized, task num %d, forceUpdate %d, elapsed time:%.2f ms"
,
pJob
->
queryId
,
pJob
->
refId
,
taskNum
,
pReq
->
forceUpdate
,
el
);
pJob
->
queryId
,
pJob
->
refId
,
taskNum
,
pReq
->
forceUpdate
,
el
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/catalog/src/ctgDbg.c
浏览文件 @
d5255f1e
...
@@ -13,16 +13,16 @@
...
@@ -13,16 +13,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
trpc
.h"
#include "
catalogInt
.h"
#include "query.h"
#include "query.h"
#include "tname.h"
#include "tname.h"
#include "
catalogInt
.h"
#include "
trpc
.h"
extern
SCatalogMgmt
gCtgMgmt
;
extern
SCatalogMgmt
gCtgMgmt
;
SCtgDebug
gCTGDebug
=
{
0
};
SCtgDebug
gCTGDebug
=
{
0
};
void
ctgdUserCallback
(
SMetaData
*
pResult
,
void
*
param
,
int32_t
code
)
{
void
ctgdUserCallback
(
SMetaData
*
pResult
,
void
*
param
,
int32_t
code
)
{
ASSERT
(
*
(
int32_t
*
)
param
==
1
);
ASSERT
(
*
(
int32_t
*
)
param
==
1
);
taosMemoryFree
(
param
);
taosMemoryFree
(
param
);
qDebug
(
"async call result: %s"
,
tstrerror
(
code
));
qDebug
(
"async call result: %s"
,
tstrerror
(
code
));
...
@@ -40,10 +40,13 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
...
@@ -40,10 +40,13 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
STableComInfo
*
c
=
&
p
->
tableInfo
;
STableComInfo
*
c
=
&
p
->
tableInfo
;
if
(
TSDB_CHILD_TABLE
==
p
->
tableType
)
{
if
(
TSDB_CHILD_TABLE
==
p
->
tableType
)
{
qDebug
(
"table meta: type:%d, vgId:%d, uid:0x%"
PRIx64
",suid:0x%"
PRIx64
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
);
qDebug
(
"table meta: type:%d, vgId:%d, uid:0x%"
PRIx64
",suid:0x%"
PRIx64
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
);
}
else
{
}
else
{
qDebug
(
"table meta: type:%d, vgId:%d, uid:0x%"
PRIx64
",suid:0x%"
PRIx64
",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d"
,
qDebug
(
"table meta: type:%d, vgId:%d, uid:0x%"
PRIx64
",suid:0x%"
PRIx64
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
,
p
->
sversion
,
p
->
tversion
,
c
->
numOfTags
,
c
->
precision
,
c
->
numOfColumns
,
c
->
rowSize
);
",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d"
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
,
p
->
sversion
,
p
->
tversion
,
c
->
numOfTags
,
c
->
precision
,
c
->
numOfColumns
,
c
->
rowSize
);
}
}
int32_t
colNum
=
c
->
numOfColumns
+
c
->
numOfTags
;
int32_t
colNum
=
c
->
numOfColumns
+
c
->
numOfTags
;
...
@@ -59,11 +62,11 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
...
@@ -59,11 +62,11 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
if
(
pResult
->
pDbVgroup
&&
taosArrayGetSize
(
pResult
->
pDbVgroup
)
>
0
)
{
if
(
pResult
->
pDbVgroup
&&
taosArrayGetSize
(
pResult
->
pDbVgroup
)
>
0
)
{
num
=
taosArrayGetSize
(
pResult
->
pDbVgroup
);
num
=
taosArrayGetSize
(
pResult
->
pDbVgroup
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SArray
*
pDb
=
*
(
SArray
**
)
taosArrayGet
(
pResult
->
pDbVgroup
,
i
);
SArray
*
pDb
=
*
(
SArray
**
)
taosArrayGet
(
pResult
->
pDbVgroup
,
i
);
int32_t
vgNum
=
taosArrayGetSize
(
pDb
);
int32_t
vgNum
=
taosArrayGetSize
(
pDb
);
qDebug
(
"db %d vgInfo:"
,
i
);
qDebug
(
"db %d vgInfo:"
,
i
);
for
(
int32_t
j
=
0
;
j
<
vgNum
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
vgNum
;
++
j
)
{
SVgroupInfo
*
pInfo
=
taosArrayGet
(
pDb
,
j
);
SVgroupInfo
*
pInfo
=
taosArrayGet
(
pDb
,
j
);
qDebug
(
"vg :%d info: vgId:%d"
,
j
,
pInfo
->
vgId
);
qDebug
(
"vg :%d info: vgId:%d"
,
j
,
pInfo
->
vgId
);
}
}
}
}
...
@@ -84,7 +87,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
...
@@ -84,7 +87,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
if
(
pResult
->
pTableHash
&&
taosArrayGetSize
(
pResult
->
pTableHash
)
>
0
)
{
if
(
pResult
->
pTableHash
&&
taosArrayGetSize
(
pResult
->
pTableHash
)
>
0
)
{
num
=
taosArrayGetSize
(
pResult
->
pTableHash
);
num
=
taosArrayGetSize
(
pResult
->
pTableHash
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SVgroupInfo
*
pInfo
=
taosArrayGet
(
pResult
->
pTableHash
,
i
);
SVgroupInfo
*
pInfo
=
taosArrayGet
(
pResult
->
pTableHash
,
i
);
qDebug
(
"table %d vg info: vgId:%d"
,
i
,
pInfo
->
vgId
);
qDebug
(
"table %d vg info: vgId:%d"
,
i
,
pInfo
->
vgId
);
}
}
}
else
{
}
else
{
...
@@ -94,7 +97,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
...
@@ -94,7 +97,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
if
(
pResult
->
pUdfList
&&
taosArrayGetSize
(
pResult
->
pUdfList
)
>
0
)
{
if
(
pResult
->
pUdfList
&&
taosArrayGetSize
(
pResult
->
pUdfList
)
>
0
)
{
num
=
taosArrayGetSize
(
pResult
->
pUdfList
);
num
=
taosArrayGetSize
(
pResult
->
pUdfList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SFuncInfo
*
pInfo
=
taosArrayGet
(
pResult
->
pUdfList
,
i
);
SFuncInfo
*
pInfo
=
taosArrayGet
(
pResult
->
pUdfList
,
i
);
qDebug
(
"udf %d info: name:%s, funcType:%d"
,
i
,
pInfo
->
name
,
pInfo
->
funcType
);
qDebug
(
"udf %d info: name:%s, funcType:%d"
,
i
,
pInfo
->
name
,
pInfo
->
funcType
);
}
}
}
else
{
}
else
{
...
@@ -104,7 +107,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
...
@@ -104,7 +107,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
if
(
pResult
->
pDbCfg
&&
taosArrayGetSize
(
pResult
->
pDbCfg
)
>
0
)
{
if
(
pResult
->
pDbCfg
&&
taosArrayGetSize
(
pResult
->
pDbCfg
)
>
0
)
{
num
=
taosArrayGetSize
(
pResult
->
pDbCfg
);
num
=
taosArrayGetSize
(
pResult
->
pDbCfg
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SDbCfgInfo
*
pInfo
=
taosArrayGet
(
pResult
->
pDbCfg
,
i
);
SDbCfgInfo
*
pInfo
=
taosArrayGet
(
pResult
->
pDbCfg
,
i
);
qDebug
(
"db %d info: numOFVgroups:%d, numOfStables:%d"
,
i
,
pInfo
->
numOfVgroups
,
pInfo
->
numOfStables
);
qDebug
(
"db %d info: numOFVgroups:%d, numOfStables:%d"
,
i
,
pInfo
->
numOfVgroups
,
pInfo
->
numOfStables
);
}
}
}
else
{
}
else
{
...
@@ -114,7 +117,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
...
@@ -114,7 +117,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
if
(
pResult
->
pUser
&&
taosArrayGetSize
(
pResult
->
pUser
)
>
0
)
{
if
(
pResult
->
pUser
&&
taosArrayGetSize
(
pResult
->
pUser
)
>
0
)
{
num
=
taosArrayGetSize
(
pResult
->
pUser
);
num
=
taosArrayGetSize
(
pResult
->
pUser
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
bool
*
auth
=
taosArrayGet
(
pResult
->
pUser
,
i
);
bool
*
auth
=
taosArrayGet
(
pResult
->
pUser
,
i
);
qDebug
(
"user auth %d info: %d"
,
i
,
*
auth
);
qDebug
(
"user auth %d info: %d"
,
i
,
*
auth
);
}
}
}
else
{
}
else
{
...
@@ -124,7 +127,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
...
@@ -124,7 +127,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
if
(
pResult
->
pQnodeList
&&
taosArrayGetSize
(
pResult
->
pQnodeList
)
>
0
)
{
if
(
pResult
->
pQnodeList
&&
taosArrayGetSize
(
pResult
->
pQnodeList
)
>
0
)
{
num
=
taosArrayGetSize
(
pResult
->
pQnodeList
);
num
=
taosArrayGetSize
(
pResult
->
pQnodeList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SQueryNodeAddr
*
qaddr
=
taosArrayGet
(
pResult
->
pQnodeList
,
i
);
SQueryNodeAddr
*
qaddr
=
taosArrayGet
(
pResult
->
pQnodeList
,
i
);
qDebug
(
"qnode %d info: id:%d"
,
i
,
qaddr
->
nodeId
);
qDebug
(
"qnode %d info: id:%d"
,
i
,
qaddr
->
nodeId
);
}
}
}
else
{
}
else
{
...
@@ -132,7 +135,6 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
...
@@ -132,7 +135,6 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
}
}
}
}
/*
/*
prepare SQL:
prepare SQL:
create database db1;
create database db1;
...
@@ -147,7 +149,7 @@ grant write on db2.* to user1;
...
@@ -147,7 +149,7 @@ grant write on db2.* to user1;
create function udf1 as '/tmp/libudf1.so' outputtype int;
create function udf1 as '/tmp/libudf1.so' outputtype int;
create aggregate function udf2 as '/tmp/libudf2.so' outputtype int;
create aggregate function udf2 as '/tmp/libudf2.so' outputtype int;
*/
*/
int32_t
ctgdLaunchAsyncCall
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
uint64_t
reqId
,
bool
forceUpdate
)
{
int32_t
ctgdLaunchAsyncCall
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
uint64_t
reqId
,
bool
forceUpdate
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
req
.
pTableMeta
=
taosArrayInit
(
2
,
sizeof
(
SName
));
req
.
pTableMeta
=
taosArrayInit
(
2
,
sizeof
(
SName
));
...
@@ -156,7 +158,7 @@ int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t re
...
@@ -156,7 +158,7 @@ int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t re
req
.
pTableHash
=
taosArrayInit
(
2
,
sizeof
(
SName
));
req
.
pTableHash
=
taosArrayInit
(
2
,
sizeof
(
SName
));
req
.
pUdf
=
taosArrayInit
(
2
,
TSDB_FUNC_NAME_LEN
);
req
.
pUdf
=
taosArrayInit
(
2
,
TSDB_FUNC_NAME_LEN
);
req
.
pDbCfg
=
taosArrayInit
(
2
,
TSDB_DB_FNAME_LEN
);
req
.
pDbCfg
=
taosArrayInit
(
2
,
TSDB_DB_FNAME_LEN
);
req
.
pIndex
=
NULL
;
//
taosArrayInit(2, TSDB_INDEX_FNAME_LEN);
req
.
pIndex
=
NULL
;
//
taosArrayInit(2, TSDB_INDEX_FNAME_LEN);
req
.
pUser
=
taosArrayInit
(
2
,
sizeof
(
SUserAuthInfo
));
req
.
pUser
=
taosArrayInit
(
2
,
sizeof
(
SUserAuthInfo
));
req
.
qNodeRequired
=
true
;
req
.
qNodeRequired
=
true
;
req
.
forceUpdate
=
forceUpdate
;
req
.
forceUpdate
=
forceUpdate
;
...
@@ -287,7 +289,7 @@ int32_t ctgdGetRentNum(SCtgRentMgmt *rent) {
...
@@ -287,7 +289,7 @@ int32_t ctgdGetRentNum(SCtgRentMgmt *rent) {
return
num
;
return
num
;
}
}
int32_t
ctgdGetClusterCacheNum
(
SCatalog
*
pCtg
,
int32_t
type
)
{
int32_t
ctgdGetClusterCacheNum
(
SCatalog
*
pCtg
,
int32_t
type
)
{
if
(
NULL
==
pCtg
||
NULL
==
pCtg
->
dbCache
)
{
if
(
NULL
==
pCtg
||
NULL
==
pCtg
->
dbCache
)
{
return
0
;
return
0
;
}
}
...
@@ -325,7 +327,7 @@ int32_t ctgdGetClusterCacheNum(SCatalog* pCtg, int32_t type) {
...
@@ -325,7 +327,7 @@ int32_t ctgdGetClusterCacheNum(SCatalog* pCtg, int32_t type) {
return
num
;
return
num
;
}
}
void
ctgdShowTableMeta
(
SCatalog
*
pCtg
,
const
char
*
tbName
,
STableMeta
*
p
)
{
void
ctgdShowTableMeta
(
SCatalog
*
pCtg
,
const
char
*
tbName
,
STableMeta
*
p
)
{
if
(
!
gCTGDebug
.
metaEnable
)
{
if
(
!
gCTGDebug
.
metaEnable
)
{
return
;
return
;
}
}
...
@@ -333,11 +335,14 @@ void ctgdShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) {
...
@@ -333,11 +335,14 @@ void ctgdShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) {
STableComInfo
*
c
=
&
p
->
tableInfo
;
STableComInfo
*
c
=
&
p
->
tableInfo
;
if
(
TSDB_CHILD_TABLE
==
p
->
tableType
)
{
if
(
TSDB_CHILD_TABLE
==
p
->
tableType
)
{
ctgDebug
(
"table [%s] meta: type:%d, vgId:%d, uid:0x%"
PRIx64
",suid:0x%"
PRIx64
,
tbName
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
);
ctgDebug
(
"table [%s] meta: type:%d, vgId:%d, uid:0x%"
PRIx64
",suid:0x%"
PRIx64
,
tbName
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
);
return
;
return
;
}
else
{
}
else
{
ctgDebug
(
"table [%s] meta: type:%d, vgId:%d, uid:0x%"
PRIx64
",suid:0x%"
PRIx64
",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d"
,
ctgDebug
(
"table [%s] meta: type:%d, vgId:%d, uid:0x%"
PRIx64
",suid:0x%"
PRIx64
tbName
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
,
p
->
sversion
,
p
->
tversion
,
c
->
numOfTags
,
c
->
precision
,
c
->
numOfColumns
,
c
->
rowSize
);
",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d"
,
tbName
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
,
p
->
sversion
,
p
->
tversion
,
c
->
numOfTags
,
c
->
precision
,
c
->
numOfColumns
,
c
->
rowSize
);
}
}
int32_t
colNum
=
c
->
numOfColumns
+
c
->
numOfTags
;
int32_t
colNum
=
c
->
numOfColumns
+
c
->
numOfTags
;
...
@@ -347,7 +352,7 @@ void ctgdShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) {
...
@@ -347,7 +352,7 @@ void ctgdShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) {
}
}
}
}
void
ctgdShowDBCache
(
SCatalog
*
pCtg
,
SHashObj
*
dbHash
)
{
void
ctgdShowDBCache
(
SCatalog
*
pCtg
,
SHashObj
*
dbHash
)
{
if
(
NULL
==
dbHash
||
!
gCTGDebug
.
cacheEnable
)
{
if
(
NULL
==
dbHash
||
!
gCTGDebug
.
cacheEnable
)
{
return
;
return
;
}
}
...
@@ -381,28 +386,28 @@ void ctgdShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
...
@@ -381,28 +386,28 @@ void ctgdShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
}
}
}
}
ctgDebug
(
"[%d] db [%.*s][0x%"
PRIx64
"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, prefix:%d, suffix:%d, vgNum:%d"
,
ctgDebug
(
"[%d] db [%.*s][0x%"
PRIx64
i
,
(
int32_t
)
len
,
dbFName
,
dbCache
->
dbId
,
dbCache
->
deleted
?
"deleted"
:
""
,
metaNum
,
stbNum
,
vgVersion
,
hashMethod
,
hashPrefix
,
hashSuffix
,
vgNum
);
"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, prefix:%d, suffix:%d, vgNum:%d"
,
i
,
(
int32_t
)
len
,
dbFName
,
dbCache
->
dbId
,
dbCache
->
deleted
?
"deleted"
:
""
,
metaNum
,
stbNum
,
vgVersion
,
hashMethod
,
hashPrefix
,
hashSuffix
,
vgNum
);
pIter
=
taosHashIterate
(
dbHash
,
pIter
);
pIter
=
taosHashIterate
(
dbHash
,
pIter
);
}
}
}
}
void
ctgdShowClusterCache
(
SCatalog
*
pCtg
)
{
void
ctgdShowClusterCache
(
SCatalog
*
pCtg
)
{
if
(
!
gCTGDebug
.
cacheEnable
||
NULL
==
pCtg
)
{
if
(
!
gCTGDebug
.
cacheEnable
||
NULL
==
pCtg
)
{
return
;
return
;
}
}
ctgDebug
(
"## cluster 0x%"
PRIx64
" %p cache Info BEGIN ##"
,
pCtg
->
clusterId
,
pCtg
);
ctgDebug
(
"## cluster 0x%"
PRIx64
" %p cache Info BEGIN ##"
,
pCtg
->
clusterId
,
pCtg
);
ctgDebug
(
"db:%d meta:%d stb:%d dbRent:%d stbRent:%d"
,
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
),
ctgDebug
(
"db:%d meta:%d stb:%d dbRent:%d stbRent:%d"
,
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_RENT_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_RENT_NUM
));
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_RENT_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_RENT_NUM
));
ctgdShowDBCache
(
pCtg
,
pCtg
->
dbCache
);
ctgdShowDBCache
(
pCtg
,
pCtg
->
dbCache
);
ctgDebug
(
"## cluster 0x%"
PRIx64
" %p cache Info END ##"
,
pCtg
->
clusterId
,
pCtg
);
ctgDebug
(
"## cluster 0x%"
PRIx64
" %p cache Info END ##"
,
pCtg
->
clusterId
,
pCtg
);
}
}
int32_t
ctgdShowCacheInfo
(
void
)
{
int32_t
ctgdShowCacheInfo
(
void
)
{
...
@@ -428,4 +433,3 @@ int32_t ctgdShowCacheInfo(void) {
...
@@ -428,4 +433,3 @@ int32_t ctgdShowCacheInfo(void) {
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
}
}
source/libs/catalog/src/ctgUtil.c
浏览文件 @
d5255f1e
此差异已折叠。
点击以展开。
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
d5255f1e
...
@@ -27,20 +27,20 @@
...
@@ -27,20 +27,20 @@
#ifdef WINDOWS
#ifdef WINDOWS
#define TD_USE_WINSOCK
#define TD_USE_WINSOCK
#endif
#endif
#include "os.h"
#include "tglobal.h"
#include "catalog.h"
#include "catalog.h"
#include "catalogInt.h"
#include "catalogInt.h"
#include "os.h"
#include "stub.h"
#include "stub.h"
#include "taos.h"
#include "taos.h"
#include "tdatablock.h"
#include "tdatablock.h"
#include "tdef.h"
#include "tdef.h"
#include "tglobal.h"
#include "trpc.h"
#include "trpc.h"
#include "tvariant.h"
#include "tvariant.h"
namespace
{
namespace
{
extern
"C"
int32_t
ctgdGetClusterCacheNum
(
struct
SCatalog
*
pCatalog
,
int32_t
type
);
extern
"C"
int32_t
ctgdGetClusterCacheNum
(
struct
SCatalog
*
pCatalog
,
int32_t
type
);
extern
"C"
int32_t
ctgdEnableDebug
(
char
*
option
);
extern
"C"
int32_t
ctgdEnableDebug
(
char
*
option
);
extern
"C"
int32_t
ctgdGetStatNum
(
char
*
option
,
void
*
res
);
extern
"C"
int32_t
ctgdGetStatNum
(
char
*
option
,
void
*
res
);
...
@@ -49,7 +49,7 @@ void ctgTestSetRspCTableMeta();
...
@@ -49,7 +49,7 @@ void ctgTestSetRspCTableMeta();
void
ctgTestSetRspSTableMeta
();
void
ctgTestSetRspSTableMeta
();
void
ctgTestSetRspMultiSTableMeta
();
void
ctgTestSetRspMultiSTableMeta
();
//extern "C" SCatalogMgmt gCtgMgmt;
//
extern "C" SCatalogMgmt gCtgMgmt;
enum
{
enum
{
CTGT_RSP_VGINFO
=
1
,
CTGT_RSP_VGINFO
=
1
,
...
@@ -153,11 +153,11 @@ int32_t ctgTestGetVgNumFromVgVersion(int32_t vgVersion) {
...
@@ -153,11 +153,11 @@ int32_t ctgTestGetVgNumFromVgVersion(int32_t vgVersion) {
}
}
void
ctgTestBuildCTableMetaOutput
(
STableMetaOutput
*
output
)
{
void
ctgTestBuildCTableMetaOutput
(
STableMetaOutput
*
output
)
{
SName
cn
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
cn
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
cn
.
dbname
,
"db1"
);
strcpy
(
cn
.
dbname
,
"db1"
);
strcpy
(
cn
.
tname
,
ctgTestCTablename
);
strcpy
(
cn
.
tname
,
ctgTestCTablename
);
SName
sn
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
sn
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
sn
.
dbname
,
"db1"
);
strcpy
(
sn
.
dbname
,
"db1"
);
strcpy
(
sn
.
tname
,
ctgTestSTablename
);
strcpy
(
sn
.
tname
,
ctgTestSTablename
);
...
@@ -175,7 +175,8 @@ void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) {
...
@@ -175,7 +175,8 @@ void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) {
output
->
ctbMeta
.
uid
=
3
;
output
->
ctbMeta
.
uid
=
3
;
output
->
ctbMeta
.
suid
=
2
;
output
->
ctbMeta
.
suid
=
2
;
output
->
tbMeta
=
(
STableMeta
*
)
taosMemoryCalloc
(
1
,
sizeof
(
STableMeta
)
+
sizeof
(
SSchema
)
*
(
ctgTestColNum
+
ctgTestColNum
));
output
->
tbMeta
=
(
STableMeta
*
)
taosMemoryCalloc
(
1
,
sizeof
(
STableMeta
)
+
sizeof
(
SSchema
)
*
(
ctgTestColNum
+
ctgTestColNum
));
output
->
tbMeta
->
vgId
=
9
;
output
->
tbMeta
->
vgId
=
9
;
output
->
tbMeta
->
tableType
=
TSDB_SUPER_TABLE
;
output
->
tbMeta
->
tableType
=
TSDB_SUPER_TABLE
;
output
->
tbMeta
->
uid
=
2
;
output
->
tbMeta
->
uid
=
2
;
...
@@ -364,7 +365,6 @@ void ctgTestRspTableMetaNotExist(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, S
...
@@ -364,7 +365,6 @@ void ctgTestRspTableMetaNotExist(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, S
pRsp
->
code
=
CTG_ERR_CODE_TABLE_NOT_EXIST
;
pRsp
->
code
=
CTG_ERR_CODE_TABLE_NOT_EXIST
;
}
}
void
ctgTestRspCTableMeta
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
void
ctgTestRspCTableMeta
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
STableMetaRsp
metaRsp
=
{
0
};
STableMetaRsp
metaRsp
=
{
0
};
strcpy
(
metaRsp
.
dbFName
,
ctgTestDbname
);
strcpy
(
metaRsp
.
dbFName
,
ctgTestDbname
);
...
@@ -574,7 +574,7 @@ void ctgTestSetRspDbVgroups() {
...
@@ -574,7 +574,7 @@ void ctgTestSetRspDbVgroups() {
{
{
#ifdef WINDOWS
#ifdef WINDOWS
AddrAny
any
;
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#endif
#ifdef LINUX
#ifdef LINUX
...
@@ -594,7 +594,7 @@ void ctgTestSetRspTableMeta() {
...
@@ -594,7 +594,7 @@ void ctgTestSetRspTableMeta() {
{
{
#ifdef WINDOWS
#ifdef WINDOWS
AddrAny
any
;
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#endif
#ifdef LINUX
#ifdef LINUX
...
@@ -614,7 +614,7 @@ void ctgTestSetRspCTableMeta() {
...
@@ -614,7 +614,7 @@ void ctgTestSetRspCTableMeta() {
{
{
#ifdef WINDOWS
#ifdef WINDOWS
AddrAny
any
;
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#endif
#ifdef LINUX
#ifdef LINUX
...
@@ -634,7 +634,7 @@ void ctgTestSetRspSTableMeta() {
...
@@ -634,7 +634,7 @@ void ctgTestSetRspSTableMeta() {
{
{
#ifdef WINDOWS
#ifdef WINDOWS
AddrAny
any
;
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#endif
#ifdef LINUX
#ifdef LINUX
...
@@ -654,7 +654,7 @@ void ctgTestSetRspMultiSTableMeta() {
...
@@ -654,7 +654,7 @@ void ctgTestSetRspMultiSTableMeta() {
{
{
#ifdef WINDOWS
#ifdef WINDOWS
AddrAny
any
;
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#endif
#ifdef LINUX
#ifdef LINUX
...
@@ -674,7 +674,7 @@ void ctgTestSetRspByIdx() {
...
@@ -674,7 +674,7 @@ void ctgTestSetRspByIdx() {
{
{
#ifdef WINDOWS
#ifdef WINDOWS
AddrAny
any
;
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#endif
#ifdef LINUX
#ifdef LINUX
...
@@ -688,14 +688,13 @@ void ctgTestSetRspByIdx() {
...
@@ -688,14 +688,13 @@ void ctgTestSetRspByIdx() {
}
}
}
}
void
ctgTestSetRspDbVgroupsAndNormalMeta
()
{
void
ctgTestSetRspDbVgroupsAndNormalMeta
()
{
static
Stub
stub
;
static
Stub
stub
;
stub
.
set
(
rpcSendRecv
,
ctgTestRspDbVgroupsAndNormalMeta
);
stub
.
set
(
rpcSendRecv
,
ctgTestRspDbVgroupsAndNormalMeta
);
{
{
#ifdef WINDOWS
#ifdef WINDOWS
AddrAny
any
;
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#endif
#ifdef LINUX
#ifdef LINUX
...
@@ -715,7 +714,7 @@ void ctgTestSetRspDbVgroupsAndChildMeta() {
...
@@ -715,7 +714,7 @@ void ctgTestSetRspDbVgroupsAndChildMeta() {
{
{
#ifdef WINDOWS
#ifdef WINDOWS
AddrAny
any
;
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#endif
#ifdef LINUX
#ifdef LINUX
...
@@ -735,7 +734,7 @@ void ctgTestSetRspDbVgroupsAndSuperMeta() {
...
@@ -735,7 +734,7 @@ void ctgTestSetRspDbVgroupsAndSuperMeta() {
{
{
#ifdef WINDOWS
#ifdef WINDOWS
AddrAny
any
;
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#endif
#ifdef LINUX
#ifdef LINUX
...
@@ -755,7 +754,7 @@ void ctgTestSetRspDbVgroupsAndMultiSuperMeta() {
...
@@ -755,7 +754,7 @@ void ctgTestSetRspDbVgroupsAndMultiSuperMeta() {
{
{
#ifdef WINDOWS
#ifdef WINDOWS
AddrAny
any
;
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#endif
#ifdef LINUX
#ifdef LINUX
...
@@ -854,7 +853,7 @@ void *ctgTestGetCtableMetaThread(void *param) {
...
@@ -854,7 +853,7 @@ void *ctgTestGetCtableMetaThread(void *param) {
STableMeta
*
tbMeta
=
NULL
;
STableMeta
*
tbMeta
=
NULL
;
bool
inCache
=
false
;
bool
inCache
=
false
;
SName
cn
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
cn
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
cn
.
dbname
,
"db1"
);
strcpy
(
cn
.
dbname
,
"db1"
);
strcpy
(
cn
.
tname
,
ctgTestCTablename
);
strcpy
(
cn
.
tname
,
ctgTestCTablename
);
...
@@ -920,7 +919,6 @@ void *ctgTestSetCtableMetaThread(void *param) {
...
@@ -920,7 +919,6 @@ void *ctgTestSetCtableMetaThread(void *param) {
#if 1
#if 1
TEST
(
tableMeta
,
normalTable
)
{
TEST
(
tableMeta
,
normalTable
)
{
struct
SCatalog
*
pCtg
=
NULL
;
struct
SCatalog
*
pCtg
=
NULL
;
SRequestConnInfo
*
mockPointer
=
(
SRequestConnInfo
*
)
0x1
;
SRequestConnInfo
*
mockPointer
=
(
SRequestConnInfo
*
)
0x1
;
...
@@ -940,7 +938,7 @@ TEST(tableMeta, normalTable) {
...
@@ -940,7 +938,7 @@ TEST(tableMeta, normalTable) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
...
@@ -977,7 +975,6 @@ TEST(tableMeta, normalTable) {
...
@@ -977,7 +975,6 @@ TEST(tableMeta, normalTable) {
}
}
}
}
tableMeta
=
NULL
;
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
&
n
,
&
tableMeta
);
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
&
n
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
...
@@ -1047,7 +1044,7 @@ TEST(tableMeta, childTableCase) {
...
@@ -1047,7 +1044,7 @@ TEST(tableMeta, childTableCase) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestCTablename
);
strcpy
(
n
.
tname
,
ctgTestCTablename
);
...
@@ -1072,7 +1069,6 @@ TEST(tableMeta, childTableCase) {
...
@@ -1072,7 +1069,6 @@ TEST(tableMeta, childTableCase) {
}
}
}
}
tableMeta
=
NULL
;
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
&
n
,
&
tableMeta
);
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
&
n
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
...
@@ -1154,7 +1150,7 @@ TEST(tableMeta, superTableCase) {
...
@@ -1154,7 +1150,7 @@ TEST(tableMeta, superTableCase) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestSTablename
);
strcpy
(
n
.
tname
,
ctgTestSTablename
);
...
@@ -1181,7 +1177,6 @@ TEST(tableMeta, superTableCase) {
...
@@ -1181,7 +1177,6 @@ TEST(tableMeta, superTableCase) {
}
}
}
}
ctgTestSetRspCTableMeta
();
ctgTestSetRspCTableMeta
();
tableMeta
=
NULL
;
tableMeta
=
NULL
;
...
@@ -1208,7 +1203,6 @@ TEST(tableMeta, superTableCase) {
...
@@ -1208,7 +1203,6 @@ TEST(tableMeta, superTableCase) {
}
}
}
}
tableMeta
=
NULL
;
tableMeta
=
NULL
;
code
=
catalogRefreshGetTableMeta
(
pCtg
,
mockPointer
,
&
n
,
&
tableMeta
,
0
);
code
=
catalogRefreshGetTableMeta
(
pCtg
,
mockPointer
,
&
n
,
&
tableMeta
,
0
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
...
@@ -1279,7 +1273,7 @@ TEST(tableMeta, rmStbMeta) {
...
@@ -1279,7 +1273,7 @@ TEST(tableMeta, rmStbMeta) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestSTablename
);
strcpy
(
n
.
tname
,
ctgTestSTablename
);
...
@@ -1306,7 +1300,6 @@ TEST(tableMeta, rmStbMeta) {
...
@@ -1306,7 +1300,6 @@ TEST(tableMeta, rmStbMeta) {
}
}
}
}
code
=
catalogRemoveStbMeta
(
pCtg
,
"1.db1"
,
ctgTestDbId
,
ctgTestSTablename
,
ctgTestSuid
-
1
);
code
=
catalogRemoveStbMeta
(
pCtg
,
"1.db1"
,
ctgTestDbId
,
ctgTestSTablename
,
ctgTestSuid
-
1
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
...
@@ -1320,7 +1313,6 @@ TEST(tableMeta, rmStbMeta) {
...
@@ -1320,7 +1313,6 @@ TEST(tableMeta, rmStbMeta) {
}
}
}
}
ASSERT_EQ
(
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
),
1
);
ASSERT_EQ
(
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
),
1
);
ASSERT_EQ
(
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
),
0
);
ASSERT_EQ
(
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
),
0
);
ASSERT_EQ
(
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_NUM
),
0
);
ASSERT_EQ
(
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_NUM
),
0
);
...
@@ -1349,7 +1341,7 @@ TEST(tableMeta, updateStbMeta) {
...
@@ -1349,7 +1341,7 @@ TEST(tableMeta, updateStbMeta) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestSTablename
);
strcpy
(
n
.
tname
,
ctgTestSTablename
);
...
@@ -1376,7 +1368,6 @@ TEST(tableMeta, updateStbMeta) {
...
@@ -1376,7 +1368,6 @@ TEST(tableMeta, updateStbMeta) {
}
}
}
}
taosMemoryFreeClear
(
tableMeta
);
taosMemoryFreeClear
(
tableMeta
);
STableMetaRsp
rsp
=
{
0
};
STableMetaRsp
rsp
=
{
0
};
...
@@ -1447,7 +1438,7 @@ TEST(refreshGetMeta, normal2normal) {
...
@@ -1447,7 +1438,7 @@ TEST(refreshGetMeta, normal2normal) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
...
@@ -1526,7 +1517,7 @@ TEST(refreshGetMeta, normal2notexist) {
...
@@ -1526,7 +1517,7 @@ TEST(refreshGetMeta, normal2notexist) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
...
@@ -1570,7 +1561,6 @@ TEST(refreshGetMeta, normal2notexist) {
...
@@ -1570,7 +1561,6 @@ TEST(refreshGetMeta, normal2notexist) {
memset
(
&
gCtgMgmt
,
0
,
sizeof
(
gCtgMgmt
));
memset
(
&
gCtgMgmt
,
0
,
sizeof
(
gCtgMgmt
));
}
}
TEST
(
refreshGetMeta
,
normal2child
)
{
TEST
(
refreshGetMeta
,
normal2child
)
{
struct
SCatalog
*
pCtg
=
NULL
;
struct
SCatalog
*
pCtg
=
NULL
;
SRequestConnInfo
*
mockPointer
=
(
SRequestConnInfo
*
)
0x1
;
SRequestConnInfo
*
mockPointer
=
(
SRequestConnInfo
*
)
0x1
;
...
@@ -1598,7 +1588,7 @@ TEST(refreshGetMeta, normal2child) {
...
@@ -1598,7 +1588,7 @@ TEST(refreshGetMeta, normal2child) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
ctgTestCurrentCTableName
=
ctgTestTablename
;
ctgTestCurrentCTableName
=
ctgTestTablename
;
...
@@ -1682,7 +1672,7 @@ TEST(refreshGetMeta, stable2child) {
...
@@ -1682,7 +1672,7 @@ TEST(refreshGetMeta, stable2child) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
ctgTestCurrentSTableName
=
ctgTestTablename
;
ctgTestCurrentSTableName
=
ctgTestTablename
;
...
@@ -1768,7 +1758,7 @@ TEST(refreshGetMeta, stable2stable) {
...
@@ -1768,7 +1758,7 @@ TEST(refreshGetMeta, stable2stable) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
ctgTestCurrentSTableName
=
ctgTestTablename
;
ctgTestCurrentSTableName
=
ctgTestTablename
;
...
@@ -1826,7 +1816,6 @@ TEST(refreshGetMeta, stable2stable) {
...
@@ -1826,7 +1816,6 @@ TEST(refreshGetMeta, stable2stable) {
ctgTestCurrentSTableName
=
NULL
;
ctgTestCurrentSTableName
=
NULL
;
}
}
TEST
(
refreshGetMeta
,
child2stable
)
{
TEST
(
refreshGetMeta
,
child2stable
)
{
struct
SCatalog
*
pCtg
=
NULL
;
struct
SCatalog
*
pCtg
=
NULL
;
SRequestConnInfo
*
mockPointer
=
(
SRequestConnInfo
*
)
0x1
;
SRequestConnInfo
*
mockPointer
=
(
SRequestConnInfo
*
)
0x1
;
...
@@ -1855,7 +1844,7 @@ TEST(refreshGetMeta, child2stable) {
...
@@ -1855,7 +1844,7 @@ TEST(refreshGetMeta, child2stable) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
ctgTestCurrentCTableName
=
ctgTestTablename
;
ctgTestCurrentCTableName
=
ctgTestTablename
;
...
@@ -1913,7 +1902,6 @@ TEST(refreshGetMeta, child2stable) {
...
@@ -1913,7 +1902,6 @@ TEST(refreshGetMeta, child2stable) {
ctgTestCurrentSTableName
=
NULL
;
ctgTestCurrentSTableName
=
NULL
;
}
}
TEST
(
tableDistVgroup
,
normalTable
)
{
TEST
(
tableDistVgroup
,
normalTable
)
{
struct
SCatalog
*
pCtg
=
NULL
;
struct
SCatalog
*
pCtg
=
NULL
;
SRequestConnInfo
*
mockPointer
=
(
SRequestConnInfo
*
)
0x1
;
SRequestConnInfo
*
mockPointer
=
(
SRequestConnInfo
*
)
0x1
;
...
@@ -1940,7 +1928,7 @@ TEST(tableDistVgroup, normalTable) {
...
@@ -1940,7 +1928,7 @@ TEST(tableDistVgroup, normalTable) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
...
@@ -1982,7 +1970,7 @@ TEST(tableDistVgroup, childTableCase) {
...
@@ -1982,7 +1970,7 @@ TEST(tableDistVgroup, childTableCase) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestCTablename
);
strcpy
(
n
.
tname
,
ctgTestCTablename
);
...
@@ -2014,8 +2002,6 @@ TEST(tableDistVgroup, superTableCase) {
...
@@ -2014,8 +2002,6 @@ TEST(tableDistVgroup, superTableCase) {
ctgTestSetRspByIdx
();
ctgTestSetRspByIdx
();
initQueryModuleMsgHandle
();
initQueryModuleMsgHandle
();
int32_t
code
=
catalogInit
(
NULL
);
int32_t
code
=
catalogInit
(
NULL
);
...
@@ -2025,7 +2011,7 @@ TEST(tableDistVgroup, superTableCase) {
...
@@ -2025,7 +2011,7 @@ TEST(tableDistVgroup, superTableCase) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestSTablename
);
strcpy
(
n
.
tname
,
ctgTestSTablename
);
...
@@ -2061,10 +2047,8 @@ TEST(dbVgroup, getSetDbVgroupCase) {
...
@@ -2061,10 +2047,8 @@ TEST(dbVgroup, getSetDbVgroupCase) {
ctgTestRspFunc
[
0
]
=
CTGT_RSP_VGINFO
;
ctgTestRspFunc
[
0
]
=
CTGT_RSP_VGINFO
;
ctgTestRspFunc
[
1
]
=
CTGT_RSP_TBMETA
;
ctgTestRspFunc
[
1
]
=
CTGT_RSP_TBMETA
;
ctgTestSetRspByIdx
();
ctgTestSetRspByIdx
();
initQueryModuleMsgHandle
();
initQueryModuleMsgHandle
();
// sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet);
// sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet);
...
@@ -2075,7 +2059,7 @@ TEST(dbVgroup, getSetDbVgroupCase) {
...
@@ -2075,7 +2059,7 @@ TEST(dbVgroup, getSetDbVgroupCase) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
...
@@ -2119,7 +2103,6 @@ TEST(dbVgroup, getSetDbVgroupCase) {
...
@@ -2119,7 +2103,6 @@ TEST(dbVgroup, getSetDbVgroupCase) {
}
}
}
}
code
=
catalogGetTableHashVgroup
(
pCtg
,
mockPointer
,
&
n
,
&
vgInfo
);
code
=
catalogGetTableHashVgroup
(
pCtg
,
mockPointer
,
&
n
,
&
vgInfo
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
vgInfo
.
vgId
,
7
);
ASSERT_EQ
(
vgInfo
.
vgId
,
7
);
...
@@ -2160,7 +2143,7 @@ TEST(multiThread, getSetRmSameDbVgroup) {
...
@@ -2160,7 +2143,7 @@ TEST(multiThread, getSetRmSameDbVgroup) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
...
@@ -2212,7 +2195,7 @@ TEST(multiThread, getSetRmDiffDbVgroup) {
...
@@ -2212,7 +2195,7 @@ TEST(multiThread, getSetRmDiffDbVgroup) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
...
@@ -2264,7 +2247,7 @@ TEST(multiThread, ctableMeta) {
...
@@ -2264,7 +2247,7 @@ TEST(multiThread, ctableMeta) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
...
@@ -2316,7 +2299,7 @@ TEST(rentTest, allRent) {
...
@@ -2316,7 +2299,7 @@ TEST(rentTest, allRent) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
dbname
,
"db1"
);
for
(
int32_t
i
=
1
;
i
<=
10
;
++
i
)
{
for
(
int32_t
i
=
1
;
i
<=
10
;
++
i
)
{
...
...
source/libs/command/test/commandTest.cpp
浏览文件 @
d5255f1e
source/libs/executor/inc/dataSinkInt.h
浏览文件 @
d5255f1e
...
@@ -20,9 +20,9 @@
...
@@ -20,9 +20,9 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#include "tcommon.h"
#include "dataSinkMgt.h"
#include "dataSinkMgt.h"
#include "plannodes.h"
#include "plannodes.h"
#include "tcommon.h"
struct
SDataSink
;
struct
SDataSink
;
struct
SDataSinkHandle
;
struct
SDataSinkHandle
;
...
@@ -49,8 +49,10 @@ typedef struct SDataSinkHandle {
...
@@ -49,8 +49,10 @@ typedef struct SDataSinkHandle {
}
SDataSinkHandle
;
}
SDataSinkHandle
;
int32_t
createDataDispatcher
(
SDataSinkManager
*
pManager
,
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
);
int32_t
createDataDispatcher
(
SDataSinkManager
*
pManager
,
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
);
int32_t
createDataDeleter
(
SDataSinkManager
*
pManager
,
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
,
void
*
pParam
);
int32_t
createDataDeleter
(
SDataSinkManager
*
pManager
,
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
,
int32_t
createDataInserter
(
SDataSinkManager
*
pManager
,
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
,
void
*
pParam
);
void
*
pParam
);
int32_t
createDataInserter
(
SDataSinkManager
*
pManager
,
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
,
void
*
pParam
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/executor/inc/executorInt.h
浏览文件 @
d5255f1e
source/libs/executor/inc/tlinearhash.h
浏览文件 @
d5255f1e
...
@@ -32,9 +32,9 @@ typedef struct SLHashObj SLHashObj;
...
@@ -32,9 +32,9 @@ typedef struct SLHashObj SLHashObj;
SLHashObj
*
tHashInit
(
int32_t
inMemPages
,
int32_t
pageSize
,
_hash_fn_t
fn
,
int32_t
numOfTuplePerPage
);
SLHashObj
*
tHashInit
(
int32_t
inMemPages
,
int32_t
pageSize
,
_hash_fn_t
fn
,
int32_t
numOfTuplePerPage
);
void
*
tHashCleanup
(
SLHashObj
*
pHashObj
);
void
*
tHashCleanup
(
SLHashObj
*
pHashObj
);
int32_t
tHashPut
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
*
data
,
size_t
size
);
int32_t
tHashPut
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
*
data
,
size_t
size
);
char
*
tHashGet
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
);
char
*
tHashGet
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
);
int32_t
tHashRemove
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
);
int32_t
tHashRemove
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
);
void
tHashPrint
(
const
SLHashObj
*
pHashObj
,
int32_t
type
);
void
tHashPrint
(
const
SLHashObj
*
pHashObj
,
int32_t
type
);
...
...
source/libs/executor/inc/tsimplehash.h
浏览文件 @
d5255f1e
...
@@ -112,7 +112,7 @@ void tSimpleHashCleanup(SSHashObj *pHashObj);
...
@@ -112,7 +112,7 @@ void tSimpleHashCleanup(SSHashObj *pHashObj);
size_t
tSimpleHashGetMemSize
(
const
SSHashObj
*
pHashObj
);
size_t
tSimpleHashGetMemSize
(
const
SSHashObj
*
pHashObj
);
#pragma pack(push, 4)
#pragma pack(push, 4)
typedef
struct
SHNode
{
typedef
struct
SHNode
{
struct
SHNode
*
next
;
struct
SHNode
*
next
;
uint32_t
keyLen
:
20
;
uint32_t
keyLen
:
20
;
uint32_t
dataLen
:
12
;
uint32_t
dataLen
:
12
;
...
...
source/libs/executor/inc/tsort.h
浏览文件 @
d5255f1e
...
@@ -20,8 +20,8 @@
...
@@ -20,8 +20,8 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#include "tcommon.h"
#include "os.h"
#include "os.h"
#include "tcommon.h"
enum
{
enum
{
SORT_MULTISOURCE_MERGE
=
0x1
,
SORT_MULTISOURCE_MERGE
=
0x1
,
...
@@ -31,25 +31,25 @@ enum {
...
@@ -31,25 +31,25 @@ enum {
typedef
struct
SMultiMergeSource
{
typedef
struct
SMultiMergeSource
{
int32_t
type
;
int32_t
type
;
int32_t
rowIndex
;
int32_t
rowIndex
;
SSDataBlock
*
pBlock
;
SSDataBlock
*
pBlock
;
}
SMultiMergeSource
;
}
SMultiMergeSource
;
typedef
struct
SSortSource
{
typedef
struct
SSortSource
{
SMultiMergeSource
src
;
SMultiMergeSource
src
;
union
{
union
{
struct
{
struct
{
SArray
*
pageIdList
;
SArray
*
pageIdList
;
int32_t
pageIndex
;
int32_t
pageIndex
;
};
};
void
*
param
;
void
*
param
;
};
};
}
SSortSource
;
}
SSortSource
;
typedef
struct
SMsortComparParam
{
typedef
struct
SMsortComparParam
{
void
**
pSources
;
void
**
pSources
;
int32_t
numOfSources
;
int32_t
numOfSources
;
SArray
*
orderInfo
;
// SArray<SBlockOrderInfo>
SArray
*
orderInfo
;
// SArray<SBlockOrderInfo>
bool
cmpGroupId
;
bool
cmpGroupId
;
}
SMsortComparParam
;
}
SMsortComparParam
;
...
@@ -64,7 +64,8 @@ typedef int32_t (*_sort_merge_compar_fn_t)(const void* p1, const void* p2, void*
...
@@ -64,7 +64,8 @@ typedef int32_t (*_sort_merge_compar_fn_t)(const void* p1, const void* p2, void*
* @param type
* @param type
* @return
* @return
*/
*/
SSortHandle
*
tsortCreateSortHandle
(
SArray
*
pOrderInfo
,
int32_t
type
,
int32_t
pageSize
,
int32_t
numOfPages
,
SSDataBlock
*
pBlock
,
const
char
*
idstr
);
SSortHandle
*
tsortCreateSortHandle
(
SArray
*
pOrderInfo
,
int32_t
type
,
int32_t
pageSize
,
int32_t
numOfPages
,
SSDataBlock
*
pBlock
,
const
char
*
idstr
);
/**
/**
*
*
...
@@ -90,7 +91,8 @@ int32_t tsortClose(SSortHandle* pHandle);
...
@@ -90,7 +91,8 @@ int32_t tsortClose(SSortHandle* pHandle);
*
*
* @return
* @return
*/
*/
int32_t
tsortSetFetchRawDataFp
(
SSortHandle
*
pHandle
,
_sort_fetch_block_fn_t
fetchFp
,
void
(
*
fp
)(
SSDataBlock
*
,
void
*
),
void
*
param
);
int32_t
tsortSetFetchRawDataFp
(
SSortHandle
*
pHandle
,
_sort_fetch_block_fn_t
fetchFp
,
void
(
*
fp
)(
SSDataBlock
*
,
void
*
),
void
*
param
);
/**
/**
*
*
...
...
source/libs/executor/src/cachescanoperator.c
浏览文件 @
d5255f1e
...
@@ -13,8 +13,8 @@
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "os.h"
#include "function.h"
#include "function.h"
#include "os.h"
#include "tname.h"
#include "tname.h"
#include "tdatablock.h"
#include "tdatablock.h"
...
@@ -43,8 +43,8 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
...
@@ -43,8 +43,8 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
pInfo
->
pRes
=
createResDataBlock
(
pScanNode
->
scan
.
node
.
pOutputDataBlockDesc
);
pInfo
->
pRes
=
createResDataBlock
(
pScanNode
->
scan
.
node
.
pOutputDataBlockDesc
);
int32_t
numOfCols
=
0
;
int32_t
numOfCols
=
0
;
pInfo
->
pColMatchInfo
=
extractColMatchInfo
(
pScanNode
->
scan
.
pScanCols
,
pScanNode
->
scan
.
node
.
pOutputDataBlockDesc
,
&
numOfCols
,
pInfo
->
pColMatchInfo
=
extractColMatchInfo
(
pScanNode
->
scan
.
pScanCols
,
pScanNode
->
scan
.
node
.
pOutputDataBlockDesc
,
COL_MATCH_FROM_COL_ID
);
&
numOfCols
,
COL_MATCH_FROM_COL_ID
);
code
=
extractTargetSlotId
(
pInfo
->
pColMatchInfo
,
pTaskInfo
,
&
pInfo
->
pSlotIds
);
code
=
extractTargetSlotId
(
pInfo
->
pColMatchInfo
,
pTaskInfo
,
&
pInfo
->
pSlotIds
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
goto
_error
;
...
@@ -58,7 +58,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
...
@@ -58,7 +58,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
// partition by tbname
// partition by tbname
if
(
taosArrayGetSize
(
pTableList
->
pGroupList
)
==
taosArrayGetSize
(
pTableList
->
pTableList
))
{
if
(
taosArrayGetSize
(
pTableList
->
pGroupList
)
==
taosArrayGetSize
(
pTableList
->
pTableList
))
{
pInfo
->
retrieveType
=
CACHESCAN_RETRIEVE_TYPE_ALL
|
CACHESCAN_RETRIEVE_LAST_ROW
;
pInfo
->
retrieveType
=
CACHESCAN_RETRIEVE_TYPE_ALL
|
CACHESCAN_RETRIEVE_LAST_ROW
;
code
=
tsdbCacherowsReaderOpen
(
pInfo
->
readHandle
.
vnode
,
pInfo
->
retrieveType
,
pTableList
->
pTableList
,
code
=
tsdbCacherowsReaderOpen
(
pInfo
->
readHandle
.
vnode
,
pInfo
->
retrieveType
,
pTableList
->
pTableList
,
taosArrayGetSize
(
pInfo
->
pColMatchInfo
),
&
pInfo
->
pLastrowReader
);
taosArrayGetSize
(
pInfo
->
pColMatchInfo
),
&
pInfo
->
pLastrowReader
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -68,14 +68,15 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
...
@@ -68,14 +68,15 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
pInfo
->
pBufferredRes
=
createOneDataBlock
(
pInfo
->
pRes
,
false
);
pInfo
->
pBufferredRes
=
createOneDataBlock
(
pInfo
->
pRes
,
false
);
blockDataEnsureCapacity
(
pInfo
->
pBufferredRes
,
pOperator
->
resultInfo
.
capacity
);
blockDataEnsureCapacity
(
pInfo
->
pBufferredRes
,
pOperator
->
resultInfo
.
capacity
);
}
else
{
// by tags
}
else
{
// by tags
pInfo
->
retrieveType
=
CACHESCAN_RETRIEVE_TYPE_SINGLE
|
CACHESCAN_RETRIEVE_LAST_ROW
;
pInfo
->
retrieveType
=
CACHESCAN_RETRIEVE_TYPE_SINGLE
|
CACHESCAN_RETRIEVE_LAST_ROW
;
}
}
if
(
pScanNode
->
scan
.
pScanPseudoCols
!=
NULL
)
{
if
(
pScanNode
->
scan
.
pScanPseudoCols
!=
NULL
)
{
SExprSupp
*
pPseudoExpr
=
&
pInfo
->
pseudoExprSup
;
SExprSupp
*
pPseudoExpr
=
&
pInfo
->
pseudoExprSup
;
pPseudoExpr
->
pExprInfo
=
createExprInfo
(
pScanNode
->
scan
.
pScanPseudoCols
,
NULL
,
&
pPseudoExpr
->
numOfExprs
);
pPseudoExpr
->
pExprInfo
=
createExprInfo
(
pScanNode
->
scan
.
pScanPseudoCols
,
NULL
,
&
pPseudoExpr
->
numOfExprs
);
pPseudoExpr
->
pCtx
=
createSqlFunctionCtx
(
pPseudoExpr
->
pExprInfo
,
pPseudoExpr
->
numOfExprs
,
&
pPseudoExpr
->
rowEntryInfoOffset
);
pPseudoExpr
->
pCtx
=
createSqlFunctionCtx
(
pPseudoExpr
->
pExprInfo
,
pPseudoExpr
->
numOfExprs
,
&
pPseudoExpr
->
rowEntryInfoOffset
);
}
}
pOperator
->
name
=
"LastrowScanOperator"
;
pOperator
->
name
=
"LastrowScanOperator"
;
...
@@ -92,7 +93,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
...
@@ -92,7 +93,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
pOperator
->
cost
.
openCost
=
0
;
pOperator
->
cost
.
openCost
=
0
;
return
pOperator
;
return
pOperator
;
_error:
_error:
pTaskInfo
->
code
=
code
;
pTaskInfo
->
code
=
code
;
destroyLastrowScanOperator
(
pInfo
);
destroyLastrowScanOperator
(
pInfo
);
taosMemoryFree
(
pOperator
);
taosMemoryFree
(
pOperator
);
...
@@ -121,7 +122,8 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
...
@@ -121,7 +122,8 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
blockDataCleanup
(
pInfo
->
pBufferredRes
);
blockDataCleanup
(
pInfo
->
pBufferredRes
);
taosArrayClear
(
pInfo
->
pUidList
);
taosArrayClear
(
pInfo
->
pUidList
);
int32_t
code
=
tsdbRetrieveCacheRows
(
pInfo
->
pLastrowReader
,
pInfo
->
pBufferredRes
,
pInfo
->
pSlotIds
,
pInfo
->
pUidList
);
int32_t
code
=
tsdbRetrieveCacheRows
(
pInfo
->
pLastrowReader
,
pInfo
->
pBufferredRes
,
pInfo
->
pSlotIds
,
pInfo
->
pUidList
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
}
}
...
@@ -133,7 +135,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
...
@@ -133,7 +135,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
}
}
if
(
pInfo
->
indexOfBufferedRes
<
pInfo
->
pBufferredRes
->
info
.
rows
)
{
if
(
pInfo
->
indexOfBufferedRes
<
pInfo
->
pBufferredRes
->
info
.
rows
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
pColMatchInfo
);
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
pColMatchInfo
);
++
i
)
{
SColMatchInfo
*
pMatchInfo
=
taosArrayGet
(
pInfo
->
pColMatchInfo
,
i
);
SColMatchInfo
*
pMatchInfo
=
taosArrayGet
(
pInfo
->
pColMatchInfo
,
i
);
int32_t
slotId
=
pMatchInfo
->
targetSlotId
;
int32_t
slotId
=
pMatchInfo
->
targetSlotId
;
...
...
source/libs/executor/src/dataDispatcher.c
浏览文件 @
d5255f1e
...
@@ -93,8 +93,8 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn
...
@@ -93,8 +93,8 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn
pBuf
->
useSize
=
sizeof
(
SDataCacheEntry
);
pBuf
->
useSize
=
sizeof
(
SDataCacheEntry
);
blockEncode
(
pInput
->
pData
,
pEntry
->
data
,
&
pEntry
->
dataLen
,
numOfCols
,
pEntry
->
compressed
);
blockEncode
(
pInput
->
pData
,
pEntry
->
data
,
&
pEntry
->
dataLen
,
numOfCols
,
pEntry
->
compressed
);
ASSERT
(
pEntry
->
numOfRows
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
));
ASSERT
(
pEntry
->
numOfRows
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
));
ASSERT
(
pEntry
->
numOfCols
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
+
4
));
ASSERT
(
pEntry
->
numOfCols
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
+
4
));
pBuf
->
useSize
+=
pEntry
->
dataLen
;
pBuf
->
useSize
+=
pEntry
->
dataLen
;
...
@@ -103,14 +103,14 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn
...
@@ -103,14 +103,14 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn
}
}
static
bool
allocBuf
(
SDataDispatchHandle
*
pDispatcher
,
const
SInputData
*
pInput
,
SDataDispatchBuf
*
pBuf
)
{
static
bool
allocBuf
(
SDataDispatchHandle
*
pDispatcher
,
const
SInputData
*
pInput
,
SDataDispatchBuf
*
pBuf
)
{
/*
/*
uint32_t capacity = pDispatcher->pManager->cfg.maxDataBlockNumPerQuery;
uint32_t capacity = pDispatcher->pManager->cfg.maxDataBlockNumPerQuery;
if (taosQueueItemSize(pDispatcher->pDataBlocks) > capacity) {
if (taosQueueItemSize(pDispatcher->pDataBlocks) > capacity) {
qError("SinkNode queue is full, no capacity, max:%d, current:%d, no capacity", capacity,
qError("SinkNode queue is full, no capacity, max:%d, current:%d, no capacity", capacity,
taosQueueItemSize(pDispatcher->pDataBlocks));
taosQueueItemSize(pDispatcher->pDataBlocks));
return false;
return false;
}
}
*/
*/
pBuf
->
allocSize
=
sizeof
(
SDataCacheEntry
)
+
blockGetEncodeSize
(
pInput
->
pData
);
pBuf
->
allocSize
=
sizeof
(
SDataCacheEntry
)
+
blockGetEncodeSize
(
pInput
->
pData
);
...
@@ -176,11 +176,12 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
...
@@ -176,11 +176,12 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
SDataCacheEntry
*
pEntry
=
(
SDataCacheEntry
*
)
pDispatcher
->
nextOutput
.
pData
;
SDataCacheEntry
*
pEntry
=
(
SDataCacheEntry
*
)
pDispatcher
->
nextOutput
.
pData
;
*
pLen
=
pEntry
->
dataLen
;
*
pLen
=
pEntry
->
dataLen
;
ASSERT
(
pEntry
->
numOfRows
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
));
ASSERT
(
pEntry
->
numOfRows
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
));
ASSERT
(
pEntry
->
numOfCols
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
+
4
));
ASSERT
(
pEntry
->
numOfCols
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
+
4
));
*
pQueryEnd
=
pDispatcher
->
queryEnd
;
*
pQueryEnd
=
pDispatcher
->
queryEnd
;
qDebug
(
"got data len %"
PRId64
", row num %d in sink"
,
*
pLen
,
((
SDataCacheEntry
*
)(
pDispatcher
->
nextOutput
.
pData
))
->
numOfRows
);
qDebug
(
"got data len %"
PRId64
", row num %d in sink"
,
*
pLen
,
((
SDataCacheEntry
*
)(
pDispatcher
->
nextOutput
.
pData
))
->
numOfRows
);
}
}
static
int32_t
getDataBlock
(
SDataSinkHandle
*
pHandle
,
SOutputData
*
pOutput
)
{
static
int32_t
getDataBlock
(
SDataSinkHandle
*
pHandle
,
SOutputData
*
pOutput
)
{
...
@@ -199,8 +200,8 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
...
@@ -199,8 +200,8 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
pOutput
->
numOfCols
=
pEntry
->
numOfCols
;
pOutput
->
numOfCols
=
pEntry
->
numOfCols
;
pOutput
->
compressed
=
pEntry
->
compressed
;
pOutput
->
compressed
=
pEntry
->
compressed
;
ASSERT
(
pEntry
->
numOfRows
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
));
ASSERT
(
pEntry
->
numOfRows
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
));
ASSERT
(
pEntry
->
numOfCols
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
+
4
));
ASSERT
(
pEntry
->
numOfCols
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
+
4
));
atomic_sub_fetch_64
(
&
pDispatcher
->
cachedSize
,
pEntry
->
dataLen
);
atomic_sub_fetch_64
(
&
pDispatcher
->
cachedSize
,
pEntry
->
dataLen
);
atomic_sub_fetch_64
(
&
gDataSinkStat
.
cachedSize
,
pEntry
->
dataLen
);
atomic_sub_fetch_64
(
&
gDataSinkStat
.
cachedSize
,
pEntry
->
dataLen
);
...
...
source/libs/executor/src/dataInserter.c
浏览文件 @
d5255f1e
...
@@ -27,7 +27,7 @@ extern SDataSinkStat gDataSinkStat;
...
@@ -27,7 +27,7 @@ extern SDataSinkStat gDataSinkStat;
typedef
struct
SSubmitRes
{
typedef
struct
SSubmitRes
{
int64_t
affectedRows
;
int64_t
affectedRows
;
int32_t
code
;
int32_t
code
;
SSubmitRsp
*
pRsp
;
SSubmitRsp
*
pRsp
;
}
SSubmitRes
;
}
SSubmitRes
;
typedef
struct
SDataInserterHandle
{
typedef
struct
SDataInserterHandle
{
...
@@ -70,7 +70,7 @@ int32_t inserterCallback(void* param, SDataBuf* pMsg, int32_t code) {
...
@@ -70,7 +70,7 @@ int32_t inserterCallback(void* param, SDataBuf* pMsg, int32_t code) {
if
(
pInserter
->
submitRes
.
pRsp
->
nBlocks
>
0
)
{
if
(
pInserter
->
submitRes
.
pRsp
->
nBlocks
>
0
)
{
for
(
int32_t
i
=
0
;
i
<
pInserter
->
submitRes
.
pRsp
->
nBlocks
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInserter
->
submitRes
.
pRsp
->
nBlocks
;
++
i
)
{
SSubmitBlkRsp
*
blk
=
pInserter
->
submitRes
.
pRsp
->
pBlocks
+
i
;
SSubmitBlkRsp
*
blk
=
pInserter
->
submitRes
.
pRsp
->
pBlocks
+
i
;
if
(
TSDB_CODE_SUCCESS
!=
blk
->
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
blk
->
code
)
{
code
=
blk
->
code
;
code
=
blk
->
code
;
tFreeSSubmitRsp
(
pInserter
->
submitRes
.
pRsp
);
tFreeSSubmitRsp
(
pInserter
->
submitRes
.
pRsp
);
...
@@ -81,7 +81,8 @@ int32_t inserterCallback(void* param, SDataBuf* pMsg, int32_t code) {
...
@@ -81,7 +81,8 @@ int32_t inserterCallback(void* param, SDataBuf* pMsg, int32_t code) {
}
}
pInserter
->
submitRes
.
affectedRows
+=
pInserter
->
submitRes
.
pRsp
->
affectedRows
;
pInserter
->
submitRes
.
affectedRows
+=
pInserter
->
submitRes
.
pRsp
->
affectedRows
;
qDebug
(
"submit rsp received, affectedRows:%d, total:%d"
,
pInserter
->
submitRes
.
pRsp
->
affectedRows
,
pInserter
->
submitRes
.
affectedRows
);
qDebug
(
"submit rsp received, affectedRows:%d, total:%d"
,
pInserter
->
submitRes
.
pRsp
->
affectedRows
,
pInserter
->
submitRes
.
affectedRows
);
tFreeSSubmitRsp
(
pInserter
->
submitRes
.
pRsp
);
tFreeSSubmitRsp
(
pInserter
->
submitRes
.
pRsp
);
}
}
...
@@ -95,7 +96,6 @@ _return:
...
@@ -95,7 +96,6 @@ _return:
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
sendSubmitRequest
(
SDataInserterHandle
*
pInserter
,
SSubmitReq
*
pMsg
,
void
*
pTransporter
,
SEpSet
*
pEpset
)
{
static
int32_t
sendSubmitRequest
(
SDataInserterHandle
*
pInserter
,
SSubmitReq
*
pMsg
,
void
*
pTransporter
,
SEpSet
*
pEpset
)
{
// send the fetch remote task result reques
// send the fetch remote task result reques
SMsgSendInfo
*
pMsgSendInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SMsgSendInfo
));
SMsgSendInfo
*
pMsgSendInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SMsgSendInfo
));
...
@@ -119,7 +119,6 @@ static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, SSubmitReq* pMs
...
@@ -119,7 +119,6 @@ static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, SSubmitReq* pMs
return
asyncSendMsgToServer
(
pTransporter
,
pEpset
,
&
transporterId
,
pMsgSendInfo
);
return
asyncSendMsgToServer
(
pTransporter
,
pEpset
,
&
transporterId
,
pMsgSendInfo
);
}
}
int32_t
dataBlockToSubmit
(
SDataInserterHandle
*
pInserter
,
SSubmitReq
**
pReq
)
{
int32_t
dataBlockToSubmit
(
SDataInserterHandle
*
pInserter
,
SSubmitReq
**
pReq
)
{
const
SArray
*
pBlocks
=
pInserter
->
pDataBlocks
;
const
SArray
*
pBlocks
=
pInserter
->
pDataBlocks
;
const
STSchema
*
pTSchema
=
pInserter
->
pSchema
;
const
STSchema
*
pTSchema
=
pInserter
->
pSchema
;
...
@@ -178,7 +177,7 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) {
...
@@ -178,7 +177,7 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) {
SColumnInfoData
*
pColData
=
NULL
;
SColumnInfoData
*
pColData
=
NULL
;
int16_t
colIdx
=
k
;
int16_t
colIdx
=
k
;
if
(
!
fullCol
)
{
if
(
!
fullCol
)
{
int16_t
*
slotId
=
taosHashGet
(
pInserter
->
pCols
,
&
pColumn
->
colId
,
sizeof
(
pColumn
->
colId
));
int16_t
*
slotId
=
taosHashGet
(
pInserter
->
pCols
,
&
pColumn
->
colId
,
sizeof
(
pColumn
->
colId
));
if
(
NULL
==
slotId
)
{
if
(
NULL
==
slotId
)
{
continue
;
continue
;
}
}
...
@@ -213,7 +212,7 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) {
...
@@ -213,7 +212,7 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) {
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NORM
,
data
,
true
,
pColumn
->
offset
,
k
);
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NORM
,
data
,
true
,
pColumn
->
offset
,
k
);
}
}
}
}
if
(
!
fullCol
)
{
if
(
!
fullCol
)
{
rb
.
hasNone
=
true
;
rb
.
hasNone
=
true
;
}
}
tdSRowEnd
(
&
rb
);
tdSRowEnd
(
&
rb
);
...
@@ -242,7 +241,6 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) {
...
@@ -242,7 +241,6 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
putDataBlock
(
SDataSinkHandle
*
pHandle
,
const
SInputData
*
pInput
,
bool
*
pContinue
)
{
static
int32_t
putDataBlock
(
SDataSinkHandle
*
pHandle
,
const
SInputData
*
pInput
,
bool
*
pContinue
)
{
SDataInserterHandle
*
pInserter
=
(
SDataInserterHandle
*
)
pHandle
;
SDataInserterHandle
*
pInserter
=
(
SDataInserterHandle
*
)
pHandle
;
taosArrayPush
(
pInserter
->
pDataBlocks
,
&
pInput
->
pData
);
taosArrayPush
(
pInserter
->
pDataBlocks
,
&
pInput
->
pData
);
...
@@ -279,10 +277,9 @@ static void endPut(struct SDataSinkHandle* pHandle, uint64_t useconds) {
...
@@ -279,10 +277,9 @@ static void endPut(struct SDataSinkHandle* pHandle, uint64_t useconds) {
static
void
getDataLength
(
SDataSinkHandle
*
pHandle
,
int64_t
*
pLen
,
bool
*
pQueryEnd
)
{
static
void
getDataLength
(
SDataSinkHandle
*
pHandle
,
int64_t
*
pLen
,
bool
*
pQueryEnd
)
{
SDataInserterHandle
*
pDispatcher
=
(
SDataInserterHandle
*
)
pHandle
;
SDataInserterHandle
*
pDispatcher
=
(
SDataInserterHandle
*
)
pHandle
;
*
pLen
=
pDispatcher
->
submitRes
.
affectedRows
;
*
pLen
=
pDispatcher
->
submitRes
.
affectedRows
;
qDebug
(
"got total affectedRows %"
PRId64
,
*
pLen
);
qDebug
(
"got total affectedRows %"
PRId64
,
*
pLen
);
}
}
static
int32_t
destroyDataSinker
(
SDataSinkHandle
*
pHandle
)
{
static
int32_t
destroyDataSinker
(
SDataSinkHandle
*
pHandle
)
{
SDataInserterHandle
*
pInserter
=
(
SDataInserterHandle
*
)
pHandle
;
SDataInserterHandle
*
pInserter
=
(
SDataInserterHandle
*
)
pHandle
;
atomic_sub_fetch_64
(
&
gDataSinkStat
.
cachedSize
,
pInserter
->
cachedSize
);
atomic_sub_fetch_64
(
&
gDataSinkStat
.
cachedSize
,
pInserter
->
cachedSize
);
...
@@ -301,14 +298,15 @@ static int32_t getCacheSize(struct SDataSinkHandle* pHandle, uint64_t* size) {
...
@@ -301,14 +298,15 @@ static int32_t getCacheSize(struct SDataSinkHandle* pHandle, uint64_t* size) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
createDataInserter
(
SDataSinkManager
*
pManager
,
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
,
void
*
pParam
)
{
int32_t
createDataInserter
(
SDataSinkManager
*
pManager
,
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
,
void
*
pParam
)
{
SDataInserterHandle
*
inserter
=
taosMemoryCalloc
(
1
,
sizeof
(
SDataInserterHandle
));
SDataInserterHandle
*
inserter
=
taosMemoryCalloc
(
1
,
sizeof
(
SDataInserterHandle
));
if
(
NULL
==
inserter
)
{
if
(
NULL
==
inserter
)
{
terrno
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
}
SQueryInserterNode
*
pInserterNode
=
(
SQueryInserterNode
*
)
pDataSink
;
SQueryInserterNode
*
pInserterNode
=
(
SQueryInserterNode
*
)
pDataSink
;
inserter
->
sink
.
fPut
=
putDataBlock
;
inserter
->
sink
.
fPut
=
putDataBlock
;
inserter
->
sink
.
fEndPut
=
endPut
;
inserter
->
sink
.
fEndPut
=
endPut
;
inserter
->
sink
.
fGetLen
=
getDataLength
;
inserter
->
sink
.
fGetLen
=
getDataLength
;
...
@@ -322,7 +320,8 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat
...
@@ -322,7 +320,8 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat
inserter
->
queryEnd
=
false
;
inserter
->
queryEnd
=
false
;
int64_t
suid
=
0
;
int64_t
suid
=
0
;
int32_t
code
=
tsdbGetTableSchema
(
inserter
->
pParam
->
readHandle
->
vnode
,
pInserterNode
->
tableId
,
&
inserter
->
pSchema
,
&
suid
);
int32_t
code
=
tsdbGetTableSchema
(
inserter
->
pParam
->
readHandle
->
vnode
,
pInserterNode
->
tableId
,
&
inserter
->
pSchema
,
&
suid
);
if
(
code
)
{
if
(
code
)
{
return
code
;
return
code
;
}
}
...
@@ -339,7 +338,8 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat
...
@@ -339,7 +338,8 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
}
inserter
->
pCols
=
taosHashInit
(
pInserterNode
->
pCols
->
length
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_SMALLINT
),
false
,
HASH_NO_LOCK
);
inserter
->
pCols
=
taosHashInit
(
pInserterNode
->
pCols
->
length
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_SMALLINT
),
false
,
HASH_NO_LOCK
);
SNode
*
pNode
=
NULL
;
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pInserterNode
->
pCols
)
{
FOREACH
(
pNode
,
pInserterNode
->
pCols
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
...
...
source/libs/executor/src/dataSinkMgt.c
浏览文件 @
d5255f1e
...
@@ -13,28 +13,27 @@
...
@@ -13,28 +13,27 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "tarray.h"
#include "dataSinkMgt.h"
#include "dataSinkMgt.h"
#include "dataSinkInt.h"
#include "dataSinkInt.h"
#include "planner.h"
#include "planner.h"
#include "tarray.h"
static
SDataSinkManager
gDataSinkManager
=
{
0
};
static
SDataSinkManager
gDataSinkManager
=
{
0
};
SDataSinkStat
gDataSinkStat
=
{
0
};
SDataSinkStat
gDataSinkStat
=
{
0
};
int32_t
dsDataSinkMgtInit
(
SDataSinkMgtCfg
*
cfg
)
{
int32_t
dsDataSinkMgtInit
(
SDataSinkMgtCfg
*
cfg
)
{
gDataSinkManager
.
cfg
=
*
cfg
;
gDataSinkManager
.
cfg
=
*
cfg
;
taosThreadMutexInit
(
&
gDataSinkManager
.
mutex
,
NULL
);
taosThreadMutexInit
(
&
gDataSinkManager
.
mutex
,
NULL
);
return
0
;
// to avoid compiler eror
return
0
;
// to avoid compiler eror
}
}
int32_t
dsDataSinkGetCacheSize
(
SDataSinkStat
*
pStat
)
{
int32_t
dsDataSinkGetCacheSize
(
SDataSinkStat
*
pStat
)
{
pStat
->
cachedSize
=
atomic_load_64
(
&
gDataSinkStat
.
cachedSize
);
pStat
->
cachedSize
=
atomic_load_64
(
&
gDataSinkStat
.
cachedSize
);
return
0
;
return
0
;
}
}
int32_t
dsCreateDataSinker
(
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
,
void
*
pParam
)
{
int32_t
dsCreateDataSinker
(
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
,
void
*
pParam
)
{
switch
((
int
)
nodeType
(
pDataSink
))
{
switch
((
int
)
nodeType
(
pDataSink
))
{
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
createDataDispatcher
(
&
gDataSinkManager
,
pDataSink
,
pHandle
);
return
createDataDispatcher
(
&
gDataSinkManager
,
pDataSink
,
pHandle
);
...
@@ -66,12 +65,11 @@ int32_t dsGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) {
...
@@ -66,12 +65,11 @@ int32_t dsGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) {
return
pHandleImpl
->
fGetData
(
pHandleImpl
,
pOutput
);
return
pHandleImpl
->
fGetData
(
pHandleImpl
,
pOutput
);
}
}
int32_t
dsGetCacheSize
(
DataSinkHandle
handle
,
uint64_t
*
pSize
)
{
int32_t
dsGetCacheSize
(
DataSinkHandle
handle
,
uint64_t
*
pSize
)
{
SDataSinkHandle
*
pHandleImpl
=
(
SDataSinkHandle
*
)
handle
;
SDataSinkHandle
*
pHandleImpl
=
(
SDataSinkHandle
*
)
handle
;
return
pHandleImpl
->
fGetCacheSize
(
pHandleImpl
,
pSize
);
return
pHandleImpl
->
fGetCacheSize
(
pHandleImpl
,
pSize
);
}
}
void
dsScheduleProcess
(
void
*
ahandle
,
void
*
pItem
)
{
void
dsScheduleProcess
(
void
*
ahandle
,
void
*
pItem
)
{
// todo
// todo
}
}
...
...
source/libs/executor/src/joinoperator.c
浏览文件 @
d5255f1e
...
@@ -267,13 +267,14 @@ static int32_t mergeJoinJoinDownstreamTsRanges(SOperatorInfo* pOperator, int64_t
...
@@ -267,13 +267,14 @@ static int32_t mergeJoinJoinDownstreamTsRanges(SOperatorInfo* pOperator, int64_t
size_t
rightNumJoin
=
taosArrayGetSize
(
rightRowLocations
);
size_t
rightNumJoin
=
taosArrayGetSize
(
rightRowLocations
);
code
=
blockDataEnsureCapacity
(
pRes
,
*
nRows
+
leftNumJoin
*
rightNumJoin
);
code
=
blockDataEnsureCapacity
(
pRes
,
*
nRows
+
leftNumJoin
*
rightNumJoin
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"%s can not ensure block capacity for join. left: %zu, right: %zu"
,
GET_TASKID
(
pOperator
->
pTaskInfo
),
leftNumJoin
,
rightNumJoin
);
qError
(
"%s can not ensure block capacity for join. left: %zu, right: %zu"
,
GET_TASKID
(
pOperator
->
pTaskInfo
),
leftNumJoin
,
rightNumJoin
);
}
}
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
for
(
int32_t
i
=
0
;
i
<
leftNumJoin
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
leftNumJoin
;
++
i
)
{
for
(
int32_t
j
=
0
;
j
<
rightNumJoin
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
rightNumJoin
;
++
j
)
{
SRowLocation
*
leftRow
=
taosArrayGet
(
leftRowLocations
,
i
);
SRowLocation
*
leftRow
=
taosArrayGet
(
leftRowLocations
,
i
);
SRowLocation
*
rightRow
=
taosArrayGet
(
rightRowLocations
,
j
);
SRowLocation
*
rightRow
=
taosArrayGet
(
rightRowLocations
,
j
);
mergeJoinJoinLeftRight
(
pOperator
,
pRes
,
*
nRows
,
leftRow
->
pDataBlock
,
leftRow
->
pos
,
rightRow
->
pDataBlock
,
mergeJoinJoinLeftRight
(
pOperator
,
pRes
,
*
nRows
,
leftRow
->
pDataBlock
,
leftRow
->
pos
,
rightRow
->
pDataBlock
,
rightRow
->
pos
);
rightRow
->
pos
);
++*
nRows
;
++*
nRows
;
...
...
source/libs/executor/src/sortoperator.c
浏览文件 @
d5255f1e
...
@@ -658,7 +658,8 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
...
@@ -658,7 +658,8 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
blockDataDestroy
(
p
);
blockDataDestroy
(
p
);
qDebug
(
"%s get sorted block, groupId:%0x"
PRIx64
" rows:%d"
,
GET_TASKID
(
pTaskInfo
),
pDataBlock
->
info
.
groupId
,
pDataBlock
->
info
.
rows
);
qDebug
(
"%s get sorted block, groupId:%0x"
PRIx64
" rows:%d"
,
GET_TASKID
(
pTaskInfo
),
pDataBlock
->
info
.
groupId
,
pDataBlock
->
info
.
rows
);
return
(
pDataBlock
->
info
.
rows
>
0
)
?
pDataBlock
:
NULL
;
return
(
pDataBlock
->
info
.
rows
>
0
)
?
pDataBlock
:
NULL
;
}
}
...
...
source/libs/executor/src/tfill.c
浏览文件 @
d5255f1e
source/libs/executor/src/timewindowoperator.c
浏览文件 @
d5255f1e
source/libs/executor/src/tlinearhash.c
浏览文件 @
d5255f1e
...
@@ -14,22 +14,22 @@
...
@@ -14,22 +14,22 @@
*/
*/
#include "tlinearhash.h"
#include "tlinearhash.h"
#include "tdef.h"
#include "taoserror.h"
#include "taoserror.h"
#include "tdef.h"
#include "tpagedbuf.h"
#include "tpagedbuf.h"
#define LHASH_CAP_RATIO 0.85
#define LHASH_CAP_RATIO 0.85
// Always located in memory
// Always located in memory
typedef
struct
SLHashBucket
{
typedef
struct
SLHashBucket
{
SArray
*
pPageIdList
;
SArray
*
pPageIdList
;
int32_t
size
;
// the number of element in this entry
int32_t
size
;
// the number of element in this entry
}
SLHashBucket
;
}
SLHashBucket
;
struct
SLHashObj
{
struct
SLHashObj
{
SDiskbasedBuf
*
pBuf
;
SDiskbasedBuf
*
pBuf
;
_hash_fn_t
hashFn
;
_hash_fn_t
hashFn
;
SLHashBucket
**
pBucket
;
// entry list
SLHashBucket
**
pBucket
;
// entry list
int32_t
tuplesPerPage
;
int32_t
tuplesPerPage
;
int32_t
numOfAlloc
;
// number of allocated bucket ptr slot
int32_t
numOfAlloc
;
// number of allocated bucket ptr slot
int32_t
bits
;
// the number of bits used in hash
int32_t
bits
;
// the number of bits used in hash
...
@@ -54,9 +54,7 @@ typedef struct SLHashNode {
...
@@ -54,9 +54,7 @@ typedef struct SLHashNode {
static
int32_t
doAddNewBucket
(
SLHashObj
*
pHashObj
);
static
int32_t
doAddNewBucket
(
SLHashObj
*
pHashObj
);
static
int32_t
doGetBucketIdFromHashVal
(
int32_t
hashv
,
int32_t
bits
)
{
static
int32_t
doGetBucketIdFromHashVal
(
int32_t
hashv
,
int32_t
bits
)
{
return
hashv
&
((
1ul
<<
(
bits
))
-
1
);
}
return
hashv
&
((
1ul
<<
(
bits
))
-
1
);
}
static
int32_t
doGetAlternativeBucketId
(
int32_t
bucketId
,
int32_t
bits
,
int32_t
numOfBuckets
)
{
static
int32_t
doGetAlternativeBucketId
(
int32_t
bucketId
,
int32_t
bits
,
int32_t
numOfBuckets
)
{
int32_t
v
=
bucketId
-
(
1ul
<<
(
bits
-
1
));
int32_t
v
=
bucketId
-
(
1ul
<<
(
bits
-
1
));
...
@@ -70,9 +68,9 @@ static int32_t doGetRelatedSplitBucketId(int32_t bucketId, int32_t bits) {
...
@@ -70,9 +68,9 @@ static int32_t doGetRelatedSplitBucketId(int32_t bucketId, int32_t bits) {
}
}
static
void
doCopyObject
(
char
*
p
,
const
void
*
key
,
int32_t
keyLen
,
const
void
*
data
,
int32_t
size
)
{
static
void
doCopyObject
(
char
*
p
,
const
void
*
key
,
int32_t
keyLen
,
const
void
*
data
,
int32_t
size
)
{
*
(
uint16_t
*
)
p
=
keyLen
;
*
(
uint16_t
*
)
p
=
keyLen
;
p
+=
sizeof
(
uint16_t
);
p
+=
sizeof
(
uint16_t
);
*
(
uint16_t
*
)
p
=
size
;
*
(
uint16_t
*
)
p
=
size
;
p
+=
sizeof
(
uint16_t
);
p
+=
sizeof
(
uint16_t
);
memcpy
(
p
,
key
,
keyLen
);
memcpy
(
p
,
key
,
keyLen
);
...
@@ -86,7 +84,7 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t
...
@@ -86,7 +84,7 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t
int32_t
pageId
=
*
(
int32_t
*
)
taosArrayGetLast
(
pBucket
->
pPageIdList
);
int32_t
pageId
=
*
(
int32_t
*
)
taosArrayGetLast
(
pBucket
->
pPageIdList
);
SFilePage
*
pPage
=
getBufPage
(
pHashObj
->
pBuf
,
pageId
);
SFilePage
*
pPage
=
getBufPage
(
pHashObj
->
pBuf
,
pageId
);
ASSERT
(
pPage
!=
NULL
);
ASSERT
(
pPage
!=
NULL
);
// put to current buf page
// put to current buf page
size_t
nodeSize
=
sizeof
(
SLHashNode
)
+
keyLen
+
size
;
size_t
nodeSize
=
sizeof
(
SLHashNode
)
+
keyLen
+
size
;
...
@@ -110,7 +108,7 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t
...
@@ -110,7 +108,7 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t
setBufPageDirty
(
pNewPage
,
true
);
setBufPageDirty
(
pNewPage
,
true
);
releaseBufPage
(
pHashObj
->
pBuf
,
pNewPage
);
releaseBufPage
(
pHashObj
->
pBuf
,
pNewPage
);
}
else
{
}
else
{
char
*
p
=
(
char
*
)
pPage
+
pPage
->
num
;
char
*
p
=
(
char
*
)
pPage
+
pPage
->
num
;
doCopyObject
(
p
,
key
,
keyLen
,
data
,
size
);
doCopyObject
(
p
,
key
,
keyLen
,
data
,
size
);
pPage
->
num
+=
nodeSize
;
pPage
->
num
+=
nodeSize
;
setBufPageDirty
(
pPage
,
true
);
setBufPageDirty
(
pPage
,
true
);
...
@@ -118,7 +116,7 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t
...
@@ -118,7 +116,7 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t
}
}
pBucket
->
size
+=
1
;
pBucket
->
size
+=
1
;
// printf("===> add to bucket:0x%x, num:%d, key:%d\n", index, pBucket->size, *(int*) key);
// printf("===> add to bucket:0x%x, num:%d, key:%d\n", index, pBucket->size, *(int*) key);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -127,7 +125,7 @@ static void doRemoveFromBucket(SFilePage* pPage, SLHashNode* pNode, SLHashBucket
...
@@ -127,7 +125,7 @@ static void doRemoveFromBucket(SFilePage* pPage, SLHashNode* pNode, SLHashBucket
ASSERT
(
pPage
!=
NULL
&&
pNode
!=
NULL
&&
pBucket
->
size
>=
1
);
ASSERT
(
pPage
!=
NULL
&&
pNode
!=
NULL
&&
pBucket
->
size
>=
1
);
int32_t
len
=
GET_LHASH_NODE_LEN
(
pNode
);
int32_t
len
=
GET_LHASH_NODE_LEN
(
pNode
);
char
*
p
=
(
char
*
)
pNode
+
len
;
char
*
p
=
(
char
*
)
pNode
+
len
;
char
*
pEnd
=
(
char
*
)
pPage
+
pPage
->
num
;
char
*
pEnd
=
(
char
*
)
pPage
+
pPage
->
num
;
memmove
(
pNode
,
p
,
(
pEnd
-
p
));
memmove
(
pNode
,
p
,
(
pEnd
-
p
));
...
@@ -141,7 +139,7 @@ static void doRemoveFromBucket(SFilePage* pPage, SLHashNode* pNode, SLHashBucket
...
@@ -141,7 +139,7 @@ static void doRemoveFromBucket(SFilePage* pPage, SLHashNode* pNode, SLHashBucket
pBucket
->
size
-=
1
;
pBucket
->
size
-=
1
;
}
}
static
void
doTrimBucketPages
(
SLHashObj
*
pHashObj
,
SLHashBucket
*
pBucket
)
{
static
void
doTrimBucketPages
(
SLHashObj
*
pHashObj
,
SLHashBucket
*
pBucket
)
{
size_t
numOfPages
=
taosArrayGetSize
(
pBucket
->
pPageIdList
);
size_t
numOfPages
=
taosArrayGetSize
(
pBucket
->
pPageIdList
);
if
(
numOfPages
<=
1
)
{
if
(
numOfPages
<=
1
)
{
return
;
return
;
...
@@ -214,7 +212,7 @@ static int32_t doAddNewBucket(SLHashObj* pHashObj) {
...
@@ -214,7 +212,7 @@ static int32_t doAddNewBucket(SLHashObj* pHashObj) {
}
}
memset
(
p
+
POINTER_BYTES
*
pHashObj
->
numOfBuckets
,
0
,
newLen
-
pHashObj
->
numOfBuckets
);
memset
(
p
+
POINTER_BYTES
*
pHashObj
->
numOfBuckets
,
0
,
newLen
-
pHashObj
->
numOfBuckets
);
pHashObj
->
pBucket
=
(
SLHashBucket
**
)
p
;
pHashObj
->
pBucket
=
(
SLHashBucket
**
)
p
;
pHashObj
->
numOfAlloc
=
newLen
;
pHashObj
->
numOfAlloc
=
newLen
;
}
}
...
@@ -239,7 +237,7 @@ static int32_t doAddNewBucket(SLHashObj* pHashObj) {
...
@@ -239,7 +237,7 @@ static int32_t doAddNewBucket(SLHashObj* pHashObj) {
taosArrayPush
(
pBucket
->
pPageIdList
,
&
pageId
);
taosArrayPush
(
pBucket
->
pPageIdList
,
&
pageId
);
pHashObj
->
numOfBuckets
+=
1
;
pHashObj
->
numOfBuckets
+=
1
;
// printf("---------------add new bucket, id:0x%x, total:%d\n", pHashObj->numOfBuckets - 1, pHashObj->numOfBuckets);
// printf("---------------add new bucket, id:0x%x, total:%d\n", pHashObj->numOfBuckets - 1, pHashObj->numOfBuckets);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -266,8 +264,8 @@ SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_
...
@@ -266,8 +264,8 @@ SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_
setBufPageCompressOnDisk
(
pHashObj
->
pBuf
,
false
);
setBufPageCompressOnDisk
(
pHashObj
->
pBuf
,
false
);
/**
/**
* The number of bits in the hash value, which is used to decide the exact bucket where the object should be located
in.
* The number of bits in the hash value, which is used to decide the exact bucket where the object should be located
* The initial value is 0.
*
in.
The initial value is 0.
*/
*/
pHashObj
->
bits
=
0
;
pHashObj
->
bits
=
0
;
pHashObj
->
hashFn
=
fn
;
pHashObj
->
hashFn
=
fn
;
...
@@ -289,7 +287,7 @@ SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_
...
@@ -289,7 +287,7 @@ SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_
void
*
tHashCleanup
(
SLHashObj
*
pHashObj
)
{
void
*
tHashCleanup
(
SLHashObj
*
pHashObj
)
{
destroyDiskbasedBuf
(
pHashObj
->
pBuf
);
destroyDiskbasedBuf
(
pHashObj
->
pBuf
);
for
(
int32_t
i
=
0
;
i
<
pHashObj
->
numOfBuckets
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pHashObj
->
numOfBuckets
;
++
i
)
{
taosArrayDestroy
(
pHashObj
->
pBucket
[
i
]
->
pPageIdList
);
taosArrayDestroy
(
pHashObj
->
pBucket
[
i
]
->
pPageIdList
);
taosMemoryFreeClear
(
pHashObj
->
pBucket
[
i
]);
taosMemoryFreeClear
(
pHashObj
->
pBucket
[
i
]);
}
}
...
@@ -299,7 +297,7 @@ void* tHashCleanup(SLHashObj* pHashObj) {
...
@@ -299,7 +297,7 @@ void* tHashCleanup(SLHashObj* pHashObj) {
return
NULL
;
return
NULL
;
}
}
int32_t
tHashPut
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
*
data
,
size_t
size
)
{
int32_t
tHashPut
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
*
data
,
size_t
size
)
{
ASSERT
(
pHashObj
!=
NULL
&&
key
!=
NULL
);
ASSERT
(
pHashObj
!=
NULL
&&
key
!=
NULL
);
if
(
pHashObj
->
bits
==
0
)
{
if
(
pHashObj
->
bits
==
0
)
{
...
@@ -311,7 +309,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
...
@@ -311,7 +309,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
if
(
v
>=
pHashObj
->
numOfBuckets
)
{
if
(
v
>=
pHashObj
->
numOfBuckets
)
{
int32_t
newBucketId
=
doGetAlternativeBucketId
(
v
,
pHashObj
->
bits
,
pHashObj
->
numOfBuckets
);
int32_t
newBucketId
=
doGetAlternativeBucketId
(
v
,
pHashObj
->
bits
,
pHashObj
->
numOfBuckets
);
// printf("bucketId: 0x%x not exists, put it into 0x%x instead\n", v, newBucketId);
// printf("bucketId: 0x%x not exists, put it into 0x%x instead\n", v, newBucketId);
v
=
newBucketId
;
v
=
newBucketId
;
}
}
...
@@ -335,7 +333,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
...
@@ -335,7 +333,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
int32_t
numOfBits
=
ceil
(
log
(
pHashObj
->
numOfBuckets
)
/
log
(
2
));
int32_t
numOfBits
=
ceil
(
log
(
pHashObj
->
numOfBuckets
)
/
log
(
2
));
if
(
numOfBits
>
pHashObj
->
bits
)
{
if
(
numOfBits
>
pHashObj
->
bits
)
{
// printf("extend the bits from %d to %d, new bucket:%d\n", pHashObj->bits, numOfBits, newBucketId);
// printf("extend the bits from %d to %d, new bucket:%d\n", pHashObj->bits, numOfBits, newBucketId);
ASSERT
(
numOfBits
==
pHashObj
->
bits
+
1
);
ASSERT
(
numOfBits
==
pHashObj
->
bits
+
1
);
pHashObj
->
bits
=
numOfBits
;
pHashObj
->
bits
=
numOfBits
;
}
}
...
@@ -344,14 +342,14 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
...
@@ -344,14 +342,14 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
// load all data in this bucket and check if the data needs to relocated into the new bucket
// load all data in this bucket and check if the data needs to relocated into the new bucket
SLHashBucket
*
pBucket
=
pHashObj
->
pBucket
[
splitBucketId
];
SLHashBucket
*
pBucket
=
pHashObj
->
pBucket
[
splitBucketId
];
// printf("split %d items' bucket:0x%x to new bucket:0x%x\n", pBucket->size, splitBucketId, newBucketId);
// printf("split %d items' bucket:0x%x to new bucket:0x%x\n", pBucket->size, splitBucketId, newBucketId);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pBucket
->
pPageIdList
);
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pBucket
->
pPageIdList
);
++
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
);
char
*
pStart
=
p
->
data
;
char
*
pStart
=
p
->
data
;
while
(
pStart
-
((
char
*
)
p
)
<
p
->
num
)
{
while
(
pStart
-
((
char
*
)
p
)
<
p
->
num
)
{
SLHashNode
*
pNode
=
(
SLHashNode
*
)
pStart
;
SLHashNode
*
pNode
=
(
SLHashNode
*
)
pStart
;
ASSERT
(
pNode
->
keyLen
>
0
&&
pNode
->
dataLen
>=
0
);
ASSERT
(
pNode
->
keyLen
>
0
&&
pNode
->
dataLen
>=
0
);
...
@@ -361,14 +359,14 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
...
@@ -361,14 +359,14 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
if
(
v1
!=
splitBucketId
)
{
// place it into the new bucket
if
(
v1
!=
splitBucketId
)
{
// place it into the new bucket
ASSERT
(
v1
==
newBucketId
);
ASSERT
(
v1
==
newBucketId
);
// printf("move key:%d to 0x%x bucket, remain items:%d\n", *(int32_t*)k, v1, pBucket->size - 1);
// printf("move key:%d to 0x%x bucket, remain items:%d\n", *(int32_t*)k, v1, pBucket->size - 1);
SLHashBucket
*
pNewBucket
=
pHashObj
->
pBucket
[
newBucketId
];
SLHashBucket
*
pNewBucket
=
pHashObj
->
pBucket
[
newBucketId
];
doAddToBucket
(
pHashObj
,
pNewBucket
,
newBucketId
,
(
void
*
)
GET_LHASH_NODE_KEY
(
pNode
),
pNode
->
keyLen
,
doAddToBucket
(
pHashObj
,
pNewBucket
,
newBucketId
,
(
void
*
)
GET_LHASH_NODE_KEY
(
pNode
),
pNode
->
keyLen
,
GET_LHASH_NODE_KEY
(
pNode
),
pNode
->
dataLen
);
GET_LHASH_NODE_KEY
(
pNode
),
pNode
->
dataLen
);
doRemoveFromBucket
(
p
,
pNode
,
pBucket
);
doRemoveFromBucket
(
p
,
pNode
,
pBucket
);
}
else
{
}
else
{
// printf("check key:%d, located into: %d, skip it\n", *(int*) k, v1);
// printf("check key:%d, located into: %d, skip it\n", *(int*) k, v1);
int32_t
nodeSize
=
GET_LHASH_NODE_LEN
(
pStart
);
int32_t
nodeSize
=
GET_LHASH_NODE_LEN
(
pStart
);
pStart
+=
nodeSize
;
pStart
+=
nodeSize
;
...
@@ -383,7 +381,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
...
@@ -383,7 +381,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
char
*
tHashGet
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
)
{
char
*
tHashGet
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
)
{
ASSERT
(
pHashObj
!=
NULL
&&
key
!=
NULL
&&
keyLen
>
0
);
ASSERT
(
pHashObj
!=
NULL
&&
key
!=
NULL
&&
keyLen
>
0
);
int32_t
hashv
=
pHashObj
->
hashFn
(
key
,
keyLen
);
int32_t
hashv
=
pHashObj
->
hashFn
(
key
,
keyLen
);
...
@@ -418,7 +416,7 @@ char* tHashGet(SLHashObj* pHashObj, const void *key, size_t keyLen) {
...
@@ -418,7 +416,7 @@ char* tHashGet(SLHashObj* pHashObj, const void *key, size_t keyLen) {
return
NULL
;
return
NULL
;
}
}
int32_t
tHashRemove
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
)
{
int32_t
tHashRemove
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
)
{
// todo
// todo
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -431,8 +429,8 @@ void tHashPrint(const SLHashObj* pHashObj, int32_t type) {
...
@@ -431,8 +429,8 @@ void tHashPrint(const SLHashObj* pHashObj, int32_t type) {
if
(
type
==
LINEAR_HASH_DATA
)
{
if
(
type
==
LINEAR_HASH_DATA
)
{
for
(
int32_t
i
=
0
;
i
<
pHashObj
->
numOfBuckets
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pHashObj
->
numOfBuckets
;
++
i
)
{
// printf("bucket: 0x%x, obj:%d, page:%d\n", i, pHashObj->pBucket[i]->size,
// printf("bucket: 0x%x, obj:%d, page:%d\n", i, pHashObj->pBucket[i]->size,
// (int)taosArrayGetSize(pHashObj->pBucket[i]->pPageIdList));
// (int)taosArrayGetSize(pHashObj->pBucket[i]->pPageIdList));
}
}
}
else
{
}
else
{
dBufPrintStatis
(
pHashObj
->
pBuf
);
dBufPrintStatis
(
pHashObj
->
pBuf
);
...
...
source/libs/executor/src/tsort.c
浏览文件 @
d5255f1e
...
@@ -13,16 +13,16 @@
...
@@ -13,16 +13,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "tcommon.h"
#include "query.h"
#include "query.h"
#include "tcommon.h"
#include "tcompare.h"
#include "tdatablock.h"
#include "tdatablock.h"
#include "tdef.h"
#include "tdef.h"
#include "tlosertree.h"
#include "tlosertree.h"
#include "tpagedbuf.h"
#include "tpagedbuf.h"
#include "tsort.h"
#include "tsort.h"
#include "tutil.h"
#include "tutil.h"
#include "tcompare.h"
struct
STupleHandle
{
struct
STupleHandle
{
SSDataBlock
*
pBlock
;
SSDataBlock
*
pBlock
;
...
@@ -33,10 +33,10 @@ struct SSortHandle {
...
@@ -33,10 +33,10 @@ struct SSortHandle {
int32_t
type
;
int32_t
type
;
int32_t
pageSize
;
int32_t
pageSize
;
int32_t
numOfPages
;
int32_t
numOfPages
;
SDiskbasedBuf
*
pBuf
;
SDiskbasedBuf
*
pBuf
;
SArray
*
pSortInfo
;
SArray
*
pSortInfo
;
SArray
*
pOrderedSource
;
SArray
*
pOrderedSource
;
int32_t
loops
;
int32_t
loops
;
uint64_t
sortElapsed
;
uint64_t
sortElapsed
;
...
@@ -44,23 +44,23 @@ struct SSortHandle {
...
@@ -44,23 +44,23 @@ struct SSortHandle {
uint64_t
totalElapsed
;
uint64_t
totalElapsed
;
int32_t
sourceId
;
int32_t
sourceId
;
SSDataBlock
*
pDataBlock
;
SSDataBlock
*
pDataBlock
;
SMsortComparParam
cmpParam
;
SMsortComparParam
cmpParam
;
int32_t
numOfCompletedSources
;
int32_t
numOfCompletedSources
;
bool
opened
;
bool
opened
;
const
char
*
idStr
;
const
char
*
idStr
;
bool
inMemSort
;
bool
inMemSort
;
bool
needAdjust
;
bool
needAdjust
;
STupleHandle
tupleHandle
;
STupleHandle
tupleHandle
;
void
*
param
;
void
*
param
;
void
(
*
beforeFp
)(
SSDataBlock
*
pBlock
,
void
*
param
);
void
(
*
beforeFp
)(
SSDataBlock
*
pBlock
,
void
*
param
);
_sort_fetch_block_fn_t
fetchfp
;
_sort_fetch_block_fn_t
fetchfp
;
_sort_merge_compar_fn_t
comparFn
;
_sort_merge_compar_fn_t
comparFn
;
SMultiwayMergeTreeInfo
*
pMergeTree
;
SMultiwayMergeTreeInfo
*
pMergeTree
;
};
};
static
int32_t
msortComparFn
(
const
void
*
pLeft
,
const
void
*
pRight
,
void
*
param
);
static
int32_t
msortComparFn
(
const
void
*
pLeft
,
const
void
*
pRight
,
void
*
param
);
SSDataBlock
*
tsortGetSortedDataBlock
(
const
SSortHandle
*
pSortHandle
)
{
SSDataBlock
*
tsortGetSortedDataBlock
(
const
SSortHandle
*
pSortHandle
)
{
return
createOneDataBlock
(
pSortHandle
->
pDataBlock
,
false
);
return
createOneDataBlock
(
pSortHandle
->
pDataBlock
,
false
);
...
@@ -71,7 +71,8 @@ SSDataBlock* tsortGetSortedDataBlock(const SSortHandle* pSortHandle) {
...
@@ -71,7 +71,8 @@ SSDataBlock* tsortGetSortedDataBlock(const SSortHandle* pSortHandle) {
* @param type
* @param type
* @return
* @return
*/
*/
SSortHandle
*
tsortCreateSortHandle
(
SArray
*
pSortInfo
,
int32_t
type
,
int32_t
pageSize
,
int32_t
numOfPages
,
SSDataBlock
*
pBlock
,
const
char
*
idstr
)
{
SSortHandle
*
tsortCreateSortHandle
(
SArray
*
pSortInfo
,
int32_t
type
,
int32_t
pageSize
,
int32_t
numOfPages
,
SSDataBlock
*
pBlock
,
const
char
*
idstr
)
{
SSortHandle
*
pSortHandle
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortHandle
));
SSortHandle
*
pSortHandle
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortHandle
));
pSortHandle
->
type
=
type
;
pSortHandle
->
type
=
type
;
...
@@ -98,8 +99,9 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t page
...
@@ -98,8 +99,9 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t page
}
}
static
int32_t
sortComparCleanup
(
SMsortComparParam
*
cmpParam
)
{
static
int32_t
sortComparCleanup
(
SMsortComparParam
*
cmpParam
)
{
for
(
int32_t
i
=
0
;
i
<
cmpParam
->
numOfSources
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
cmpParam
->
numOfSources
;
++
i
)
{
SSortSource
*
pSource
=
cmpParam
->
pSources
[
i
];
// NOTICE: pSource may be SGenericSource *, if it is SORT_MULTISOURCE_MERGE
SSortSource
*
pSource
=
cmpParam
->
pSources
[
i
];
// NOTICE: pSource may be SGenericSource *, if it is SORT_MULTISOURCE_MERGE
blockDataDestroy
(
pSource
->
src
.
pBlock
);
blockDataDestroy
(
pSource
->
src
.
pBlock
);
taosMemoryFreeClear
(
pSource
);
taosMemoryFreeClear
(
pSource
);
}
}
...
@@ -121,7 +123,7 @@ void tsortDestroySortHandle(SSortHandle* pSortHandle) {
...
@@ -121,7 +123,7 @@ void tsortDestroySortHandle(SSortHandle* pSortHandle) {
destroyDiskbasedBuf
(
pSortHandle
->
pBuf
);
destroyDiskbasedBuf
(
pSortHandle
->
pBuf
);
taosMemoryFreeClear
(
pSortHandle
->
idStr
);
taosMemoryFreeClear
(
pSortHandle
->
idStr
);
blockDataDestroy
(
pSortHandle
->
pDataBlock
);
blockDataDestroy
(
pSortHandle
->
pDataBlock
);
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
pSortHandle
->
pOrderedSource
);
i
++
){
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
pSortHandle
->
pOrderedSource
);
i
++
)
{
SSortSource
**
pSource
=
taosArrayGet
(
pSortHandle
->
pOrderedSource
,
i
);
SSortSource
**
pSource
=
taosArrayGet
(
pSortHandle
->
pOrderedSource
,
i
);
taosMemoryFreeClear
(
*
pSource
);
taosMemoryFreeClear
(
*
pSource
);
}
}
...
@@ -134,7 +136,8 @@ int32_t tsortAddSource(SSortHandle* pSortHandle, void* pSource) {
...
@@ -134,7 +136,8 @@ int32_t tsortAddSource(SSortHandle* pSortHandle, void* pSource) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
doAddNewExternalMemSource
(
SDiskbasedBuf
*
pBuf
,
SArray
*
pAllSources
,
SSDataBlock
*
pBlock
,
int32_t
*
sourceId
,
SArray
*
pPageIdList
)
{
static
int32_t
doAddNewExternalMemSource
(
SDiskbasedBuf
*
pBuf
,
SArray
*
pAllSources
,
SSDataBlock
*
pBlock
,
int32_t
*
sourceId
,
SArray
*
pPageIdList
)
{
SSortSource
*
pSource
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortSource
));
SSortSource
*
pSource
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortSource
));
if
(
pSource
==
NULL
)
{
if
(
pSource
==
NULL
)
{
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
...
@@ -149,7 +152,8 @@ static int32_t doAddNewExternalMemSource(SDiskbasedBuf *pBuf, SArray* pAllSource
...
@@ -149,7 +152,8 @@ static int32_t doAddNewExternalMemSource(SDiskbasedBuf *pBuf, SArray* pAllSource
int32_t
rowSize
=
blockDataGetSerialRowSize
(
pSource
->
src
.
pBlock
);
int32_t
rowSize
=
blockDataGetSerialRowSize
(
pSource
->
src
.
pBlock
);
// The value of numOfRows must be greater than 0, which is guaranteed by the previous memory allocation
// The value of numOfRows must be greater than 0, which is guaranteed by the previous memory allocation
int32_t
numOfRows
=
(
getBufPageSize
(
pBuf
)
-
blockDataGetSerialMetaSize
(
taosArrayGetSize
(
pBlock
->
pDataBlock
)))
/
rowSize
;
int32_t
numOfRows
=
(
getBufPageSize
(
pBuf
)
-
blockDataGetSerialMetaSize
(
taosArrayGetSize
(
pBlock
->
pDataBlock
)))
/
rowSize
;
ASSERT
(
numOfRows
>
0
);
ASSERT
(
numOfRows
>
0
);
return
blockDataEnsureCapacity
(
pSource
->
src
.
pBlock
,
numOfRows
);
return
blockDataEnsureCapacity
(
pSource
->
src
.
pBlock
,
numOfRows
);
}
}
...
@@ -163,7 +167,8 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
...
@@ -163,7 +167,8 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
qError
(
"Add to buf failed since %s"
,
terrstr
(
terrno
));
qError
(
"Add to buf failed since %s"
,
terrstr
(
terrno
));
return
terrno
;
return
terrno
;
}
}
int32_t
code
=
createDiskbasedBuf
(
&
pHandle
->
pBuf
,
pHandle
->
pageSize
,
pHandle
->
numOfPages
*
pHandle
->
pageSize
,
"doAddToBuf"
,
tsTempDir
);
int32_t
code
=
createDiskbasedBuf
(
&
pHandle
->
pBuf
,
pHandle
->
pageSize
,
pHandle
->
numOfPages
*
pHandle
->
pageSize
,
"doAddToBuf"
,
tsTempDir
);
dBufSetPrintInfo
(
pHandle
->
pBuf
);
dBufSetPrintInfo
(
pHandle
->
pBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -171,7 +176,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
...
@@ -171,7 +176,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
}
}
SArray
*
pPageIdList
=
taosArrayInit
(
4
,
sizeof
(
int32_t
));
SArray
*
pPageIdList
=
taosArrayInit
(
4
,
sizeof
(
int32_t
));
while
(
start
<
pDataBlock
->
info
.
rows
)
{
while
(
start
<
pDataBlock
->
info
.
rows
)
{
int32_t
stop
=
0
;
int32_t
stop
=
0
;
blockDataSplitRows
(
pDataBlock
,
pDataBlock
->
info
.
hasVarCol
,
start
,
&
stop
,
pHandle
->
pageSize
);
blockDataSplitRows
(
pDataBlock
,
pDataBlock
->
info
.
hasVarCol
,
start
,
&
stop
,
pHandle
->
pageSize
);
SSDataBlock
*
p
=
blockDataExtractBlock
(
pDataBlock
,
start
,
stop
-
start
+
1
);
SSDataBlock
*
p
=
blockDataExtractBlock
(
pDataBlock
,
start
,
stop
-
start
+
1
);
...
@@ -211,7 +216,8 @@ static void setCurrentSourceIsDone(SSortSource* pSource, SSortHandle* pHandle) {
...
@@ -211,7 +216,8 @@ static void setCurrentSourceIsDone(SSortSource* pSource, SSortHandle* pHandle) {
++
pHandle
->
numOfCompletedSources
;
++
pHandle
->
numOfCompletedSources
;
}
}
static
int32_t
sortComparInit
(
SMsortComparParam
*
cmpParam
,
SArray
*
pSources
,
int32_t
startIndex
,
int32_t
endIndex
,
SSortHandle
*
pHandle
)
{
static
int32_t
sortComparInit
(
SMsortComparParam
*
cmpParam
,
SArray
*
pSources
,
int32_t
startIndex
,
int32_t
endIndex
,
SSortHandle
*
pHandle
)
{
cmpParam
->
pSources
=
taosArrayGet
(
pSources
,
startIndex
);
cmpParam
->
pSources
=
taosArrayGet
(
pSources
,
startIndex
);
cmpParam
->
numOfSources
=
(
endIndex
-
startIndex
+
1
);
cmpParam
->
numOfSources
=
(
endIndex
-
startIndex
+
1
);
...
@@ -246,7 +252,8 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int
...
@@ -246,7 +252,8 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int
qError
(
"Sort compare init failed since %s"
,
terrstr
(
terrno
));
qError
(
"Sort compare init failed since %s"
,
terrstr
(
terrno
));
return
code
;
return
code
;
}
}
code
=
createDiskbasedBuf
(
&
pHandle
->
pBuf
,
pHandle
->
pageSize
,
pHandle
->
numOfPages
*
pHandle
->
pageSize
,
"sortComparInit"
,
tsTempDir
);
code
=
createDiskbasedBuf
(
&
pHandle
->
pBuf
,
pHandle
->
pageSize
,
pHandle
->
numOfPages
*
pHandle
->
pageSize
,
"sortComparInit"
,
tsTempDir
);
dBufSetPrintInfo
(
pHandle
->
pBuf
);
dBufSetPrintInfo
(
pHandle
->
pBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -267,7 +274,7 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int
...
@@ -267,7 +274,7 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int
return
code
;
return
code
;
}
}
static
void
appendOneRowToDataBlock
(
SSDataBlock
*
pBlock
,
const
SSDataBlock
*
pSource
,
int32_t
*
rowIndex
)
{
static
void
appendOneRowToDataBlock
(
SSDataBlock
*
pBlock
,
const
SSDataBlock
*
pSource
,
int32_t
*
rowIndex
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pBlock
->
pDataBlock
);
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pBlock
->
pDataBlock
);
++
i
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
...
@@ -286,7 +293,8 @@ static void appendOneRowToDataBlock(SSDataBlock *pBlock, const SSDataBlock* pSou
...
@@ -286,7 +293,8 @@ static void appendOneRowToDataBlock(SSDataBlock *pBlock, const SSDataBlock* pSou
*
rowIndex
+=
1
;
*
rowIndex
+=
1
;
}
}
static
int32_t
adjustMergeTreeForNextTuple
(
SSortSource
*
pSource
,
SMultiwayMergeTreeInfo
*
pTree
,
SSortHandle
*
pHandle
,
int32_t
*
numOfCompleted
)
{
static
int32_t
adjustMergeTreeForNextTuple
(
SSortSource
*
pSource
,
SMultiwayMergeTreeInfo
*
pTree
,
SSortHandle
*
pHandle
,
int32_t
*
numOfCompleted
)
{
/*
/*
* load a new SDataBlock into memory of a given intermediate data-set source,
* load a new SDataBlock into memory of a given intermediate data-set source,
* since it's last record in buffer has been chosen to be processed, as the winner of loser-tree
* since it's last record in buffer has been chosen to be processed, as the winner of loser-tree
...
@@ -295,7 +303,7 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource *pSource, SMultiwayMergeT
...
@@ -295,7 +303,7 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource *pSource, SMultiwayMergeT
pSource
->
src
.
rowIndex
=
0
;
pSource
->
src
.
rowIndex
=
0
;
if
(
pHandle
->
type
==
SORT_SINGLESOURCE_SORT
)
{
if
(
pHandle
->
type
==
SORT_SINGLESOURCE_SORT
)
{
pSource
->
pageIndex
++
;
pSource
->
pageIndex
++
;
if
(
pSource
->
pageIndex
>=
taosArrayGetSize
(
pSource
->
pageIdList
))
{
if
(
pSource
->
pageIndex
>=
taosArrayGetSize
(
pSource
->
pageIdList
))
{
(
*
numOfCompleted
)
+=
1
;
(
*
numOfCompleted
)
+=
1
;
pSource
->
src
.
rowIndex
=
-
1
;
pSource
->
src
.
rowIndex
=
-
1
;
...
@@ -344,14 +352,14 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource *pSource, SMultiwayMergeT
...
@@ -344,14 +352,14 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource *pSource, SMultiwayMergeT
static
SSDataBlock
*
getSortedBlockDataInner
(
SSortHandle
*
pHandle
,
SMsortComparParam
*
cmpParam
,
int32_t
capacity
)
{
static
SSDataBlock
*
getSortedBlockDataInner
(
SSortHandle
*
pHandle
,
SMsortComparParam
*
cmpParam
,
int32_t
capacity
)
{
blockDataCleanup
(
pHandle
->
pDataBlock
);
blockDataCleanup
(
pHandle
->
pDataBlock
);
while
(
1
)
{
while
(
1
)
{
if
(
cmpParam
->
numOfSources
==
pHandle
->
numOfCompletedSources
)
{
if
(
cmpParam
->
numOfSources
==
pHandle
->
numOfCompletedSources
)
{
break
;
break
;
}
}
int32_t
index
=
tMergeTreeGetChosenIndex
(
pHandle
->
pMergeTree
);
int32_t
index
=
tMergeTreeGetChosenIndex
(
pHandle
->
pMergeTree
);
SSortSource
*
pSource
=
(
*
cmpParam
).
pSources
[
index
];
SSortSource
*
pSource
=
(
*
cmpParam
).
pSources
[
index
];
appendOneRowToDataBlock
(
pHandle
->
pDataBlock
,
pSource
->
src
.
pBlock
,
&
pSource
->
src
.
rowIndex
);
appendOneRowToDataBlock
(
pHandle
->
pDataBlock
,
pSource
->
src
.
pBlock
,
&
pSource
->
src
.
rowIndex
);
int32_t
code
=
adjustMergeTreeForNextTuple
(
pSource
,
pHandle
->
pMergeTree
,
pHandle
,
&
pHandle
->
numOfCompletedSources
);
int32_t
code
=
adjustMergeTreeForNextTuple
(
pSource
,
pHandle
->
pMergeTree
,
pHandle
,
&
pHandle
->
numOfCompletedSources
);
...
@@ -365,16 +373,16 @@ static SSDataBlock* getSortedBlockDataInner(SSortHandle* pHandle, SMsortComparPa
...
@@ -365,16 +373,16 @@ static SSDataBlock* getSortedBlockDataInner(SSortHandle* pHandle, SMsortComparPa
}
}
}
}
return
(
pHandle
->
pDataBlock
->
info
.
rows
>
0
)
?
pHandle
->
pDataBlock
:
NULL
;
return
(
pHandle
->
pDataBlock
->
info
.
rows
>
0
)
?
pHandle
->
pDataBlock
:
NULL
;
}
}
int32_t
msortComparFn
(
const
void
*
pLeft
,
const
void
*
pRight
,
void
*
param
)
{
int32_t
msortComparFn
(
const
void
*
pLeft
,
const
void
*
pRight
,
void
*
param
)
{
int32_t
pLeftIdx
=
*
(
int32_t
*
)
pLeft
;
int32_t
pLeftIdx
=
*
(
int32_t
*
)
pLeft
;
int32_t
pRightIdx
=
*
(
int32_t
*
)
pRight
;
int32_t
pRightIdx
=
*
(
int32_t
*
)
pRight
;
SMsortComparParam
*
pParam
=
(
SMsortComparParam
*
)
param
;
SMsortComparParam
*
pParam
=
(
SMsortComparParam
*
)
param
;
SArray
*
pInfo
=
pParam
->
orderInfo
;
SArray
*
pInfo
=
pParam
->
orderInfo
;
SSortSource
*
pLeftSource
=
pParam
->
pSources
[
pLeftIdx
];
SSortSource
*
pLeftSource
=
pParam
->
pSources
[
pLeftIdx
];
SSortSource
*
pRightSource
=
pParam
->
pSources
[
pRightIdx
];
SSortSource
*
pRightSource
=
pParam
->
pSources
[
pRightIdx
];
...
@@ -397,7 +405,7 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
...
@@ -397,7 +405,7 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
}
}
}
}
for
(
int32_t
i
=
0
;
i
<
pInfo
->
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInfo
->
size
;
++
i
)
{
SBlockOrderInfo
*
pOrder
=
TARRAY_GET_ELEM
(
pInfo
,
i
);
SBlockOrderInfo
*
pOrder
=
TARRAY_GET_ELEM
(
pInfo
,
i
);
SColumnInfoData
*
pLeftColInfoData
=
TARRAY_GET_ELEM
(
pLeftBlock
->
pDataBlock
,
pOrder
->
slotId
);
SColumnInfoData
*
pLeftColInfoData
=
TARRAY_GET_ELEM
(
pLeftBlock
->
pDataBlock
,
pOrder
->
slotId
);
...
@@ -406,7 +414,8 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
...
@@ -406,7 +414,8 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
if
(
pLeftBlock
->
pBlockAgg
==
NULL
)
{
if
(
pLeftBlock
->
pBlockAgg
==
NULL
)
{
leftNull
=
colDataIsNull_s
(
pLeftColInfoData
,
pLeftSource
->
src
.
rowIndex
);
leftNull
=
colDataIsNull_s
(
pLeftColInfoData
,
pLeftSource
->
src
.
rowIndex
);
}
else
{
}
else
{
leftNull
=
colDataIsNull
(
pLeftColInfoData
,
pLeftBlock
->
info
.
rows
,
pLeftSource
->
src
.
rowIndex
,
pLeftBlock
->
pBlockAgg
[
i
]);
leftNull
=
colDataIsNull
(
pLeftColInfoData
,
pLeftBlock
->
info
.
rows
,
pLeftSource
->
src
.
rowIndex
,
pLeftBlock
->
pBlockAgg
[
i
]);
}
}
}
}
...
@@ -416,7 +425,8 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
...
@@ -416,7 +425,8 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
if
(
pLeftBlock
->
pBlockAgg
==
NULL
)
{
if
(
pLeftBlock
->
pBlockAgg
==
NULL
)
{
rightNull
=
colDataIsNull_s
(
pRightColInfoData
,
pRightSource
->
src
.
rowIndex
);
rightNull
=
colDataIsNull_s
(
pRightColInfoData
,
pRightSource
->
src
.
rowIndex
);
}
else
{
}
else
{
rightNull
=
colDataIsNull
(
pRightColInfoData
,
pRightBlock
->
info
.
rows
,
pRightSource
->
src
.
rowIndex
,
pRightBlock
->
pBlockAgg
[
i
]);
rightNull
=
colDataIsNull
(
pRightColInfoData
,
pRightBlock
->
info
.
rows
,
pRightSource
->
src
.
rowIndex
,
pRightBlock
->
pBlockAgg
[
i
]);
}
}
}
}
...
@@ -425,11 +435,11 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
...
@@ -425,11 +435,11 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
}
}
if
(
rightNull
)
{
if
(
rightNull
)
{
return
pOrder
->
nullFirst
?
1
:
-
1
;
return
pOrder
->
nullFirst
?
1
:
-
1
;
}
}
if
(
leftNull
)
{
if
(
leftNull
)
{
return
pOrder
->
nullFirst
?
-
1
:
1
;
return
pOrder
->
nullFirst
?
-
1
:
1
;
}
}
void
*
left1
=
colDataGetData
(
pLeftColInfoData
,
pLeftSource
->
src
.
rowIndex
);
void
*
left1
=
colDataGetData
(
pLeftColInfoData
,
pLeftSource
->
src
.
rowIndex
);
...
@@ -464,7 +474,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
...
@@ -464,7 +474,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
", sort elapsed:%"
PRId64
", total elapsed:%"
PRId64
,
", sort elapsed:%"
PRId64
", total elapsed:%"
PRId64
,
pHandle
->
idStr
,
(
int32_t
)(
sortPass
+
1
),
s
,
pHandle
->
sortElapsed
,
pHandle
->
totalElapsed
);
pHandle
->
idStr
,
(
int32_t
)(
sortPass
+
1
),
s
,
pHandle
->
sortElapsed
,
pHandle
->
totalElapsed
);
}
else
{
}
else
{
qDebug
(
"%s ordered source:%"
PRIzu
", available buf:%d, no need internal sort"
,
pHandle
->
idStr
,
numOfSources
,
qDebug
(
"%s ordered source:%"
PRIzu
", available buf:%d, no need internal sort"
,
pHandle
->
idStr
,
numOfSources
,
pHandle
->
numOfPages
);
pHandle
->
numOfPages
);
}
}
...
@@ -475,7 +485,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
...
@@ -475,7 +485,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
pHandle
->
loops
=
sortPass
+
2
;
pHandle
->
loops
=
sortPass
+
2
;
size_t
numOfSorted
=
taosArrayGetSize
(
pHandle
->
pOrderedSource
);
size_t
numOfSorted
=
taosArrayGetSize
(
pHandle
->
pOrderedSource
);
for
(
int32_t
t
=
0
;
t
<
sortPass
;
++
t
)
{
for
(
int32_t
t
=
0
;
t
<
sortPass
;
++
t
)
{
int64_t
st
=
taosGetTimestampUs
();
int64_t
st
=
taosGetTimestampUs
();
SArray
*
pResList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
SArray
*
pResList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
...
@@ -484,7 +494,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
...
@@ -484,7 +494,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
int32_t
sortGroup
=
(
numOfSorted
+
numOfInputSources
-
1
)
/
numOfInputSources
;
int32_t
sortGroup
=
(
numOfSorted
+
numOfInputSources
-
1
)
/
numOfInputSources
;
// Only *numOfInputSources* can be loaded into buffer to perform the external sort.
// Only *numOfInputSources* can be loaded into buffer to perform the external sort.
for
(
int32_t
i
=
0
;
i
<
sortGroup
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
sortGroup
;
++
i
)
{
pHandle
->
sourceId
+=
1
;
pHandle
->
sourceId
+=
1
;
int32_t
end
=
(
i
+
1
)
*
numOfInputSources
-
1
;
int32_t
end
=
(
i
+
1
)
*
numOfInputSources
-
1
;
...
@@ -499,7 +509,8 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
...
@@ -499,7 +509,8 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
return
code
;
return
code
;
}
}
code
=
tMergeTreeCreate
(
&
pHandle
->
pMergeTree
,
pHandle
->
cmpParam
.
numOfSources
,
&
pHandle
->
cmpParam
,
pHandle
->
comparFn
);
code
=
tMergeTreeCreate
(
&
pHandle
->
pMergeTree
,
pHandle
->
cmpParam
.
numOfSources
,
&
pHandle
->
cmpParam
,
pHandle
->
comparFn
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
@@ -519,7 +530,8 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
...
@@ -519,7 +530,8 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
taosArrayPush
(
pPageIdList
,
&
pageId
);
taosArrayPush
(
pPageIdList
,
&
pageId
);
int32_t
size
=
blockDataGetSize
(
pDataBlock
)
+
sizeof
(
int32_t
)
+
taosArrayGetSize
(
pDataBlock
->
pDataBlock
)
*
sizeof
(
int32_t
);
int32_t
size
=
blockDataGetSize
(
pDataBlock
)
+
sizeof
(
int32_t
)
+
taosArrayGetSize
(
pDataBlock
->
pDataBlock
)
*
sizeof
(
int32_t
);
assert
(
size
<=
getBufPageSize
(
pHandle
->
pBuf
));
assert
(
size
<=
getBufPageSize
(
pHandle
->
pBuf
));
blockDataToBuf
(
pPage
,
pDataBlock
);
blockDataToBuf
(
pPage
,
pDataBlock
);
...
@@ -551,8 +563,8 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
...
@@ -551,8 +563,8 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
pHandle
->
totalElapsed
+=
el
;
pHandle
->
totalElapsed
+=
el
;
SDiskbasedBufStatis
statis
=
getDBufStatis
(
pHandle
->
pBuf
);
SDiskbasedBufStatis
statis
=
getDBufStatis
(
pHandle
->
pBuf
);
qDebug
(
"%s %d round mergesort, elapsed:%"
PRId64
" readDisk:%.2f Kb, flushDisk:%.2f Kb"
,
pHandle
->
idStr
,
t
+
1
,
el
,
statis
.
loadBytes
/
1024
.
0
,
qDebug
(
"%s %d round mergesort, elapsed:%"
PRId64
" readDisk:%.2f Kb, flushDisk:%.2f Kb"
,
pHandle
->
idStr
,
t
+
1
,
el
,
statis
.
flushBytes
/
1024
.
0
);
statis
.
loadBytes
/
1024
.
0
,
statis
.
flushBytes
/
1024
.
0
);
if
(
pHandle
->
type
==
SORT_MULTISOURCE_MERGE
)
{
if
(
pHandle
->
type
==
SORT_MULTISOURCE_MERGE
)
{
pHandle
->
type
=
SORT_SINGLESOURCE_SORT
;
pHandle
->
type
=
SORT_SINGLESOURCE_SORT
;
...
@@ -701,7 +713,8 @@ int32_t tsortClose(SSortHandle* pHandle) {
...
@@ -701,7 +713,8 @@ int32_t tsortClose(SSortHandle* pHandle) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
tsortSetFetchRawDataFp
(
SSortHandle
*
pHandle
,
_sort_fetch_block_fn_t
fetchFp
,
void
(
*
fp
)(
SSDataBlock
*
,
void
*
),
void
*
param
)
{
int32_t
tsortSetFetchRawDataFp
(
SSortHandle
*
pHandle
,
_sort_fetch_block_fn_t
fetchFp
,
void
(
*
fp
)(
SSDataBlock
*
,
void
*
),
void
*
param
)
{
pHandle
->
fetchfp
=
fetchFp
;
pHandle
->
fetchfp
=
fetchFp
;
pHandle
->
beforeFp
=
fp
;
pHandle
->
beforeFp
=
fp
;
pHandle
->
param
=
param
;
pHandle
->
param
=
param
;
...
@@ -735,7 +748,7 @@ STupleHandle* tsortNextTuple(SSortHandle* pHandle) {
...
@@ -735,7 +748,7 @@ STupleHandle* tsortNextTuple(SSortHandle* pHandle) {
}
}
int32_t
index
=
tMergeTreeGetChosenIndex
(
pHandle
->
pMergeTree
);
int32_t
index
=
tMergeTreeGetChosenIndex
(
pHandle
->
pMergeTree
);
SSortSource
*
pSource
=
pHandle
->
cmpParam
.
pSources
[
index
];
SSortSource
*
pSource
=
pHandle
->
cmpParam
.
pSources
[
index
];
if
(
pHandle
->
needAdjust
)
{
if
(
pHandle
->
needAdjust
)
{
int32_t
code
=
adjustMergeTreeForNextTuple
(
pSource
,
pHandle
->
pMergeTree
,
pHandle
,
&
pHandle
->
numOfCompletedSources
);
int32_t
code
=
adjustMergeTreeForNextTuple
(
pSource
,
pHandle
->
pMergeTree
,
pHandle
,
&
pHandle
->
numOfCompletedSources
);
...
@@ -778,15 +791,13 @@ void* tsortGetValue(STupleHandle* pVHandle, int32_t colIndex) {
...
@@ -778,15 +791,13 @@ void* tsortGetValue(STupleHandle* pVHandle, int32_t colIndex) {
}
}
}
}
uint64_t
tsortGetGroupId
(
STupleHandle
*
pVHandle
)
{
uint64_t
tsortGetGroupId
(
STupleHandle
*
pVHandle
)
{
return
pVHandle
->
pBlock
->
info
.
groupId
;
}
return
pVHandle
->
pBlock
->
info
.
groupId
;
}
SSortExecInfo
tsortGetSortExecInfo
(
SSortHandle
*
pHandle
)
{
SSortExecInfo
tsortGetSortExecInfo
(
SSortHandle
*
pHandle
)
{
SSortExecInfo
info
=
{
0
};
SSortExecInfo
info
=
{
0
};
info
.
sortBuffer
=
pHandle
->
pageSize
*
pHandle
->
numOfPages
;
info
.
sortBuffer
=
pHandle
->
pageSize
*
pHandle
->
numOfPages
;
info
.
sortMethod
=
pHandle
->
inMemSort
?
SORT_QSORT_T
:
SORT_SPILLED_MERGE_SORT_T
;
info
.
sortMethod
=
pHandle
->
inMemSort
?
SORT_QSORT_T
:
SORT_SPILLED_MERGE_SORT_T
;
info
.
loops
=
pHandle
->
loops
;
info
.
loops
=
pHandle
->
loops
;
if
(
pHandle
->
pBuf
!=
NULL
)
{
if
(
pHandle
->
pBuf
!=
NULL
)
{
...
@@ -797,4 +808,3 @@ SSortExecInfo tsortGetSortExecInfo(SSortHandle* pHandle) {
...
@@ -797,4 +808,3 @@ SSortExecInfo tsortGetSortExecInfo(SSortHandle* pHandle) {
return
info
;
return
info
;
}
}
source/libs/executor/test/lhashTests.cpp
浏览文件 @
d5255f1e
...
@@ -32,41 +32,42 @@ TEST(testCase, linear_hash_Tests) {
...
@@ -32,41 +32,42 @@ TEST(testCase, linear_hash_Tests) {
int64_t
st
=
taosGetTimestampUs
();
int64_t
st
=
taosGetTimestampUs
();
SLHashObj
*
pHashObj
=
tHashInit
(
4098
*
4
*
2
,
512
,
fn
,
40
);
SLHashObj
*
pHashObj
=
tHashInit
(
4098
*
4
*
2
,
512
,
fn
,
40
);
for
(
int32_t
i
=
0
;
i
<
1000000
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
1000000
;
++
i
)
{
int32_t
code
=
tHashPut
(
pHashObj
,
&
i
,
sizeof
(
i
),
&
i
,
sizeof
(
i
));
int32_t
code
=
tHashPut
(
pHashObj
,
&
i
,
sizeof
(
i
),
&
i
,
sizeof
(
i
));
assert
(
code
==
0
);
assert
(
code
==
0
);
}
}
// tHashPrint(pHashObj, LINEAR_HASH_STATIS);
// tHashPrint(pHashObj, LINEAR_HASH_STATIS);
int64_t
et
=
taosGetTimestampUs
();
int64_t
et
=
taosGetTimestampUs
();
for
(
int32_t
i
=
0
;
i
<
1000000
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
1000000
;
++
i
)
{
if
(
i
==
950000
)
{
if
(
i
==
950000
)
{
printf
(
"kf
\n
"
);
printf
(
"kf
\n
"
);
}
}
char
*
v
=
tHashGet
(
pHashObj
,
&
i
,
sizeof
(
i
));
char
*
v
=
tHashGet
(
pHashObj
,
&
i
,
sizeof
(
i
));
if
(
v
!=
NULL
)
{
if
(
v
!=
NULL
)
{
// printf("find value: %d, key:%d\n", *(int32_t*) v, i);
// printf("find value: %d, key:%d\n", *(int32_t*) v, i);
}
else
{
}
else
{
// printf("failed to found key:%d in hash\n", i);
// printf("failed to found key:%d in hash\n", i);
}
}
}
}
// tHashPrint(pHashObj, LINEAR_HASH_STATIS);
// tHashPrint(pHashObj, LINEAR_HASH_STATIS);
tHashCleanup
(
pHashObj
);
tHashCleanup
(
pHashObj
);
int64_t
et1
=
taosGetTimestampUs
();
int64_t
et1
=
taosGetTimestampUs
();
SHashObj
*
pHashObj1
=
taosHashInit
(
1000
,
fn
,
false
,
HASH_NO_LOCK
);
SHashObj
*
pHashObj1
=
taosHashInit
(
1000
,
fn
,
false
,
HASH_NO_LOCK
);
for
(
int32_t
i
=
0
;
i
<
1000000
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
1000000
;
++
i
)
{
taosHashPut
(
pHashObj1
,
&
i
,
sizeof
(
i
),
&
i
,
sizeof
(
i
));
taosHashPut
(
pHashObj1
,
&
i
,
sizeof
(
i
),
&
i
,
sizeof
(
i
));
}
}
for
(
int32_t
i
=
0
;
i
<
1000000
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
1000000
;
++
i
)
{
void
*
v
=
taosHashGet
(
pHashObj1
,
&
i
,
sizeof
(
i
));
void
*
v
=
taosHashGet
(
pHashObj1
,
&
i
,
sizeof
(
i
));
}
}
taosHashCleanup
(
pHashObj1
);
taosHashCleanup
(
pHashObj1
);
int64_t
et2
=
taosGetTimestampUs
();
int64_t
et2
=
taosGetTimestampUs
();
printf
(
"linear hash time:%.2f ms, buildHash:%.2f ms, hash:%.2f
\n
"
,
(
et1
-
st
)
/
1000.0
,
(
et
-
st
)
/
1000.0
,
(
et2
-
et1
)
/
1000.0
);
printf
(
"linear hash time:%.2f ms, buildHash:%.2f ms, hash:%.2f
\n
"
,
(
et1
-
st
)
/
1000.0
,
(
et
-
st
)
/
1000.0
,
(
et2
-
et1
)
/
1000.0
);
}
}
\ No newline at end of file
source/libs/executor/test/sortTests.cpp
浏览文件 @
d5255f1e
...
@@ -25,14 +25,14 @@
...
@@ -25,14 +25,14 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "os.h"
#include "executorimpl.h"
#include "executor.h"
#include "executor.h"
#include "executorimpl.h"
#include "taos.h"
#include "taos.h"
#include "tcompare.h"
#include "tdatablock.h"
#include "tdatablock.h"
#include "tdef.h"
#include "tdef.h"
#include "trpc.h"
#include "trpc.h"
#include "tvariant.h"
#include "tvariant.h"
#include "tcompare.h"
namespace
{
namespace
{
typedef
struct
{
typedef
struct
{
...
@@ -44,8 +44,7 @@ typedef struct {
...
@@ -44,8 +44,7 @@ typedef struct {
int16_t
VARCOUNT
=
16
;
int16_t
VARCOUNT
=
16
;
float
rand_f2
()
float
rand_f2
()
{
{
unsigned
r
=
taosRand
();
unsigned
r
=
taosRand
();
r
&=
0x007fffff
;
r
&=
0x007fffff
;
r
|=
0x40800000
;
r
|=
0x40800000
;
...
@@ -53,10 +52,10 @@ float rand_f2()
...
@@ -53,10 +52,10 @@ float rand_f2()
}
}
static
const
int32_t
TEST_NUMBER
=
1
;
static
const
int32_t
TEST_NUMBER
=
1
;
#define bigendian()
((*(char
*)&TEST_NUMBER) == 0)
#define bigendian()
((*(char
*)&TEST_NUMBER) == 0)
SSDataBlock
*
getSingleColDummyBlock
(
void
*
param
)
{
SSDataBlock
*
getSingleColDummyBlock
(
void
*
param
)
{
_info
*
pInfo
=
(
_info
*
)
param
;
_info
*
pInfo
=
(
_info
*
)
param
;
if
(
--
pInfo
->
count
<
0
)
{
if
(
--
pInfo
->
count
<
0
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -65,11 +64,11 @@ SSDataBlock* getSingleColDummyBlock(void* param) {
...
@@ -65,11 +64,11 @@ SSDataBlock* getSingleColDummyBlock(void* param) {
SColumnInfoData
colInfo
=
{
0
};
SColumnInfoData
colInfo
=
{
0
};
colInfo
.
info
.
type
=
pInfo
->
type
;
colInfo
.
info
.
type
=
pInfo
->
type
;
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_NCHAR
){
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
colInfo
.
info
.
bytes
=
TSDB_NCHAR_SIZE
*
VARCOUNT
+
VARSTR_HEADER_SIZE
;
colInfo
.
info
.
bytes
=
TSDB_NCHAR_SIZE
*
VARCOUNT
+
VARSTR_HEADER_SIZE
;
}
else
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_BINARY
)
{
}
else
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_BINARY
)
{
colInfo
.
info
.
bytes
=
VARCOUNT
+
VARSTR_HEADER_SIZE
;
colInfo
.
info
.
bytes
=
VARCOUNT
+
VARSTR_HEADER_SIZE
;
}
else
{
}
else
{
colInfo
.
info
.
bytes
=
tDataTypes
[
pInfo
->
type
].
bytes
;
colInfo
.
info
.
bytes
=
tDataTypes
[
pInfo
->
type
].
bytes
;
}
}
colInfo
.
info
.
colId
=
1
;
colInfo
.
info
.
colId
=
1
;
...
@@ -80,22 +79,22 @@ SSDataBlock* getSingleColDummyBlock(void* param) {
...
@@ -80,22 +79,22 @@ SSDataBlock* getSingleColDummyBlock(void* param) {
for
(
int32_t
i
=
0
;
i
<
pInfo
->
pageRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInfo
->
pageRows
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
static_cast
<
SColumnInfoData
*>
(
TARRAY_GET_ELEM
(
pBlock
->
pDataBlock
,
0
));
SColumnInfoData
*
pColInfo
=
static_cast
<
SColumnInfoData
*>
(
TARRAY_GET_ELEM
(
pBlock
->
pDataBlock
,
0
));
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_NCHAR
){
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
int32_t
size
=
taosRand
()
%
VARCOUNT
;
int32_t
size
=
taosRand
()
%
VARCOUNT
;
char
str
[
128
]
=
{
0
};
char
str
[
128
]
=
{
0
};
char
strOri
[
128
]
=
{
0
};
char
strOri
[
128
]
=
{
0
};
taosRandStr
(
strOri
,
size
);
taosRandStr
(
strOri
,
size
);
int32_t
len
=
0
;
int32_t
len
=
0
;
bool
ret
=
taosMbsToUcs4
(
strOri
,
size
,
(
TdUcs4
*
)
varDataVal
(
str
),
size
*
TSDB_NCHAR_SIZE
,
&
len
);
bool
ret
=
taosMbsToUcs4
(
strOri
,
size
,
(
TdUcs4
*
)
varDataVal
(
str
),
size
*
TSDB_NCHAR_SIZE
,
&
len
);
if
(
!
ret
){
if
(
!
ret
)
{
printf
(
"error
\n
"
);
printf
(
"error
\n
"
);
return
NULL
;
return
NULL
;
}
}
varDataSetLen
(
str
,
len
);
varDataSetLen
(
str
,
len
);
colDataAppend
(
pColInfo
,
i
,
reinterpret_cast
<
const
char
*>
(
str
),
false
);
colDataAppend
(
pColInfo
,
i
,
reinterpret_cast
<
const
char
*>
(
str
),
false
);
pBlock
->
info
.
hasVarCol
=
true
;
pBlock
->
info
.
hasVarCol
=
true
;
printf
(
"nchar: %s
\n
"
,
strOri
);
printf
(
"nchar: %s
\n
"
,
strOri
);
}
else
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_BINARY
)
{
}
else
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_BINARY
)
{
int32_t
size
=
taosRand
()
%
VARCOUNT
;
int32_t
size
=
taosRand
()
%
VARCOUNT
;
char
str
[
64
]
=
{
0
};
char
str
[
64
]
=
{
0
};
taosRandStr
(
varDataVal
(
str
),
size
);
taosRandStr
(
varDataVal
(
str
),
size
);
...
@@ -103,16 +102,16 @@ SSDataBlock* getSingleColDummyBlock(void* param) {
...
@@ -103,16 +102,16 @@ SSDataBlock* getSingleColDummyBlock(void* param) {
colDataAppend
(
pColInfo
,
i
,
reinterpret_cast
<
const
char
*>
(
str
),
false
);
colDataAppend
(
pColInfo
,
i
,
reinterpret_cast
<
const
char
*>
(
str
),
false
);
pBlock
->
info
.
hasVarCol
=
true
;
pBlock
->
info
.
hasVarCol
=
true
;
printf
(
"binary: %s
\n
"
,
varDataVal
(
str
));
printf
(
"binary: %s
\n
"
,
varDataVal
(
str
));
}
else
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_DOUBLE
||
pInfo
->
type
==
TSDB_DATA_TYPE_FLOAT
)
{
}
else
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_DOUBLE
||
pInfo
->
type
==
TSDB_DATA_TYPE_FLOAT
)
{
double
v
=
rand_f2
();
double
v
=
rand_f2
();
colDataAppend
(
pColInfo
,
i
,
reinterpret_cast
<
const
char
*>
(
&
v
),
false
);
colDataAppend
(
pColInfo
,
i
,
reinterpret_cast
<
const
char
*>
(
&
v
),
false
);
printf
(
"float: %f
\n
"
,
v
);
printf
(
"float: %f
\n
"
,
v
);
}
else
{
}
else
{
int64_t
v
=
++
pInfo
->
startVal
;
int64_t
v
=
++
pInfo
->
startVal
;
char
*
result
=
static_cast
<
char
*>
(
taosMemoryCalloc
(
tDataTypes
[
pInfo
->
type
].
bytes
,
1
));
char
*
result
=
static_cast
<
char
*>
(
taosMemoryCalloc
(
tDataTypes
[
pInfo
->
type
].
bytes
,
1
));
if
(
!
bigendian
()){
if
(
!
bigendian
())
{
memcpy
(
result
,
&
v
,
tDataTypes
[
pInfo
->
type
].
bytes
);
memcpy
(
result
,
&
v
,
tDataTypes
[
pInfo
->
type
].
bytes
);
}
else
{
}
else
{
memcpy
(
result
,
(
char
*
)(
&
v
)
+
sizeof
(
int64_t
)
-
tDataTypes
[
pInfo
->
type
].
bytes
,
tDataTypes
[
pInfo
->
type
].
bytes
);
memcpy
(
result
,
(
char
*
)(
&
v
)
+
sizeof
(
int64_t
)
-
tDataTypes
[
pInfo
->
type
].
bytes
,
tDataTypes
[
pInfo
->
type
].
bytes
);
}
}
...
@@ -126,15 +125,14 @@ SSDataBlock* getSingleColDummyBlock(void* param) {
...
@@ -126,15 +125,14 @@ SSDataBlock* getSingleColDummyBlock(void* param) {
return
pBlock
;
return
pBlock
;
}
}
int32_t
docomp
(
const
void
*
p1
,
const
void
*
p2
,
void
*
param
)
{
int32_t
docomp
(
const
void
*
p1
,
const
void
*
p2
,
void
*
param
)
{
int32_t
pLeftIdx
=
*
(
int32_t
*
)
p1
;
int32_t
pLeftIdx
=
*
(
int32_t
*
)
p1
;
int32_t
pRightIdx
=
*
(
int32_t
*
)
p2
;
int32_t
pRightIdx
=
*
(
int32_t
*
)
p2
;
SMsortComparParam
*
pParam
=
(
SMsortComparParam
*
)
param
;
SMsortComparParam
*
pParam
=
(
SMsortComparParam
*
)
param
;
SSortSource
**
px
=
reinterpret_cast
<
SSortSource
**>
(
pParam
->
pSources
);
SSortSource
**
px
=
reinterpret_cast
<
SSortSource
**>
(
pParam
->
pSources
);
SArray
*
pInfo
=
pParam
->
orderInfo
;
SArray
*
pInfo
=
pParam
->
orderInfo
;
SSortSource
*
pLeftSource
=
px
[
pLeftIdx
];
SSortSource
*
pLeftSource
=
px
[
pLeftIdx
];
SSortSource
*
pRightSource
=
px
[
pRightIdx
];
SSortSource
*
pRightSource
=
px
[
pRightIdx
];
...
@@ -151,20 +149,22 @@ int32_t docomp(const void* p1, const void* p2, void* param) {
...
@@ -151,20 +149,22 @@ int32_t docomp(const void* p1, const void* p2, void* param) {
SSDataBlock
*
pLeftBlock
=
pLeftSource
->
src
.
pBlock
;
SSDataBlock
*
pLeftBlock
=
pLeftSource
->
src
.
pBlock
;
SSDataBlock
*
pRightBlock
=
pRightSource
->
src
.
pBlock
;
SSDataBlock
*
pRightBlock
=
pRightSource
->
src
.
pBlock
;
for
(
int32_t
i
=
0
;
i
<
pInfo
->
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInfo
->
size
;
++
i
)
{
SBlockOrderInfo
*
pOrder
=
(
SBlockOrderInfo
*
)
TARRAY_GET_ELEM
(
pInfo
,
i
);
SBlockOrderInfo
*
pOrder
=
(
SBlockOrderInfo
*
)
TARRAY_GET_ELEM
(
pInfo
,
i
);
SColumnInfoData
*
pLeftColInfoData
=
(
SColumnInfoData
*
)
TARRAY_GET_ELEM
(
pLeftBlock
->
pDataBlock
,
pOrder
->
slotId
);
SColumnInfoData
*
pLeftColInfoData
=
(
SColumnInfoData
*
)
TARRAY_GET_ELEM
(
pLeftBlock
->
pDataBlock
,
pOrder
->
slotId
);
bool
leftNull
=
false
;
bool
leftNull
=
false
;
if
(
pLeftColInfoData
->
hasNull
)
{
if
(
pLeftColInfoData
->
hasNull
)
{
leftNull
=
colDataIsNull
(
pLeftColInfoData
,
pLeftBlock
->
info
.
rows
,
pLeftSource
->
src
.
rowIndex
,
pLeftBlock
->
pBlockAgg
[
pOrder
->
slotId
]);
leftNull
=
colDataIsNull
(
pLeftColInfoData
,
pLeftBlock
->
info
.
rows
,
pLeftSource
->
src
.
rowIndex
,
pLeftBlock
->
pBlockAgg
[
pOrder
->
slotId
]);
}
}
SColumnInfoData
*
pRightColInfoData
=
(
SColumnInfoData
*
)
TARRAY_GET_ELEM
(
pRightBlock
->
pDataBlock
,
pOrder
->
slotId
);
SColumnInfoData
*
pRightColInfoData
=
(
SColumnInfoData
*
)
TARRAY_GET_ELEM
(
pRightBlock
->
pDataBlock
,
pOrder
->
slotId
);
bool
rightNull
=
false
;
bool
rightNull
=
false
;
if
(
pRightColInfoData
->
hasNull
)
{
if
(
pRightColInfoData
->
hasNull
)
{
rightNull
=
colDataIsNull
(
pRightColInfoData
,
pRightBlock
->
info
.
rows
,
pRightSource
->
src
.
rowIndex
,
pRightBlock
->
pBlockAgg
[
pOrder
->
slotId
]);
rightNull
=
colDataIsNull
(
pRightColInfoData
,
pRightBlock
->
info
.
rows
,
pRightSource
->
src
.
rowIndex
,
pRightBlock
->
pBlockAgg
[
pOrder
->
slotId
]);
}
}
if
(
leftNull
&&
rightNull
)
{
if
(
leftNull
&&
rightNull
)
{
...
@@ -172,11 +172,11 @@ int32_t docomp(const void* p1, const void* p2, void* param) {
...
@@ -172,11 +172,11 @@ int32_t docomp(const void* p1, const void* p2, void* param) {
}
}
if
(
rightNull
)
{
if
(
rightNull
)
{
return
pOrder
->
nullFirst
?
1
:
-
1
;
return
pOrder
->
nullFirst
?
1
:
-
1
;
}
}
if
(
leftNull
)
{
if
(
leftNull
)
{
return
pOrder
->
nullFirst
?
-
1
:
1
;
return
pOrder
->
nullFirst
?
-
1
:
1
;
}
}
void
*
left1
=
colDataGetData
(
pLeftColInfoData
,
pLeftSource
->
src
.
rowIndex
);
void
*
left1
=
colDataGetData
(
pLeftColInfoData
,
pLeftSource
->
src
.
rowIndex
);
...
...
source/libs/executor/test/tSimpleHashTests.cpp
浏览文件 @
d5255f1e
...
@@ -31,8 +31,7 @@
...
@@ -31,8 +31,7 @@
// }
// }
TEST
(
testCase
,
tSimpleHashTest_intKey
)
{
TEST
(
testCase
,
tSimpleHashTest_intKey
)
{
SSHashObj
*
pHashObj
=
SSHashObj
*
pHashObj
=
tSimpleHashInit
(
8
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
));
tSimpleHashInit
(
8
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
));
assert
(
pHashObj
!=
nullptr
);
assert
(
pHashObj
!=
nullptr
);
...
@@ -76,10 +75,8 @@ TEST(testCase, tSimpleHashTest_intKey) {
...
@@ -76,10 +75,8 @@ TEST(testCase, tSimpleHashTest_intKey) {
tSimpleHashCleanup
(
pHashObj
);
tSimpleHashCleanup
(
pHashObj
);
}
}
TEST
(
testCase
,
tSimpleHashTest_binaryKey
)
{
TEST
(
testCase
,
tSimpleHashTest_binaryKey
)
{
SSHashObj
*
pHashObj
=
SSHashObj
*
pHashObj
=
tSimpleHashInit
(
8
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
));
tSimpleHashInit
(
8
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
));
assert
(
pHashObj
!=
nullptr
);
assert
(
pHashObj
!=
nullptr
);
...
@@ -140,5 +137,4 @@ TEST(testCase, tSimpleHashTest_binaryKey) {
...
@@ -140,5 +137,4 @@ TEST(testCase, tSimpleHashTest_binaryKey) {
tSimpleHashCleanup
(
pHashObj
);
tSimpleHashCleanup
(
pHashObj
);
}
}
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
\ No newline at end of file
source/libs/tfs/inc/tfsInt.h
浏览文件 @
d5255f1e
...
@@ -26,12 +26,14 @@
...
@@ -26,12 +26,14 @@
#include "tlog.h"
#include "tlog.h"
// For debug purpose
// For debug purpose
// clang-format off
#define fFatal(...) { if (fsDebugFlag & DEBUG_FATAL) { taosPrintLog("TFS FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
#define fFatal(...) { if (fsDebugFlag & DEBUG_FATAL) { taosPrintLog("TFS FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
#define fError(...) { if (fsDebugFlag & DEBUG_ERROR) { taosPrintLog("TFS ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
#define fError(...) { if (fsDebugFlag & DEBUG_ERROR) { taosPrintLog("TFS ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
#define fWarn(...) { if (fsDebugFlag & DEBUG_WARN) { taosPrintLog("TFS WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
#define fWarn(...) { if (fsDebugFlag & DEBUG_WARN) { taosPrintLog("TFS WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
#define fInfo(...) { if (fsDebugFlag & DEBUG_INFO) { taosPrintLog("TFS ", DEBUG_INFO, 255, __VA_ARGS__); }}
#define fInfo(...) { if (fsDebugFlag & DEBUG_INFO) { taosPrintLog("TFS ", DEBUG_INFO, 255, __VA_ARGS__); }}
#define fDebug(...) { if (fsDebugFlag & DEBUG_DEBUG) { taosPrintLog("TFS ", DEBUG_DEBUG, fsDebugFlag, __VA_ARGS__); }}
#define fDebug(...) { if (fsDebugFlag & DEBUG_DEBUG) { taosPrintLog("TFS ", DEBUG_DEBUG, fsDebugFlag, __VA_ARGS__); }}
#define fTrace(...) { if (fsDebugFlag & DEBUG_TRACE) { taosPrintLog("TFS ", DEBUG_TRACE, fsDebugFlag, __VA_ARGS__); }}
#define fTrace(...) { if (fsDebugFlag & DEBUG_TRACE) { taosPrintLog("TFS ", DEBUG_TRACE, fsDebugFlag, __VA_ARGS__); }}
// clang-format on
typedef
struct
{
typedef
struct
{
int32_t
level
;
int32_t
level
;
...
...
source/libs/tfs/src/tfs.c
浏览文件 @
d5255f1e
source/libs/tfs/test/tfsTest.cpp
浏览文件 @
d5255f1e
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
class
TfsTest
:
public
::
testing
::
Test
{
class
TfsTest
:
public
::
testing
::
Test
{
protected:
protected:
#ifdef _TD_DARWIN_64
#ifdef _TD_DARWIN_64
static
void
SetUpTestSuite
()
{
root
=
"/private"
TD_TMP_DIR_PATH
"tfsTest"
;
}
static
void
SetUpTestSuite
()
{
root
=
"/private"
TD_TMP_DIR_PATH
"tfsTest"
;
}
#else
#else
static
void
SetUpTestSuite
()
{
root
=
TD_TMP_DIR_PATH
"tfsTest"
;
}
static
void
SetUpTestSuite
()
{
root
=
TD_TMP_DIR_PATH
"tfsTest"
;
}
...
@@ -303,7 +303,7 @@ TEST_F(TfsTest, 04_File) {
...
@@ -303,7 +303,7 @@ TEST_F(TfsTest, 04_File) {
TEST_F
(
TfsTest
,
05
_MultiDisk
)
{
TEST_F
(
TfsTest
,
05
_MultiDisk
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
#ifdef _TD_DARWIN_64
#ifdef _TD_DARWIN_64
const
char
*
root00
=
"/private"
TD_TMP_DIR_PATH
"tfsTest00"
;
const
char
*
root00
=
"/private"
TD_TMP_DIR_PATH
"tfsTest00"
;
const
char
*
root01
=
"/private"
TD_TMP_DIR_PATH
"tfsTest01"
;
const
char
*
root01
=
"/private"
TD_TMP_DIR_PATH
"tfsTest01"
;
const
char
*
root10
=
"/private"
TD_TMP_DIR_PATH
"tfsTest10"
;
const
char
*
root10
=
"/private"
TD_TMP_DIR_PATH
"tfsTest10"
;
...
...
tools/scripts/codeFormat.sh
浏览文件 @
d5255f1e
...
@@ -12,7 +12,25 @@ FORMAT_DIR_LIST=(
...
@@ -12,7 +12,25 @@ FORMAT_DIR_LIST=(
"source/os"
"source/os"
"source/util"
"source/util"
"source/common"
"source/common"
# "source/libs"
"source/libs/cache"
"source/libs/catalog"
"source/libs/command"
"source/libs/executor"
# "source/libs/function"
# "source/libs/index"
# "source/libs/monitor"
# "source/libs/nodes"
# "source/libs/parser"
# "source/libs/planner"
# "source/libs/qcom"
# "source/libs/qworker"
# "source/libs/scalar"
# "source/libs/stream"
# "source/libs/sync"
"source/libs/tdb"
"source/libs/tfs"
# "source/libs/transport"
"source/libs/wal"
# "source/client"
# "source/client"
"source/dnode"
"source/dnode"
)
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录