Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
哥们要飞
TDengine
提交
6f30ae25
T
TDengine
项目概览
哥们要飞
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6f30ae25
编写于
2月 02, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug
上级
71357a21
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
61 addition
and
12 deletion
+61
-12
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+61
-12
未找到文件。
src/tsdb/src/tsdbRead.c
浏览文件 @
6f30ae25
...
...
@@ -1176,13 +1176,15 @@ int32_t doCopyRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, int32_t capacity
}
static
void
copyOneRowFromMem
(
STsdbQueryHandle
*
pQueryHandle
,
int32_t
capacity
,
int32_t
numOfRows
,
SDataRow
row
,
int32_t
numOfCols
,
STable
*
pTable
)
{
int32_t
numOfCols
,
STable
*
pTable
,
STSchema
*
pSchema
)
{
char
*
pData
=
NULL
;
// the schema version info is embeded in SDataRow
STSchema
*
pSchema
=
tsdbGetTableSchemaByVersion
(
pTable
,
dataRowVersion
(
row
));
int32_t
numOfRowCols
=
schemaNCols
(
pSchema
);
if
(
pSchema
==
NULL
)
{
pSchema
=
tsdbGetTableSchemaByVersion
(
pTable
,
dataRowVersion
(
row
));
}
int32_t
i
=
0
,
j
=
0
;
while
(
i
<
numOfCols
&&
j
<
numOfRowCols
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
i
);
...
...
@@ -1199,10 +1201,38 @@ static void copyOneRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
if
(
pSchema
->
columns
[
j
].
colId
==
pColInfo
->
info
.
colId
)
{
void
*
value
=
tdGetRowDataOfCol
(
row
,
(
int8_t
)
pColInfo
->
info
.
type
,
TD_DATA_ROW_HEAD_SIZE
+
pSchema
->
columns
[
j
].
offset
);
if
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
||
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_NCHAR
)
{
memcpy
(
pData
,
value
,
varDataTLen
(
value
));
}
else
{
memcpy
(
pData
,
value
,
pColInfo
->
info
.
bytes
);
switch
(
pColInfo
->
info
.
type
)
{
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
memcpy
(
pData
,
value
,
varDataTLen
(
value
));
break
;
case
TSDB_DATA_TYPE_NULL
:
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
*
(
uint8_t
*
)
pData
=
*
(
uint8_t
*
)
value
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
*
(
uint16_t
*
)
pData
=
*
(
uint16_t
*
)
value
;
break
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
*
(
uint32_t
*
)
pData
=
*
(
uint32_t
*
)
value
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
*
(
uint64_t
*
)
pData
=
*
(
uint64_t
*
)
value
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
SET_FLOAT_PTR
(
pData
,
value
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
SET_DOUBLE_PTR
(
pData
,
value
);
break
;
default:
memcpy
(
pData
,
value
,
pColInfo
->
info
.
bytes
);
}
j
++
;
...
...
@@ -1401,6 +1431,9 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
// compared with the data from in-memory buffer, to generate the correct timestamp array list
int32_t
numOfRows
=
0
;
int16_t
rv
=
-
1
;
STSchema
*
pSchema
=
NULL
;
int32_t
pos
=
cur
->
pos
;
cur
->
win
=
TSWINDOW_INITIALIZER
;
...
...
@@ -1429,7 +1462,12 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
if
((
key
<
tsArray
[
pos
]
&&
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
||
(
key
>
tsArray
[
pos
]
&&
!
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)))
{
copyOneRowFromMem
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
numOfRows
,
row
,
numOfCols
,
pTable
);
if
(
rv
!=
dataRowVersion
(
row
))
{
pSchema
=
tsdbGetTableSchemaByVersion
(
pTable
,
dataRowVersion
(
row
));
rv
=
dataRowVersion
(
row
);
}
copyOneRowFromMem
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
numOfRows
,
row
,
numOfCols
,
pTable
,
pSchema
);
numOfRows
+=
1
;
if
(
cur
->
win
.
skey
==
TSKEY_INITIAL_VAL
)
{
cur
->
win
.
skey
=
key
;
...
...
@@ -1442,7 +1480,12 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
moveToNextRowInMem
(
pCheckInfo
);
}
else
if
(
key
==
tsArray
[
pos
])
{
// data in buffer has the same timestamp of data in file block, ignore it
if
(
pCfg
->
update
)
{
copyOneRowFromMem
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
numOfRows
,
row
,
numOfCols
,
pTable
);
if
(
rv
!=
dataRowVersion
(
row
))
{
pSchema
=
tsdbGetTableSchemaByVersion
(
pTable
,
dataRowVersion
(
row
));
rv
=
dataRowVersion
(
row
);
}
copyOneRowFromMem
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
numOfRows
,
row
,
numOfCols
,
pTable
,
pSchema
);
numOfRows
+=
1
;
if
(
cur
->
win
.
skey
==
TSKEY_INITIAL_VAL
)
{
cur
->
win
.
skey
=
key
;
...
...
@@ -1987,6 +2030,8 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
int64_t
st
=
taosGetTimestampUs
();
STable
*
pTable
=
pCheckInfo
->
pTableObj
;
int16_t
rv
=
-
1
;
STSchema
*
pSchema
=
NULL
;
do
{
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
,
pQueryHandle
->
order
,
pCfg
->
update
);
...
...
@@ -2007,7 +2052,11 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
}
win
->
ekey
=
key
;
copyOneRowFromMem
(
pQueryHandle
,
maxRowsToRead
,
numOfRows
,
row
,
numOfCols
,
pTable
);
if
(
rv
!=
dataRowVersion
(
row
))
{
pSchema
=
tsdbGetTableSchemaByVersion
(
pTable
,
dataRowVersion
(
row
));
rv
=
dataRowVersion
(
row
);
}
copyOneRowFromMem
(
pQueryHandle
,
maxRowsToRead
,
numOfRows
,
row
,
numOfCols
,
pTable
,
pSchema
);
if
(
++
numOfRows
>=
maxRowsToRead
)
{
moveToNextRowInMem
(
pCheckInfo
);
...
...
@@ -2090,7 +2139,7 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) {
return
false
;
}
copyOneRowFromMem
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
0
,
pRow
,
numOfCols
,
pCheckInfo
->
pTableObj
);
copyOneRowFromMem
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
0
,
pRow
,
numOfCols
,
pCheckInfo
->
pTableObj
,
NULL
);
tfree
(
pRow
);
// update the last key value
...
...
@@ -2164,7 +2213,7 @@ bool tsdbNextDataBlockWithoutMerge(TsdbQueryHandleT* pHandle) {
return
false
;
}
copyOneRowFromMem
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
0
,
pRow
,
numOfCols
,
pCheckInfo
->
pTableObj
);
copyOneRowFromMem
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
0
,
pRow
,
numOfCols
,
pCheckInfo
->
pTableObj
,
NULL
);
tfree
(
pRow
);
// update the last key value
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录