Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9a35d4e9
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
9a35d4e9
编写于
4月 26, 2023
作者:
H
Haojun Liao
提交者:
GitHub
4月 26, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21087 from taosdata/fix/liaohj_main
refactor: do some internal refactor.
上级
51a1e07d
ca4df761
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
43 addition
and
209 deletion
+43
-209
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+4
-6
source/dnode/vnode/src/tq/tqScan.c
source/dnode/vnode/src/tq/tqScan.c
+0
-2
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+36
-48
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+3
-153
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
9a35d4e9
...
...
@@ -123,15 +123,13 @@ int32_t tsdbRowCmprFn(const void *p1, const void *p2);
int32_t
tsdbRowIterOpen
(
STSDBRowIter
*
pIter
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
);
void
tsdbRowClose
(
STSDBRowIter
*
pIter
);
SColVal
*
tsdbRowIterNext
(
STSDBRowIter
*
pIter
);
// SRowMerger
int32_t
tsdbRowMergerInit
(
SRowMerger
*
pMerger
,
STSchema
*
p
ResTSchema
,
TSDBROW
*
pRow
,
STSchema
*
pT
Schema
);
int32_t
tsdbRowMergerInit
(
SRowMerger
*
pMerger
,
STSchema
*
pSchema
);
int32_t
tsdbRowMergerAdd
(
SRowMerger
*
pMerger
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
);
void
tsdbRowMergerClear
(
SRowMerger
*
pMerger
);
int32_t
tsdbRowMergerGetRow
(
SRowMerger
*
pMerger
,
SRow
**
ppRow
);
int32_t
tsdbRowMergerInit_rv
(
SRowMerger
*
pMerger
,
STSchema
*
pSchema
);
void
tsdbRowMergerClear_rv
(
SRowMerger
*
pMerger
);
void
tsdbRowMergerCleanup_rv
(
SRowMerger
*
pMerger
);
void
tsdbRowMergerClear
(
SRowMerger
*
pMerger
);
void
tsdbRowMergerCleanup
(
SRowMerger
*
pMerger
);
// TABLEID
int32_t
tTABLEIDCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
...
...
source/dnode/vnode/src/tq/tqScan.c
浏览文件 @
9a35d4e9
...
...
@@ -74,7 +74,6 @@ int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffs
qTaskInfo_t
task
=
pExec
->
task
;
if
(
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
)
<
0
)
{
tqError
(
"prepare scan failed, return"
);
return
-
1
;
}
...
...
@@ -119,7 +118,6 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta
qTaskInfo_t
task
=
pExec
->
task
;
if
(
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
)
<
0
)
{
tqDebug
(
"tqScanTaosx prepare scan failed, return"
);
return
-
1
;
}
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
9a35d4e9
...
...
@@ -780,7 +780,6 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
}
pSup
->
tsColAgg
.
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
setColumnIdSlotList
(
pSup
,
pCond
->
colList
,
pCond
->
pSlotList
,
pCond
->
numOfCols
);
code
=
tBlockDataCreate
(
&
pReader
->
status
.
fileBlockData
);
...
...
@@ -789,8 +788,20 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
goto
_end
;
}
ASSERT
(
pReader
->
suppInfo
.
colId
[
0
]
==
PRIMARYKEY_TIMESTAMP_COL_ID
);
if
(
pReader
->
suppInfo
.
colId
[
0
]
!=
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
tsdbError
(
"the first column isn't primary timestamp, %d, %s"
,
pReader
->
suppInfo
.
colId
[
0
],
pReader
->
idStr
);
terrno
=
TSDB_CODE_INVALID_PARA
;
goto
_end
;
}
pReader
->
status
.
pPrimaryTsCol
=
taosArrayGet
(
pReader
->
pResBlock
->
pDataBlock
,
pSup
->
slotId
[
0
]);
int32_t
type
=
pReader
->
status
.
pPrimaryTsCol
->
info
.
type
;
if
(
type
!=
TSDB_DATA_TYPE_TIMESTAMP
)
{
tsdbError
(
"the first column isn't primary timestamp in result block, actual: %s, %s"
,
tDataTypes
[
type
].
name
,
pReader
->
idStr
);
terrno
=
TSDB_CODE_INVALID_PARA
;
goto
_end
;
}
tsdbInitReaderLock
(
pReader
);
...
...
@@ -1464,7 +1475,6 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
pBlockIter
->
pTableMap
=
pReader
->
status
.
pTableMap
;
// access data blocks according to the offset of each block in asc/desc order.
// int32_t numOfTables = (int32_t)tSimpleHashGetSize(pReader->status.pTableMap);
int32_t
numOfTables
=
taosArrayGetSize
(
pTableList
);
int64_t
st
=
taosGetTimestampUs
();
...
...
@@ -1474,21 +1484,10 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
}
int32_t
cnt
=
0
;
// void* ptr = NULL;
// int32_t iter = 0;
// while (1) {
// ptr = tSimpleHashIterate(pReader->status.pTableMap, ptr, &iter);
// if (ptr == NULL) {
// break;
// }
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
STableBlockScanInfo
*
pTableScanInfo
=
taosArrayGetP
(
pTableList
,
i
);
ASSERT
(
pTableScanInfo
->
pBlockList
!=
NULL
&&
taosArrayGetSize
(
pTableScanInfo
->
pBlockList
)
>
0
);
// if (pTableScanInfo->pBlockList == NULL || taosArrayGetSize(pTableScanInfo->pBlockList) == 0) {
// continue;
// }
size_t
num
=
taosArrayGetSize
(
pTableScanInfo
->
pBlockList
);
sup
.
numOfBlocksPerTable
[
sup
.
numOfTables
]
=
num
;
...
...
@@ -1876,8 +1875,6 @@ static bool nextRowFromLastBlocks(SLastBlockReader* pLastBlockReader, STableBloc
pScanInfo
->
lastKeyInStt
=
key
;
if
(
!
hasBeenDropped
(
pScanInfo
->
delSkyline
,
&
pScanInfo
->
lastBlockDelIndex
,
key
,
ver
,
pLastBlockReader
->
order
,
pVerRange
))
{
// the qualifed ts may equal to k.ts, only a greater version one.
// here we need to fallback one step.
return
true
;
}
}
...
...
@@ -1939,7 +1936,7 @@ static FORCE_INLINE STSchema* doGetSchemaForTSRow(int32_t sversion, STsdbReader*
return
NULL
;
}
code
=
tsdbRowMergerInit
_rv
(
&
pReader
->
status
.
merger
,
pReader
->
pSchema
);
code
=
tsdbRowMergerInit
(
&
pReader
->
status
.
merger
,
pReader
->
pSchema
);
if
(
code
!=
0
)
{
terrno
=
code
;
return
NULL
;
...
...
@@ -2021,7 +2018,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
if
(
pReader
->
order
==
TSDB_ORDER_ASC
)
{
if
(
minKey
==
key
)
{
init
=
true
;
// todo check if pReader->pSchema is null or not
int32_t
code
=
tsdbRowMergerAdd
(
&
pReader
->
status
.
m
erger
,
&
fRow
,
pReader
->
pSchema
);
int32_t
code
=
tsdbRowMergerAdd
(
pM
erger
,
&
fRow
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2031,15 +2028,15 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
if
(
minKey
==
tsLast
)
{
TSDBROW
*
fRow1
=
tMergeTreeGetRow
(
&
pLastBlockReader
->
mergeTree
);
if
(
init
)
{
tsdbRowMergerAdd
(
&
pReader
->
status
.
m
erger
,
fRow1
,
NULL
);
tsdbRowMergerAdd
(
pM
erger
,
fRow1
,
NULL
);
}
else
{
init
=
true
;
int32_t
code
=
tsdbRowMergerAdd
(
&
pReader
->
status
.
m
erger
,
fRow1
,
pReader
->
pSchema
);
int32_t
code
=
tsdbRowMergerAdd
(
pM
erger
,
fRow1
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLast
,
&
pReader
->
status
.
m
erger
,
&
pReader
->
verRange
,
pReader
->
idStr
);
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLast
,
pM
erger
,
&
pReader
->
verRange
,
pReader
->
idStr
);
}
if
(
minKey
==
k
.
ts
)
{
...
...
@@ -2051,7 +2048,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
tsdbRowMergerAdd
(
pMerger
,
pRow
,
pSchema
);
}
else
{
init
=
true
;
int32_t
code
=
tsdbRowMergerAdd
(
&
pReader
->
status
.
m
erger
,
pRow
,
pSchema
);
int32_t
code
=
tsdbRowMergerAdd
(
pM
erger
,
pRow
,
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2069,7 +2066,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
return
terrno
;
}
int32_t
code
=
tsdbRowMergerAdd
(
&
pReader
->
status
.
m
erger
,
pRow
,
pSchema
);
int32_t
code
=
tsdbRowMergerAdd
(
pM
erger
,
pRow
,
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2086,7 +2083,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
tsdbRowMergerAdd
(
pMerger
,
fRow1
,
NULL
);
}
else
{
init
=
true
;
int32_t
code
=
tsdbRowMergerAdd
(
&
pReader
->
status
.
m
erger
,
fRow1
,
pReader
->
pSchema
);
int32_t
code
=
tsdbRowMergerAdd
(
pM
erger
,
fRow1
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2099,7 +2096,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
tsdbRowMergerAdd
(
pMerger
,
&
fRow
,
NULL
);
}
else
{
init
=
true
;
int32_t
code
=
tsdbRowMergerAdd
(
&
pReader
->
status
.
m
erger
,
&
fRow
,
pReader
->
pSchema
);
int32_t
code
=
tsdbRowMergerAdd
(
pM
erger
,
&
fRow
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2116,7 +2113,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
code
=
doAppendRowFromTSRow
(
pReader
->
pResBlock
,
pReader
,
pTSRow
,
pBlockScanInfo
);
taosMemoryFree
(
pTSRow
);
tsdbRowMergerClear
_rv
(
pMerger
);
tsdbRowMergerClear
(
pMerger
);
return
code
;
}
...
...
@@ -2149,7 +2146,7 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader,
pBlockScanInfo
->
lastKey
=
tsLastBlock
;
return
TSDB_CODE_SUCCESS
;
}
else
{
code
=
tsdbRowMergerAdd
(
&
pReader
->
status
.
m
erger
,
&
fRow
,
pReader
->
pSchema
);
code
=
tsdbRowMergerAdd
(
pM
erger
,
&
fRow
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2166,14 +2163,14 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader,
code
=
doAppendRowFromTSRow
(
pReader
->
pResBlock
,
pReader
,
pTSRow
,
pBlockScanInfo
);
taosMemoryFree
(
pTSRow
);
tsdbRowMergerClear
_rv
(
pMerger
);
tsdbRowMergerClear
(
pMerger
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
}
else
{
// not merge block data
code
=
tsdbRowMergerAdd
(
&
pReader
->
status
.
m
erger
,
&
fRow
,
pReader
->
pSchema
);
code
=
tsdbRowMergerAdd
(
pM
erger
,
&
fRow
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2193,7 +2190,7 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader,
code
=
doAppendRowFromTSRow
(
pReader
->
pResBlock
,
pReader
,
pTSRow
,
pBlockScanInfo
);
taosMemoryFree
(
pTSRow
);
tsdbRowMergerClear
_rv
(
pMerger
);
tsdbRowMergerClear
(
pMerger
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
@@ -2245,7 +2242,7 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader
code
=
doAppendRowFromTSRow
(
pReader
->
pResBlock
,
pReader
,
pTSRow
,
pBlockScanInfo
);
taosMemoryFree
(
pTSRow
);
tsdbRowMergerClear
_rv
(
pMerger
);
tsdbRowMergerClear
(
pMerger
);
return
code
;
}
else
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -2454,7 +2451,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
code
=
doAppendRowFromTSRow
(
pReader
->
pResBlock
,
pReader
,
pTSRow
,
pBlockScanInfo
);
taosMemoryFree
(
pTSRow
);
tsdbRowMergerClear
_rv
(
pMerger
);
tsdbRowMergerClear
(
pMerger
);
return
code
;
}
...
...
@@ -2627,7 +2624,7 @@ int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBloc
code
=
doAppendRowFromTSRow
(
pReader
->
pResBlock
,
pReader
,
pTSRow
,
pBlockScanInfo
);
taosMemoryFree
(
pTSRow
);
tsdbRowMergerClear
_rv
(
&
pReader
->
status
.
merger
);
tsdbRowMergerClear
(
&
pReader
->
status
.
merger
);
return
code
;
}
}
...
...
@@ -2966,7 +2963,6 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum, SAr
}
if
(
pBlockNum
->
numOfBlocks
+
pBlockNum
->
numOfLastFiles
>
0
)
{
// ASSERT(taosArrayGetSize(pTableList) > 0);
break
;
}
}
...
...
@@ -3913,7 +3909,7 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter,
}
pResRow
->
type
=
TSDBROW_ROW_FMT
;
tsdbRowMergerClear
_rv
(
&
pReader
->
status
.
merger
);
tsdbRowMergerClear
(
&
pReader
->
status
.
merger
);
*
freeTSRow
=
true
;
return
TSDB_CODE_SUCCESS
;
...
...
@@ -3972,7 +3968,7 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p
}
int32_t
code
=
tsdbRowMergerGetRow
(
pMerger
,
pTSRow
);
tsdbRowMergerClear
_rv
(
pMerger
);
tsdbRowMergerClear
(
pMerger
);
return
code
;
}
...
...
@@ -4097,12 +4093,8 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S
int32_t
code
=
TSDB_CODE_SUCCESS
;
SBlockLoadSuppInfo
*
pSupInfo
=
&
pReader
->
suppInfo
;
// ASSERT (pReader->suppInfo.colId[i] == PRIMARYKEY_TIMESTAMP_COL_ID);// {
// SColumnInfoData* pColData = taosArrayGet(pResBlock->pDataBlock, pSupInfo->slotId[i]);
// ((int64_t*)pColData->pData)[outputRowIndex] = pBlockData->aTSKEY[rowIndex];
((
int64_t
*
)
pReader
->
status
.
pPrimaryTsCol
->
pData
)[
outputRowIndex
]
=
pBlockData
->
aTSKEY
[
rowIndex
];
i
+=
1
;
// }
SColVal
cv
=
{
0
};
int32_t
numOfInputCols
=
pBlockData
->
nColData
;
...
...
@@ -4355,7 +4347,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL
}
if
(
pReader
->
pSchema
!=
NULL
)
{
tsdbRowMergerInit
_rv
(
&
pReader
->
status
.
merger
,
pReader
->
pSchema
);
tsdbRowMergerInit
(
&
pReader
->
status
.
merger
,
pReader
->
pSchema
);
}
pReader
->
pSchemaMap
=
tSimpleHashInit
(
8
,
taosFastHash
);
...
...
@@ -4515,7 +4507,7 @@ void tsdbReaderClose(STsdbReader* pReader) {
taosMemoryFree
(
pReader
->
idStr
);
tsdbRowMergerCleanup
_rv
(
&
pReader
->
status
.
merger
);
tsdbRowMergerCleanup
(
&
pReader
->
status
.
merger
);
taosMemoryFree
(
pReader
->
pSchema
);
tSimpleHashCleanup
(
pReader
->
pSchemaMap
);
...
...
@@ -4562,7 +4554,6 @@ int32_t tsdbReaderSuspend(STsdbReader* pReader) {
}
pInfo
->
delSkyline
=
taosArrayDestroy
(
pInfo
->
delSkyline
);
// pInfo->lastKey = ts;
}
}
else
{
// resetDataBlockScanInfo excluding lastKey
...
...
@@ -4585,7 +4576,6 @@ int32_t tsdbReaderSuspend(STsdbReader* pReader) {
}
pInfo
->
delSkyline
=
taosArrayDestroy
(
pInfo
->
delSkyline
);
// pInfo->lastKey = ts;
}
pBlockScanInfo
=
pStatus
->
pTableIter
==
NULL
?
NULL
:
*
pStatus
->
pTableIter
;
...
...
@@ -5134,8 +5124,6 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
const
int32_t
numOfBuckets
=
20
.
0
;
// find the start data block in file
// find the start data block in file
tsdbAcquireReader
(
pReader
);
if
(
pReader
->
suspended
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
9a35d4e9
...
...
@@ -637,78 +637,6 @@ SColVal *tsdbRowIterNext(STSDBRowIter *pIter) {
}
// SRowMerger ======================================================
int32_t
tsdbRowMergerInit
(
SRowMerger
*
pMerger
,
STSchema
*
pResTSchema
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
)
{
int32_t
code
=
0
;
TSDBKEY
key
=
TSDBROW_KEY
(
pRow
);
SColVal
*
pColVal
=
&
(
SColVal
){
0
};
STColumn
*
pTColumn
;
int32_t
iCol
,
jCol
=
0
;
if
(
NULL
==
pResTSchema
)
{
pResTSchema
=
pTSchema
;
}
pMerger
->
pTSchema
=
pResTSchema
;
pMerger
->
version
=
key
.
version
;
pMerger
->
pArray
=
taosArrayInit
(
pResTSchema
->
numOfCols
,
sizeof
(
SColVal
));
if
(
pMerger
->
pArray
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
// ts
pTColumn
=
&
pTSchema
->
columns
[
jCol
++
];
ASSERT
(
pTColumn
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
*
pColVal
=
COL_VAL_VALUE
(
pTColumn
->
colId
,
pTColumn
->
type
,
(
SValue
){.
val
=
key
.
ts
});
if
(
taosArrayPush
(
pMerger
->
pArray
,
pColVal
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
// other
for
(
iCol
=
1
;
jCol
<
pTSchema
->
numOfCols
&&
iCol
<
pResTSchema
->
numOfCols
;
++
iCol
)
{
pTColumn
=
&
pResTSchema
->
columns
[
iCol
];
if
(
pTSchema
->
columns
[
jCol
].
colId
<
pTColumn
->
colId
)
{
++
jCol
;
--
iCol
;
continue
;
}
else
if
(
pTSchema
->
columns
[
jCol
].
colId
>
pTColumn
->
colId
)
{
taosArrayPush
(
pMerger
->
pArray
,
&
COL_VAL_NONE
(
pTColumn
->
colId
,
pTColumn
->
type
));
continue
;
}
tsdbRowGetColVal
(
pRow
,
pTSchema
,
jCol
++
,
pColVal
);
if
((
!
COL_VAL_IS_NONE
(
pColVal
))
&&
(
!
COL_VAL_IS_NULL
(
pColVal
))
&&
IS_VAR_DATA_TYPE
(
pColVal
->
type
))
{
uint8_t
*
pVal
=
pColVal
->
value
.
pData
;
pColVal
->
value
.
pData
=
NULL
;
code
=
tRealloc
(
&
pColVal
->
value
.
pData
,
pColVal
->
value
.
nData
);
if
(
code
)
goto
_exit
;
if
(
pColVal
->
value
.
nData
)
{
memcpy
(
pColVal
->
value
.
pData
,
pVal
,
pColVal
->
value
.
nData
);
}
}
if
(
taosArrayPush
(
pMerger
->
pArray
,
pColVal
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
}
for
(;
iCol
<
pResTSchema
->
numOfCols
;
++
iCol
)
{
pTColumn
=
&
pResTSchema
->
columns
[
iCol
];
taosArrayPush
(
pMerger
->
pArray
,
&
COL_VAL_NONE
(
pTColumn
->
colId
,
pTColumn
->
type
));
}
_exit:
return
code
;
}
int32_t
tsdbRowMergerAdd
(
SRowMerger
*
pMerger
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
)
{
int32_t
code
=
0
;
TSDBKEY
key
=
TSDBROW_KEY
(
pRow
);
...
...
@@ -836,7 +764,7 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema)
}
}
int32_t
tsdbRowMergerInit
_rv
(
SRowMerger
*
pMerger
,
STSchema
*
pSchema
)
{
int32_t
tsdbRowMergerInit
(
SRowMerger
*
pMerger
,
STSchema
*
pSchema
)
{
pMerger
->
pTSchema
=
pSchema
;
pMerger
->
pArray
=
taosArrayInit
(
pSchema
->
numOfCols
,
sizeof
(
SColVal
));
if
(
pMerger
->
pArray
==
NULL
)
{
...
...
@@ -846,7 +774,7 @@ int32_t tsdbRowMergerInit_rv(SRowMerger* pMerger, STSchema *pSchema) {
}
}
void
tsdbRowMergerClear
_rv
(
SRowMerger
*
pMerger
)
{
void
tsdbRowMergerClear
(
SRowMerger
*
pMerger
)
{
for
(
int32_t
iCol
=
1
;
iCol
<
pMerger
->
pTSchema
->
numOfCols
;
iCol
++
)
{
SColVal
*
pTColVal
=
taosArrayGet
(
pMerger
->
pArray
,
iCol
);
if
(
IS_VAR_DATA_TYPE
(
pTColVal
->
type
))
{
...
...
@@ -857,7 +785,7 @@ void tsdbRowMergerClear_rv(SRowMerger* pMerger) {
taosArrayClear
(
pMerger
->
pArray
);
}
void
tsdbRowMergerCleanup
_rv
(
SRowMerger
*
pMerger
)
{
void
tsdbRowMergerCleanup
(
SRowMerger
*
pMerger
)
{
int32_t
numOfCols
=
taosArrayGetSize
(
pMerger
->
pArray
);
for
(
int32_t
iCol
=
1
;
iCol
<
numOfCols
;
iCol
++
)
{
SColVal
*
pTColVal
=
taosArrayGet
(
pMerger
->
pArray
,
iCol
);
...
...
@@ -869,82 +797,6 @@ void tsdbRowMergerCleanup_rv(SRowMerger* pMerger) {
taosArrayDestroy
(
pMerger
->
pArray
);
}
void
tsdbRowMergerClear
(
SRowMerger
*
pMerger
)
{
for
(
int32_t
iCol
=
1
;
iCol
<
pMerger
->
pTSchema
->
numOfCols
;
iCol
++
)
{
SColVal
*
pTColVal
=
taosArrayGet
(
pMerger
->
pArray
,
iCol
);
if
(
IS_VAR_DATA_TYPE
(
pTColVal
->
type
))
{
tFree
(
pTColVal
->
value
.
pData
);
}
}
taosArrayDestroy
(
pMerger
->
pArray
);
}
/*
int32_t tsdbRowMerge(SRowMerger *pMerger, TSDBROW *pRow) {
int32_t code = 0;
TSDBKEY key = TSDBROW_KEY(pRow);
SColVal *pColVal = &(SColVal){0};
ASSERT(((SColVal *)pMerger->pArray->pData)->value.val == key.ts);
for (int32_t iCol = 1; iCol < pMerger->pTSchema->numOfCols; iCol++) {
tsdbRowGetColVal(pRow, pMerger->pTSchema, iCol, pColVal);
if (key.version > pMerger->version) {
if (!COL_VAL_IS_NONE(pColVal)) {
if (IS_VAR_DATA_TYPE(pColVal->type)) {
SColVal *pTColVal = taosArrayGet(pMerger->pArray, iCol);
if (!COL_VAL_IS_NULL(pColVal)) {
code = tRealloc(&pTColVal->value.pData, pColVal->value.nData);
if (code) goto _exit;
pTColVal->value.nData = pColVal->value.nData;
if (pTColVal->value.nData) {
memcpy(pTColVal->value.pData, pColVal->value.pData, pTColVal->value.nData);
}
pTColVal->flag = 0;
} else {
tFree(pTColVal->value.pData);
pTColVal->value.pData = NULL;
taosArraySet(pMerger->pArray, iCol, pColVal);
}
} else {
taosArraySet(pMerger->pArray, iCol, pColVal);
}
}
} else if (key.version < pMerger->version) {
SColVal *tColVal = (SColVal *)taosArrayGet(pMerger->pArray, iCol);
if (COL_VAL_IS_NONE(tColVal) && !COL_VAL_IS_NONE(pColVal)) {
if (IS_VAR_DATA_TYPE(pColVal->type)) {
if (!COL_VAL_IS_NULL(pColVal)) {
code = tRealloc(&tColVal->value.pData, pColVal->value.nData);
if (code) goto _exit;
tColVal->value.nData = pColVal->value.nData;
if (tColVal->value.nData) {
memcpy(tColVal->value.pData, pColVal->value.pData, tColVal->value.nData);
}
tColVal->flag = 0;
} else {
tFree(tColVal->value.pData);
tColVal->value.pData = NULL;
taosArraySet(pMerger->pArray, iCol, pColVal);
}
} else {
taosArraySet(pMerger->pArray, iCol, pColVal);
}
}
} else {
ASSERT(0);
}
}
pMerger->version = key.version;
_exit:
return code;
}
*/
int32_t
tsdbRowMergerGetRow
(
SRowMerger
*
pMerger
,
SRow
**
ppRow
)
{
return
tRowBuild
(
pMerger
->
pArray
,
pMerger
->
pTSchema
,
ppRow
);
}
...
...
@@ -1199,8 +1051,6 @@ int32_t tBlockDataCreate(SBlockData *pBlockData) {
pBlockData
->
aTSKEY
=
NULL
;
pBlockData
->
nColData
=
0
;
pBlockData
->
aColData
=
NULL
;
_exit:
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录