Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
116d1451
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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,发现更多精彩内容 >>
提交
116d1451
编写于
10月 19, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): do some internal refactor.
上级
64033889
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
12 deletion
+28
-12
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
+25
-10
tests/script/tsim/parser/last_cache_query.sim
tests/script/tsim/parser/last_cache_query.sim
+3
-2
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
浏览文件 @
116d1451
...
...
@@ -29,12 +29,14 @@ typedef struct SCacheRowsReader {
SArray
*
pTableList
;
// table id list
}
SCacheRowsReader
;
#define HASTYPE(_type, _t) (((_type) & (_t)) == (_t))
static
void
saveOneRow
(
SArray
*
pRow
,
SSDataBlock
*
pBlock
,
SCacheRowsReader
*
pReader
,
const
int32_t
*
slotIds
,
void
**
pRes
)
{
ASSERT
(
pReader
->
numOfCols
<=
taosArrayGetSize
(
pBlock
->
pDataBlock
));
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
if
(
(
pReader
->
type
&
CACHESCAN_RETRIEVE_LAST
)
==
CACHESCAN_RETRIEVE_LAST
)
{
if
(
HASTYPE
(
pReader
->
type
,
CACHESCAN_RETRIEVE_LAST
)
)
{
for
(
int32_t
i
=
0
;
i
<
pReader
->
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
SFirstLastRes
*
p
=
(
SFirstLastRes
*
)
varDataVal
(
pRes
[
i
]);
...
...
@@ -54,7 +56,7 @@ static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pRea
if
(
IS_VAR_DATA_TYPE
(
pColVal
->
colVal
.
type
))
{
varDataSetLen
(
p
->
buf
,
pColVal
->
colVal
.
value
.
nData
);
memcpy
(
varDataVal
(
p
->
buf
),
pColVal
->
colVal
.
value
.
pData
,
pColVal
->
colVal
.
value
.
nData
);
p
->
bytes
=
pColVal
->
colVal
.
value
.
nData
+
VARSTR_HEADER_SIZE
;
p
->
bytes
=
pColVal
->
colVal
.
value
.
nData
+
VARSTR_HEADER_SIZE
;
// binary needs to plus the header size
}
else
{
memcpy
(
p
->
buf
,
&
pColVal
->
colVal
.
value
,
pReader
->
pSchema
->
columns
[
slotId
].
bytes
);
p
->
bytes
=
pReader
->
pSchema
->
columns
[
slotId
].
bytes
;
...
...
@@ -62,12 +64,13 @@ static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pRea
}
}
// pColInfoData->info.bytes includes the VARSTR_HEADER_SIZE, need to substruct it
p
->
hasResult
=
true
;
varDataSetLen
(
pRes
[
i
],
pColInfoData
->
info
.
bytes
);
varDataSetLen
(
pRes
[
i
],
pColInfoData
->
info
.
bytes
-
VARSTR_HEADER_SIZE
);
colDataAppend
(
pColInfoData
,
numOfRows
,
(
const
char
*
)
pRes
[
i
],
false
);
}
}
else
{
ASSERT
(
(
pReader
->
type
&
CACHESCAN_RETRIEVE_LAST_ROW
)
==
CACHESCAN_RETRIEVE_LAST_ROW
);
ASSERT
(
HASTYPE
(
pReader
->
type
,
CACHESCAN_RETRIEVE_LAST_ROW
)
);
for
(
int32_t
i
=
0
;
i
<
pReader
->
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
...
...
@@ -177,6 +180,13 @@ static int32_t doExtractCacheRow(SCacheRowsReader* pr, SLRUCache* lruCache, uint
return
code
;
}
static
void
freeItem
(
void
*
pItem
)
{
SLastCol
*
pCol
=
(
SLastCol
*
)
pItem
;
if
(
IS_VAR_DATA_TYPE
(
pCol
->
colVal
.
type
))
{
taosMemoryFree
(
pCol
->
colVal
.
value
.
pData
);
}
}
int32_t
tsdbRetrieveCacheRows
(
void
*
pReader
,
SSDataBlock
*
pResBlock
,
const
int32_t
*
slotIds
,
SArray
*
pTableUidList
)
{
if
(
pReader
==
NULL
||
pResBlock
==
NULL
)
{
return
TSDB_CODE_INVALID_PARA
;
...
...
@@ -217,7 +227,6 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
p
.
colVal
.
value
.
pData
=
taosMemoryCalloc
(
pCol
->
bytes
,
sizeof
(
char
));
}
taosArrayPush
(
pLastCols
,
&
p
);
}
...
...
@@ -237,19 +246,25 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
{
for
(
int32_t
k
=
0
;
k
<
pr
->
numOfCols
;
++
k
)
{
SLastCol
*
p
=
taosArrayGet
(
pLastCols
,
k
);
if
(
slotIds
[
k
]
==
-
1
)
{
// the primary timestamp
SLastCol
*
pCol
=
(
SLastCol
*
)
taosArrayGet
(
pRow
,
k
);
int32_t
slotId
=
slotIds
[
k
];
if
(
slotId
==
-
1
)
{
// the primary timestamp
SLastCol
*
p
=
taosArrayGet
(
pLastCols
,
0
);
SLastCol
*
pCol
=
(
SLastCol
*
)
taosArrayGet
(
pRow
,
0
);
if
(
pCol
->
ts
>
p
->
ts
)
{
hasRes
=
true
;
p
->
ts
=
pCol
->
ts
;
p
->
colVal
=
pCol
->
colVal
;
}
}
else
{
int32_t
slotId
=
slotIds
[
k
]
;
SLastCol
*
p
=
taosArrayGet
(
pLastCols
,
slotId
)
;
SLastCol
*
pColVal
=
(
SLastCol
*
)
taosArrayGet
(
pRow
,
slotId
);
if
(
pColVal
->
ts
>
p
->
ts
)
{
if
(
!
COL_VAL_IS_VALUE
(
&
pColVal
->
colVal
)
&&
HASTYPE
(
pr
->
type
,
CACHESCAN_RETRIEVE_LAST
))
{
continue
;
}
hasRes
=
true
;
p
->
ts
=
pColVal
->
ts
;
...
...
@@ -308,6 +323,6 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
}
taosMemoryFree
(
pRes
);
taosArrayDestroy
(
pLastCols
);
taosArrayDestroy
Ex
(
pLastCols
,
freeItem
);
return
code
;
}
tests/script/tsim/parser/last_cache_query.sim
浏览文件 @
116d1451
...
...
@@ -39,6 +39,7 @@ if $data02 != 5.000000000 then
return -1
endi
if $data03 != 3 then
print expect 3, actual: $data03
return -1
endi
if $data04 != @70-01-01 07:59:57.000@ then
...
...
@@ -210,7 +211,7 @@ if $data01 != 6 then
return -1
endi
if $data02 != 37.000000000 then
print $data02
print
expect 37.000000000 actual:
$data02
return -1
endi
if $data03 != 27 then
...
...
@@ -233,7 +234,7 @@ if $data01 != 6 then
return -1
endi
if $data02 != 37.000000000 then
print $data02
print
expect 37.000000000, acutal:
$data02
return -1
endi
if $data03 != 27 then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录