Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2c52b316
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
未验证
提交
2c52b316
编写于
7月 28, 2022
作者:
M
Minglei Jin
提交者:
GitHub
7月 28, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15502 from taosdata/fix/TD-17925
fix: cleanup tsdbCache, removing unused functions
上级
d45c7bb3
6e92950a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
584 deletion
+23
-584
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+23
-584
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
2c52b316
...
...
@@ -46,10 +46,10 @@ void tsdbCloseCache(SLRUCache *pCache) {
}
}
static
void
getTableCacheKeyS
(
tb_uid_t
uid
,
const
char
*
cacheType
,
char
*
key
,
int
*
len
)
{
snprintf
(
key
,
30
,
"%"
PRIi64
"%s"
,
uid
,
cacheType
);
*
len
=
strlen
(
key
);
}
/* static void getTableCacheKeyS(tb_uid_t uid, const char *cacheType, char *key, int *len) { */
/* snprintf(key, 30, "%" PRIi64 "%s", uid, cacheType); */
/* *len = strlen(key); */
/* } */
static
void
getTableCacheKey
(
tb_uid_t
uid
,
int
cacheType
,
char
*
key
,
int
*
len
)
{
if
(
cacheType
==
0
)
{
// last_row
...
...
@@ -245,8 +245,6 @@ int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, STSRow *row, STsdb
char
key
[
32
]
=
{
0
};
int
keyLen
=
0
;
// ((void)(row));
// getTableCacheKey(uid, "l", key, &keyLen);
getTableCacheKey
(
uid
,
1
,
key
,
&
keyLen
);
LRUHandle
*
h
=
taosLRUCacheLookup
(
pCache
,
key
,
keyLen
);
...
...
@@ -323,26 +321,10 @@ static tb_uid_t getTableSuidByUid(tb_uid_t uid, STsdb *pTsdb) {
static
int32_t
getTableDelDataFromDelIdx
(
SDelFReader
*
pDelReader
,
SDelIdx
*
pDelIdx
,
SArray
*
aDelData
)
{
int32_t
code
=
0
;
// SMapData delDataMap;
// SDelData delData;
if
(
pDelIdx
)
{
// tMapDataReset(&delDataMap);
// code = tsdbReadDelData(pDelReader, pDelIdx, &delDataMap, NULL);
code
=
tsdbReadDelData
(
pDelReader
,
pDelIdx
,
aDelData
,
NULL
);
if
(
code
)
goto
_err
;
/*
for (int32_t iDelData = 0; iDelData < delDataMap.nItem; ++iDelData) {
code = tMapDataGetItemByIdx(&delDataMap, iDelData, &delData, tGetDelData);
if (code) goto _err;
taosArrayPush(aDelData, &delData);
}
*/
}
_err:
return
code
;
}
...
...
@@ -444,18 +426,16 @@ typedef struct SFSNextRowIter {
SArray
*
aDFileSet
;
SDataFReader
*
pDataFReader
;
SArray
*
aBlockIdx
;
// SMapData blockIdxMap;
// SBlockIdx blockIdx;
SBlockIdx
*
pBlockIdx
;
SMapData
blockMap
;
int32_t
nBlock
;
int32_t
iBlock
;
SBlock
block
;
SBlockData
blockData
;
SBlockData
*
pBlockData
;
int32_t
nRow
;
int32_t
iRow
;
TSDBROW
row
;
SBlockIdx
*
pBlockIdx
;
SMapData
blockMap
;
int32_t
nBlock
;
int32_t
iBlock
;
SBlock
block
;
SBlockData
blockData
;
SBlockData
*
pBlockData
;
int32_t
nRow
;
int32_t
iRow
;
TSDBROW
row
;
}
SFSNextRowIter
;
static
int32_t
getNextRowFromFS
(
void
*
iter
,
TSDBROW
**
ppRow
)
{
...
...
@@ -629,41 +609,8 @@ typedef struct SMemNextRowIter {
}
SMemNextRowIter
;
static
int32_t
getNextRowFromMem
(
void
*
iter
,
TSDBROW
**
ppRow
)
{
// static int32_t getNextRowFromMem(void *iter, SArray *pRowArray) {
SMemNextRowIter
*
state
=
(
SMemNextRowIter
*
)
iter
;
int32_t
code
=
0
;
/*
if (!state->iterOpened) {
if (state->pMem != NULL) {
tsdbTbDataIterOpen(state->pMem, NULL, 1, &state->iter);
state->iterOpened = true;
TSDBROW *pMemRow = tsdbTbDataIterGet(&state->iter);
if (pMemRow) {
state->curRow = pMemRow;
} else {
return code;
}
} else {
return code;
}
}
taosArrayPush(pRowArray, state->curRow);
while (tsdbTbDataIterNext(&state->iter)) {
TSDBROW *row = tsdbTbDataIterGet(&state->iter);
if (TSDBROW_TS(row) < TSDBROW_TS(state->curRow)) {
state->curRow = row;
break;
} else {
taosArrayPush(pRowArray, row);
}
}
return code;
*/
switch
(
state
->
state
)
{
case
SMEMNEXTROW_ENTER
:
{
if
(
state
->
pMem
!=
NULL
)
{
...
...
@@ -768,10 +715,8 @@ static bool tsdbKeyDeleted(TSDBKEY *key, SArray *pSkyline, int64_t *iSkyline) {
}
typedef
int32_t
(
*
_next_row_fn_t
)(
void
*
iter
,
TSDBROW
**
ppRow
);
// typedef int32_t (*_next_row_fn_t)(void *iter, SArray *pRowArray);
typedef
int32_t
(
*
_next_row_clear_fn_t
)(
void
*
iter
);
// typedef struct TsdbNextRowState {
typedef
struct
{
TSDBROW
*
pRow
;
bool
stop
;
...
...
@@ -782,7 +727,6 @@ typedef struct {
}
TsdbNextRowState
;
typedef
struct
{
// STsdb *pTsdb;
SArray
*
pSkyline
;
int64_t
iSkyline
;
...
...
@@ -793,10 +737,8 @@ typedef struct {
TSDBROW
memRow
,
imemRow
,
fsRow
;
TsdbNextRowState
input
[
3
];
// SMemTable *pMemTable;
// SMemTable *pIMemTable;
STsdbReadSnap
*
pReadSnap
;
STsdb
*
pTsdb
;
STsdbReadSnap
*
pReadSnap
;
STsdb
*
pTsdb
;
}
CacheNextRowIter
;
static
int32_t
nextRowIterOpen
(
CacheNextRowIter
*
pIter
,
tb_uid_t
uid
,
STsdb
*
pTsdb
)
{
...
...
@@ -967,7 +909,7 @@ _err:
return
code
;
}
static
int32_t
mergeLastRow
2
(
tb_uid_t
uid
,
STsdb
*
pTsdb
,
bool
*
dup
,
STSRow
**
ppRow
)
{
static
int32_t
mergeLastRow
(
tb_uid_t
uid
,
STsdb
*
pTsdb
,
bool
*
dup
,
STSRow
**
ppRow
)
{
int32_t
code
=
0
;
STSchema
*
pTSchema
=
metaGetTbTSchema
(
pTsdb
->
pVnode
->
pMeta
,
uid
,
-
1
);
...
...
@@ -978,8 +920,6 @@ static int32_t mergeLastRow2(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppR
SArray
*
pColArray
=
taosArrayInit
(
nCol
,
sizeof
(
SColVal
));
SColVal
*
pColVal
=
&
(
SColVal
){
0
};
// tb_uid_t suid = getTableSuidByUid(uid, pTsdb);
TSKEY
lastRowTs
=
TSKEY_MAX
;
CacheNextRowIter
iter
=
{
0
};
...
...
@@ -1066,7 +1006,7 @@ _err:
return
code
;
}
static
int32_t
mergeLast
2
(
tb_uid_t
uid
,
STsdb
*
pTsdb
,
SArray
**
ppLastArray
)
{
static
int32_t
mergeLast
(
tb_uid_t
uid
,
STsdb
*
pTsdb
,
SArray
**
ppLastArray
)
{
int32_t
code
=
0
;
STSchema
*
pTSchema
=
metaGetTbTSchema
(
pTsdb
->
pVnode
->
pMeta
,
uid
,
-
1
);
...
...
@@ -1077,8 +1017,6 @@ static int32_t mergeLast2(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
SArray
*
pColArray
=
taosArrayInit
(
nCol
,
sizeof
(
SLastCol
));
SColVal
*
pColVal
=
&
(
SColVal
){
0
};
// tb_uid_t suid = getTableSuidByUid(uid, pTsdb);
TSKEY
lastRowTs
=
TSKEY_MAX
;
CacheNextRowIter
iter
=
{
0
};
...
...
@@ -1124,12 +1062,7 @@ static int32_t mergeLast2(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
continue
;
}
}
/*
if ((TSDBROW_TS(pRow) < lastRowTs)) {
// goto build the result ts row
break;
}
*/
// merge into pColArray
setNoneCol
=
false
;
for
(
iCol
=
noneCol
;
iCol
<
nCol
;
++
iCol
)
{
...
...
@@ -1139,7 +1072,6 @@ static int32_t mergeLast2(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
tsdbRowGetColVal
(
pRow
,
pTSchema
,
iCol
,
pColVal
);
if
((
tColVal
->
isNone
||
tColVal
->
isNull
)
&&
(
!
pColVal
->
isNone
&&
!
pColVal
->
isNull
))
{
taosArraySet
(
pColArray
,
iCol
,
&
(
SLastCol
){.
ts
=
rowTs
,
.
colVal
=
*
pColVal
});
//} else if (tColVal->isNone && pColVal->isNone && !setNoneCol) {
}
else
if
((
tColVal
->
isNone
||
tColVal
->
isNull
)
&&
(
pColVal
->
isNone
||
pColVal
->
isNull
)
&&
!
setNoneCol
)
{
noneCol
=
iCol
;
setNoneCol
=
true
;
...
...
@@ -1148,521 +1080,36 @@ static int32_t mergeLast2(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
}
while
(
setNoneCol
);
// build the result ts row here
//*dup = false;
if
(
taosArrayGetSize
(
pColArray
)
<=
0
)
{
*
ppLastArray
=
NULL
;
taosArrayDestroy
(
pColArray
);
}
else
{
*
ppLastArray
=
pColArray
;
}
/* if (taosArrayGetSize(pColArray) == nCol) {
code = tdSTSRowNew(pColArray, pTSchema, ppRow);
if (code) goto _err;
} else {
*ppRow = NULL;
}*/
nextRowIterClose
(
&
iter
);
// taosArrayDestroy(pColArray);
taosMemoryFreeClear
(
pTSchema
);
return
code
;
_err:
nextRowIterClose
(
&
iter
);
// taosArrayDestroy(pColArray);
taosMemoryFreeClear
(
pTSchema
);
return
code
;
}
// static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRow) {
// int32_t code = 0;
// SArray *pSkyline = NULL;
// STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1);
// int16_t nCol = pTSchema->numOfCols;
// SArray *pColArray = taosArrayInit(nCol, sizeof(SColVal));
// tb_uid_t suid = getTableSuidByUid(uid, pTsdb);
// STbData *pMem = NULL;
// if (pTsdb->mem) {
// tsdbGetTbDataFromMemTable(pTsdb->mem, suid, uid, &pMem);
// }
// STbData *pIMem = NULL;
// if (pTsdb->imem) {
// tsdbGetTbDataFromMemTable(pTsdb->imem, suid, uid, &pIMem);
// }
// *ppRow = NULL;
// pSkyline = taosArrayInit(32, sizeof(TSDBKEY));
// SDelIdx delIdx;
// SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
// if (pDelFile) {
// SDelFReader *pDelFReader;
// code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb, NULL);
// if (code) goto _err;
// code = getTableDelIdx(pDelFReader, suid, uid, &delIdx);
// if (code) goto _err;
// code = getTableDelSkyline(pMem, pIMem, pDelFReader, &delIdx, pSkyline);
// if (code) goto _err;
// tsdbDelFReaderClose(&pDelFReader);
// } else {
// code = getTableDelSkyline(pMem, pIMem, NULL, NULL, pSkyline);
// if (code) goto _err;
// }
// int64_t iSkyline = taosArrayGetSize(pSkyline) - 1;
// SBlockIdx idx = {.suid = suid, .uid = uid};
// SFSNextRowIter fsState = {0};
// fsState.state = SFSNEXTROW_FS;
// fsState.pTsdb = pTsdb;
// fsState.pBlockIdxExp = &idx;
// SMemNextRowIter memState = {0};
// SMemNextRowIter imemState = {0};
// TSDBROW memRow, imemRow, fsRow;
// TsdbNextRowState input[3] = {{&memRow, true, false, &memState, getNextRowFromMem, NULL},
// {&imemRow, true, false, &imemState, getNextRowFromMem, NULL},
// {&fsRow, false, true, &fsState, getNextRowFromFS, clearNextRowFromFS}};
// if (pMem) {
// memState.pMem = pMem;
// memState.state = SMEMNEXTROW_ENTER;
// input[0].stop = false;
// input[0].next = true;
// }
// if (pIMem) {
// imemState.pMem = pIMem;
// imemState.state = SMEMNEXTROW_ENTER;
// input[1].stop = false;
// input[1].next = true;
// }
// int16_t nilColCount = nCol - 1; // count of null & none cols
// int iCol = 0; // index of first nil col index from left to right
// bool setICol = false;
// do {
// for (int i = 0; i < 3; ++i) {
// if (input[i].next && !input[i].stop) {
// if (input[i].pRow == NULL) {
// code = input[i].nextRowFn(input[i].iter, &input[i].pRow);
// if (code) goto _err;
// if (input[i].pRow == NULL) {
// input[i].stop = true;
// input[i].next = false;
// }
// }
// }
// }
// if (input[0].stop && input[1].stop && input[2].stop) {
// break;
// }
// // select maxpoint(s) from mem, imem, fs
// TSDBROW *max[3] = {0};
// int iMax[3] = {-1, -1, -1};
// int nMax = 0;
// TSKEY maxKey = TSKEY_MIN;
// for (int i = 0; i < 3; ++i) {
// if (!input[i].stop && input[i].pRow != NULL) {
// TSDBKEY key = TSDBROW_KEY(input[i].pRow);
// // merging & deduplicating on client side
// if (maxKey <= key.ts) {
// if (maxKey < key.ts) {
// nMax = 0;
// maxKey = key.ts;
// }
// iMax[nMax] = i;
// max[nMax++] = input[i].pRow;
// }
// }
// }
// // delete detection
// TSDBROW *merge[3] = {0};
// int iMerge[3] = {-1, -1, -1};
// int nMerge = 0;
// for (int i = 0; i < nMax; ++i) {
// TSDBKEY maxKey = TSDBROW_KEY(max[i]);
// bool deleted = tsdbKeyDeleted(&maxKey, pSkyline, &iSkyline);
// if (!deleted) {
// iMerge[nMerge] = i;
// merge[nMerge++] = max[i];
// }
// input[iMax[i]].next = deleted;
// }
// // merge if nMerge > 1
// if (nMerge > 0) {
// *dup = false;
// if (nMerge == 1) {
// code = tsRowFromTsdbRow(pTSchema, merge[nMerge - 1], ppRow);
// if (code) goto _err;
// } else {
// // merge 2 or 3 rows
// SRowMerger merger = {0};
// tRowMergerInit(&merger, merge[0], pTSchema);
// for (int i = 1; i < nMerge; ++i) {
// tRowMerge(&merger, merge[i]);
// }
// tRowMergerGetRow(&merger, ppRow);
// tRowMergerClear(&merger);
// }
// }
// } while (1);
// for (int i = 0; i < 3; ++i) {
// if (input[i].nextRowClearFn) {
// input[i].nextRowClearFn(input[i].iter);
// }
// }
// if (pSkyline) {
// taosArrayDestroy(pSkyline);
// }
// taosMemoryFreeClear(pTSchema);
// return code;
// _err:
// for (int i = 0; i < 3; ++i) {
// if (input[i].nextRowClearFn) {
// input[i].nextRowClearFn(input[i].iter);
// }
// }
// if (pSkyline) {
// taosArrayDestroy(pSkyline);
// }
// taosMemoryFreeClear(pTSchema);
// tsdbError("vgId:%d merge last_row failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
// return code;
// }
// static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, STSRow **ppRow) {
// static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
// int32_t code = 0;
// SArray *pSkyline = NULL;
// STSRow *pRow = NULL;
// STSRow **ppRow = &pRow;
// STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1);
// int16_t nCol = pTSchema->numOfCols;
// // SArray *pColArray = taosArrayInit(nCol, sizeof(SColVal));
// SArray *pColArray = taosArrayInit(nCol, sizeof(SLastCol));
// tb_uid_t suid = getTableSuidByUid(uid, pTsdb);
// STbData *pMem = NULL;
// if (pTsdb->mem) {
// tsdbGetTbDataFromMemTable(pTsdb->mem, suid, uid, &pMem);
// }
// STbData *pIMem = NULL;
// if (pTsdb->imem) {
// tsdbGetTbDataFromMemTable(pTsdb->imem, suid, uid, &pIMem);
// }
// *ppLastArray = NULL;
// pSkyline = taosArrayInit(32, sizeof(TSDBKEY));
// SDelIdx delIdx;
// SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
// if (pDelFile) {
// SDelFReader *pDelFReader;
// code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb, NULL);
// if (code) goto _err;
// code = getTableDelIdx(pDelFReader, suid, uid, &delIdx);
// if (code) goto _err;
// code = getTableDelSkyline(pMem, pIMem, pDelFReader, &delIdx, pSkyline);
// if (code) goto _err;
// tsdbDelFReaderClose(&pDelFReader);
// } else {
// code = getTableDelSkyline(pMem, pIMem, NULL, NULL, pSkyline);
// if (code) goto _err;
// }
// int64_t iSkyline = taosArrayGetSize(pSkyline) - 1;
// SBlockIdx idx = {.suid = suid, .uid = uid};
// SFSNextRowIter fsState = {0};
// fsState.state = SFSNEXTROW_FS;
// fsState.pTsdb = pTsdb;
// fsState.pBlockIdxExp = &idx;
// SMemNextRowIter memState = {0};
// SMemNextRowIter imemState = {0};
// TSDBROW memRow, imemRow, fsRow;
// TsdbNextRowState input[3] = {{&memRow, true, false, &memState, getNextRowFromMem, NULL},
// {&imemRow, true, false, &imemState, getNextRowFromMem, NULL},
// {&fsRow, false, true, &fsState, getNextRowFromFS, clearNextRowFromFS}};
// if (pMem) {
// memState.pMem = pMem;
// memState.state = SMEMNEXTROW_ENTER;
// input[0].stop = false;
// input[0].next = true;
// }
// if (pIMem) {
// imemState.pMem = pIMem;
// imemState.state = SMEMNEXTROW_ENTER;
// input[1].stop = false;
// input[1].next = true;
// }
// int16_t nilColCount = nCol - 1; // count of null & none cols
// int iCol = 0; // index of first nil col index from left to right
// bool setICol = false;
// do {
// for (int i = 0; i < 3; ++i) {
// if (input[i].next && !input[i].stop) {
// code = input[i].nextRowFn(input[i].iter, &input[i].pRow);
// if (code) goto _err;
// if (input[i].pRow == NULL) {
// input[i].stop = true;
// input[i].next = false;
// }
// }
// }
// if (input[0].stop && input[1].stop && input[2].stop) {
// break;
// }
// // select maxpoint(s) from mem, imem, fs
// TSDBROW *max[3] = {0};
// int iMax[3] = {-1, -1, -1};
// int nMax = 0;
// TSKEY maxKey = TSKEY_MIN;
// for (int i = 0; i < 3; ++i) {
// if (!input[i].stop && input[i].pRow != NULL) {
// TSDBKEY key = TSDBROW_KEY(input[i].pRow);
// // merging & deduplicating on client side
// if (maxKey <= key.ts) {
// if (maxKey < key.ts) {
// nMax = 0;
// maxKey = key.ts;
// }
// iMax[nMax] = i;
// max[nMax++] = input[i].pRow;
// }
// }
// }
// // delete detection
// TSDBROW *merge[3] = {0};
// int iMerge[3] = {-1, -1, -1};
// int nMerge = 0;
// for (int i = 0; i < nMax; ++i) {
// TSDBKEY maxKey = TSDBROW_KEY(max[i]);
// bool deleted = tsdbKeyDeleted(&maxKey, pSkyline, &iSkyline);
// if (!deleted) {
// iMerge[nMerge] = iMax[i];
// merge[nMerge++] = max[i];
// }
// input[iMax[i]].next = deleted;
// }
// // merge if nMerge > 1
// if (nMerge > 0) {
// if (nMerge == 1) {
// code = tsRowFromTsdbRow(pTSchema, merge[nMerge - 1], ppRow);
// if (code) goto _err;
// } else {
// // merge 2 or 3 rows
// SRowMerger merger = {0};
// tRowMergerInit(&merger, merge[0], pTSchema);
// for (int i = 1; i < nMerge; ++i) {
// tRowMerge(&merger, merge[i]);
// }
// tRowMergerGetRow(&merger, ppRow);
// tRowMergerClear(&merger);
// }
// } else {
// /* *ppRow = NULL; */
// /* return code; */
// continue;
// }
// if (iCol == 0) {
// STColumn *pTColumn = &pTSchema->columns[0];
// SColVal *pColVal = &(SColVal){0};
// *pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.ts = maxKey});
// // if (taosArrayPush(pColArray, pColVal) == NULL) {
// if (taosArrayPush(pColArray, &(SLastCol){.ts = maxKey, .colVal = *pColVal}) == NULL) {
// code = TSDB_CODE_OUT_OF_MEMORY;
// goto _err;
// }
// ++iCol;
// setICol = false;
// for (int16_t i = iCol; i < nCol; ++i) {
// // tsdbRowGetColVal(*ppRow, pTSchema, i, pColVal);
// tTSRowGetVal(*ppRow, pTSchema, i, pColVal);
// // if (taosArrayPush(pColArray, pColVal) == NULL) {
// if (taosArrayPush(pColArray, &(SLastCol){.ts = maxKey, .colVal = *pColVal}) == NULL) {
// code = TSDB_CODE_OUT_OF_MEMORY;
// goto _err;
// }
// if (pColVal->isNull || pColVal->isNone) {
// for (int j = 0; j < nMerge; ++j) {
// SColVal jColVal = {0};
// tsdbRowGetColVal(merge[j], pTSchema, i, &jColVal);
// if (jColVal.isNull || jColVal.isNone) {
// input[iMerge[j]].next = true;
// }
// }
// if (!setICol) {
// iCol = i;
// setICol = true;
// }
// } else {
// --nilColCount;
// }
// }
// if (*ppRow) {
// taosMemoryFreeClear(*ppRow);
// }
// continue;
// }
// setICol = false;
// for (int16_t i = iCol; i < nCol; ++i) {
// SColVal colVal = {0};
// tTSRowGetVal(*ppRow, pTSchema, i, &colVal);
// TSKEY rowTs = (*ppRow)->ts;
// // SColVal *tColVal = (SColVal *)taosArrayGet(pColArray, i);
// SLastCol *tTsVal = (SLastCol *)taosArrayGet(pColArray, i);
// SColVal *tColVal = &tTsVal->colVal;
// if (!colVal.isNone && !colVal.isNull) {
// if (tColVal->isNull || tColVal->isNone) {
// // taosArraySet(pColArray, i, &colVal);
// taosArraySet(pColArray, i, &(SLastCol){.ts = rowTs, .colVal = colVal});
// --nilColCount;
// }
// } else {
// if ((tColVal->isNull || tColVal->isNone) && !setICol) {
// iCol = i;
// setICol = true;
// for (int j = 0; j < nMerge; ++j) {
// SColVal jColVal = {0};
// tsdbRowGetColVal(merge[j], pTSchema, i, &jColVal);
// if (jColVal.isNull || jColVal.isNone) {
// input[iMerge[j]].next = true;
// }
// }
// }
// }
// }
// if (*ppRow) {
// taosMemoryFreeClear(*ppRow);
// }
// } while (nilColCount > 0);
// // if () new ts row from pColArray if non empty
// /* if (taosArrayGetSize(pColArray) == nCol) { */
// /* code = tdSTSRowNew(pColArray, pTSchema, ppRow); */
// /* if (code) goto _err; */
// /* } */
// /* taosArrayDestroy(pColArray); */
// if (taosArrayGetSize(pColArray) <= 0) {
// *ppLastArray = NULL;
// taosArrayDestroy(pColArray);
// } else {
// *ppLastArray = pColArray;
// }
// if (*ppRow) {
// taosMemoryFreeClear(*ppRow);
// }
// for (int i = 0; i < 3; ++i) {
// if (input[i].nextRowClearFn) {
// input[i].nextRowClearFn(input[i].iter);
// }
// }
// if (pSkyline) {
// taosArrayDestroy(pSkyline);
// }
// taosMemoryFreeClear(pTSchema);
// return code;
// _err:
// taosArrayDestroy(pColArray);
// if (*ppRow) {
// taosMemoryFreeClear(*ppRow);
// }
// for (int i = 0; i < 3; ++i) {
// if (input[i].nextRowClearFn) {
// input[i].nextRowClearFn(input[i].iter);
// }
// }
// if (pSkyline) {
// taosArrayDestroy(pSkyline);
// }
// taosMemoryFreeClear(pTSchema);
// tsdbError("vgId:%d merge last_row failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
// return code;
// }
int32_t
tsdbCacheGetLastrowH
(
SLRUCache
*
pCache
,
tb_uid_t
uid
,
STsdb
*
pTsdb
,
LRUHandle
**
handle
)
{
int32_t
code
=
0
;
char
key
[
32
]
=
{
0
};
int
keyLen
=
0
;
// getTableCacheKey(uid, "lr", key, &keyLen);
// getTableCacheKey
S
(uid, "lr", key, &keyLen);
getTableCacheKey
(
uid
,
0
,
key
,
&
keyLen
);
LRUHandle
*
h
=
taosLRUCacheLookup
(
pCache
,
key
,
keyLen
);
if
(
h
)
{
//*ppRow = (STSRow *)taosLRUCacheValue(pCache, h);
}
else
{
STSRow
*
pRow
=
NULL
;
bool
dup
=
false
;
// which is always false for now
code
=
mergeLastRow
2
(
uid
,
pTsdb
,
&
dup
,
&
pRow
);
code
=
mergeLastRow
(
uid
,
pTsdb
,
&
dup
,
&
pRow
);
// if table's empty or error, return code of -1
if
(
code
<
0
||
pRow
==
NULL
)
{
if
(
!
dup
&&
pRow
)
{
...
...
@@ -1680,9 +1127,7 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUH
code
=
-
1
;
}
// tsdbCacheInsertLastrow(pCache, pTsdb, uid, pRow, dup);
h
=
taosLRUCacheLookup
(
pCache
,
key
,
keyLen
);
//*ppRow = (STSRow *)taosLRUCacheValue(pCache, h);
}
*
handle
=
h
;
...
...
@@ -1719,18 +1164,13 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUHand
char
key
[
32
]
=
{
0
};
int
keyLen
=
0
;
// getTableCacheKey(uid, "l", key, &keyLen);
// getTableCacheKey
S
(uid, "l", key, &keyLen);
getTableCacheKey
(
uid
,
1
,
key
,
&
keyLen
);
LRUHandle
*
h
=
taosLRUCacheLookup
(
pCache
,
key
,
keyLen
);
if
(
h
)
{
//*ppRow = (STSRow *)taosLRUCacheValue(pCache, h);
}
else
{
// STSRow *pRow = NULL;
// code = mergeLast(uid, pTsdb, &pRow);
SArray
*
pLastArray
=
NULL
;
// code = mergeLast(uid, pTsdb, &pLastArray);
code
=
mergeLast2
(
uid
,
pTsdb
,
&
pLastArray
);
code
=
mergeLast
(
uid
,
pTsdb
,
&
pLastArray
);
// if table's empty or error, return code of -1
// if (code < 0 || pRow == NULL) {
if
(
code
<
0
||
pLastArray
==
NULL
)
{
...
...
@@ -1746,7 +1186,6 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUHand
}
h
=
taosLRUCacheLookup
(
pCache
,
key
,
keyLen
);
//*ppRow = (STSRow *)taosLRUCacheValue(pCache, h);
}
*
handle
=
h
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录