Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ae625d31
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
ae625d31
编写于
10月 19, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: remove redundant codes and do some internal refactor.
上级
a43ccdf5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
27 addition
and
103 deletion
+27
-103
include/common/ttypes.h
include/common/ttypes.h
+0
-4
source/common/src/ttime.c
source/common/src/ttime.c
+25
-29
source/common/src/ttypes.c
source/common/src/ttypes.c
+0
-13
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+2
-6
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+0
-51
未找到文件。
include/common/ttypes.h
浏览文件 @
ae625d31
...
...
@@ -340,12 +340,8 @@ typedef struct tDataTypeDescriptor {
}
tDataTypeDescriptor
;
extern
tDataTypeDescriptor
tDataTypes
[
TSDB_DATA_TYPE_MAX
];
bool
isValidDataType
(
int32_t
type
);
void
setVardataNull
(
void
*
val
,
int32_t
type
);
//void setNull(void *val, int32_t type, int32_t bytes);
//void setNullN(void *val, int32_t type, int32_t bytes, int32_t numOfElems);
void
assignVal
(
char
*
val
,
const
char
*
src
,
int32_t
len
,
int32_t
type
);
void
operateVal
(
void
*
dst
,
void
*
s1
,
void
*
s2
,
int32_t
optr
,
int32_t
type
);
void
*
getDataMin
(
int32_t
type
);
...
...
source/common/src/ttime.c
浏览文件 @
ae625d31
...
...
@@ -244,8 +244,7 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
* 2013-04-12T15:52:01.123+0800
*/
int32_t
parseTimeWithTz
(
const
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
,
char
delim
)
{
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
(
timePrec
==
TSDB_TIME_PRECISION_MICRO
?
1000000
:
1000000000
);
int64_t
factor
=
TSDB_TICK_PER_SECOND
(
timePrec
);
int64_t
tzOffset
=
0
;
struct
tm
tm
=
{
0
};
...
...
@@ -339,8 +338,8 @@ static FORCE_INLINE bool validateTm(struct tm* pTm) {
return
true
;
}
int32_t
parseLocaltime
(
char
*
timestr
,
int32_t
len
,
int64_t
*
time
,
int32_t
timePrec
,
char
delim
)
{
*
time
=
0
;
int32_t
parseLocaltime
(
char
*
timestr
,
int32_t
len
,
int64_t
*
u
time
,
int32_t
timePrec
,
char
delim
)
{
*
u
time
=
0
;
struct
tm
tm
=
{
0
};
char
*
str
;
...
...
@@ -378,15 +377,12 @@ int32_t parseLocaltime(char* timestr, int32_t len, int64_t* time, int32_t timePr
}
}
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
(
timePrec
==
TSDB_TIME_PRECISION_MICRO
?
1000000
:
1000000000
);
*
time
=
factor
*
seconds
+
fraction
;
*
utime
=
TSDB_TICK_PER_SECOND
(
timePrec
)
*
seconds
+
fraction
;
return
0
;
}
int32_t
parseLocaltimeDst
(
char
*
timestr
,
int32_t
len
,
int64_t
*
time
,
int32_t
timePrec
,
char
delim
)
{
*
time
=
0
;
int32_t
parseLocaltimeDst
(
char
*
timestr
,
int32_t
len
,
int64_t
*
u
time
,
int32_t
timePrec
,
char
delim
)
{
*
u
time
=
0
;
struct
tm
tm
=
{
0
};
tm
.
tm_isdst
=
-
1
;
...
...
@@ -411,7 +407,6 @@ int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* time, int32_t tim
int64_t
seconds
=
taosMktime
(
&
tm
);
int64_t
fraction
=
0
;
if
(
*
str
==
'.'
)
{
/* parse the second fraction part */
if
((
fraction
=
parseFraction
(
str
+
1
,
&
str
,
timePrec
))
<
0
)
{
...
...
@@ -419,9 +414,7 @@ int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* time, int32_t tim
}
}
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
(
timePrec
==
TSDB_TIME_PRECISION_MICRO
?
1000000
:
1000000000
);
*
time
=
factor
*
seconds
+
fraction
;
*
utime
=
TSDB_TICK_PER_SECOND
(
timePrec
)
*
seconds
+
fraction
;
return
0
;
}
...
...
@@ -437,58 +430,61 @@ char getPrecisionUnit(int32_t precision) {
}
}
int64_t
convertTimePrecision
(
int64_t
time
,
int32_t
fromPrecision
,
int32_t
toPrecision
)
{
assert
(
fromPrecision
==
TSDB_TIME_PRECISION_MILLI
||
fromPrecision
==
TSDB_TIME_PRECISION_MICRO
||
int64_t
convertTimePrecision
(
int64_t
u
time
,
int32_t
fromPrecision
,
int32_t
toPrecision
)
{
ASSERT
(
fromPrecision
==
TSDB_TIME_PRECISION_MILLI
||
fromPrecision
==
TSDB_TIME_PRECISION_MICRO
||
fromPrecision
==
TSDB_TIME_PRECISION_NANO
);
assert
(
toPrecision
==
TSDB_TIME_PRECISION_MILLI
||
toPrecision
==
TSDB_TIME_PRECISION_MICRO
||
ASSERT
(
toPrecision
==
TSDB_TIME_PRECISION_MILLI
||
toPrecision
==
TSDB_TIME_PRECISION_MICRO
||
toPrecision
==
TSDB_TIME_PRECISION_NANO
);
double
tempResult
=
(
double
)
time
;
double
tempResult
=
(
double
)
utime
;
switch
(
fromPrecision
)
{
case
TSDB_TIME_PRECISION_MILLI
:
{
switch
(
toPrecision
)
{
case
TSDB_TIME_PRECISION_MILLI
:
return
time
;
return
u
time
;
case
TSDB_TIME_PRECISION_MICRO
:
tempResult
*=
1000
;
time
*=
1000
;
u
time
*=
1000
;
goto
end_
;
case
TSDB_TIME_PRECISION_NANO
:
tempResult
*=
1000000
;
time
*=
1000000
;
u
time
*=
1000000
;
goto
end_
;
}
}
// end from milli
case
TSDB_TIME_PRECISION_MICRO
:
{
switch
(
toPrecision
)
{
case
TSDB_TIME_PRECISION_MILLI
:
return
time
/
1000
;
return
u
time
/
1000
;
case
TSDB_TIME_PRECISION_MICRO
:
return
time
;
return
u
time
;
case
TSDB_TIME_PRECISION_NANO
:
tempResult
*=
1000
;
time
*=
1000
;
u
time
*=
1000
;
goto
end_
;
}
}
// end from micro
case
TSDB_TIME_PRECISION_NANO
:
{
switch
(
toPrecision
)
{
case
TSDB_TIME_PRECISION_MILLI
:
return
time
/
1000000
;
return
u
time
/
1000000
;
case
TSDB_TIME_PRECISION_MICRO
:
return
time
/
1000
;
return
u
time
/
1000
;
case
TSDB_TIME_PRECISION_NANO
:
return
time
;
return
u
time
;
}
}
// end from nano
default:
{
assert
(
0
);
return
time
;
// only to pass windows compilation
return
u
time
;
// only to pass windows compilation
}
}
// end switch fromPrecision
end_:
if
(
tempResult
>=
(
double
)
INT64_MAX
)
return
INT64_MAX
;
if
(
tempResult
<=
(
double
)
INT64_MIN
)
return
INT64_MIN
;
// INT64_MIN means NULL
return
time
;
return
u
time
;
}
// !!!!notice:there are precision problems, double lose precison if time is too large, for example:
...
...
source/common/src/ttypes.c
浏览文件 @
ae625d31
...
...
@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#include "ttypes.h"
#include "tcompression.h"
#include "trow.h"
const
int32_t
TYPE_BYTES
[
16
]
=
{
-
1
,
// TSDB_DATA_TYPE_NULL
...
...
@@ -86,18 +85,6 @@ FORCE_INLINE void *getDataMax(int32_t type) {
bool
isValidDataType
(
int32_t
type
)
{
return
type
>=
TSDB_DATA_TYPE_NULL
&&
type
<
TSDB_DATA_TYPE_MAX
;
}
void
setVardataNull
(
void
*
val
,
int32_t
type
)
{
if
(
type
==
TSDB_DATA_TYPE_BINARY
)
{
varDataSetLen
(
val
,
sizeof
(
int8_t
));
*
(
uint8_t
*
)
varDataVal
(
val
)
=
TSDB_DATA_BINARY_NULL
;
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
varDataSetLen
(
val
,
sizeof
(
int32_t
));
*
(
uint32_t
*
)
varDataVal
(
val
)
=
TSDB_DATA_NCHAR_NULL
;
}
else
{
assert
(
0
);
}
}
#define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b)))
void
assignVal
(
char
*
val
,
const
char
*
src
,
int32_t
len
,
int32_t
type
)
{
...
...
source/libs/scalar/src/sclfunc.c
浏览文件 @
ae625d31
...
...
@@ -1178,9 +1178,7 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
GET_TYPED_DATA
(
timeUnit
,
int64_t
,
GET_PARAM_TYPE
(
&
pInput
[
1
]),
pInput
[
1
].
columnData
->
pData
);
GET_TYPED_DATA
(
timePrec
,
int64_t
,
GET_PARAM_TYPE
(
&
pInput
[
2
]),
pInput
[
2
].
columnData
->
pData
);
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
(
timePrec
==
TSDB_TIME_PRECISION_MICRO
?
1000000
:
1000000000
);
int64_t
factor
=
TSDB_TICK_PER_SECOND
(
timePrec
);
int64_t
unit
=
timeUnit
*
1000
/
factor
;
for
(
int32_t
i
=
0
;
i
<
pInput
[
0
].
numOfRows
;
++
i
)
{
...
...
@@ -1372,9 +1370,7 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
GET_TYPED_DATA
(
timePrec
,
int64_t
,
GET_PARAM_TYPE
(
&
pInput
[
2
]),
pInput
[
2
].
columnData
->
pData
);
}
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
(
timePrec
==
TSDB_TIME_PRECISION_MICRO
?
1000000
:
1000000000
);
int64_t
factor
=
TSDB_TICK_PER_SECOND
(
timePrec
);
int32_t
numOfRows
=
0
;
for
(
int32_t
i
=
0
;
i
<
inputNum
;
++
i
)
{
if
(
pInput
[
i
].
numOfRows
>
numOfRows
)
{
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
ae625d31
...
...
@@ -1426,57 +1426,6 @@ void vectorAssign(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut,
pOut
->
numOfQualified
=
pRight
->
numOfQualified
*
pOut
->
numOfRows
;
}
void
vectorConcat
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
#if 0
int32_t len = pLeft->bytes + pRight->bytes;
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1;
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
char *output = (char *)out;
if (pLeft->numOfRows == pRight->numOfRows) {
for (; i < pRight->numOfRows && i >= 0; i += step, output += len) {
char* left = POINTER_SHIFT(pLeft->data, pLeft->bytes * i);
char* right = POINTER_SHIFT(pRight->data, pRight->bytes * i);
if (isNull(left, pLeftCol->info.type) || isNull(right, pRight->info.type)) {
setVardataNull(output, TSDB_DATA_TYPE_BINARY);
continue;
}
// todo define a macro
memcpy(varDataVal(output), varDataVal(left), varDataLen(left));
memcpy(varDataVal(output) + varDataLen(left), varDataVal(right), varDataLen(right));
varDataSetLen(output, varDataLen(left) + varDataLen(right));
}
} else if (pLeft->numOfRows == 1) {
for (; i >= 0 && i < pRight->numOfRows; i += step, output += len) {
char *right = POINTER_SHIFT(pRight->data, pRight->bytes * i);
if (isNull(pLeft->data, pLeftCol->info.type) || isNull(right, pRight->info.type)) {
setVardataNull(output, TSDB_DATA_TYPE_BINARY);
continue;
}
memcpy(varDataVal(output), varDataVal(pLeft->data), varDataLen(pLeft->data));
memcpy(varDataVal(output) + varDataLen(pLeft->data), varDataVal(right), varDataLen(right));
varDataSetLen(output, varDataLen(pLeft->data) + varDataLen(right));
}
} else if (pRight->numOfRows == 1) {
for (; i >= 0 && i < pLeft->numOfRows; i += step, output += len) {
char* left = POINTER_SHIFT(pLeft->data, pLeft->bytes * i);
if (isNull(left, pLeftCol->info.type) || isNull(pRight->data, pRight->info.type)) {
SET_DOUBLE_NULL(output);
continue;
}
memcpy(varDataVal(output), varDataVal(left), varDataLen(pRight->data));
memcpy(varDataVal(output) + varDataLen(left), varDataVal(pRight->data), varDataLen(pRight->data));
varDataSetLen(output, varDataLen(left) + varDataLen(pRight->data));
}
}
#endif
}
static
void
vectorBitAndHelper
(
SColumnInfoData
*
pLeftCol
,
SColumnInfoData
*
pRightCol
,
SColumnInfoData
*
pOutputCol
,
int32_t
numOfRows
,
int32_t
step
,
int32_t
i
)
{
_getBigintValue_fn_t
getVectorBigintValueFnLeft
=
getVectorBigintValueFn
(
pLeftCol
->
info
.
type
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录