Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1e23f805
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看板
提交
1e23f805
编写于
12月 07, 2022
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tsdb/cache: use empty array as negative entry to empty table's last/lr
上级
7d26a821
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
100 addition
and
39 deletion
+100
-39
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+98
-37
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
+2
-2
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
1e23f805
...
...
@@ -91,12 +91,10 @@ int32_t tsdbCacheDeleteLastrow(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey) {
}
}
taosLRUCacheRelease
(
pCache
,
h
,
invalidate
);
if
(
invalidate
)
{
taosLRUCacheRelease
(
pCache
,
h
,
true
);
}
else
{
taosLRUCacheRelease
(
pCache
,
h
,
false
);
taosLRUCacheErase
(
pCache
,
key
,
keyLen
);
}
// void taosLRUCacheErase(SLRUCache * cache, const void *key, size_t keyLen);
}
return
code
;
...
...
@@ -124,12 +122,10 @@ int32_t tsdbCacheDeleteLast(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey) {
}
}
taosLRUCacheRelease
(
pCache
,
h
,
invalidate
);
if
(
invalidate
)
{
taosLRUCacheRelease
(
pCache
,
h
,
true
);
}
else
{
taosLRUCacheRelease
(
pCache
,
h
,
false
);
taosLRUCacheErase
(
pCache
,
key
,
keyLen
);
}
// void taosLRUCacheErase(SLRUCache * cache, const void *key, size_t keyLen);
}
return
code
;
...
...
@@ -208,6 +204,44 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, TS
int16_t
nCol
=
taosArrayGetSize
(
pLast
);
int16_t
iCol
=
0
;
if
(
nCol
<=
0
)
{
nCol
=
pTSchema
->
numOfCols
;
STColumn
*
pTColumn
=
&
pTSchema
->
columns
[
0
];
SColVal
tColVal
=
COL_VAL_VALUE
(
pTColumn
->
colId
,
pTColumn
->
type
,
(
SValue
){.
val
=
keyTs
});
if
(
taosArrayPush
(
pLast
,
&
(
SLastCol
){.
ts
=
keyTs
,
.
colVal
=
tColVal
})
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_invalidate
;
}
for
(
iCol
=
1
;
iCol
<
nCol
;
++
iCol
)
{
SColVal
colVal
=
{
0
};
tsdbRowGetColVal
(
row
,
pTSchema
,
iCol
,
&
colVal
);
SLastCol
lastCol
=
{.
ts
=
keyTs
,
.
colVal
=
colVal
};
if
(
IS_VAR_DATA_TYPE
(
colVal
.
type
)
&&
colVal
.
value
.
nData
>
0
)
{
SLastCol
*
pLastCol
=
(
SLastCol
*
)
taosArrayGet
(
pLast
,
iCol
);
taosMemoryFree
(
pLastCol
->
colVal
.
value
.
pData
);
lastCol
.
colVal
.
value
.
pData
=
taosMemoryMalloc
(
colVal
.
value
.
nData
);
if
(
lastCol
.
colVal
.
value
.
pData
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_invalidate
;
}
memcpy
(
lastCol
.
colVal
.
value
.
pData
,
colVal
.
value
.
pData
,
colVal
.
value
.
nData
);
}
if
(
taosArrayPush
(
pLast
,
&
lastCol
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_invalidate
;
}
}
goto
_invalidate
;
}
SLastCol
*
tTsVal
=
(
SLastCol
*
)
taosArrayGet
(
pLast
,
iCol
);
if
(
keyTs
>
tTsVal
->
ts
)
{
STColumn
*
pTColumn
=
&
pTSchema
->
columns
[
0
];
...
...
@@ -279,6 +313,44 @@ int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, TSDBROW *row, STsdb
int16_t
nCol
=
taosArrayGetSize
(
pLast
);
int16_t
iCol
=
0
;
if
(
nCol
<=
0
)
{
nCol
=
pTSchema
->
numOfCols
;
STColumn
*
pTColumn
=
&
pTSchema
->
columns
[
0
];
SColVal
tColVal
=
COL_VAL_VALUE
(
pTColumn
->
colId
,
pTColumn
->
type
,
(
SValue
){.
val
=
keyTs
});
if
(
taosArrayPush
(
pLast
,
&
(
SLastCol
){.
ts
=
keyTs
,
.
colVal
=
tColVal
})
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_invalidate
;
}
for
(
iCol
=
1
;
iCol
<
nCol
;
++
iCol
)
{
SColVal
colVal
=
{
0
};
tsdbRowGetColVal
(
row
,
pTSchema
,
iCol
,
&
colVal
);
SLastCol
lastCol
=
{.
ts
=
keyTs
,
.
colVal
=
colVal
};
if
(
IS_VAR_DATA_TYPE
(
colVal
.
type
)
&&
colVal
.
value
.
nData
>
0
)
{
SLastCol
*
pLastCol
=
(
SLastCol
*
)
taosArrayGet
(
pLast
,
iCol
);
taosMemoryFree
(
pLastCol
->
colVal
.
value
.
pData
);
lastCol
.
colVal
.
value
.
pData
=
taosMemoryMalloc
(
colVal
.
value
.
nData
);
if
(
lastCol
.
colVal
.
value
.
pData
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_invalidate
;
}
memcpy
(
lastCol
.
colVal
.
value
.
pData
,
colVal
.
value
.
pData
,
colVal
.
value
.
nData
);
}
if
(
taosArrayPush
(
pLast
,
&
lastCol
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_invalidate
;
}
}
goto
_invalidate
;
}
SLastCol
*
tTsVal
=
(
SLastCol
*
)
taosArrayGet
(
pLast
,
iCol
);
if
(
keyTs
>
tTsVal
->
ts
)
{
STColumn
*
pTColumn
=
&
pTSchema
->
columns
[
0
];
...
...
@@ -1215,12 +1287,12 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, SArray **ppCo
// build the result ts row here
*
dup
=
false
;
if
(
taosArrayGetSize
(
pColArray
)
!=
nCol
)
{
*
ppColArray
=
NULL
;
taosArrayDestroy
(
pColArray
);
}
else
{
*
ppColArray
=
pColArray
;
}
//
if (taosArrayGetSize(pColArray) != nCol) {
//
*ppColArray = NULL;
//
taosArrayDestroy(pColArray);
//
} else {
*
ppColArray
=
pColArray
;
//
}
nextRowIterClose
(
&
iter
);
// taosMemoryFreeClear(pTSchema);
...
...
@@ -1333,12 +1405,12 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SCach
}
}
while
(
setNoneCol
);
if
(
taosArrayGetSize
(
pColArray
)
<=
0
)
{
*
ppLastArray
=
NULL
;
taosArrayDestroy
(
pColArray
);
}
else
{
*
ppLastArray
=
pColArray
;
}
//
if (taosArrayGetSize(pColArray) <= 0) {
//
*ppLastArray = NULL;
//
taosArrayDestroy(pColArray);
//
} else {
*
ppLastArray
=
pColArray
;
//
}
nextRowIterClose
(
&
iter
);
// taosMemoryFreeClear(pTSchema);
...
...
@@ -1369,8 +1441,8 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *
SArray
*
pArray
=
NULL
;
bool
dup
=
false
;
// which is always false for now
code
=
mergeLastRow
(
uid
,
pTsdb
,
&
dup
,
&
pArray
,
pr
);
// if table's empty or error,
return code of -1
if
(
code
<
0
||
pArray
==
NULL
)
{
// if table's empty or error,
set handle NULL and return
if
(
code
<
0
/* || pArray == NULL*/
)
{
if
(
!
dup
&&
pArray
)
{
taosArrayDestroy
(
pArray
);
}
...
...
@@ -1388,20 +1460,14 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *
if
(
status
!=
TAOS_LRU_STATUS_OK
)
{
code
=
-
1
;
}
// taosThreadMutexUnlock(&pTsdb->lruMutex);
// h = taosLRUCacheLookup(pCache, key, keyLen);
}
// else {
}
taosThreadMutexUnlock
(
&
pTsdb
->
lruMutex
);
//}
}
*
handle
=
h
;
return
code
;
}
// int32_t tsdbCacheLastArray2Row(SArray *pLastArray, STSRow **ppRow, STSchema *pTSchema) {
// int32_t code = 0;
// int16_t nCol = taosArrayGetSize(pLastArray);
...
...
@@ -1442,8 +1508,8 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *pr,
if
(
!
h
)
{
SArray
*
pLastArray
=
NULL
;
code
=
mergeLast
(
uid
,
pTsdb
,
&
pLastArray
,
pr
);
// if table's empty or error,
return code of -1
if
(
code
<
0
||
pLastArray
==
NULL
)
{
// if table's empty or error,
set handle NULL and return
if
(
code
<
0
/* || pLastArray == NULL*/
)
{
taosThreadMutexUnlock
(
&
pTsdb
->
lruMutex
);
*
handle
=
NULL
;
...
...
@@ -1457,13 +1523,8 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *pr,
if
(
status
!=
TAOS_LRU_STATUS_OK
)
{
code
=
-
1
;
}
// taosThreadMutexUnlock(&pTsdb->lruMutex);
// h = taosLRUCacheLookup(pCache, key, keyLen);
}
// else {
}
taosThreadMutexUnlock
(
&
pTsdb
->
lruMutex
);
//}
}
*
handle
=
h
;
...
...
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
浏览文件 @
1e23f805
...
...
@@ -250,7 +250,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
return
code
;
}
if
(
h
==
NULL
)
{
if
(
h
==
NULL
||
taosArrayGetSize
(
pRow
)
<=
0
)
{
continue
;
}
...
...
@@ -319,7 +319,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
return
code
;
}
if
(
h
==
NULL
)
{
if
(
h
==
NULL
||
taosArrayGetSize
(
pRow
)
<=
0
)
{
continue
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录