Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0c427b5f
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看板
提交
0c427b5f
编写于
11月 09, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: do some internal refactor.
上级
e3aabacf
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
97 addition
and
81 deletion
+97
-81
include/common/tdataformat.h
include/common/tdataformat.h
+1
-1
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+94
-79
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+1
-0
未找到文件。
include/common/tdataformat.h
浏览文件 @
0c427b5f
...
...
@@ -130,7 +130,7 @@ void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t smaOn)
void
tColDataClear
(
SColData
*
pColData
);
int32_t
tColDataAppendValue
(
SColData
*
pColData
,
SColVal
*
pColVal
);
void
tColDataGetValue
(
SColData
*
pColData
,
int32_t
iVal
,
SColVal
*
pColVal
);
uint8_t
tColDataGetBitValue
(
SColData
*
pColData
,
int32_t
iVal
);
uint8_t
tColDataGetBitValue
(
const
SColData
*
pColData
,
int32_t
iVal
);
int32_t
tColDataCopy
(
SColData
*
pColDataSrc
,
SColData
*
pColDataDest
);
extern
void
(
*
tColDataCalcSMA
[])(
SColData
*
pColData
,
int64_t
*
sum
,
int64_t
*
max
,
int64_t
*
min
,
int16_t
*
numOfNull
);
...
...
source/common/src/tdataformat.c
浏览文件 @
0c427b5f
...
...
@@ -1557,7 +1557,7 @@ void tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal) {
tColDataGetValueImpl
[
pColData
->
flag
](
pColData
,
iVal
,
pColVal
);
}
uint8_t
tColDataGetBitValue
(
SColData
*
pColData
,
int32_t
iVal
)
{
uint8_t
tColDataGetBitValue
(
const
SColData
*
pColData
,
int32_t
iVal
)
{
uint8_t
v
;
switch
(
pColData
->
flag
)
{
case
HAS_NONE
:
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
0c427b5f
...
...
@@ -910,7 +910,7 @@ static int32_t getEndPosInDataBlock(STsdbReader* pReader, SBlockData* pBlockData
return
endPos
;
}
static
void
copyPrimaryTsCol
(
SBlockData
*
pBlockData
,
SFileBlockDumpInfo
*
pDumpInfo
,
SColumnInfoData
*
pColData
,
static
void
copyPrimaryTsCol
(
const
SBlockData
*
pBlockData
,
SFileBlockDumpInfo
*
pDumpInfo
,
SColumnInfoData
*
pColData
,
int32_t
dumpedRows
,
bool
asc
)
{
if
(
asc
)
{
memcpy
(
pColData
->
pData
,
&
pBlockData
->
aTSKEY
[
pDumpInfo
->
rowIndex
],
dumpedRows
*
sizeof
(
int64_t
));
...
...
@@ -930,6 +930,97 @@ static void copyPrimaryTsCol(SBlockData* pBlockData, SFileBlockDumpInfo* pDumpIn
}
}
// a faster version of copy procedure.
static
void
copyNumericCols
(
const
SColData
*
pData
,
SFileBlockDumpInfo
*
pDumpInfo
,
SColumnInfoData
*
pColData
,
int32_t
dumpedRows
,
bool
asc
)
{
uint8_t
*
p
=
NULL
;
if
(
asc
)
{
p
=
pData
->
pData
+
tDataTypes
[
pData
->
type
].
bytes
*
pDumpInfo
->
rowIndex
;
}
else
{
int32_t
startIndex
=
pDumpInfo
->
rowIndex
-
dumpedRows
+
1
;
p
=
pData
->
pData
+
tDataTypes
[
pData
->
type
].
bytes
*
startIndex
;
}
int32_t
step
=
asc
?
1
:-
1
;
// make sure it is aligned to 8bit
ASSERT
((((
uint64_t
)
pColData
->
pData
)
&
(
0x8
-
1
))
==
0
);
// 1. copy data in a batch model
memcpy
(
pColData
->
pData
,
p
,
dumpedRows
*
tDataTypes
[
pData
->
type
].
bytes
);
// 2. reverse the array list in case of descending order scan data block
if
(
!
asc
)
{
switch
(
pColData
->
info
.
type
)
{
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
{
int32_t
mid
=
dumpedRows
>>
1u
;
int64_t
*
pts
=
(
int64_t
*
)
pColData
->
pData
;
for
(
int32_t
j
=
0
;
j
<
mid
;
++
j
)
{
int64_t
t
=
pts
[
j
];
pts
[
j
]
=
pts
[
dumpedRows
-
j
-
1
];
pts
[
dumpedRows
-
j
-
1
]
=
t
;
}
break
;
}
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
{
int32_t
mid
=
dumpedRows
>>
1u
;
int8_t
*
pts
=
(
int8_t
*
)
pColData
->
pData
;
for
(
int32_t
j
=
0
;
j
<
mid
;
++
j
)
{
int64_t
t
=
pts
[
j
];
pts
[
j
]
=
pts
[
dumpedRows
-
j
-
1
];
pts
[
dumpedRows
-
j
-
1
]
=
t
;
}
break
;
}
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
{
int32_t
mid
=
dumpedRows
>>
1u
;
int16_t
*
pts
=
(
int16_t
*
)
pColData
->
pData
;
for
(
int32_t
j
=
0
;
j
<
mid
;
++
j
)
{
int64_t
t
=
pts
[
j
];
pts
[
j
]
=
pts
[
dumpedRows
-
j
-
1
];
pts
[
dumpedRows
-
j
-
1
]
=
t
;
}
break
;
}
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
{
int32_t
mid
=
dumpedRows
>>
1u
;
int32_t
*
pts
=
(
int32_t
*
)
pColData
->
pData
;
for
(
int32_t
j
=
0
;
j
<
mid
;
++
j
)
{
int64_t
t
=
pts
[
j
];
pts
[
j
]
=
pts
[
dumpedRows
-
j
-
1
];
pts
[
dumpedRows
-
j
-
1
]
=
t
;
}
break
;
}
}
}
// 3. if the null value exists, check items one-by-one
if
(
pData
->
flag
!=
HAS_VALUE
)
{
int32_t
rowIndex
=
0
;
for
(
int32_t
j
=
pDumpInfo
->
rowIndex
;
rowIndex
<
dumpedRows
;
j
+=
step
,
rowIndex
++
)
{
uint8_t
v
=
tColDataGetBitValue
(
pData
,
j
);
if
(
v
==
0
||
v
==
1
)
{
colDataSetNull_f
(
pColData
->
nullbitmap
,
rowIndex
);
pColData
->
hasNull
=
true
;
}
}
}
}
static
int32_t
copyBlockDataToSDataBlock
(
STsdbReader
*
pReader
,
STableBlockScanInfo
*
pBlockScanInfo
)
{
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SDataBlockIter
*
pBlockIter
=
&
pStatus
->
blockIter
;
...
...
@@ -997,84 +1088,8 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
colDataAppendNNULL
(
pColData
,
0
,
dumpedRows
);
}
else
{
if
(
IS_MATHABLE_TYPE
(
pColData
->
info
.
type
))
{
uint8_t
*
p
=
NULL
;
if
(
asc
)
{
p
=
pData
->
pData
+
tDataTypes
[
pData
->
type
].
bytes
*
pDumpInfo
->
rowIndex
;
}
else
{
int32_t
startIndex
=
pDumpInfo
->
rowIndex
-
dumpedRows
+
1
;
p
=
pData
->
pData
+
tDataTypes
[
pData
->
type
].
bytes
*
startIndex
;
}
// make sure it is aligned to 8bit
ASSERT
((((
uint64_t
)
pColData
->
pData
)
&
(
0x8
-
1
))
==
0
);
memcpy
(
pColData
->
pData
,
p
,
dumpedRows
*
tDataTypes
[
pData
->
type
].
bytes
);
if
(
!
asc
)
{
switch
(
pColData
->
info
.
type
)
{
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
{
int32_t
mid
=
dumpedRows
>>
1u
;
int64_t
*
pts
=
(
int64_t
*
)
pColData
->
pData
;
for
(
int32_t
j
=
0
;
j
<
mid
;
++
j
)
{
int64_t
t
=
pts
[
j
];
pts
[
j
]
=
pts
[
dumpedRows
-
j
-
1
];
pts
[
dumpedRows
-
j
-
1
]
=
t
;
}
break
;
}
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
{
int32_t
mid
=
dumpedRows
>>
1u
;
int8_t
*
pts
=
(
int8_t
*
)
pColData
->
pData
;
for
(
int32_t
j
=
0
;
j
<
mid
;
++
j
)
{
int64_t
t
=
pts
[
j
];
pts
[
j
]
=
pts
[
dumpedRows
-
j
-
1
];
pts
[
dumpedRows
-
j
-
1
]
=
t
;
}
break
;
}
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
{
int32_t
mid
=
dumpedRows
>>
1u
;
int16_t
*
pts
=
(
int16_t
*
)
pColData
->
pData
;
for
(
int32_t
j
=
0
;
j
<
mid
;
++
j
)
{
int64_t
t
=
pts
[
j
];
pts
[
j
]
=
pts
[
dumpedRows
-
j
-
1
];
pts
[
dumpedRows
-
j
-
1
]
=
t
;
}
break
;
}
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
{
int32_t
mid
=
dumpedRows
>>
1u
;
int32_t
*
pts
=
(
int32_t
*
)
pColData
->
pData
;
for
(
int32_t
j
=
0
;
j
<
mid
;
++
j
)
{
int64_t
t
=
pts
[
j
];
pts
[
j
]
=
pts
[
dumpedRows
-
j
-
1
];
pts
[
dumpedRows
-
j
-
1
]
=
t
;
}
break
;
}
}
}
// null value exists, check one-by-one
if
(
pData
->
flag
!=
HAS_VALUE
)
{
for
(
int32_t
j
=
pDumpInfo
->
rowIndex
;
rowIndex
<
dumpedRows
;
j
+=
step
,
rowIndex
++
)
{
uint8_t
v
=
tColDataGetBitValue
(
pData
,
j
);
if
(
v
==
0
||
v
==
1
)
{
colDataSetNull_f
(
pColData
->
nullbitmap
,
rowIndex
);
}
}
}
}
else
{
copyNumericCols
(
pData
,
pDumpInfo
,
pColData
,
dumpedRows
,
asc
);
}
else
{
// varchar/nchar type
for
(
int32_t
j
=
pDumpInfo
->
rowIndex
;
rowIndex
<
dumpedRows
;
j
+=
step
)
{
tColDataGetValue
(
pData
,
j
,
&
cv
);
doCopyColVal
(
pColData
,
rowIndex
++
,
i
,
&
cv
,
pSupInfo
);
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
0c427b5f
...
...
@@ -3022,6 +3022,7 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
}
}
#endif
if
(
numOfElems
==
0
)
{
// save selectivity value for column consisted of all null values
firstlastSaveTupleData
(
pCtx
->
pSrcBlock
,
pInput
->
startRowIndex
,
pCtx
,
pInfo
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录