Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
74903336
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
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看板
提交
74903336
编写于
1月 12, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-2700]<fix>: fix incorrect generated time window.
上级
c718cf48
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
54 addition
and
2 deletion
+54
-2
src/os/CMakeLists.txt
src/os/CMakeLists.txt
+2
-0
src/os/src/detail/osTime.c
src/os/src/detail/osTime.c
+3
-2
src/os/tests/CMakeLists.txt
src/os/tests/CMakeLists.txt
+15
-0
src/os/tests/test.cpp
src/os/tests/test.cpp
+34
-0
未找到文件。
src/os/CMakeLists.txt
浏览文件 @
74903336
...
...
@@ -10,3 +10,5 @@ ELSEIF (TD_WINDOWS)
ENDIF
()
ADD_SUBDIRECTORY
(
src/detail
)
ADD_SUBDIRECTORY
(
tests
)
src/os/src/detail/osTime.c
浏览文件 @
74903336
...
...
@@ -486,7 +486,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
start
=
(
delta
/
pInterval
->
sliding
+
factor
)
*
pInterval
->
sliding
;
if
(
pInterval
->
intervalUnit
==
'd'
||
pInterval
->
intervalUnit
==
'w'
)
{
/*
/*
* here we revised the start time of day according to the local time zone,
* but in case of DST, the start time of one day need to be dynamically decided.
*/
...
...
@@ -502,8 +502,9 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
}
int64_t
end
=
start
+
pInterval
->
interval
-
1
;
if
(
end
<
t
)
{
while
(
end
<
t
)
{
// move forward to the correct time window
start
+=
pInterval
->
sliding
;
end
=
start
+
pInterval
->
interval
-
1
;
}
}
...
...
src/os/tests/CMakeLists.txt
0 → 100644
浏览文件 @
74903336
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
PROJECT
(
TDengine
)
FIND_PATH
(
HEADER_GTEST_INCLUDE_DIR gtest.h /usr/include/gtest /usr/local/include/gtest
)
FIND_LIBRARY
(
LIB_GTEST_STATIC_DIR libgtest.a /usr/lib/ /usr/local/lib
)
IF
(
HEADER_GTEST_INCLUDE_DIR AND LIB_GTEST_STATIC_DIR
)
MESSAGE
(
STATUS
"gTest library found, build unit test"
)
INCLUDE_DIRECTORIES
(
${
HEADER_GTEST_INCLUDE_DIR
}
)
AUX_SOURCE_DIRECTORY
(
${
CMAKE_CURRENT_SOURCE_DIR
}
SOURCE_LIST
)
ADD_EXECUTABLE
(
osTest
${
SOURCE_LIST
}
)
TARGET_LINK_LIBRARIES
(
osTest taos osdetail tutil common gtest pthread
)
ENDIF
()
\ No newline at end of file
src/os/tests/test.cpp
0 → 100644
浏览文件 @
74903336
#include "os.h"
#include <gtest/gtest.h>
#include <cassert>
#include <iostream>
#include "taos.h"
#include "tstoken.h"
#include "tutil.h"
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
// test function in os module
TEST
(
testCase
,
parse_time
)
{
taos_options
(
TSDB_OPTION_TIMEZONE
,
"GMT-8"
);
deltaToUtcInitOnce
();
// window: 1500000001000, 1500002000000
// pQuery->interval: interval: 86400000, sliding:3600000
int64_t
key
=
1500000001000
;
SInterval
interval
=
{
0
};
interval
.
interval
=
86400000
;
interval
.
intervalUnit
=
'd'
;
interval
.
sliding
=
3600000
;
interval
.
slidingUnit
=
'h'
;
int64_t
s
=
taosTimeTruncate
(
key
,
&
interval
,
TSDB_TIME_PRECISION_MILLI
);
ASSERT_TRUE
(
s
+
interval
.
interval
>=
key
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录