Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6a32f812
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看板
提交
6a32f812
编写于
6月 28, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): retrieve in-memory buffer data.
上级
c638c33a
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
49 addition
and
12 deletion
+49
-12
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+49
-12
未找到文件。
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
6a32f812
...
...
@@ -92,8 +92,8 @@ typedef struct SIOCostSummary {
typedef
struct
SBlockLoadSuppInfo
{
SColumnDataAgg
*
pstatis
;
SColumnDataAgg
**
plist
;
int16_t
*
colIdList
;
// default load column
int32_t
*
slotIds
;
// colId to slotId
char
**
buildBuf
;
// build string tmp buffer, todo remove it later after all string format being updated.
}
SBlockLoadSuppInfo
;
typedef
struct
SFileSetIter
{
...
...
@@ -189,16 +189,34 @@ static void setComposedBlockFlag(STsdbReader* pReader, bool composed);
// pCompBlockLoadInfo->fileId = -1;
// }
static
int32_t
setColumnIdList
(
STsdbReader
*
pReader
,
SSDataBlock
*
pBlock
)
{
static
int32_t
setColumnIdSlotList
(
STsdbReader
*
pReader
,
SSDataBlock
*
pBlock
)
{
SBlockLoadSuppInfo
*
pSupInfo
=
&
pReader
->
suppInfo
;
size_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
p
Reader
->
suppInfo
.
colIdList
=
taosMemoryCalloc
(
numOfCols
,
sizeof
(
int16_t
));
if
(
p
Reader
->
suppInfo
.
colIdList
==
NULL
)
{
p
SupInfo
->
slotIds
=
taosMemoryCalloc
(
numOfCols
,
sizeof
(
int16_t
));
if
(
p
SupInfo
->
slotIds
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pSupInfo
->
buildBuf
=
taosMemoryCalloc
(
numOfCols
,
POINTER_BYTES
);
if
(
pSupInfo
->
buildBuf
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
STSchema
*
pSchema
=
pReader
->
pSchema
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
pReader
->
suppInfo
.
colIdList
[
i
]
=
pCol
->
info
.
colId
;
for
(
int32_t
j
=
0
;
j
<
pSchema
->
numOfCols
;
++
j
)
{
if
(
pCol
->
info
.
colId
==
pSchema
->
columns
[
j
].
colId
)
{
pSupInfo
->
slotIds
[
i
]
=
j
;
break
;
}
}
if
(
IS_VAR_DATA_TYPE
(
pCol
->
info
.
type
))
{
pSupInfo
->
buildBuf
[
i
]
=
taosMemoryMalloc
(
pCol
->
info
.
bytes
);
}
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -426,8 +444,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
blockDataEnsureCapacity
(
pReader
->
pResBlock
,
pReader
->
capacity
);
setColumnIdList
(
pReader
,
pReader
->
pResBlock
);
pReader
->
suppInfo
.
slotIds
=
taosMemoryCalloc
(
pCond
->
numOfCols
,
sizeof
(
int32_t
));
setColumnIdSlotList
(
pReader
,
pReader
->
pResBlock
);
pReader
->
suppInfo
.
plist
=
taosMemoryCalloc
(
pCond
->
numOfCols
,
POINTER_BYTES
);
}
...
...
@@ -2504,7 +2521,6 @@ static int32_t loadDataInFiles(STsdbReader* pReader, bool* exists) {
return
code
;
}
// todo extract method: getCurrentKeyInBuf()
SFileDataBlockInfo
*
pFBlock
=
getCurrentBlockInfo
(
pBlockIter
);
STableBlockScanInfo
*
pScanInfo
=
taosHashGet
(
pReader
->
status
.
pTableMap
,
&
pFBlock
->
uid
,
sizeof
(
pFBlock
->
uid
));
SBlock
*
pBlock
=
taosArrayGet
(
pScanInfo
->
pBlockList
,
pFBlock
->
tbBlockIdx
);
...
...
@@ -2522,7 +2538,10 @@ static int32_t loadDataInFiles(STsdbReader* pReader, bool* exists) {
buildInmemDataBlock
(
pReader
,
pScanInfo
,
&
maxKey
);
// build data block from in-memory buffer data completed.
}
else
{
// whole block is required, return it directly
// todo check the data version
// todo
// 1. the version of all rows should be less than the endVersion
// 2. current block should not overlap with next neighbor block
// 3. current timestamp should not be overlap with each other
SDataBlockInfo
*
pInfo
=
&
pReader
->
pResBlock
->
info
;
pInfo
->
rows
=
pBlock
->
nRow
;
pInfo
->
uid
=
pScanInfo
->
uid
;
...
...
@@ -2740,13 +2759,31 @@ int32_t doAppendOneRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* pTSRow
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
int32_t
numOfCols
=
(
int32_t
)
taosArrayGetSize
(
pBlock
->
pDataBlock
);
SBlockLoadSuppInfo
*
pSupInfo
=
&
pReader
->
suppInfo
;
SColVal
colVal
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
int32_t
slotId
=
pSupInfo
->
slotIds
[
i
];
tTSRowGetVal
(
pTSRow
,
pReader
->
pSchema
,
pColInfoData
->
info
.
colId
,
&
colVal
);
if
(
pColInfoData
->
info
.
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
&&
slotId
==
0
)
{
colDataAppend
(
pColInfoData
,
numOfRows
,
(
const
char
*
)
&
pTSRow
->
ts
,
false
);
}
else
{
tTSRowGetVal
(
pTSRow
,
pReader
->
pSchema
,
slotId
,
&
colVal
);
if
(
IS_VAR_DATA_TYPE
(
colVal
.
type
))
{
if
(
colVal
.
isNull
)
{
colDataAppendNULL
(
pColInfoData
,
numOfRows
);
}
else
{
varDataSetLen
(
pSupInfo
->
buildBuf
[
i
],
colVal
.
value
.
nData
);
memcpy
(
varDataVal
(
pSupInfo
->
buildBuf
[
i
]),
colVal
.
value
.
pData
,
colVal
.
value
.
nData
);
colDataAppend
(
pColInfoData
,
numOfRows
,
pSupInfo
->
buildBuf
[
i
],
false
);
}
}
else
{
colDataAppend
(
pColInfoData
,
numOfRows
,
(
const
char
*
)
&
colVal
.
value
,
colVal
.
isNull
);
}
}
}
pBlock
->
info
.
rows
+=
1
;
return
TSDB_CODE_SUCCESS
;
...
...
@@ -3135,7 +3172,7 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
}
// current table is exhausted, let's try the next table
pStatus
->
pTableIter
=
taosHashIterate
(
pStatus
->
pTableMap
,
&
pStatus
->
pTableIter
);
pStatus
->
pTableIter
=
taosHashIterate
(
pStatus
->
pTableMap
,
pStatus
->
pTableIter
);
if
(
pStatus
->
pTableIter
==
NULL
)
{
return
false
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录