Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
883a65f6
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
883a65f6
编写于
4月 25, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact more
上级
bb8384e8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
92 addition
and
102 deletion
+92
-102
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+0
-2
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+43
-70
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+9
-4
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+40
-26
未找到文件。
source/dnode/vnode/src/inc/meta.h
浏览文件 @
883a65f6
...
...
@@ -114,8 +114,6 @@ int metaDropTable(SMeta* pMeta, tb_uid_t uid);
int
metaCommit
(
SMeta
*
pMeta
);
int32_t
metaCreateTSma
(
SMeta
*
pMeta
,
SSmaCfg
*
pCfg
);
int32_t
metaDropTSma
(
SMeta
*
pMeta
,
int64_t
indexUid
);
STbCfg
*
metaGetTbInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
void
*
metaGetSmaInfoByIndex
(
SMeta
*
pMeta
,
int64_t
indexUid
,
bool
isDecode
);
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
883a65f6
...
...
@@ -132,39 +132,43 @@ int metaTbCursorNext(SMTbCursor *pTbCur) {
return
0
;
}
STbCfg
*
metaGetTbInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
)
{
#if 0
int ret;
SMetaDB *pMetaDb = pMeta->pDB;
void *pKey;
void *pVal;
int kLen;
int vLen;
STbCfg *pTbCfg;
// Fetch
pKey = &uid;
kLen = sizeof(uid);
pVal = NULL;
ret = tdbDbGet(pMetaDb->pTbDB, pKey, kLen, &pVal, &vLen);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
)
{
void
*
pKey
=
NULL
;
void
*
pVal
=
NULL
;
int
kLen
=
0
;
int
vLen
=
0
;
int
ret
;
SSkmDbKey
skmDbKey
;
SSchemaWrapper
*
pSW
=
NULL
;
SSchema
*
pSchema
=
NULL
;
void
*
pBuf
;
SCoder
coder
=
{
0
};
// fetch
skmDbKey
.
uid
=
uid
;
skmDbKey
.
sver
=
sver
;
pKey
=
&
skmDbKey
;
kLen
=
sizeof
(
skmDbKey
);
ret
=
tdbDbGet
(
pMeta
->
pSkmDb
,
pKey
,
kLen
,
&
pVal
,
&
vLen
);
if
(
ret
<
0
)
{
return
NULL
;
}
//
D
ecode
p
TbCfg = taosMemoryMalloc(sizeof(*pTbCfg))
;
metaDecodeTbInfo(pVal, pTbCfg
);
//
d
ecode
p
Buf
=
pVal
;
pSW
=
taosMemoryMalloc
(
sizeof
(
pSW
)
);
TDB_FREE(pVal);
tCoderInit
(
&
coder
,
TD_LITTLE_ENDIAN
,
pVal
,
vLen
,
TD_DECODER
);
tDecodeSSchemaWrapper
(
&
coder
,
pSW
);
pSchema
=
taosMemoryMalloc
(
sizeof
(
SSchema
)
*
pSW
->
nCols
);
memcpy
(
pSchema
,
pSW
->
pSchema
,
sizeof
(
SSchema
)
*
pSW
->
nCols
);
tCoderClear
(
&
coder
);
return pTbCfg;
#endif
return
NULL
;
}
pSW
->
pSchema
=
pSchema
;
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
)
{
// return metaGetTableSchemaImpl(pMeta, uid, sver, isinline, false);
return
NULL
;
TDB_FREE
(
pVal
);
return
pSW
;
}
SMCtbCursor
*
metaOpenCtbCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
)
{
...
...
@@ -216,26 +220,25 @@ tb_uid_t metaCtbCursorNext(SMCtbCursor *pCtbCur) {
}
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
)
{
#if 0
tb_uid_t
quid
;
SSchemaWrapper *pSW;
STSchemaBuilder sb;
SMetaReader
mr
=
{
0
};
STSchema
*
pTSchema
=
NULL
;
SSchemaWrapper
*
pSW
=
NULL
;
STSchemaBuilder
sb
=
{
0
};
SSchema
*
pSchema
;
STSchema *pTSchema;
STbCfg *pTbCfg;
pTbCfg = metaGetTbInfoByUid(pMeta, uid);
if (pTbCfg->type == META_CHILD_TABLE) {
quid = pTbCfg->ctbCfg.suid;
metaReaderInit
(
&
mr
,
pMeta
->
pVnode
,
0
);
metaGetTableEntryByUid
(
&
mr
,
uid
);
if
(
mr
.
me
.
type
==
TSDB_CHILD_TABLE
)
{
quid
=
mr
.
me
.
ctbEntry
.
suid
;
}
else
{
quid
=
uid
;
}
pSW = metaGetTableSchemaImpl(pMeta, quid, sver, true, true);
if (pSW == NULL) {
return NULL;
}
metaReaderClear
(
&
mr
);
pSW
=
metaGetTableSchema
(
pMeta
,
quid
,
sver
,
0
);
tdInitTSchemaBuilder
(
&
sb
,
0
);
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
pSchema
=
pSW
->
pSchema
+
i
;
...
...
@@ -244,9 +247,9 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) {
pTSchema
=
tdGetSchemaFromBuilder
(
&
sb
);
tdDestroyTSchemaBuilder
(
&
sb
);
taosMemoryFree
(
pSW
->
pSchema
);
taosMemoryFree
(
pSW
);
return
pTSchema
;
#endif
return
NULL
;
}
STSmaWrapper
*
metaGetSmaInfoByTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
)
{
...
...
@@ -314,36 +317,6 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
return
NULL
;
}
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
)
{
#if 0
void *pKey;
void *pVal;
void *ppKey;
int pkLen;
int kLen;
int vLen;
int ret;
pKey = tbname;
kLen = strlen(tbname) + 1;
pVal = NULL;
ppKey = NULL;
ret = tdbDbPGet(pMeta->pDB->pNameIdx, pKey, kLen, &ppKey, &pkLen, &pVal, &vLen);
if (ret < 0) {
return NULL;
}
ASSERT(pkLen == kLen + sizeof(uid));
*uid = *(tb_uid_t *)POINTER_SHIFT(ppKey, kLen);
TDB_FREE(ppKey);
TDB_FREE(pVal);
return metaGetTbInfoByUid(pMeta, *uid);
#endif
return
NULL
;
}
int
metaGetTbNum
(
SMeta
*
pMeta
)
{
// TODO
// ASSERT(0);
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
883a65f6
...
...
@@ -90,10 +90,15 @@ int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* p
if
(
pHandle
->
sver
!=
sversion
)
{
pHandle
->
pSchema
=
metaGetTbTSchema
(
pHandle
->
pVnodeMeta
,
pHandle
->
pBlock
->
uid
,
sversion
);
tb_uid_t
quid
;
STbCfg
*
pTbCfg
=
metaGetTbInfoByUid
(
pHandle
->
pVnodeMeta
,
pHandle
->
pBlock
->
uid
);
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
quid
=
pTbCfg
->
ctb
.
suid
;
tb_uid_t
quid
;
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
pHandle
->
pVnodeMeta
->
pVnode
,
0
);
metaGetTableEntryByUid
(
&
mr
,
pHandle
->
pBlock
->
uid
);
if
(
mr
.
me
.
type
==
META_CHILD_TABLE
)
{
quid
=
mr
.
me
.
ctbEntry
.
suid
;
}
else
{
quid
=
pHandle
->
pBlock
->
uid
;
}
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
883a65f6
...
...
@@ -98,24 +98,24 @@ typedef struct SIOCostSummary {
}
SIOCostSummary
;
typedef
struct
STsdbReadHandle
{
STsdb
*
pTsdb
;
SQueryFilePos
cur
;
// current position
int16_t
order
;
STimeWindow
window
;
// the primary query time window that applies to all queries
STsdb
*
pTsdb
;
SQueryFilePos
cur
;
// current position
int16_t
order
;
STimeWindow
window
;
// the primary query time window that applies to all queries
SColumnDataAgg
*
statis
;
// query level statistics, only one table block statistics info exists at any time
int32_t
numOfBlocks
;
SArray
*
pColumns
;
// column list, SColumnInfoData array list
bool
locateStart
;
int32_t
outputCapacity
;
int32_t
realNumOfRows
;
SArray
*
pTableCheckInfo
;
// SArray<STableCheckInfo>
int32_t
activeIndex
;
bool
checkFiles
;
// check file stage
int8_t
cachelastrow
;
// check if last row cached
bool
loadExternalRow
;
// load time window external data rows
bool
currentLoadExternalRows
;
// current load external rows
int32_t
loadType
;
// block load type
char
*
idStr
;
// query info handle, for debug purpose
int32_t
numOfBlocks
;
SArray
*
pColumns
;
// column list, SColumnInfoData array list
bool
locateStart
;
int32_t
outputCapacity
;
int32_t
realNumOfRows
;
SArray
*
pTableCheckInfo
;
// SArray<STableCheckInfo>
int32_t
activeIndex
;
bool
checkFiles
;
// check file stage
int8_t
cachelastrow
;
// check if last row cached
bool
loadExternalRow
;
// load time window external data rows
bool
currentLoadExternalRows
;
// current load external rows
int32_t
loadType
;
// block load type
char
*
idStr
;
// query info handle, for debug purpose
int32_t
type
;
// query type: retrieve all data blocks, 2. retrieve only last row, 3. retrieve direct prev|next rows
SDFileSet
*
pFileGroup
;
SFSIter
fileIter
;
...
...
@@ -1443,7 +1443,7 @@ static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t
j
++
;
i
++
;
}
else
{
// pColInfo->info.colId < src->colId, it is a NULL data
}
else
{
// pColInfo->info.colId < src->colId, it is a NULL data
int32_t
rowIndex
=
numOfRows
;
for
(
int32_t
k
=
start
;
k
<
num
+
start
;
++
k
,
++
rowIndex
)
{
// TODO opt performance
colDataAppend
(
pColInfo
,
rowIndex
,
NULL
,
true
);
...
...
@@ -1454,10 +1454,11 @@ static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t
while
(
i
<
requiredNumOfCols
)
{
// the remain columns are all null data
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pTsdbReadHandle
->
pColumns
,
i
);
int32_t
rowIndex
=
numOfRows
;
int32_t
rowIndex
=
numOfRows
;
for
(
int32_t
k
=
start
;
k
<
num
+
start
;
++
k
,
++
rowIndex
)
{
colDataAppend
(
pColInfo
,
rowIndex
,
NULL
,
true
);
// TODO add a fast version to set a number of consecutive NULL value.
colDataAppend
(
pColInfo
,
rowIndex
,
NULL
,
true
);
// TODO add a fast version to set a number of consecutive NULL value.
}
i
++
;
}
...
...
@@ -1777,7 +1778,8 @@ static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInf
STable
*
pTable
=
NULL
;
int32_t
endPos
=
getEndPosInDataBlock
(
pTsdbReadHandle
,
&
blockInfo
);
tsdbDebug
(
"%p uid:%"
PRIu64
" start merge data block, file block range:%"
PRIu64
"-%"
PRIu64
" rows:%d, start:%d, end:%d, %s"
,
tsdbDebug
(
"%p uid:%"
PRIu64
" start merge data block, file block range:%"
PRIu64
"-%"
PRIu64
" rows:%d, start:%d, end:%d, %s"
,
pTsdbReadHandle
,
pCheckInfo
->
tableId
,
blockInfo
.
window
.
skey
,
blockInfo
.
window
.
ekey
,
blockInfo
.
rows
,
cur
->
pos
,
endPos
,
pTsdbReadHandle
->
idStr
);
...
...
@@ -3626,20 +3628,25 @@ SArray* createTableGroup(SArray* pTableList, SSchemaWrapper* pTagSchema, SColInd
int32_t
tsdbQuerySTableByTagCond
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
skey
,
const
char
*
pTagCond
,
size_t
len
,
int16_t
tagNameRelType
,
const
char
*
tbnameCond
,
STableGroupInfo
*
pGroupInfo
,
SColIndex
*
pColIndex
,
int32_t
numOfCols
,
uint64_t
reqId
,
uint64_t
taskId
)
{
STbCfg
*
pTbCfg
=
metaGetTbInfoByUid
(
pMeta
,
uid
);
if
(
pTbCfg
==
NULL
)
{
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
((
SMeta
*
)
pMeta
)
->
pVnode
,
0
);
if
(
metaGetTableEntryByUid
(
&
mr
,
uid
)
<
0
)
{
tsdbError
(
"%p failed to get stable, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
uid
,
taskId
,
reqId
);
terrno
=
TSDB_CODE_TDB_INVALID_TABLE_ID
;
goto
_error
;
}
if
(
pTbCfg
->
type
!=
META_SUPER_TABLE
)
{
if
(
mr
.
me
.
type
!=
META_SUPER_TABLE
)
{
tsdbError
(
"%p query normal tag not allowed, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
uid
,
taskId
,
reqId
);
terrno
=
TSDB_CODE_OPS_NOT_SUPPORT
;
// basically, this error is caused by invalid sql issued by client
goto
_error
;
}
metaReaderClear
(
&
mr
);
// NOTE: not add ref count for super table
SArray
*
res
=
taosArrayInit
(
8
,
sizeof
(
STableKeyInfo
));
SSchemaWrapper
*
pTagSchema
=
metaGetTableSchema
(
pMeta
,
uid
,
0
,
true
);
...
...
@@ -3690,12 +3697,18 @@ int32_t tsdbQueryTableList(void* pMeta, SArray* pRes, void* filterInfo) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
tsdbGetOneTableGroup
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
startKey
,
STableGroupInfo
*
pGroupInfo
)
{
STbCfg
*
pTbCfg
=
metaGetTbInfoByUid
(
pMeta
,
uid
);
if
(
pTbCfg
==
NULL
)
{
SMeta
*
metaP
=
(
SMeta
*
)
pMeta
;
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
metaP
->
pVnode
,
0
);
if
(
metaGetTableEntryByUid
(
&
mr
,
uid
)
<
0
)
{
terrno
=
TSDB_CODE_TDB_INVALID_TABLE_ID
;
goto
_error
;
}
metaReaderClear
(
&
mr
);
pGroupInfo
->
numOfTables
=
1
;
pGroupInfo
->
pGroupList
=
taosArrayInit
(
1
,
POINTER_BYTES
);
...
...
@@ -3708,6 +3721,7 @@ int32_t tsdbGetOneTableGroup(void* pMeta, uint64_t uid, TSKEY startKey, STableGr
return
TSDB_CODE_SUCCESS
;
_error:
metaReaderClear
(
&
mr
);
return
terrno
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录