Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ba509423
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
ba509423
编写于
4月 25, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
差异文件
fix: some problems of udf and 'create table'
上级
103418bf
fe5a6dab
变更
79
展开全部
显示空白变更内容
内联
并排
Showing
79 changed file
with
2319 addition
and
1101 deletion
+2319
-1101
CMakeLists.txt
CMakeLists.txt
+1
-1
contrib/CMakeLists.txt
contrib/CMakeLists.txt
+5
-90
contrib/test/craft/CMakeLists.txt
contrib/test/craft/CMakeLists.txt
+1
-8
contrib/test/tdev/src/main.c
contrib/test/tdev/src/main.c
+38
-34
example/src/tmq.c
example/src/tmq.c
+4
-4
examples/c/CMakeLists.txt
examples/c/CMakeLists.txt
+2
-2
include/common/tdatablock.h
include/common/tdatablock.h
+11
-2
include/common/tglobal.h
include/common/tglobal.h
+3
-3
include/common/tmsg.h
include/common/tmsg.h
+53
-82
include/libs/function/function.h
include/libs/function/function.h
+26
-9
include/util/taoserror.h
include/util/taoserror.h
+1
-1
include/util/tconfig.h
include/util/tconfig.h
+4
-1
include/util/tenv.h
include/util/tenv.h
+33
-0
include/util/tjson.h
include/util/tjson.h
+3
-0
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+4
-0
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+2
-2
source/client/src/clientHb.c
source/client/src/clientHb.c
+32
-32
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+26
-16
source/client/src/tmq.c
source/client/src/tmq.c
+4
-2
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+2
-3
source/common/src/tglobal.c
source/common/src/tglobal.c
+15
-8
source/common/src/tmsg.c
source/common/src/tmsg.c
+80
-0
source/dnode/mgmt/exe/dmMain.c
source/dnode/mgmt/exe/dmMain.c
+22
-4
source/dnode/mgmt/interface/src/dmFile.c
source/dnode/mgmt/interface/src/dmFile.c
+1
-1
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+11
-0
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+50
-8
source/dnode/mnode/impl/src/mndInfoSchema.c
source/dnode/mnode/impl/src/mndInfoSchema.c
+3
-3
source/dnode/mnode/impl/src/mndPerfSchema.c
source/dnode/mnode/impl/src/mndPerfSchema.c
+1
-1
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+41
-40
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+9
-4
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+0
-1
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+11
-5
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+3
-5
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+2
-2
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+0
-1
source/dnode/vnode/src/inc/tsdbSma.h
source/dnode/vnode/src/inc/tsdbSma.h
+64
-0
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+4
-0
source/dnode/vnode/src/meta/metaTDBImpl.c
source/dnode/vnode/src/meta/metaTDBImpl.c
+7
-1
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+2
-2
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+24
-6
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+45
-21
source/dnode/vnode/src/tsdb/tsdbMain.c
source/dnode/vnode/src/tsdb/tsdbMain.c
+2
-2
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+9
-2
source/dnode/vnode/src/tsdb/tsdbSma.c
source/dnode/vnode/src/tsdb/tsdbSma.c
+524
-79
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+11
-0
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+13
-11
source/dnode/vnode/test/tsdbSmaTest.cpp
source/dnode/vnode/test/tsdbSmaTest.cpp
+1
-1
source/libs/command/src/explain.c
source/libs/command/src/explain.c
+23
-19
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+7
-4
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+12
-13
source/libs/executor/src/dataDispatcher.c
source/libs/executor/src/dataDispatcher.c
+4
-4
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+40
-2
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+146
-375
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+1
-1
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+175
-23
source/libs/function/inc/builtinsimpl.h
source/libs/function/inc/builtinsimpl.h
+5
-5
source/libs/function/inc/tudf.h
source/libs/function/inc/tudf.h
+0
-12
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+1
-1
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+178
-54
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+2
-2
source/libs/function/test/runUdf.c
source/libs/function/test/runUdf.c
+2
-2
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+3
-1
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+3
-3
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+4
-1
source/libs/sync/CMakeLists.txt
source/libs/sync/CMakeLists.txt
+1
-1
source/libs/sync/test/CMakeLists.txt
source/libs/sync/test/CMakeLists.txt
+39
-39
source/util/src/tarray.c
source/util/src/tarray.c
+1
-0
source/util/src/tconfig.c
source/util/src/tconfig.c
+343
-7
source/util/src/tenv.c
source/util/src/tenv.c
+78
-0
source/util/src/terror.c
source/util/src/terror.c
+4
-1
source/util/src/tjson.c
source/util/src/tjson.c
+19
-1
source/util/test/CMakeLists.txt
source/util/test/CMakeLists.txt
+1
-1
source/util/test/cfgTest.cpp
source/util/test/cfgTest.cpp
+1
-0
tests/script/sh/massiveTable/compileVersion.sh
tests/script/sh/massiveTable/compileVersion.sh
+2
-16
tests/script/tsim/parser/groupby-basic.sim
tests/script/tsim/parser/groupby-basic.sim
+9
-9
tests/script/tsim/stable/disk.sim
tests/script/tsim/stable/disk.sim
+1
-0
tests/tsim/src/simSystem.c
tests/tsim/src/simSystem.c
+2
-2
tools/shell/CMakeLists.txt
tools/shell/CMakeLists.txt
+1
-1
tools/shell/src/shellCommand.c
tools/shell/src/shellCommand.c
+1
-1
未找到文件。
CMakeLists.txt
浏览文件 @
ba509423
...
@@ -7,7 +7,7 @@ project(
...
@@ -7,7 +7,7 @@ project(
)
)
if
(
NOT DEFINED TD_SOURCE_DIR
)
if
(
NOT DEFINED TD_SOURCE_DIR
)
set
(
TD_SOURCE_DIR
${
CMAKE
_SOURCE_DIR
}
)
set
(
TD_SOURCE_DIR
${
PROJECT
_SOURCE_DIR
}
)
endif
()
endif
()
set
(
TD_SUPPORT_DIR
"
${
TD_SOURCE_DIR
}
/cmake"
)
set
(
TD_SUPPORT_DIR
"
${
TD_SOURCE_DIR
}
/cmake"
)
...
...
contrib/CMakeLists.txt
浏览文件 @
ba509423
...
@@ -14,24 +14,9 @@ if(${BUILD_PTHREAD})
...
@@ -14,24 +14,9 @@ if(${BUILD_PTHREAD})
cat
(
"
${
TD_SUPPORT_DIR
}
/pthread_CMakeLists.txt.in"
${
CONTRIB_TMP_FILE
}
)
cat
(
"
${
TD_SUPPORT_DIR
}
/pthread_CMakeLists.txt.in"
${
CONTRIB_TMP_FILE
}
)
endif
()
endif
()
# iconv
# gnu regex
if
(
${
BUILD_WITH_ICONV
}
)
if
(
${
BUILD_GNUREGEX
}
)
cat
(
"
${
TD_SUPPORT_DIR
}
/iconv_CMakeLists.txt.in"
${
CONTRIB_TMP_FILE
}
)
cat
(
"
${
TD_SUPPORT_DIR
}
/gnuregex_CMakeLists.txt.in"
${
CONTRIB_TMP_FILE
}
)
endif
()
# msvc regex
if
(
${
BUILD_MSVCREGEX
}
)
cat
(
"
${
TD_SUPPORT_DIR
}
/msvcregex_CMakeLists.txt.in"
${
CONTRIB_TMP_FILE
}
)
endif
()
# wcwidth
if
(
${
BUILD_WCWIDTH
}
)
cat
(
"
${
TD_SUPPORT_DIR
}
/wcwidth_CMakeLists.txt.in"
${
CONTRIB_TMP_FILE
}
)
endif
()
# wingetopt
if
(
${
BUILD_WINGETOPT
}
)
cat
(
"
${
TD_SUPPORT_DIR
}
/wingetopt_CMakeLists.txt.in"
${
CONTRIB_TMP_FILE
}
)
endif
()
endif
()
# googletest
# googletest
...
@@ -114,27 +99,8 @@ if(${BUILD_TEST})
...
@@ -114,27 +99,8 @@ if(${BUILD_TEST})
target_include_directories
(
target_include_directories
(
gtest
gtest
PUBLIC $<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/cpp-stub/src>
PUBLIC $<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/cpp-stub/src>
)
if
(
${
TD_WINDOWS
}
)
target_include_directories
(
gtest
PUBLIC $<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/cpp-stub/src_win>
)
endif
(
${
TD_WINDOWS
}
)
if
(
${
TD_LINUX
}
)
target_include_directories
(
gtest
PUBLIC $<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/cpp-stub/src_linux>
PUBLIC $<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/cpp-stub/src_linux>
)
)
endif
(
${
TD_LINUX
}
)
if
(
${
TD_DARWIN
}
)
target_include_directories
(
gtest
PUBLIC $<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/cpp-stub/src_darwin>
)
endif
(
${
TD_DARWIN
}
)
endif
(
${
BUILD_TEST
}
)
endif
(
${
BUILD_TEST
}
)
# cJson
# cJson
...
@@ -216,53 +182,6 @@ if(${BUILD_WITH_NURAFT})
...
@@ -216,53 +182,6 @@ if(${BUILD_WITH_NURAFT})
add_subdirectory
(
nuraft
)
add_subdirectory
(
nuraft
)
endif
(
${
BUILD_WITH_NURAFT
}
)
endif
(
${
BUILD_WITH_NURAFT
}
)
# pthread
if
(
${
BUILD_PTHREAD
}
)
set
(
CMAKE_BUILD_TYPE release
)
add_definitions
(
-DPTW32_STATIC_LIB
)
add_subdirectory
(
pthread
)
set_target_properties
(
libpthreadVC3 PROPERTIES OUTPUT_NAME pthread
)
add_library
(
pthread STATIC IMPORTED GLOBAL
)
SET_PROPERTY
(
TARGET pthread PROPERTY IMPORTED_LOCATION
${
LIBRARY_OUTPUT_PATH
}
/pthread.lib
)
endif
()
# iconv
if
(
${
BUILD_WITH_ICONV
}
)
add_subdirectory
(
iconv
)
endif
(
${
BUILD_WITH_ICONV
}
)
# wingetopt
if
(
${
BUILD_WINGETOPT
}
)
add_subdirectory
(
wingetopt
)
endif
(
${
BUILD_WINGETOPT
}
)
# msvcregex
if
(
${
BUILD_MSVCREGEX
}
)
add_library
(
msvcregex STATIC
""
)
target_sources
(
msvcregex
PRIVATE
"msvcregex/regex.c"
)
target_include_directories
(
msvcregex
PRIVATE
"msvcregex"
)
target_link_libraries
(
msvcregex
INTERFACE Shell32
)
SET_TARGET_PROPERTIES
(
msvcregex PROPERTIES OUTPUT_NAME msvcregex
)
endif
(
${
BUILD_MSVCREGEX
}
)
# msvcregex
if
(
${
BUILD_WCWIDTH
}
)
add_library
(
wcwidth STATIC
""
)
target_sources
(
wcwidth
PRIVATE
"wcwidth/wcwidth.c"
)
target_include_directories
(
wcwidth
PRIVATE
"wcwidth"
)
SET_TARGET_PROPERTIES
(
wcwidth PROPERTIES OUTPUT_NAME wcwidth
)
endif
(
${
BUILD_WCWIDTH
}
)
# CRAFT
# CRAFT
if
(
${
BUILD_WITH_CRAFT
}
)
if
(
${
BUILD_WITH_CRAFT
}
)
add_library
(
craft STATIC IMPORTED GLOBAL
)
add_library
(
craft STATIC IMPORTED GLOBAL
)
...
@@ -319,12 +238,8 @@ if(${BUILD_WITH_SQLITE})
...
@@ -319,12 +238,8 @@ if(${BUILD_WITH_SQLITE})
target_link_libraries
(
sqlite
target_link_libraries
(
sqlite
INTERFACE m
INTERFACE m
INTERFACE pthread
INTERFACE pthread
)
if
(
NOT TD_WINDOWS
)
target_link_libraries
(
sqlite
INTERFACE dl
INTERFACE dl
)
)
endif
(
NOT TD_WINDOWS
)
endif
(
${
BUILD_WITH_SQLITE
}
)
endif
(
${
BUILD_WITH_SQLITE
}
)
# pthread
# pthread
...
...
contrib/test/craft/CMakeLists.txt
浏览文件 @
ba509423
add_executable
(
simulate_vnode
"simulate_vnode.c"
)
add_executable
(
simulate_vnode
"simulate_vnode.c"
)
target_link_libraries
(
simulate_vnode PUBLIC craft lz4 uv_a
)
target_link_libraries
(
simulate_vnode PUBLIC craft lz4 uv_a
)
if
(
${
BUILD_WINGETOPT
}
)
target_link_libraries
(
simulate_vnode PUBLIC wingetopt
)
target_include_directories
(
simulate_vnode
PUBLIC
"
${
TD_SOURCE_DIR
}
/contrib/wingetopt/src"
)
endif
()
\ No newline at end of file
contrib/test/tdev/src/main.c
浏览文件 @
ba509423
...
@@ -6,39 +6,43 @@
...
@@ -6,39 +6,43 @@
#define POINTER_SHIFT(ptr, s) ((void *)(((char *)ptr) + (s)))
#define POINTER_SHIFT(ptr, s) ((void *)(((char *)ptr) + (s)))
#define POINTER_DISTANCE(pa, pb) ((char *)(pb) - (char *)(pa))
#define POINTER_DISTANCE(pa, pb) ((char *)(pb) - (char *)(pa))
static
inline
void
tPutA
(
void
**
buf
,
uint64_t
val
)
{
#define tPutA(buf, val) \
memcpy
(
buf
,
&
val
,
sizeof
(
val
));
({ \
*
buf
=
POINTER_SHIFT
(
buf
,
sizeof
(
val
));
memcpy(buf, &val, sizeof(val)); \
}
POINTER_SHIFT(buf, sizeof(val)); \
})
static
inline
void
tPutB
(
void
**
buf
,
uint64_t
val
)
{
#define tPutB(buf, val) \
((
uint8_t
*
)
buf
)[
7
]
=
((
val
)
>>
56
)
&
0xff
;
({ \
((
uint8_t
*
)
buf
)[
6
]
=
((
val
)
>>
48
)
&
0xff
;
((uint8_t *)buf)[7] = ((val) >> 56) & 0xff; \
((
uint8_t
*
)
buf
)[
5
]
=
((
val
)
>>
40
)
&
0xff
;
((uint8_t *)buf)[6] = ((val) >> 48) & 0xff; \
((
uint8_t
*
)
buf
)[
4
]
=
((
val
)
>>
32
)
&
0xff
;
((uint8_t *)buf)[5] = ((val) >> 40) & 0xff; \
((
uint8_t
*
)
buf
)[
3
]
=
((
val
)
>>
24
)
&
0xff
;
((uint8_t *)buf)[4] = ((val) >> 32) & 0xff; \
((
uint8_t
*
)
buf
)[
2
]
=
((
val
)
>>
16
)
&
0xff
;
((uint8_t *)buf)[3] = ((val) >> 24) & 0xff; \
((
uint8_t
*
)
buf
)[
1
]
=
((
val
)
>>
8
)
&
0xff
;
((uint8_t *)buf)[2] = ((val) >> 16) & 0xff; \
((
uint8_t
*
)
buf
)[
0
]
=
(
val
)
&
0xff
;
((uint8_t *)buf)[1] = ((val) >> 8) & 0xff; \
*
buf
=
POINTER_SHIFT
(
buf
,
sizeof
(
val
));
((uint8_t *)buf)[0] = (val)&0xff; \
}
POINTER_SHIFT(buf, sizeof(val)); \
})
static
inline
void
tPutC
(
void
**
buf
,
uint64_t
val
)
{
#define tPutC(buf, val) \
if
(
buf
)
{
({ \
((
uint64_t
*
)
buf
)[
0
]
=
(
val
);
if (buf) { \
POINTER_SHIFT
(
buf
,
sizeof
(
val
));
((uint64_t *)buf)[0] = (val); \
}
POINTER_SHIFT(buf, sizeof(val)); \
*
buf
=
NULL
;
} \
}
NULL; \
})
static
inline
void
tPutD
(
void
**
buf
,
uint64_t
val
)
{
#define tPutD(buf, val) \
uint64_t
tmp
=
val
;
({ \
for
(
size_t
i
=
0
;
i
<
sizeof
(
val
);
i
++
)
{
uint64_t tmp = val; \
((
uint8_t
*
)
buf
)[
i
]
=
tmp
&
0xff
;
for (size_t i = 0; i < sizeof(val); i++) { \
tmp
>>=
8
;
((uint8_t *)buf)[i] = tmp & 0xff; \
}
tmp >>= 8; \
*
buf
=
POINTER_SHIFT
(
buf
,
sizeof
(
val
));
} \
}
POINTER_SHIFT(buf, sizeof(val)); \
})
static
inline
void
tPutE
(
void
**
buf
,
uint64_t
val
)
{
static
inline
void
tPutE
(
void
**
buf
,
uint64_t
val
)
{
if
(
buf
)
{
if
(
buf
)
{
...
@@ -57,7 +61,7 @@ static void func(T t) {
...
@@ -57,7 +61,7 @@ static void func(T t) {
switch
(
t
)
{
switch
(
t
)
{
case
A
:
case
A
:
for
(
size_t
i
=
0
;
i
<
10
*
1024l
*
1024l
*
1024l
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
10
*
1024l
*
1024l
*
1024l
;
i
++
)
{
tPutA
(
pBuf
,
val
);
pBuf
=
tPutA
(
pBuf
,
val
);
if
(
POINTER_DISTANCE
(
buf
,
pBuf
)
==
1024
)
{
if
(
POINTER_DISTANCE
(
buf
,
pBuf
)
==
1024
)
{
pBuf
=
buf
;
pBuf
=
buf
;
}
}
...
@@ -65,7 +69,7 @@ static void func(T t) {
...
@@ -65,7 +69,7 @@ static void func(T t) {
break
;
break
;
case
B
:
case
B
:
for
(
size_t
i
=
0
;
i
<
10
*
1024l
*
1024l
*
1024l
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
10
*
1024l
*
1024l
*
1024l
;
i
++
)
{
tPutB
(
pBuf
,
val
);
pBuf
=
tPutB
(
pBuf
,
val
);
if
(
POINTER_DISTANCE
(
buf
,
pBuf
)
==
1024
)
{
if
(
POINTER_DISTANCE
(
buf
,
pBuf
)
==
1024
)
{
pBuf
=
buf
;
pBuf
=
buf
;
}
}
...
@@ -73,7 +77,7 @@ static void func(T t) {
...
@@ -73,7 +77,7 @@ static void func(T t) {
break
;
break
;
case
C
:
case
C
:
for
(
size_t
i
=
0
;
i
<
10
*
1024l
*
1024l
*
1024l
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
10
*
1024l
*
1024l
*
1024l
;
i
++
)
{
tPutC
(
pBuf
,
val
);
pBuf
=
tPutC
(
pBuf
,
val
);
if
(
POINTER_DISTANCE
(
buf
,
pBuf
)
==
1024
)
{
if
(
POINTER_DISTANCE
(
buf
,
pBuf
)
==
1024
)
{
pBuf
=
buf
;
pBuf
=
buf
;
}
}
...
@@ -81,7 +85,7 @@ static void func(T t) {
...
@@ -81,7 +85,7 @@ static void func(T t) {
break
;
break
;
case
D
:
case
D
:
for
(
size_t
i
=
0
;
i
<
10
*
1024l
*
1024l
*
1024l
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
10
*
1024l
*
1024l
*
1024l
;
i
++
)
{
tPutD
(
pBuf
,
val
);
pBuf
=
tPutD
(
pBuf
,
val
);
if
(
POINTER_DISTANCE
(
buf
,
pBuf
)
==
1024
)
{
if
(
POINTER_DISTANCE
(
buf
,
pBuf
)
==
1024
)
{
pBuf
=
buf
;
pBuf
=
buf
;
}
}
...
...
example/src/tmq.c
浏览文件 @
ba509423
...
@@ -60,7 +60,6 @@ int32_t init_env() {
...
@@ -60,7 +60,6 @@ int32_t init_env() {
pRes
=
pRes
=
taos_query
(
pConn
,
"create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(10)) tags(t1 int)"
);
taos_query
(
pConn
,
"create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(10)) tags(t1 int)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
assert
(
0
);
printf
(
"failed to create super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"failed to create super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
return
-
1
;
}
}
...
@@ -104,8 +103,8 @@ int32_t create_topic() {
...
@@ -104,8 +103,8 @@ int32_t create_topic() {
}
}
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
/*pRes = taos_query(pConn, "create topic topic_ctb_column as abc1");*/
pRes
=
taos_query
(
pConn
,
"create topic topic_ctb_column as abc1"
);
pRes
=
taos_query
(
pConn
,
"create topic topic_ctb_column as select ts, c1, c2, c3 from ct1"
);
/*pRes = taos_query(pConn, "create topic topic_ctb_column as select ts, c1, c2, c3 from ct1");*/
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create topic topic_ctb_column, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"failed to create topic topic_ctb_column, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
return
-
1
;
...
@@ -163,9 +162,10 @@ tmq_t* build_consumer() {
...
@@ -163,9 +162,10 @@ tmq_t* build_consumer() {
tmq_conf_set
(
conf
,
"group.id"
,
"tg2"
);
tmq_conf_set
(
conf
,
"group.id"
,
"tg2"
);
tmq_conf_set
(
conf
,
"td.connect.user"
,
"root"
);
tmq_conf_set
(
conf
,
"td.connect.user"
,
"root"
);
tmq_conf_set
(
conf
,
"td.connect.pass"
,
"taosdata"
);
tmq_conf_set
(
conf
,
"td.connect.pass"
,
"taosdata"
);
tmq_conf_set
(
conf
,
"td.connect.db"
,
"abc1"
);
/*tmq_conf_set(conf, "td.connect.db", "abc1");*/
tmq_conf_set_offset_commit_cb
(
conf
,
tmq_commit_cb_print
);
tmq_conf_set_offset_commit_cb
(
conf
,
tmq_commit_cb_print
);
tmq_t
*
tmq
=
tmq_consumer_new
(
conf
,
NULL
,
0
);
tmq_t
*
tmq
=
tmq_consumer_new
(
conf
,
NULL
,
0
);
assert
(
tmq
);
return
tmq
;
return
tmq
;
}
}
...
...
examples/c/CMakeLists.txt
浏览文件 @
ba509423
PROJECT
(
TDengine
)
PROJECT
(
TDengine
)
IF
(
TD_LINUX
)
IF
(
TD_LINUX
)
INCLUDE_DIRECTORIES
(
.
${
TD_
COMMUNITY_DIR
}
/src/inc
${
TD_COMMUNITY_DIR
}
/src/client/inc
${
TD_COMMUNITY
_DIR
}
/inc
)
INCLUDE_DIRECTORIES
(
.
${
TD_
SOURCE_DIR
}
/src/inc
${
TD_SOURCE_DIR
}
/src/client/inc
${
TD_SOURCE
_DIR
}
/inc
)
AUX_SOURCE_DIRECTORY
(
. SRC
)
AUX_SOURCE_DIRECTORY
(
. SRC
)
ADD_EXECUTABLE
(
demo apitest.c
)
ADD_EXECUTABLE
(
demo apitest.c
)
TARGET_LINK_LIBRARIES
(
demo taos_static trpc tutil pthread
)
TARGET_LINK_LIBRARIES
(
demo taos_static trpc tutil pthread
)
...
@@ -13,7 +13,7 @@ IF (TD_LINUX)
...
@@ -13,7 +13,7 @@ IF (TD_LINUX)
TARGET_LINK_LIBRARIES
(
epoll taos_static trpc tutil pthread lua
)
TARGET_LINK_LIBRARIES
(
epoll taos_static trpc tutil pthread lua
)
ENDIF
()
ENDIF
()
IF
(
TD_DARWIN
)
IF
(
TD_DARWIN
)
INCLUDE_DIRECTORIES
(
.
${
TD_
COMMUNITY_DIR
}
/src/inc
${
TD_COMMUNITY_DIR
}
/src/client/inc
${
TD_COMMUNITY
_DIR
}
/inc
)
INCLUDE_DIRECTORIES
(
.
${
TD_
SOURCE_DIR
}
/src/inc
${
TD_SOURCE_DIR
}
/src/client/inc
${
TD_SOURCE
_DIR
}
/inc
)
AUX_SOURCE_DIRECTORY
(
. SRC
)
AUX_SOURCE_DIRECTORY
(
. SRC
)
ADD_EXECUTABLE
(
demo demo.c
)
ADD_EXECUTABLE
(
demo demo.c
)
TARGET_LINK_LIBRARIES
(
demo taos_static trpc tutil pthread lua
)
TARGET_LINK_LIBRARIES
(
demo taos_static trpc tutil pthread lua
)
...
...
include/common/tdatablock.h
浏览文件 @
ba509423
...
@@ -238,10 +238,16 @@ static FORCE_INLINE int32_t blockCompressColData(SColumnInfoData* pColRes, int32
...
@@ -238,10 +238,16 @@ static FORCE_INLINE int32_t blockCompressColData(SColumnInfoData* pColRes, int32
static
FORCE_INLINE
void
blockCompressEncode
(
const
SSDataBlock
*
pBlock
,
char
*
data
,
int32_t
*
dataLen
,
int32_t
numOfCols
,
static
FORCE_INLINE
void
blockCompressEncode
(
const
SSDataBlock
*
pBlock
,
char
*
data
,
int32_t
*
dataLen
,
int32_t
numOfCols
,
int8_t
needCompress
)
{
int8_t
needCompress
)
{
int32_t
*
colSizes
=
(
int32_t
*
)
data
;
int32_t
*
actualLen
=
(
int32_t
*
)
data
;
data
+=
sizeof
(
int32_t
);
uint64_t
*
groupId
=
(
uint64_t
*
)
data
;
data
+=
sizeof
(
uint64_t
);
int32_t
*
colSizes
=
(
int32_t
*
)
data
;
data
+=
numOfCols
*
sizeof
(
int32_t
);
data
+=
numOfCols
*
sizeof
(
int32_t
);
*
dataLen
=
(
numOfCols
*
sizeof
(
int32_t
));
*
dataLen
=
(
numOfCols
*
sizeof
(
int32_t
)
+
sizeof
(
uint64_t
)
+
sizeof
(
int32_t
));
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
for
(
int32_t
col
=
0
;
col
<
numOfCols
;
++
col
)
{
for
(
int32_t
col
=
0
;
col
<
numOfCols
;
++
col
)
{
...
@@ -273,6 +279,9 @@ static FORCE_INLINE void blockCompressEncode(const SSDataBlock* pBlock, char* da
...
@@ -273,6 +279,9 @@ static FORCE_INLINE void blockCompressEncode(const SSDataBlock* pBlock, char* da
colSizes
[
col
]
=
htonl
(
colSizes
[
col
]);
colSizes
[
col
]
=
htonl
(
colSizes
[
col
]);
}
}
*
actualLen
=
*
dataLen
;
*
groupId
=
pBlock
->
info
.
groupId
;
}
}
#ifdef __cplusplus
#ifdef __cplusplus
...
...
include/common/tglobal.h
浏览文件 @
ba509423
...
@@ -123,9 +123,9 @@ extern SDiskCfg tsDiskCfg[];
...
@@ -123,9 +123,9 @@ extern SDiskCfg tsDiskCfg[];
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
*
envFile
,
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
*
*
envCmd
,
const
char
*
envFile
,
c
onst
c
har
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
);
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
);
int32_t
taosInitCfg
(
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
);
int32_t
taosInitCfg
(
const
char
*
cfgDir
,
const
char
*
*
envCmd
,
const
char
*
envFile
,
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
);
void
taosCleanupCfg
();
void
taosCleanupCfg
();
void
taosCfgDynamicOptions
(
const
char
*
option
,
const
char
*
value
);
void
taosCfgDynamicOptions
(
const
char
*
option
,
const
char
*
value
);
void
taosAddDataDir
(
int32_t
index
,
char
*
v1
,
int32_t
level
,
int32_t
primary
);
void
taosAddDataDir
(
int32_t
index
,
char
*
v1
,
int32_t
level
,
int32_t
primary
);
...
...
include/common/tmsg.h
浏览文件 @
ba509423
...
@@ -229,6 +229,14 @@ typedef struct {
...
@@ -229,6 +229,14 @@ typedef struct {
typedef
struct
{
typedef
struct
{
int32_t
totalLen
;
int32_t
totalLen
;
int32_t
len
;
int32_t
len
;
// head of SSubmitBlk
// int64_t uid; // table unique id
// int64_t suid; // stable id
// int32_t sversion; // data schema version
// int32_t dataLen; // data part length, not including the SSubmitBlk head
// int32_t schemaLen; // schema length, if length is 0, no schema exists
// int16_t numOfRows; // total number of rows in current submit block
// head of SSubmitBlk
const
void
*
pMsg
;
const
void
*
pMsg
;
}
SSubmitMsgIter
;
}
SSubmitMsgIter
;
...
@@ -237,6 +245,15 @@ int32_t tGetSubmitMsgNext(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
...
@@ -237,6 +245,15 @@ int32_t tGetSubmitMsgNext(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
int32_t
tInitSubmitBlkIter
(
SSubmitBlk
*
pBlock
,
SSubmitBlkIter
*
pIter
);
int32_t
tInitSubmitBlkIter
(
SSubmitBlk
*
pBlock
,
SSubmitBlkIter
*
pIter
);
STSRow
*
tGetSubmitBlkNext
(
SSubmitBlkIter
*
pIter
);
STSRow
*
tGetSubmitBlkNext
(
SSubmitBlkIter
*
pIter
);
// TODO: KEEP one suite of iterator API finally.
// 1) use tInitSubmitMsgIterEx firstly as not decrease the merge conflicts
// 2) replace tInitSubmitMsgIterEx with tInitSubmitMsgIter later
// 3) finally, rename tInitSubmitMsgIterEx to tInitSubmitMsgIter
// int32_t tInitSubmitMsgIterEx(const SSubmitReq* pMsg, SSubmitMsgIter* pIter);
// int32_t tGetSubmitMsgNextEx(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
// int32_t tInitSubmitBlkIterEx(SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkIter* pIter);
// STSRow* tGetSubmitBlkNextEx(SSubmitBlkIter* pIter);
typedef
struct
{
typedef
struct
{
int32_t
index
;
// index of failed block in submit blocks
int32_t
index
;
// index of failed block in submit blocks
int32_t
vnode
;
// vnode index of failed block
int32_t
vnode
;
// vnode index of failed block
...
@@ -1494,8 +1511,8 @@ typedef struct {
...
@@ -1494,8 +1511,8 @@ typedef struct {
int32_t
delay
;
int32_t
delay
;
int32_t
qmsg1Len
;
int32_t
qmsg1Len
;
int32_t
qmsg2Len
;
int32_t
qmsg2Len
;
char
*
qmsg1
;
//
not null:
pAst1:qmsg1:SRetention1 => trigger aggr task1
char
*
qmsg1
;
// pAst1:qmsg1:SRetention1 => trigger aggr task1
char
*
qmsg2
;
//
not null:
pAst2:qmsg2:SRetention2 => trigger aggr task2
char
*
qmsg2
;
// pAst2:qmsg2:SRetention2 => trigger aggr task2
}
SRSmaParam
;
}
SRSmaParam
;
typedef
struct
SVCreateTbReq
{
typedef
struct
SVCreateTbReq
{
...
@@ -2049,80 +2066,6 @@ static FORCE_INLINE void* tDecodeSMqSetCVgReq(void* buf, SMqSetCVgReq* pReq) {
...
@@ -2049,80 +2066,6 @@ static FORCE_INLINE void* tDecodeSMqSetCVgReq(void* buf, SMqSetCVgReq* pReq) {
return
buf
;
return
buf
;
}
}
typedef
struct
{
int64_t
leftForVer
;
int32_t
vgId
;
int32_t
epoch
;
int64_t
consumerId
;
char
topicName
[
TSDB_TOPIC_FNAME_LEN
];
}
SMqCancelConnReq
;
static
FORCE_INLINE
int32_t
tEncodeSMqCancelConnReq
(
void
**
buf
,
const
SMqCancelConnReq
*
pReq
)
{
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
leftForVer
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
vgId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
epoch
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
consumerId
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
topicName
);
return
tlen
;
}
static
FORCE_INLINE
void
*
tDecodeSMqCancelConnReq
(
void
*
buf
,
SMqCancelConnReq
*
pReq
)
{
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
leftForVer
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
vgId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
epoch
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
consumerId
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
topicName
);
return
buf
;
}
typedef
struct
{
int8_t
reserved
;
}
SMqCancelConnRsp
;
typedef
struct
{
int64_t
leftForVer
;
int32_t
vgId
;
int64_t
oldConsumerId
;
int64_t
newConsumerId
;
char
*
topic
;
}
SMqMVRebReq
;
static
FORCE_INLINE
int32_t
tEncodeSMqMVRebReq
(
void
**
buf
,
const
SMqMVRebReq
*
pReq
)
{
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
leftForVer
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
vgId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
oldConsumerId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
newConsumerId
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
topic
);
return
tlen
;
}
static
FORCE_INLINE
void
*
tDecodeSMqMVRebReq
(
void
*
buf
,
SMqMVRebReq
*
pReq
)
{
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
leftForVer
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
vgId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
oldConsumerId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
newConsumerId
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
topic
);
return
buf
;
}
typedef
struct
{
SMsgHead
header
;
int32_t
vgId
;
int64_t
consumerId
;
char
topicName
[
TSDB_TOPIC_FNAME_LEN
];
char
cgroup
[
TSDB_CGROUP_LEN
];
}
SMqSetCVgRsp
;
typedef
struct
{
SMsgHead
header
;
int32_t
vgId
;
int64_t
consumerId
;
char
topicName
[
TSDB_TOPIC_FNAME_LEN
];
char
cgroup
[
TSDB_CGROUP_LEN
];
}
SMqMVRebRsp
;
typedef
struct
{
typedef
struct
{
int32_t
vgId
;
int32_t
vgId
;
int64_t
offset
;
int64_t
offset
;
...
@@ -2149,6 +2092,24 @@ typedef struct {
...
@@ -2149,6 +2092,24 @@ typedef struct {
SSchema
*
pSchema
;
SSchema
*
pSchema
;
}
SSchemaWrapper
;
}
SSchemaWrapper
;
static
FORCE_INLINE
SSchemaWrapper
*
tCloneSSchemaWrapper
(
const
SSchemaWrapper
*
pSchemaWrapper
)
{
SSchemaWrapper
*
pSW
=
(
SSchemaWrapper
*
)
taosMemoryMalloc
(
sizeof
(
SSchemaWrapper
));
if
(
pSW
==
NULL
)
return
pSW
;
pSW
->
nCols
=
pSchemaWrapper
->
nCols
;
pSW
->
pSchema
=
(
SSchema
*
)
taosMemoryCalloc
(
pSW
->
nCols
,
sizeof
(
SSchema
));
if
(
pSW
->
pSchema
==
NULL
)
{
taosMemoryFree
(
pSW
);
return
NULL
;
}
memcpy
(
pSW
->
pSchema
,
pSchemaWrapper
->
pSchema
,
pSW
->
nCols
*
sizeof
(
SSchema
));
return
pSW
;
}
static
FORCE_INLINE
void
tDeleteSSchemaWrapper
(
SSchemaWrapper
*
pSchemaWrapper
)
{
taosMemoryFree
(
pSchemaWrapper
->
pSchema
);
taosMemoryFree
(
pSchemaWrapper
);
}
static
FORCE_INLINE
int32_t
taosEncodeSSchema
(
void
**
buf
,
const
SSchema
*
pSchema
)
{
static
FORCE_INLINE
int32_t
taosEncodeSSchema
(
void
**
buf
,
const
SSchema
*
pSchema
)
{
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
type
);
...
@@ -2159,13 +2120,13 @@ static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema
...
@@ -2159,13 +2120,13 @@ static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema
return
tlen
;
return
tlen
;
}
}
static
FORCE_INLINE
void
*
taosDecodeSSchema
(
void
*
buf
,
SSchema
*
pSchema
)
{
static
FORCE_INLINE
void
*
taosDecodeSSchema
(
const
void
*
buf
,
SSchema
*
pSchema
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
flags
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
flags
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSchema
->
bytes
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSchema
->
bytes
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pSchema
->
colId
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pSchema
->
colId
);
buf
=
taosDecodeStringTo
(
buf
,
pSchema
->
name
);
buf
=
taosDecodeStringTo
(
buf
,
pSchema
->
name
);
return
buf
;
return
(
void
*
)
buf
;
}
}
static
FORCE_INLINE
int32_t
tEncodeSSchema
(
SCoder
*
pEncoder
,
const
SSchema
*
pSchema
)
{
static
FORCE_INLINE
int32_t
tEncodeSSchema
(
SCoder
*
pEncoder
,
const
SSchema
*
pSchema
)
{
...
@@ -2195,7 +2156,7 @@ static FORCE_INLINE int32_t taosEncodeSSchemaWrapper(void** buf, const SSchemaWr
...
@@ -2195,7 +2156,7 @@ static FORCE_INLINE int32_t taosEncodeSSchemaWrapper(void** buf, const SSchemaWr
return
tlen
;
return
tlen
;
}
}
static
FORCE_INLINE
void
*
taosDecodeSSchemaWrapper
(
void
*
buf
,
SSchemaWrapper
*
pSW
)
{
static
FORCE_INLINE
void
*
taosDecodeSSchemaWrapper
(
const
void
*
buf
,
SSchemaWrapper
*
pSW
)
{
buf
=
taosDecodeFixedU32
(
buf
,
&
pSW
->
nCols
);
buf
=
taosDecodeFixedU32
(
buf
,
&
pSW
->
nCols
);
pSW
->
pSchema
=
(
SSchema
*
)
taosMemoryCalloc
(
pSW
->
nCols
,
sizeof
(
SSchema
));
pSW
->
pSchema
=
(
SSchema
*
)
taosMemoryCalloc
(
pSW
->
nCols
,
sizeof
(
SSchema
));
if
(
pSW
->
pSchema
==
NULL
)
{
if
(
pSW
->
pSchema
==
NULL
)
{
...
@@ -2205,7 +2166,7 @@ static FORCE_INLINE void* taosDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pS
...
@@ -2205,7 +2166,7 @@ static FORCE_INLINE void* taosDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pS
for
(
int32_t
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
buf
=
taosDecodeSSchema
(
buf
,
&
pSW
->
pSchema
[
i
]);
buf
=
taosDecodeSSchema
(
buf
,
&
pSW
->
pSchema
[
i
]);
}
}
return
buf
;
return
(
void
*
)
buf
;
}
}
static
FORCE_INLINE
int32_t
tEncodeSSchemaWrapper
(
SCoder
*
pEncoder
,
const
SSchemaWrapper
*
pSW
)
{
static
FORCE_INLINE
int32_t
tEncodeSSchemaWrapper
(
SCoder
*
pEncoder
,
const
SSchemaWrapper
*
pSW
)
{
...
@@ -2612,6 +2573,10 @@ static FORCE_INLINE int32_t tEncodeSMqDataBlkRsp(void** buf, const SMqDataBlkRsp
...
@@ -2612,6 +2573,10 @@ static FORCE_INLINE int32_t tEncodeSMqDataBlkRsp(void** buf, const SMqDataBlkRsp
void
*
data
=
taosArrayGetP
(
pRsp
->
blockData
,
i
);
void
*
data
=
taosArrayGetP
(
pRsp
->
blockData
,
i
);
tlen
+=
taosEncodeFixedI32
(
buf
,
bLen
);
tlen
+=
taosEncodeFixedI32
(
buf
,
bLen
);
tlen
+=
taosEncodeBinary
(
buf
,
data
,
bLen
);
tlen
+=
taosEncodeBinary
(
buf
,
data
,
bLen
);
if
(
pRsp
->
withSchema
)
{
SSchemaWrapper
*
pSW
=
(
SSchemaWrapper
*
)
taosArrayGetP
(
pRsp
->
blockSchema
,
i
);
tlen
+=
taosEncodeSSchemaWrapper
(
buf
,
pSW
);
}
}
}
}
}
return
tlen
;
return
tlen
;
...
@@ -2624,6 +2589,7 @@ static FORCE_INLINE void* tDecodeSMqDataBlkRsp(const void* buf, SMqDataBlkRsp* p
...
@@ -2624,6 +2589,7 @@ static FORCE_INLINE void* tDecodeSMqDataBlkRsp(const void* buf, SMqDataBlkRsp* p
buf
=
taosDecodeFixedI32
(
buf
,
&
pRsp
->
blockNum
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pRsp
->
blockNum
);
pRsp
->
blockData
=
taosArrayInit
(
pRsp
->
blockNum
,
sizeof
(
void
*
));
pRsp
->
blockData
=
taosArrayInit
(
pRsp
->
blockNum
,
sizeof
(
void
*
));
pRsp
->
blockDataLen
=
taosArrayInit
(
pRsp
->
blockNum
,
sizeof
(
void
*
));
pRsp
->
blockDataLen
=
taosArrayInit
(
pRsp
->
blockNum
,
sizeof
(
void
*
));
pRsp
->
blockSchema
=
taosArrayInit
(
pRsp
->
blockNum
,
sizeof
(
void
*
));
if
(
pRsp
->
blockNum
!=
0
)
{
if
(
pRsp
->
blockNum
!=
0
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
pRsp
->
withTbName
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pRsp
->
withTbName
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pRsp
->
withSchema
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pRsp
->
withSchema
);
...
@@ -2636,6 +2602,11 @@ static FORCE_INLINE void* tDecodeSMqDataBlkRsp(const void* buf, SMqDataBlkRsp* p
...
@@ -2636,6 +2602,11 @@ static FORCE_INLINE void* tDecodeSMqDataBlkRsp(const void* buf, SMqDataBlkRsp* p
buf
=
taosDecodeBinary
(
buf
,
&
data
,
bLen
);
buf
=
taosDecodeBinary
(
buf
,
&
data
,
bLen
);
taosArrayPush
(
pRsp
->
blockDataLen
,
&
bLen
);
taosArrayPush
(
pRsp
->
blockDataLen
,
&
bLen
);
taosArrayPush
(
pRsp
->
blockData
,
&
data
);
taosArrayPush
(
pRsp
->
blockData
,
&
data
);
if
(
pRsp
->
withSchema
)
{
SSchemaWrapper
*
pSW
=
(
SSchemaWrapper
*
)
taosMemoryMalloc
(
sizeof
(
SSchemaWrapper
));
buf
=
taosDecodeSSchemaWrapper
(
buf
,
pSW
);
taosArrayPush
(
pRsp
->
blockSchema
,
&
pSW
);
}
}
}
}
}
return
(
void
*
)
buf
;
return
(
void
*
)
buf
;
...
...
include/libs/function/function.h
浏览文件 @
ba509423
...
@@ -37,7 +37,7 @@ typedef struct SFuncExecEnv {
...
@@ -37,7 +37,7 @@ typedef struct SFuncExecEnv {
typedef
bool
(
*
FExecGetEnv
)(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
typedef
bool
(
*
FExecGetEnv
)(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
typedef
bool
(
*
FExecInit
)(
struct
SqlFunctionCtx
*
pCtx
,
struct
SResultRowEntryInfo
*
pResultCellInfo
);
typedef
bool
(
*
FExecInit
)(
struct
SqlFunctionCtx
*
pCtx
,
struct
SResultRowEntryInfo
*
pResultCellInfo
);
typedef
int32_t
(
*
FExecProcess
)(
struct
SqlFunctionCtx
*
pCtx
);
typedef
int32_t
(
*
FExecProcess
)(
struct
SqlFunctionCtx
*
pCtx
);
typedef
int32_t
(
*
FExecFinalize
)(
struct
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
slotId
);
typedef
int32_t
(
*
FExecFinalize
)(
struct
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
typedef
int32_t
(
*
FScalarExecProcess
)(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
);
typedef
int32_t
(
*
FScalarExecProcess
)(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
);
typedef
struct
SScalarFuncExecFuncs
{
typedef
struct
SScalarFuncExecFuncs
{
...
@@ -141,8 +141,7 @@ struct SResultRowEntryInfo;
...
@@ -141,8 +141,7 @@ struct SResultRowEntryInfo;
//for selectivity query, the corresponding tag value is assigned if the data is qualified
//for selectivity query, the corresponding tag value is assigned if the data is qualified
typedef
struct
SSubsidiaryResInfo
{
typedef
struct
SSubsidiaryResInfo
{
int16_t
bufLen
;
// keep the tags data for top/bottom query result
int16_t
num
;
int16_t
numOfCols
;
struct
SqlFunctionCtx
**
pCtx
;
struct
SqlFunctionCtx
**
pCtx
;
}
SSubsidiaryResInfo
;
}
SSubsidiaryResInfo
;
...
@@ -187,8 +186,8 @@ typedef struct SqlFunctionCtx {
...
@@ -187,8 +186,8 @@ typedef struct SqlFunctionCtx {
uint8_t
currentStage
;
// record current running step, default: 0
uint8_t
currentStage
;
// record current running step, default: 0
bool
isAggSet
;
bool
isAggSet
;
int64_t
startTs
;
// timestamp range of current query when function is executed on a specific data block, TODO remove it
int64_t
startTs
;
// timestamp range of current query when function is executed on a specific data block, TODO remove it
/////////////////////////////////////////////////////////////////
bool
stableQuery
;
bool
stableQuery
;
/////////////////////////////////////////////////////////////////
int16_t
functionId
;
// function id
int16_t
functionId
;
// function id
char
*
pOutput
;
// final result output buffer, point to sdata->data
char
*
pOutput
;
// final result output buffer, point to sdata->data
int32_t
numOfParams
;
int32_t
numOfParams
;
...
@@ -198,11 +197,15 @@ typedef struct SqlFunctionCtx {
...
@@ -198,11 +197,15 @@ typedef struct SqlFunctionCtx {
int32_t
offset
;
int32_t
offset
;
SVariant
tag
;
SVariant
tag
;
struct
SResultRowEntryInfo
*
resultInfo
;
struct
SResultRowEntryInfo
*
resultInfo
;
SSubsidiaryResInfo
subsidiar
yR
es
;
SSubsidiaryResInfo
subsidiar
i
es
;
SPoint1
start
;
SPoint1
start
;
SPoint1
end
;
SPoint1
end
;
SFuncExecFuncs
fpSet
;
SFuncExecFuncs
fpSet
;
SScalarFuncExecFuncs
sfp
;
SScalarFuncExecFuncs
sfp
;
SExprInfo
*
pExpr
;
struct
SDiskbasedBuf
*
pBuf
;
struct
SSDataBlock
*
pSrcBlock
;
int32_t
curBufPage
;
}
SqlFunctionCtx
;
}
SqlFunctionCtx
;
enum
{
enum
{
...
@@ -319,6 +322,20 @@ struct SUdfInfo;
...
@@ -319,6 +322,20 @@ struct SUdfInfo;
void
qAddUdfInfo
(
uint64_t
id
,
struct
SUdfInfo
*
pUdfInfo
);
void
qAddUdfInfo
(
uint64_t
id
,
struct
SUdfInfo
*
pUdfInfo
);
void
qRemoveUdfInfo
(
uint64_t
id
,
struct
SUdfInfo
*
pUdfInfo
);
void
qRemoveUdfInfo
(
uint64_t
id
,
struct
SUdfInfo
*
pUdfInfo
);
/**
* create udfd proxy, called once in process that call setupUdf/callUdfxxx/teardownUdf
* @return error code
*/
int32_t
udfcOpen
();
/**
* destroy udfd proxy
* @return error code
*/
int32_t
udfcClose
();
typedef
void
*
UdfcFuncHandle
;
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/util/taoserror.h
浏览文件 @
ba509423
...
@@ -252,7 +252,7 @@ int32_t* taosGetErrno();
...
@@ -252,7 +252,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AE)
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AE)
// mnode-infoSchema
// mnode-infoSchema
#define TSDB_CODE_MND_INVALID_
INFOS_TBL
TAOS_DEF_ERROR_CODE(0, 0x03B0)
#define TSDB_CODE_MND_INVALID_
SYS_TABLENAME
TAOS_DEF_ERROR_CODE(0, 0x03B0)
// mnode-func
// mnode-func
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C0)
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C0)
...
...
include/util/tconfig.h
浏览文件 @
ba509423
...
@@ -30,6 +30,7 @@ typedef enum {
...
@@ -30,6 +30,7 @@ typedef enum {
CFG_STYPE_CFG_FILE
,
CFG_STYPE_CFG_FILE
,
CFG_STYPE_ENV_FILE
,
CFG_STYPE_ENV_FILE
,
CFG_STYPE_ENV_VAR
,
CFG_STYPE_ENV_VAR
,
CFG_STYPE_ENV_CMD
,
CFG_STYPE_APOLLO_URL
,
CFG_STYPE_APOLLO_URL
,
CFG_STYPE_ARG_LIST
,
CFG_STYPE_ARG_LIST
,
CFG_STYPE_TAOS_OPTIONS
CFG_STYPE_TAOS_OPTIONS
...
@@ -82,7 +83,7 @@ typedef struct SConfig {
...
@@ -82,7 +83,7 @@ typedef struct SConfig {
}
SConfig
;
}
SConfig
;
SConfig
*
cfgInit
();
SConfig
*
cfgInit
();
int32_t
cfgLoad
(
SConfig
*
pCfg
,
ECfgSrcType
cfgType
,
const
char
*
sourceStr
);
int32_t
cfgLoad
(
SConfig
*
pCfg
,
ECfgSrcType
cfgType
,
const
void
*
sourceStr
);
int32_t
cfgLoadFromArray
(
SConfig
*
pCfg
,
SArray
*
pArgs
);
// SConfigPair
int32_t
cfgLoadFromArray
(
SConfig
*
pCfg
,
SArray
*
pArgs
);
// SConfigPair
void
cfgCleanup
(
SConfig
*
pCfg
);
void
cfgCleanup
(
SConfig
*
pCfg
);
...
@@ -105,6 +106,8 @@ const char *cfgDtypeStr(ECfgDataType type);
...
@@ -105,6 +106,8 @@ const char *cfgDtypeStr(ECfgDataType type);
void
cfgDumpCfg
(
SConfig
*
pCfg
,
bool
tsc
,
bool
dump
);
void
cfgDumpCfg
(
SConfig
*
pCfg
,
bool
tsc
,
bool
dump
);
int32_t
cfgGetApollUrl
(
const
char
**
envCmd
,
const
char
*
envFile
,
char
*
apolloUrl
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/util/tenv.h
0 → 100644
浏览文件 @
ba509423
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_ENV_H_
#define _TD_ENV_H_
#include "os.h"
#ifdef __cplusplus
extern
"C"
{
#endif
int32_t
taosEnvNameToCfgName
(
const
char
*
envNameStr
,
char
*
cfgNameStr
,
int32_t
cfgNameMaxLen
);
int32_t
taosEnvToCfg
(
const
char
*
envStr
,
char
*
cfgStr
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_ENV_H_*/
include/util/tjson.h
浏览文件 @
ba509423
...
@@ -49,6 +49,8 @@ int32_t tjsonAddItemToObject(SJson* pJson, const char* pName, SJson* pItem);
...
@@ -49,6 +49,8 @@ int32_t tjsonAddItemToObject(SJson* pJson, const char* pName, SJson* pItem);
int32_t
tjsonAddItemToArray
(
SJson
*
pJson
,
SJson
*
pItem
);
int32_t
tjsonAddItemToArray
(
SJson
*
pJson
,
SJson
*
pItem
);
SJson
*
tjsonGetObjectItem
(
const
SJson
*
pJson
,
const
char
*
pName
);
SJson
*
tjsonGetObjectItem
(
const
SJson
*
pJson
,
const
char
*
pName
);
int32_t
tjsonGetObjectName
(
const
SJson
*
pJson
,
char
**
pName
);
int32_t
tjsonGetObjectValueString
(
const
SJson
*
pJson
,
char
**
pStringValue
);
int32_t
tjsonGetStringValue
(
const
SJson
*
pJson
,
const
char
*
pName
,
char
*
pVal
);
int32_t
tjsonGetStringValue
(
const
SJson
*
pJson
,
const
char
*
pName
,
char
*
pVal
);
int32_t
tjsonDupStringValue
(
const
SJson
*
pJson
,
const
char
*
pName
,
char
**
pVal
);
int32_t
tjsonDupStringValue
(
const
SJson
*
pJson
,
const
char
*
pName
,
char
**
pVal
);
int32_t
tjsonGetBigIntValue
(
const
SJson
*
pJson
,
const
char
*
pName
,
int64_t
*
pVal
);
int32_t
tjsonGetBigIntValue
(
const
SJson
*
pJson
,
const
char
*
pName
,
int64_t
*
pVal
);
...
@@ -81,6 +83,7 @@ char* tjsonToUnformattedString(const SJson* pJson);
...
@@ -81,6 +83,7 @@ char* tjsonToUnformattedString(const SJson* pJson);
SJson
*
tjsonParse
(
const
char
*
pStr
);
SJson
*
tjsonParse
(
const
char
*
pStr
);
bool
tjsonValidateJson
(
const
char
*
pJson
);
bool
tjsonValidateJson
(
const
char
*
pJson
);
const
char
*
tjsonGetError
();
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/client/inc/clientInt.h
浏览文件 @
ba509423
...
@@ -231,6 +231,10 @@ static FORCE_INLINE SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool conver
...
@@ -231,6 +231,10 @@ static FORCE_INLINE SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool conver
msg
->
resIter
++
;
msg
->
resIter
++
;
if
(
msg
->
resIter
<
msg
->
rsp
.
blockNum
)
{
if
(
msg
->
resIter
<
msg
->
rsp
.
blockNum
)
{
SRetrieveTableRsp
*
pRetrieve
=
(
SRetrieveTableRsp
*
)
taosArrayGetP
(
msg
->
rsp
.
blockData
,
msg
->
resIter
);
SRetrieveTableRsp
*
pRetrieve
=
(
SRetrieveTableRsp
*
)
taosArrayGetP
(
msg
->
rsp
.
blockData
,
msg
->
resIter
);
if
(
msg
->
rsp
.
withSchema
)
{
SSchemaWrapper
*
pSW
=
(
SSchemaWrapper
*
)
taosArrayGetP
(
msg
->
rsp
.
blockSchema
,
msg
->
resIter
);
setResSchemaInfo
(
&
msg
->
resInfo
,
pSW
->
pSchema
,
pSW
->
nCols
);
}
setQueryResultFromRsp
(
&
msg
->
resInfo
,
pRetrieve
,
convertUcs4
);
setQueryResultFromRsp
(
&
msg
->
resInfo
,
pRetrieve
,
convertUcs4
);
return
&
msg
->
resInfo
;
return
&
msg
->
resInfo
;
}
}
...
...
source/client/src/clientEnv.c
浏览文件 @
ba509423
...
@@ -254,12 +254,12 @@ void taos_init_imp(void) {
...
@@ -254,12 +254,12 @@ void taos_init_imp(void) {
deltaToUtcInitOnce
();
deltaToUtcInitOnce
();
if
(
taosCreateLog
(
"taoslog"
,
10
,
configDir
,
NULL
,
NULL
,
NULL
,
1
)
!=
0
)
{
if
(
taosCreateLog
(
"taoslog"
,
10
,
configDir
,
NULL
,
NULL
,
NULL
,
NULL
,
1
)
!=
0
)
{
tscInitRes
=
-
1
;
tscInitRes
=
-
1
;
return
;
return
;
}
}
if
(
taosInitCfg
(
configDir
,
NULL
,
NULL
,
NULL
,
1
)
!=
0
)
{
if
(
taosInitCfg
(
configDir
,
NULL
,
NULL
,
NULL
,
NULL
,
1
)
!=
0
)
{
tscInitRes
=
-
1
;
tscInitRes
=
-
1
;
return
;
return
;
}
}
...
...
source/client/src/clientHb.c
浏览文件 @
ba509423
...
@@ -14,9 +14,9 @@
...
@@ -14,9 +14,9 @@
*/
*/
#include "catalog.h"
#include "catalog.h"
#include "scheduler.h"
#include "clientInt.h"
#include "clientInt.h"
#include "clientLog.h"
#include "clientLog.h"
#include "scheduler.h"
#include "trpc.h"
#include "trpc.h"
static
SClientHbMgr
clientHbMgr
=
{
0
};
static
SClientHbMgr
clientHbMgr
=
{
0
};
...
@@ -110,7 +110,8 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
...
@@ -110,7 +110,8 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
static
int32_t
hbQueryHbRspHandle
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbRsp
*
pRsp
)
{
static
int32_t
hbQueryHbRspHandle
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbRsp
*
pRsp
)
{
SHbConnInfo
*
info
=
taosHashGet
(
pAppHbMgr
->
connInfo
,
&
pRsp
->
connKey
,
sizeof
(
SClientHbKey
));
SHbConnInfo
*
info
=
taosHashGet
(
pAppHbMgr
->
connInfo
,
&
pRsp
->
connKey
,
sizeof
(
SClientHbKey
));
if
(
NULL
==
info
)
{
if
(
NULL
==
info
)
{
tscWarn
(
"fail to get connInfo, may be dropped, refId:%"
PRIx64
", type:%d"
,
pRsp
->
connKey
.
tscRid
,
pRsp
->
connKey
.
connType
);
tscWarn
(
"fail to get connInfo, may be dropped, refId:%"
PRIx64
", type:%d"
,
pRsp
->
connKey
.
tscRid
,
pRsp
->
connKey
.
connType
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -471,10 +472,10 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
...
@@ -471,10 +472,10 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
pIter
=
taosHashIterate
(
pAppHbMgr
->
activeInfo
,
pIter
);
pIter
=
taosHashIterate
(
pAppHbMgr
->
activeInfo
,
pIter
);
}
}
// if (code) {
// if (code) {
// taosArrayDestroyEx(pBatchReq->reqs, hbFreeReq);
// taosArrayDestroyEx(pBatchReq->reqs, hbFreeReq);
// taosMemoryFreeClear(pBatchReq);
// taosMemoryFreeClear(pBatchReq);
// }
// }
return
pBatchReq
;
return
pBatchReq
;
}
}
...
@@ -641,7 +642,6 @@ void appHbMgrCleanup(void) {
...
@@ -641,7 +642,6 @@ void appHbMgrCleanup(void) {
taosHashCleanup
(
pTarget
->
activeInfo
);
taosHashCleanup
(
pTarget
->
activeInfo
);
pTarget
->
activeInfo
=
NULL
;
pTarget
->
activeInfo
=
NULL
;
pIter
=
taosHashIterate
(
pTarget
->
connInfo
,
NULL
);
pIter
=
taosHashIterate
(
pTarget
->
connInfo
,
NULL
);
while
(
pIter
!=
NULL
)
{
while
(
pIter
!=
NULL
)
{
SHbConnInfo
*
info
=
pIter
;
SHbConnInfo
*
info
=
pIter
;
...
@@ -668,13 +668,13 @@ int hbMgrInit() {
...
@@ -668,13 +668,13 @@ int hbMgrInit() {
hbMgrInitHandle
();
hbMgrInitHandle
();
// init backgroud thread
// init backgroud thread
/
/hbCreateThread();
/
*hbCreateThread();*/
return
0
;
return
0
;
}
}
void
hbMgrCleanUp
()
{
void
hbMgrCleanUp
()
{
//hbStopThread();
//
hbStopThread();
// destroy all appHbMgr
// destroy all appHbMgr
int8_t
old
=
atomic_val_compare_exchange_8
(
&
clientHbMgr
.
inited
,
1
,
0
);
int8_t
old
=
atomic_val_compare_exchange_8
(
&
clientHbMgr
.
inited
,
1
,
0
);
...
...
source/client/src/clientImpl.c
浏览文件 @
ba509423
...
@@ -106,8 +106,8 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass,
...
@@ -106,8 +106,8 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass,
}
}
char
*
key
=
getClusterKey
(
user
,
secretEncrypt
,
ip
,
port
);
char
*
key
=
getClusterKey
(
user
,
secretEncrypt
,
ip
,
port
);
SAppInstInfo
**
pInst
=
NULL
;
SAppInstInfo
**
pInst
=
NULL
;
taosThreadMutexLock
(
&
appInfo
.
mutex
);
taosThreadMutexLock
(
&
appInfo
.
mutex
);
pInst
=
taosHashGet
(
appInfo
.
pInstMap
,
key
,
strlen
(
key
));
pInst
=
taosHashGet
(
appInfo
.
pInstMap
,
key
,
strlen
(
key
));
...
@@ -226,16 +226,14 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
...
@@ -226,16 +226,14 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
int32_t
getPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SQueryPlan
**
pPlan
,
SArray
*
pNodeList
)
{
int32_t
getPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SQueryPlan
**
pPlan
,
SArray
*
pNodeList
)
{
pRequest
->
type
=
pQuery
->
msgType
;
pRequest
->
type
=
pQuery
->
msgType
;
SPlanContext
cxt
=
{
SPlanContext
cxt
=
{.
queryId
=
pRequest
->
requestId
,
.
queryId
=
pRequest
->
requestId
,
.
acctId
=
pRequest
->
pTscObj
->
acctId
,
.
acctId
=
pRequest
->
pTscObj
->
acctId
,
.
mgmtEpSet
=
getEpSet_s
(
&
pRequest
->
pTscObj
->
pAppInfo
->
mgmtEp
),
.
mgmtEpSet
=
getEpSet_s
(
&
pRequest
->
pTscObj
->
pAppInfo
->
mgmtEp
),
.
pAstRoot
=
pQuery
->
pRoot
,
.
pAstRoot
=
pQuery
->
pRoot
,
.
showRewrite
=
pQuery
->
showRewrite
,
.
showRewrite
=
pQuery
->
showRewrite
,
.
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
,
.
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
,
.
pMsg
=
pRequest
->
msgBuf
,
.
pMsg
=
pRequest
->
msgBuf
,
.
msgLen
=
ERROR_MSG_BUF_DEFAULT_SIZE
.
msgLen
=
ERROR_MSG_BUF_DEFAULT_SIZE
};
};
int32_t
code
=
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
cxt
.
pCatalog
);
int32_t
code
=
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
cxt
.
pCatalog
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
qCreateQueryPlan
(
&
cxt
,
pPlan
,
pNodeList
);
code
=
qCreateQueryPlan
(
&
cxt
,
pPlan
,
pNodeList
);
...
@@ -247,6 +245,7 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
...
@@ -247,6 +245,7 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
ASSERT
(
pSchema
!=
NULL
&&
numOfCols
>
0
);
ASSERT
(
pSchema
!=
NULL
&&
numOfCols
>
0
);
pResInfo
->
numOfCols
=
numOfCols
;
pResInfo
->
numOfCols
=
numOfCols
;
// TODO handle memory leak
pResInfo
->
fields
=
taosMemoryCalloc
(
numOfCols
,
sizeof
(
TAOS_FIELD
));
pResInfo
->
fields
=
taosMemoryCalloc
(
numOfCols
,
sizeof
(
TAOS_FIELD
));
pResInfo
->
userFields
=
taosMemoryCalloc
(
numOfCols
,
sizeof
(
TAOS_FIELD
));
pResInfo
->
userFields
=
taosMemoryCalloc
(
numOfCols
,
sizeof
(
TAOS_FIELD
));
...
@@ -840,10 +839,21 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
...
@@ -840,10 +839,21 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
return
code
;
return
code
;
}
}
int32_t
*
colLength
=
(
int32_t
*
)
pResultInfo
->
pData
;
char
*
p
=
(
char
*
)
pResultInfo
->
pData
;
char
*
pStart
=
((
char
*
)
pResultInfo
->
pData
)
+
sizeof
(
int32_t
)
*
numOfCols
;
int32_t
dataLen
=
*
(
int32_t
*
)
p
;
p
+=
sizeof
(
int32_t
);
uint64_t
groupId
=
*
(
uint64_t
*
)
p
;
p
+=
sizeof
(
uint64_t
);
int32_t
*
colLength
=
(
int32_t
*
)
p
;
p
+=
sizeof
(
int32_t
)
*
numOfCols
;
char
*
pStart
=
p
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
colLength
[
i
]
=
htonl
(
colLength
[
i
]);
colLength
[
i
]
=
htonl
(
colLength
[
i
]);
ASSERT
(
colLength
[
i
]
<
dataLen
);
if
(
IS_VAR_DATA_TYPE
(
pResultInfo
->
fields
[
i
].
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pResultInfo
->
fields
[
i
].
type
))
{
pResultInfo
->
pCol
[
i
].
offset
=
(
int32_t
*
)
pStart
;
pResultInfo
->
pCol
[
i
].
offset
=
(
int32_t
*
)
pStart
;
...
...
source/client/src/tmq.c
浏览文件 @
ba509423
...
@@ -376,7 +376,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
...
@@ -376,7 +376,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
ASSERT
(
user
);
ASSERT
(
user
);
ASSERT
(
pass
);
ASSERT
(
pass
);
ASSERT
(
conf
->
db
);
/*ASSERT(conf->db);*/
ASSERT
(
conf
->
groupId
[
0
]);
ASSERT
(
conf
->
groupId
[
0
]);
pTmq
->
pTscObj
=
taos_connect_internal
(
conf
->
ip
,
user
,
pass
,
NULL
,
conf
->
db
,
conf
->
port
,
CONN_TYPE__TMQ
);
pTmq
->
pTscObj
=
taos_connect_internal
(
conf
->
ip
,
user
,
pass
,
NULL
,
conf
->
db
,
conf
->
port
,
CONN_TYPE__TMQ
);
...
@@ -1118,7 +1118,9 @@ SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) {
...
@@ -1118,7 +1118,9 @@ SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) {
pRspObj
->
resInfo
.
totalRows
=
0
;
pRspObj
->
resInfo
.
totalRows
=
0
;
pRspObj
->
resInfo
.
precision
=
TSDB_TIME_PRECISION_MILLI
;
pRspObj
->
resInfo
.
precision
=
TSDB_TIME_PRECISION_MILLI
;
if
(
!
pWrapper
->
msg
.
withSchema
)
{
setResSchemaInfo
(
&
pRspObj
->
resInfo
,
pWrapper
->
topicHandle
->
schema
.
pSchema
,
pWrapper
->
topicHandle
->
schema
.
nCols
);
setResSchemaInfo
(
&
pRspObj
->
resInfo
,
pWrapper
->
topicHandle
->
schema
.
pSchema
,
pWrapper
->
topicHandle
->
schema
.
nCols
);
}
taosFreeQitem
(
pWrapper
);
taosFreeQitem
(
pWrapper
);
return
pRspObj
;
return
pRspObj
;
...
...
source/common/src/tdatablock.c
浏览文件 @
ba509423
...
@@ -644,12 +644,12 @@ size_t blockDataGetRowSize(SSDataBlock* pBlock) {
...
@@ -644,12 +644,12 @@ size_t blockDataGetRowSize(SSDataBlock* pBlock) {
/**
/**
* @refitem blockDataToBuf for the meta size
* @refitem blockDataToBuf for the meta size
*
* @param pBlock
* @param pBlock
* @return
* @return
*/
*/
size_t
blockDataGetSerialMetaSize
(
const
SSDataBlock
*
pBlock
)
{
size_t
blockDataGetSerialMetaSize
(
const
SSDataBlock
*
pBlock
)
{
return
sizeof
(
int32_t
)
+
pBlock
->
info
.
numOfCols
*
sizeof
(
int32_t
);
// | total rows/total length | block group id | each column length |
return
sizeof
(
int32_t
)
+
sizeof
(
uint64_t
)
+
pBlock
->
info
.
numOfCols
*
sizeof
(
int32_t
);
}
}
double
blockDataGetSerialRowSize
(
const
SSDataBlock
*
pBlock
)
{
double
blockDataGetSerialRowSize
(
const
SSDataBlock
*
pBlock
)
{
...
@@ -1219,7 +1219,6 @@ void colDataDestroy(SColumnInfoData* pColData) {
...
@@ -1219,7 +1219,6 @@ void colDataDestroy(SColumnInfoData* pColData) {
taosMemoryFree
(
pColData
->
pData
);
taosMemoryFree
(
pColData
->
pData
);
}
}
static
void
doShiftBitmap
(
char
*
nullBitmap
,
size_t
n
,
size_t
total
)
{
static
void
doShiftBitmap
(
char
*
nullBitmap
,
size_t
n
,
size_t
total
)
{
int32_t
len
=
BitmapLen
(
total
);
int32_t
len
=
BitmapLen
(
total
);
...
...
source/common/src/tglobal.c
浏览文件 @
ba509423
...
@@ -220,7 +220,7 @@ struct SConfig *taosGetCfg() {
...
@@ -220,7 +220,7 @@ struct SConfig *taosGetCfg() {
return
tsCfg
;
return
tsCfg
;
}
}
static
int32_t
taosLoadCfg
(
SConfig
*
pCfg
,
const
char
*
inputCfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
)
{
static
int32_t
taosLoadCfg
(
SConfig
*
pCfg
,
const
char
*
*
envCmd
,
const
char
*
inputCfgDir
,
const
char
*
envFile
,
char
*
apolloUrl
)
{
char
cfgDir
[
PATH_MAX
]
=
{
0
};
char
cfgDir
[
PATH_MAX
]
=
{
0
};
char
cfgFile
[
PATH_MAX
+
100
]
=
{
0
};
char
cfgFile
[
PATH_MAX
+
100
]
=
{
0
};
...
@@ -231,6 +231,8 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char *inputCfgDir, const char *e
...
@@ -231,6 +231,8 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char *inputCfgDir, const char *e
tstrncpy
(
cfgFile
,
cfgDir
,
sizeof
(
cfgDir
));
tstrncpy
(
cfgFile
,
cfgDir
,
sizeof
(
cfgDir
));
}
}
if
(
apolloUrl
==
NULL
||
apolloUrl
[
0
]
==
'\0'
)
cfgGetApollUrl
(
envCmd
,
envFile
,
apolloUrl
);
if
(
cfgLoad
(
pCfg
,
CFG_STYPE_APOLLO_URL
,
apolloUrl
)
!=
0
)
{
if
(
cfgLoad
(
pCfg
,
CFG_STYPE_APOLLO_URL
,
apolloUrl
)
!=
0
)
{
uError
(
"failed to load from apollo url:%s since %s"
,
apolloUrl
,
terrstr
());
uError
(
"failed to load from apollo url:%s since %s"
,
apolloUrl
,
terrstr
());
return
-
1
;
return
-
1
;
...
@@ -251,6 +253,11 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char *inputCfgDir, const char *e
...
@@ -251,6 +253,11 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char *inputCfgDir, const char *e
return
-
1
;
return
-
1
;
}
}
if
(
cfgLoad
(
pCfg
,
CFG_STYPE_ENV_CMD
,
envCmd
)
!=
0
)
{
uError
(
"failed to load from cmd env variables since %s"
,
terrstr
());
return
-
1
;
}
return
0
;
return
0
;
}
}
...
@@ -325,8 +332,8 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
...
@@ -325,8 +332,8 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
if
(
cfgAddFloat
(
pCfg
,
"numOfCores"
,
tsNumOfCores
,
0
,
100000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"numOfCores"
,
tsNumOfCores
,
0
,
100000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"openMax"
,
tsOpenMax
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"openMax"
,
tsOpenMax
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"streamMax"
,
tsStreamMax
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"streamMax"
,
tsStreamMax
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"pageSize
(KB)
"
,
tsPageSizeKB
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"pageSize
KB
"
,
tsPageSizeKB
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"totalMemory
(KB)
"
,
tsTotalMemoryKB
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"totalMemory
KB
"
,
tsTotalMemoryKB
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os sysname"
,
info
.
sysname
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os sysname"
,
info
.
sysname
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os nodename"
,
info
.
nodename
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os nodename"
,
info
.
nodename
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os release"
,
info
.
release
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os release"
,
info
.
release
,
1
)
!=
0
)
return
-
1
;
...
@@ -572,8 +579,8 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
...
@@ -572,8 +579,8 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
return
0
;
return
0
;
}
}
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
*
envFile
,
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
*
*
envCmd
,
const
char
*
envFile
,
c
onst
c
har
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
osDefaultInit
();
osDefaultInit
();
SConfig
*
pCfg
=
cfgInit
();
SConfig
*
pCfg
=
cfgInit
();
...
@@ -588,7 +595,7 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
...
@@ -588,7 +595,7 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
if
(
taosAddServerLogCfg
(
pCfg
)
!=
0
)
return
-
1
;
if
(
taosAddServerLogCfg
(
pCfg
)
!=
0
)
return
-
1
;
}
}
if
(
taosLoadCfg
(
pCfg
,
cfgDir
,
envFile
,
apolloUrl
)
!=
0
)
{
if
(
taosLoadCfg
(
pCfg
,
envCmd
,
cfgDir
,
envFile
,
apolloUrl
)
!=
0
)
{
uError
(
"failed to load cfg since %s"
,
terrstr
());
uError
(
"failed to load cfg since %s"
,
terrstr
());
cfgCleanup
(
pCfg
);
cfgCleanup
(
pCfg
);
return
-
1
;
return
-
1
;
...
@@ -625,7 +632,7 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
...
@@ -625,7 +632,7 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
return
0
;
return
0
;
}
}
int32_t
taosInitCfg
(
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
int32_t
taosInitCfg
(
const
char
*
cfgDir
,
const
char
*
*
envCmd
,
const
char
*
envFile
,
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
if
(
tsCfg
!=
NULL
)
return
0
;
if
(
tsCfg
!=
NULL
)
return
0
;
tsCfg
=
cfgInit
();
tsCfg
=
cfgInit
();
...
@@ -640,7 +647,7 @@ int32_t taosInitCfg(const char *cfgDir, const char *envFile, const char *apolloU
...
@@ -640,7 +647,7 @@ int32_t taosInitCfg(const char *cfgDir, const char *envFile, const char *apolloU
}
}
taosAddSystemCfg
(
tsCfg
);
taosAddSystemCfg
(
tsCfg
);
if
(
taosLoadCfg
(
tsCfg
,
cfgDir
,
envFile
,
apolloUrl
)
!=
0
)
{
if
(
taosLoadCfg
(
tsCfg
,
envCmd
,
cfgDir
,
envFile
,
apolloUrl
)
!=
0
)
{
uError
(
"failed to load cfg since %s"
,
terrstr
());
uError
(
"failed to load cfg since %s"
,
terrstr
());
cfgCleanup
(
tsCfg
);
cfgCleanup
(
tsCfg
);
tsCfg
=
NULL
;
tsCfg
=
NULL
;
...
...
source/common/src/tmsg.c
浏览文件 @
ba509423
...
@@ -93,7 +93,87 @@ STSRow *tGetSubmitBlkNext(SSubmitBlkIter *pIter) {
...
@@ -93,7 +93,87 @@ STSRow *tGetSubmitBlkNext(SSubmitBlkIter *pIter) {
return
row
;
return
row
;
}
}
}
}
#if 0
// TODO: KEEP one suite of iterator API finally.
// 1) use tInitSubmitMsgIterEx firstly as not decrease the merge conflicts
// 2) replace tInitSubmitMsgIterEx with tInitSubmitMsgIter later
// 3) finally, rename tInitSubmitMsgIterEx to tInitSubmitMsgIter
int32_t tInitSubmitMsgIterEx(const SSubmitReq *pMsg, SSubmitMsgIter *pIter) {
if (pMsg == NULL) {
terrno = TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP;
return -1;
}
pIter->totalLen = htonl(pMsg->length);
ASSERT(pIter->totalLen > 0);
pIter->len = 0;
pIter->pMsg = pMsg;
if (pIter->totalLen <= sizeof(SSubmitReq)) {
terrno = TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP;
return -1;
}
return 0;
}
int32_t tGetSubmitMsgNextEx(SSubmitMsgIter *pIter, SSubmitBlk **pPBlock) {
ASSERT(pIter->len >= 0);
if (pIter->len == 0) {
pIter->len += sizeof(SSubmitReq);
} else {
if (pIter->len >= pIter->totalLen) {
ASSERT(0);
}
SSubmitBlk *pSubmitBlk = (SSubmitBlk *)POINTER_SHIFT(pIter->pMsg, pIter->len);
pIter->len += (sizeof(SSubmitBlk) + pIter->dataLen + pIter->schemaLen);
ASSERT(pIter->len > 0);
}
if (pIter->len > pIter->totalLen) {
terrno = TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP;
*pPBlock = NULL;
return -1;
}
if (pIter->len == pIter->totalLen) {
*pPBlock = NULL;
} else {
*pPBlock = (SSubmitBlk *)POINTER_SHIFT(pIter->pMsg, pIter->len);
pIter->uid = htobe64((*pPBlock)->uid);
pIter->suid = htobe64((*pPBlock)->suid);
pIter->sversion = htonl((*pPBlock)->sversion);
pIter->dataLen = htonl((*pPBlock)->dataLen);
pIter->schemaLen = htonl((*pPBlock)->schemaLen);
pIter->numOfRows = htons((*pPBlock)->numOfRows);
}
return 0;
}
int32_t tInitSubmitBlkIterEx(SSubmitMsgIter *pMsgIter, SSubmitBlk *pBlock, SSubmitBlkIter *pIter) {
if (pMsgIter->dataLen <= 0) return -1;
pIter->totalLen = pMsgIter->dataLen;
pIter->len = 0;
pIter->row = (STSRow *)(pBlock->data + pMsgIter->schemaLen);
return 0;
}
STSRow *tGetSubmitBlkNextEx(SSubmitBlkIter *pIter) {
STSRow *row = pIter->row;
if (pIter->len >= pIter->totalLen) {
return NULL;
} else {
pIter->len += TD_ROW_LEN(row);
if (pIter->len < pIter->totalLen) {
pIter->row = POINTER_SHIFT(row, TD_ROW_LEN(row));
}
return row;
}
}
#endif
int32_t
tEncodeSEpSet
(
SCoder
*
pEncoder
,
const
SEpSet
*
pEp
)
{
int32_t
tEncodeSEpSet
(
SCoder
*
pEncoder
,
const
SEpSet
*
pEp
)
{
if
(
tEncodeI8
(
pEncoder
,
pEp
->
inUse
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pEp
->
inUse
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pEp
->
numOfEps
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pEp
->
numOfEps
)
<
0
)
return
-
1
;
...
...
source/dnode/mgmt/exe/dmMain.c
浏览文件 @
ba509423
...
@@ -24,6 +24,7 @@ static struct {
...
@@ -24,6 +24,7 @@ static struct {
bool
printVersion
;
bool
printVersion
;
char
envFile
[
PATH_MAX
];
char
envFile
[
PATH_MAX
];
char
apolloUrl
[
PATH_MAX
];
char
apolloUrl
[
PATH_MAX
];
const
char
**
envCmd
;
SArray
*
pArgs
;
// SConfigPair
SArray
*
pArgs
;
// SConfigPair
SDnode
*
pDnode
;
SDnode
*
pDnode
;
EDndNodeType
ntype
;
EDndNodeType
ntype
;
...
@@ -56,6 +57,9 @@ static void dmSetSignalHandle() {
...
@@ -56,6 +57,9 @@ static void dmSetSignalHandle() {
}
}
static
int32_t
dmParseArgs
(
int32_t
argc
,
char
const
*
argv
[])
{
static
int32_t
dmParseArgs
(
int32_t
argc
,
char
const
*
argv
[])
{
int32_t
cmdEnvIndex
=
0
;
global
.
envCmd
=
taosMemoryMalloc
(
argc
-
1
);
memset
(
global
.
envCmd
,
0
,
argc
-
1
);
for
(
int32_t
i
=
1
;
i
<
argc
;
++
i
)
{
for
(
int32_t
i
=
1
;
i
<
argc
;
++
i
)
{
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
if
(
i
<
argc
-
1
)
{
...
@@ -70,7 +74,7 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
...
@@ -70,7 +74,7 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
}
}
}
else
if
(
strcmp
(
argv
[
i
],
"-a"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-a"
)
==
0
)
{
tstrncpy
(
global
.
apolloUrl
,
argv
[
++
i
],
PATH_MAX
);
tstrncpy
(
global
.
apolloUrl
,
argv
[
++
i
],
PATH_MAX
);
}
else
if
(
strcmp
(
argv
[
i
],
"-
e
"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-
E
"
)
==
0
)
{
tstrncpy
(
global
.
envFile
,
argv
[
++
i
],
PATH_MAX
);
tstrncpy
(
global
.
envFile
,
argv
[
++
i
],
PATH_MAX
);
}
else
if
(
strcmp
(
argv
[
i
],
"-n"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-n"
)
==
0
)
{
global
.
ntype
=
atoi
(
argv
[
++
i
]);
global
.
ntype
=
atoi
(
argv
[
++
i
]);
...
@@ -84,6 +88,9 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
...
@@ -84,6 +88,9 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
global
.
dumpConfig
=
true
;
global
.
dumpConfig
=
true
;
}
else
if
(
strcmp
(
argv
[
i
],
"-V"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-V"
)
==
0
)
{
global
.
printVersion
=
true
;
global
.
printVersion
=
true
;
}
else
if
(
strcmp
(
argv
[
i
],
"-e"
)
==
0
)
{
global
.
envCmd
[
cmdEnvIndex
]
=
argv
[
++
i
];
cmdEnvIndex
++
;
}
else
{
}
else
{
}
}
}
}
...
@@ -129,7 +136,7 @@ static SDnodeOpt dmGetOpt() {
...
@@ -129,7 +136,7 @@ static SDnodeOpt dmGetOpt() {
static
int32_t
dmInitLog
()
{
static
int32_t
dmInitLog
()
{
char
logName
[
12
]
=
{
0
};
char
logName
[
12
]
=
{
0
};
snprintf
(
logName
,
sizeof
(
logName
),
"%slog"
,
dmLogName
(
global
.
ntype
));
snprintf
(
logName
,
sizeof
(
logName
),
"%slog"
,
dmLogName
(
global
.
ntype
));
return
taosCreateLog
(
logName
,
1
,
configDir
,
global
.
envFile
,
global
.
apolloUrl
,
global
.
pArgs
,
0
);
return
taosCreateLog
(
logName
,
1
,
configDir
,
global
.
env
Cmd
,
global
.
env
File
,
global
.
apolloUrl
,
global
.
pArgs
,
0
);
}
}
static
void
dmSetProcInfo
(
int32_t
argc
,
char
**
argv
)
{
static
void
dmSetProcInfo
(
int32_t
argc
,
char
**
argv
)
{
...
@@ -168,6 +175,10 @@ static int32_t dmRunDnode() {
...
@@ -168,6 +175,10 @@ static int32_t dmRunDnode() {
return
code
;
return
code
;
}
}
static
void
taosCleanupArgs
()
{
if
(
global
.
envCmd
!=
NULL
)
taosMemoryFree
(
global
.
envCmd
);
}
int
main
(
int
argc
,
char
const
*
argv
[])
{
int
main
(
int
argc
,
char
const
*
argv
[])
{
if
(
!
taosCheckSystemIsSmallEnd
())
{
if
(
!
taosCheckSystemIsSmallEnd
())
{
printf
(
"failed to start since on non-small-end machines
\n
"
);
printf
(
"failed to start since on non-small-end machines
\n
"
);
...
@@ -176,26 +187,31 @@ int main(int argc, char const *argv[]) {
...
@@ -176,26 +187,31 @@ int main(int argc, char const *argv[]) {
if
(
dmParseArgs
(
argc
,
argv
)
!=
0
)
{
if
(
dmParseArgs
(
argc
,
argv
)
!=
0
)
{
printf
(
"failed to start since parse args error
\n
"
);
printf
(
"failed to start since parse args error
\n
"
);
taosCleanupArgs
();
return
-
1
;
return
-
1
;
}
}
if
(
global
.
generateGrant
)
{
if
(
global
.
generateGrant
)
{
dmGenerateGrant
();
dmGenerateGrant
();
taosCleanupArgs
();
return
0
;
return
0
;
}
}
if
(
global
.
printVersion
)
{
if
(
global
.
printVersion
)
{
dmPrintVersion
();
dmPrintVersion
();
taosCleanupArgs
();
return
0
;
return
0
;
}
}
if
(
dmInitLog
()
!=
0
)
{
if
(
dmInitLog
()
!=
0
)
{
dError
(
"failed to start since init log error"
);
printf
(
"failed to start since init log error"
);
taosCleanupArgs
();
return
-
1
;
return
-
1
;
}
}
if
(
taosInitCfg
(
configDir
,
global
.
envFile
,
global
.
apolloUrl
,
global
.
pArgs
,
0
)
!=
0
)
{
if
(
taosInitCfg
(
configDir
,
global
.
env
Cmd
,
global
.
env
File
,
global
.
apolloUrl
,
global
.
pArgs
,
0
)
!=
0
)
{
dError
(
"failed to start since read config error"
);
dError
(
"failed to start since read config error"
);
taosCleanupArgs
();
return
-
1
;
return
-
1
;
}
}
...
@@ -203,9 +219,11 @@ int main(int argc, char const *argv[]) {
...
@@ -203,9 +219,11 @@ int main(int argc, char const *argv[]) {
dmDumpCfg
();
dmDumpCfg
();
taosCleanupCfg
();
taosCleanupCfg
();
taosCloseLog
();
taosCloseLog
();
taosCleanupArgs
();
return
0
;
return
0
;
}
}
dmSetProcInfo
(
argc
,
(
char
**
)
argv
);
dmSetProcInfo
(
argc
,
(
char
**
)
argv
);
taosCleanupArgs
();
return
dmRunDnode
();
return
dmRunDnode
();
}
}
source/dnode/mgmt/interface/src/dmFile.c
浏览文件 @
ba509423
...
@@ -124,7 +124,7 @@ TdFilePtr dmCheckRunning(const char *dataDir) {
...
@@ -124,7 +124,7 @@ TdFilePtr dmCheckRunning(const char *dataDir) {
TdFilePtr
pFile
=
taosOpenFile
(
filepath
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
TdFilePtr
pFile
=
taosOpenFile
(
filepath
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pFile
==
NULL
)
{
if
(
pFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
dError
(
"failed to
lock
file:%s since %s"
,
filepath
,
terrstr
());
dError
(
"failed to
open
file:%s since %s"
,
filepath
,
terrstr
());
return
NULL
;
return
NULL
;
}
}
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
ba509423
...
@@ -202,6 +202,17 @@ int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
...
@@ -202,6 +202,17 @@ int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
return
code
;
return
code
;
}
}
code
=
vnodeStart
(
pImpl
);
if
(
code
!=
0
)
{
tFreeSCreateVnodeReq
(
&
createReq
);
dError
(
"vgId:%d, failed to start sync since %s"
,
createReq
.
vgId
,
terrstr
());
vnodeClose
(
pImpl
);
vnodeDestroy
(
path
,
pMgmt
->
pTfs
);
terrno
=
code
;
return
code
;
}
code
=
vmWriteVnodesToFile
(
pMgmt
);
code
=
vmWriteVnodesToFile
(
pMgmt
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
tFreeSCreateVnodeReq
(
&
createReq
);
tFreeSCreateVnodeReq
(
&
createReq
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
ba509423
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "vmInt.h"
#include "vmInt.h"
#include "libs/function/function.h"
SVnodeObj
*
vmAcquireVnode
(
SVnodesMgmt
*
pMgmt
,
int32_t
vgId
)
{
SVnodeObj
*
vmAcquireVnode
(
SVnodesMgmt
*
pMgmt
,
int32_t
vgId
)
{
SVnodeObj
*
pVnode
=
NULL
;
SVnodeObj
*
pVnode
=
NULL
;
...
@@ -73,12 +74,6 @@ int32_t vmOpenVnode(SVnodesMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
...
@@ -73,12 +74,6 @@ int32_t vmOpenVnode(SVnodesMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
return
-
1
;
return
-
1
;
}
}
// sync integration
vnodeSyncSetQ
(
pImpl
,
NULL
);
vnodeSyncSetRpc
(
pImpl
,
NULL
);
int32_t
ret
=
vnodeSyncStart
(
pImpl
);
assert
(
ret
==
0
);
taosWLockLatch
(
&
pMgmt
->
latch
);
taosWLockLatch
(
&
pMgmt
->
latch
);
int32_t
code
=
taosHashPut
(
pMgmt
->
hash
,
&
pVnode
->
vgId
,
sizeof
(
int32_t
),
&
pVnode
,
sizeof
(
SVnodeObj
*
));
int32_t
code
=
taosHashPut
(
pMgmt
->
hash
,
&
pVnode
->
vgId
,
sizeof
(
int32_t
),
&
pVnode
,
sizeof
(
SVnodeObj
*
));
taosWUnLockLatch
(
&
pMgmt
->
latch
);
taosWUnLockLatch
(
&
pMgmt
->
latch
);
...
@@ -152,6 +147,7 @@ static void *vmOpenVnodeFunc(void *param) {
...
@@ -152,6 +147,7 @@ static void *vmOpenVnodeFunc(void *param) {
pThread
->
failed
++
;
pThread
->
failed
++
;
}
else
{
}
else
{
vmOpenVnode
(
pMgmt
,
pCfg
,
pImpl
);
vmOpenVnode
(
pMgmt
,
pCfg
,
pImpl
);
//vnodeStart(pImpl);
dDebug
(
"vgId:%d, is opened by thread:%d"
,
pCfg
->
vgId
,
pThread
->
threadIndex
);
dDebug
(
"vgId:%d, is opened by thread:%d"
,
pCfg
->
vgId
,
pThread
->
threadIndex
);
pThread
->
opened
++
;
pThread
->
opened
++
;
}
}
...
@@ -275,7 +271,7 @@ static void vmCleanup(SMgmtWrapper *pWrapper) {
...
@@ -275,7 +271,7 @@ static void vmCleanup(SMgmtWrapper *pWrapper) {
pWrapper
->
pMgmt
=
NULL
;
pWrapper
->
pMgmt
=
NULL
;
// syncCleanUp();
// syncCleanUp();
udfcClose
();
dInfo
(
"vnode-mgmt is cleaned up"
);
dInfo
(
"vnode-mgmt is cleaned up"
);
}
}
...
@@ -339,6 +335,10 @@ static int32_t vmInit(SMgmtWrapper *pWrapper) {
...
@@ -339,6 +335,10 @@ static int32_t vmInit(SMgmtWrapper *pWrapper) {
}
}
dmReportStartup
(
pDnode
,
"vnode-vnodes"
,
"initialized"
);
dmReportStartup
(
pDnode
,
"vnode-vnodes"
,
"initialized"
);
if
(
udfcOpen
()
!=
0
)
{
dError
(
"failed to open udfc in dnode"
);
}
code
=
0
;
code
=
0
;
_OVER:
_OVER:
...
@@ -359,10 +359,52 @@ static int32_t vmRequire(SMgmtWrapper *pWrapper, bool *required) {
...
@@ -359,10 +359,52 @@ static int32_t vmRequire(SMgmtWrapper *pWrapper, bool *required) {
return
0
;
return
0
;
}
}
static
int32_t
vmStart
(
SMgmtWrapper
*
pWrapper
)
{
dDebug
(
"vnode-mgmt start to run"
);
SVnodesMgmt
*
pMgmt
=
pWrapper
->
pMgmt
;
taosRLockLatch
(
&
pMgmt
->
latch
);
void
*
pIter
=
taosHashIterate
(
pMgmt
->
hash
,
NULL
);
while
(
pIter
)
{
SVnodeObj
**
ppVnode
=
pIter
;
if
(
ppVnode
==
NULL
||
*
ppVnode
==
NULL
)
continue
;
SVnodeObj
*
pVnode
=
*
ppVnode
;
vnodeStart
(
pVnode
->
pImpl
);
pIter
=
taosHashIterate
(
pMgmt
->
hash
,
pIter
);
}
taosRUnLockLatch
(
&
pMgmt
->
latch
);
return
0
;
}
static
void
vmStop
(
SMgmtWrapper
*
pWrapper
)
{
#if 0
dDebug("vnode-mgmt start to stop");
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
taosRLockLatch(&pMgmt->latch);
void *pIter = taosHashIterate(pMgmt->hash, NULL);
while (pIter) {
SVnodeObj **ppVnode = pIter;
if (ppVnode == NULL || *ppVnode == NULL) continue;
SVnodeObj *pVnode = *ppVnode;
vnodeStop(pVnode->pImpl);
pIter = taosHashIterate(pMgmt->hash, pIter);
}
taosRUnLockLatch(&pMgmt->latch);
#endif
}
void
vmSetMgmtFp
(
SMgmtWrapper
*
pWrapper
)
{
void
vmSetMgmtFp
(
SMgmtWrapper
*
pWrapper
)
{
SMgmtFp
mgmtFp
=
{
0
};
SMgmtFp
mgmtFp
=
{
0
};
mgmtFp
.
openFp
=
vmInit
;
mgmtFp
.
openFp
=
vmInit
;
mgmtFp
.
closeFp
=
vmCleanup
;
mgmtFp
.
closeFp
=
vmCleanup
;
mgmtFp
.
startFp
=
vmStart
;
mgmtFp
.
stopFp
=
vmStop
;
mgmtFp
.
requiredFp
=
vmRequire
;
mgmtFp
.
requiredFp
=
vmRequire
;
vmInitMsgHandle
(
pWrapper
);
vmInitMsgHandle
(
pWrapper
);
...
...
source/dnode/mnode/impl/src/mndInfoSchema.c
浏览文件 @
ba509423
...
@@ -325,7 +325,7 @@ static int32_t mndInsInitMeta(SHashObj *hash) {
...
@@ -325,7 +325,7 @@ static int32_t mndInsInitMeta(SHashObj *hash) {
return
-
1
;
return
-
1
;
}
}
if
(
taosHashPut
(
hash
,
meta
.
tbName
,
strlen
(
meta
.
tbName
)
+
1
,
&
meta
,
sizeof
(
meta
)))
{
if
(
taosHashPut
(
hash
,
meta
.
tbName
,
strlen
(
meta
.
tbName
),
&
meta
,
sizeof
(
meta
)))
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
...
@@ -340,10 +340,10 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *
...
@@ -340,10 +340,10 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *
return
-
1
;
return
-
1
;
}
}
STableMetaRsp
*
pMeta
=
taosHashGet
(
pMnode
->
infosMeta
,
tbName
,
strlen
(
tbName
)
+
1
);
STableMetaRsp
*
pMeta
=
taosHashGet
(
pMnode
->
infosMeta
,
tbName
,
strlen
(
tbName
));
if
(
NULL
==
pMeta
)
{
if
(
NULL
==
pMeta
)
{
mError
(
"invalid information schema table name:%s"
,
tbName
);
mError
(
"invalid information schema table name:%s"
,
tbName
);
terrno
=
TSDB_CODE_MND_INVALID_
INFOS_TBL
;
terrno
=
TSDB_CODE_MND_INVALID_
SYS_TABLENAME
;
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/mnode/impl/src/mndPerfSchema.c
浏览文件 @
ba509423
...
@@ -128,7 +128,7 @@ int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char
...
@@ -128,7 +128,7 @@ int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char
STableMetaRsp
*
meta
=
(
STableMetaRsp
*
)
taosHashGet
(
pMnode
->
perfsMeta
,
tbName
,
strlen
(
tbName
));
STableMetaRsp
*
meta
=
(
STableMetaRsp
*
)
taosHashGet
(
pMnode
->
perfsMeta
,
tbName
,
strlen
(
tbName
));
if
(
NULL
==
meta
)
{
if
(
NULL
==
meta
)
{
mError
(
"invalid performance schema table name:%s"
,
tbName
);
mError
(
"invalid performance schema table name:%s"
,
tbName
);
terrno
=
TSDB_CODE_MND_INVALID_
INFOS_TBL
;
terrno
=
TSDB_CODE_MND_INVALID_
SYS_TABLENAME
;
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
ba509423
...
@@ -476,7 +476,10 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -476,7 +476,10 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
int32_t
mndSchedInitSubEp
(
SMnode
*
pMnode
,
const
SMqTopicObj
*
pTopic
,
SMqSubscribeObj
*
pSub
)
{
int32_t
mndSchedInitSubEp
(
SMnode
*
pMnode
,
const
SMqTopicObj
*
pTopic
,
SMqSubscribeObj
*
pSub
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SVgObj
*
pVgroup
=
NULL
;
SVgObj
*
pVgroup
=
NULL
;
SQueryPlan
*
pPlan
=
qStringToQueryPlan
(
pTopic
->
physicalPlan
);
SQueryPlan
*
pPlan
=
NULL
;
SSubplan
*
plan
=
NULL
;
if
(
pTopic
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
pPlan
=
qStringToQueryPlan
(
pTopic
->
physicalPlan
);
if
(
pPlan
==
NULL
)
{
if
(
pPlan
==
NULL
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
-
1
;
return
-
1
;
...
@@ -501,7 +504,8 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
...
@@ -501,7 +504,8 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
terrno
=
TSDB_CODE_MND_UNSUPPORTED_TOPIC
;
terrno
=
TSDB_CODE_MND_UNSUPPORTED_TOPIC
;
return
-
1
;
return
-
1
;
}
}
SSubplan
*
plan
=
nodesListGetNode
(
inner
->
pNodeList
,
0
);
plan
=
nodesListGetNode
(
inner
->
pNodeList
,
0
);
}
int64_t
unexistKey
=
-
1
;
int64_t
unexistKey
=
-
1
;
SMqConsumerEpInSub
*
pEpInSub
=
taosHashGet
(
pSub
->
consumerHash
,
&
unexistKey
,
sizeof
(
int64_t
));
SMqConsumerEpInSub
*
pEpInSub
=
taosHashGet
(
pSub
->
consumerHash
,
&
unexistKey
,
sizeof
(
int64_t
));
...
@@ -519,38 +523,35 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
...
@@ -519,38 +523,35 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
}
}
pSub
->
vgNum
++
;
pSub
->
vgNum
++
;
plan
->
execNode
.
nodeId
=
pVgroup
->
vgId
;
plan
->
execNode
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
SMqVgEp
*
pVgEp
=
taosMemoryMalloc
(
sizeof
(
SMqVgEp
));
SMqVgEp
*
pVgEp
=
taosMemoryMalloc
(
sizeof
(
SMqVgEp
));
pVgEp
->
epSet
=
plan
->
execNode
.
epSet
;
pVgEp
->
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
pVgEp
->
vgId
=
plan
->
execNode
.
nodeId
;
pVgEp
->
vgId
=
pVgroup
->
vgId
;
taosArrayPush
(
pEpInSub
->
vgs
,
&
pVgEp
);
#if 0
SMqConsumerEp consumerEp = {0};
consumerEp.status = 0;
consumerEp.consumerId = -1;
consumerEp.epSet = plan->execNode.epSet;
consumerEp.vgId = plan->execNode.nodeId;
#endif
mDebug
(
"init subscribption %s, assign vg: %d"
,
pSub
->
key
,
pVgEp
->
vgId
);
mDebug
(
"init subscribption %s, assign vg: %d"
,
pSub
->
key
,
pVgEp
->
vgId
);
if
(
pTopic
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
int32_t
msgLen
;
int32_t
msgLen
;
plan
->
execNode
.
epSet
=
pVgEp
->
epSet
;
plan
->
execNode
.
nodeId
=
pVgEp
->
vgId
;
if
(
qSubPlanToString
(
plan
,
&
pVgEp
->
qmsg
,
&
msgLen
)
<
0
)
{
if
(
qSubPlanToString
(
plan
,
&
pVgEp
->
qmsg
,
&
msgLen
)
<
0
)
{
sdbRelease
(
pSdb
,
pVgroup
);
sdbRelease
(
pSdb
,
pVgroup
);
qDestroyQueryPlan
(
pPlan
);
qDestroyQueryPlan
(
pPlan
);
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
-
1
;
return
-
1
;
}
}
taosArrayPush
(
pEpInSub
->
vgs
,
&
pVgEp
);
}
else
{
pVgEp
->
qmsg
=
strdup
(
""
);
}
ASSERT
(
taosHashGetSize
(
pSub
->
consumerHash
)
==
1
);
ASSERT
(
taosHashGetSize
(
pSub
->
consumerHash
)
==
1
);
/*taosArrayPush(pSub->unassignedVg, &consumerEp);*/
/*taosArrayPush(pSub->unassignedVg, &consumerEp);*/
}
}
ASSERT
(
pEpInSub
->
vgs
->
size
>
0
);
pEpInSub
=
taosHashGet
(
pSub
->
consumerHash
,
&
unexistKey
,
sizeof
(
int64_t
));
pEpInSub
=
taosHashGet
(
pSub
->
consumerHash
,
&
unexistKey
,
sizeof
(
int64_t
));
ASSERT
(
pEpInSub
->
vgs
->
size
>
0
);
ASSERT
(
pEpInSub
->
vgs
->
size
>
0
);
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
ba509423
...
@@ -100,6 +100,8 @@ static int32_t convertToRetrieveType(char* name, int32_t len) {
...
@@ -100,6 +100,8 @@ static int32_t convertToRetrieveType(char* name, int32_t len) {
type
=
TSDB_MGMT_TABLE_QUERIES
;
type
=
TSDB_MGMT_TABLE_QUERIES
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_VNODES
,
len
)
==
0
)
{
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_VNODES
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_VNODES
;
type
=
TSDB_MGMT_TABLE_VNODES
;
}
else
if
(
strncasecmp
(
name
,
TSDB_PERFS_TABLE_TOPICS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_TOPICS
;
}
else
{
}
else
{
// ASSERT(0);
// ASSERT(0);
}
}
...
@@ -187,12 +189,15 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
...
@@ -187,12 +189,15 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
}
}
if
(
retrieveReq
.
showId
==
0
)
{
if
(
retrieveReq
.
showId
==
0
)
{
STableMetaRsp
*
pMeta
=
(
STableMetaRsp
*
)
taosHashGet
(
pMnode
->
infosMeta
,
retrieveReq
.
tb
,
strlen
(
retrieveReq
.
tb
)
+
1
);
STableMetaRsp
*
pMeta
=
(
STableMetaRsp
*
)
taosHashGet
(
pMnode
->
infosMeta
,
retrieveReq
.
tb
,
strlen
(
retrieveReq
.
tb
));
if
(
pMeta
==
NULL
)
{
if
(
pMeta
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_INFOS_TBL
;
pMeta
=
(
STableMetaRsp
*
)
taosHashGet
(
pMnode
->
perfsMeta
,
retrieveReq
.
tb
,
strlen
(
retrieveReq
.
tb
));
if
(
pMeta
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_SYS_TABLENAME
;
mError
(
"failed to process show-retrieve req:%p since %s"
,
pShow
,
terrstr
());
mError
(
"failed to process show-retrieve req:%p since %s"
,
pShow
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
}
pShow
=
mndCreateShowObj
(
pMnode
,
&
retrieveReq
);
pShow
=
mndCreateShowObj
(
pMnode
,
&
retrieveReq
);
if
(
pShow
==
NULL
)
{
if
(
pShow
==
NULL
)
{
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
ba509423
...
@@ -439,7 +439,6 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
...
@@ -439,7 +439,6 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
}
}
}
}
if
(
pStb
->
ast2Len
>
0
)
{
if
(
pStb
->
ast2Len
>
0
)
{
int32_t
qmsgLen2
=
0
;
if
(
mndConvertRSmaTask
(
pStb
->
pAst2
,
0
,
0
,
&
pRSmaParam
->
qmsg2
,
&
pRSmaParam
->
qmsg2Len
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
mndConvertRSmaTask
(
pStb
->
pAst2
,
0
,
0
,
&
pRSmaParam
->
qmsg2
,
&
pRSmaParam
->
qmsg2Len
)
!=
TSDB_CODE_SUCCESS
)
{
taosMemoryFreeClear
(
pRSmaParam
->
qmsg1
);
taosMemoryFreeClear
(
pRSmaParam
->
qmsg1
);
taosMemoryFreeClear
(
req
.
stbCfg
.
pRSmaParam
);
taosMemoryFreeClear
(
req
.
stbCfg
.
pRSmaParam
);
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
ba509423
...
@@ -282,10 +282,10 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
...
@@ -282,10 +282,10 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
topicObj
.
version
=
1
;
topicObj
.
version
=
1
;
topicObj
.
sql
=
strdup
(
pCreate
->
sql
);
topicObj
.
sql
=
strdup
(
pCreate
->
sql
);
topicObj
.
sqlLen
=
strlen
(
pCreate
->
sql
)
+
1
;
topicObj
.
sqlLen
=
strlen
(
pCreate
->
sql
)
+
1
;
topicObj
.
ast
=
strdup
(
pCreate
->
ast
);
topicObj
.
astLen
=
strlen
(
pCreate
->
ast
)
+
1
;
if
(
pCreate
->
ast
&&
pCreate
->
ast
[
0
])
{
if
(
pCreate
->
ast
&&
pCreate
->
ast
[
0
])
{
topicObj
.
ast
=
strdup
(
pCreate
->
ast
);
topicObj
.
astLen
=
strlen
(
pCreate
->
ast
)
+
1
;
topicObj
.
subType
=
TOPIC_SUB_TYPE__TABLE
;
topicObj
.
subType
=
TOPIC_SUB_TYPE__TABLE
;
topicObj
.
withTbName
=
0
;
topicObj
.
withTbName
=
0
;
topicObj
.
withSchema
=
0
;
topicObj
.
withSchema
=
0
;
...
@@ -314,6 +314,9 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
...
@@ -314,6 +314,9 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
return
-
1
;
return
-
1
;
}
}
}
else
{
}
else
{
topicObj
.
ast
=
strdup
(
""
);
topicObj
.
astLen
=
1
;
topicObj
.
physicalPlan
=
strdup
(
""
);
topicObj
.
subType
=
TOPIC_SUB_TYPE__DB
;
topicObj
.
subType
=
TOPIC_SUB_TYPE__DB
;
topicObj
.
withTbName
=
1
;
topicObj
.
withTbName
=
1
;
topicObj
.
withSchema
=
1
;
topicObj
.
withSchema
=
1
;
...
@@ -520,8 +523,11 @@ static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
...
@@ -520,8 +523,11 @@ static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
int32_t
cols
=
0
;
int32_t
cols
=
0
;
char
topicName
[
TSDB_TOPIC_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
topicName
[
TSDB_TOPIC_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
tstrncpy
(
&
topicName
[
VARSTR_HEADER_SIZE
],
pTopic
->
name
,
TSDB_TOPIC_NAME_LEN
);
varDataSetLen
(
topicName
,
strlen
(
&
topicName
[
VARSTR_HEADER_SIZE
]));
SName
n
;
tNameFromString
(
&
n
,
pTopic
->
name
,
T_NAME_ACCT
|
T_NAME_DB
);
tNameGetDbName
(
&
n
,
varDataVal
(
topicName
));
varDataSetLen
(
topicName
,
strlen
(
varDataVal
(
topicName
)));
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
topicName
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
topicName
,
false
);
...
@@ -535,7 +541,7 @@ static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
...
@@ -535,7 +541,7 @@ static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
varDataSetLen
(
sql
,
strlen
(
&
sql
[
VARSTR_HEADER_SIZE
]));
varDataSetLen
(
sql
,
strlen
(
&
sql
[
VARSTR_HEADER_SIZE
]));
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
sql
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
sql
,
false
);
taosMemoryFree
(
sql
);
//
taosMemoryFree(sql);
numOfRows
++
;
numOfRows
++
;
sdbRelease
(
pSdb
,
pTopic
);
sdbRelease
(
pSdb
,
pTopic
);
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
ba509423
...
@@ -61,6 +61,9 @@ int32_t vnodeSync(SVnode *pVnode);
...
@@ -61,6 +61,9 @@ int32_t vnodeSync(SVnode *pVnode);
int32_t
vnodeGetLoad
(
SVnode
*
pVnode
,
SVnodeLoad
*
pLoad
);
int32_t
vnodeGetLoad
(
SVnode
*
pVnode
,
SVnodeLoad
*
pLoad
);
int
vnodeValidateTableHash
(
SVnodeCfg
*
pVnodeOptions
,
char
*
tableFName
);
int
vnodeValidateTableHash
(
SVnodeCfg
*
pVnodeOptions
,
char
*
tableFName
);
int32_t
vnodeStart
(
SVnode
*
pVnode
);
void
vnodeStop
(
SVnode
*
pVnode
);
int64_t
vnodeGetSyncHandle
(
SVnode
*
pVnode
);
int64_t
vnodeGetSyncHandle
(
SVnode
*
pVnode
);
void
vnodeGetSnapshot
(
SVnode
*
pVnode
,
SSnapshot
*
pSnapshot
);
void
vnodeGetSnapshot
(
SVnode
*
pVnode
,
SSnapshot
*
pSnapshot
);
...
@@ -171,11 +174,6 @@ typedef struct {
...
@@ -171,11 +174,6 @@ typedef struct {
uint64_t
uid
;
uint64_t
uid
;
}
STableKeyInfo
;
}
STableKeyInfo
;
// sync integration
void
vnodeSyncSetQ
(
SVnode
*
pVnode
,
void
*
qHandle
);
void
vnodeSyncSetRpc
(
SVnode
*
pVnode
,
void
*
rpcHandle
);
int32_t
vnodeSyncStart
(
SVnode
*
pVnode
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/vnode/src/inc/meta.h
浏览文件 @
ba509423
...
@@ -51,7 +51,7 @@ static FORCE_INLINE tb_uid_t metaGenerateUid(SMeta* pMeta) { return tGenIdPI64()
...
@@ -51,7 +51,7 @@ static FORCE_INLINE tb_uid_t metaGenerateUid(SMeta* pMeta) { return tGenIdPI64()
#define META_CHILD_TABLE TD_CHILD_TABLE
#define META_CHILD_TABLE TD_CHILD_TABLE
#define META_NORMAL_TABLE TD_NORMAL_TABLE
#define META_NORMAL_TABLE TD_NORMAL_TABLE
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
);
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
,
STbDdlH
*
pHandle
);
int
metaDropTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaDropTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaCommit
(
SMeta
*
pMeta
);
int
metaCommit
(
SMeta
*
pMeta
);
int32_t
metaCreateTSma
(
SMeta
*
pMeta
,
SSmaCfg
*
pCfg
);
int32_t
metaCreateTSma
(
SMeta
*
pMeta
,
SSmaCfg
*
pCfg
);
...
@@ -74,7 +74,7 @@ tb_uid_t metaCtbCursorNext(SMCtbCursor* pCtbCur);
...
@@ -74,7 +74,7 @@ tb_uid_t metaCtbCursorNext(SMCtbCursor* pCtbCur);
// SMetaDB
// SMetaDB
int
metaOpenDB
(
SMeta
*
pMeta
);
int
metaOpenDB
(
SMeta
*
pMeta
);
void
metaCloseDB
(
SMeta
*
pMeta
);
void
metaCloseDB
(
SMeta
*
pMeta
);
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
);
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
,
STbDdlH
*
pHandle
);
int
metaRemoveTableFromDb
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaRemoveTableFromDb
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaSaveSmaToDB
(
SMeta
*
pMeta
,
STSma
*
pTbCfg
);
int
metaSaveSmaToDB
(
SMeta
*
pMeta
,
STSma
*
pTbCfg
);
int
metaRemoveSmaFromDb
(
SMeta
*
pMeta
,
int64_t
indexUid
);
int
metaRemoveSmaFromDb
(
SMeta
*
pMeta
,
int64_t
indexUid
);
...
...
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
ba509423
...
@@ -57,7 +57,6 @@ int32_t tsdbDropTSmaData(STsdb *pTsdb, int64_t indexUid);
...
@@ -57,7 +57,6 @@ int32_t tsdbDropTSmaData(STsdb *pTsdb, int64_t indexUid);
int32_t
tsdbInsertRSmaData
(
STsdb
*
pTsdb
,
char
*
msg
);
int32_t
tsdbInsertRSmaData
(
STsdb
*
pTsdb
,
char
*
msg
);
void
tsdbCleanupReadHandle
(
tsdbReaderT
queryHandle
);
void
tsdbCleanupReadHandle
(
tsdbReaderT
queryHandle
);
int32_t
tdScanAndConvertSubmitMsg
(
SSubmitReq
*
pMsg
);
int32_t
tdScanAndConvertSubmitMsg
(
SSubmitReq
*
pMsg
);
typedef
enum
{
typedef
enum
{
TSDB_FILE_HEAD
=
0
,
// .head
TSDB_FILE_HEAD
=
0
,
// .head
TSDB_FILE_DATA
,
// .data
TSDB_FILE_DATA
,
// .data
...
...
source/dnode/vnode/src/inc/tsdbSma.h
0 → 100644
浏览文件 @
ba509423
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_VNODE_TSDB_SMA_H_
#define _TD_VNODE_TSDB_SMA_H_
#include "os.h"
#include "thash.h"
#include "tmsg.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
int32_t
(
*
__tb_ddl_fn_t
)(
void
*
ahandle
,
void
**
result
,
void
*
p1
,
void
*
p2
);
struct
STbDdlH
{
void
*
ahandle
;
void
*
result
;
__tb_ddl_fn_t
fp
;
};
typedef
struct
{
tb_uid_t
suid
;
SArray
*
tbUids
;
SHashObj
*
uidHash
;
}
STbUidStore
;
static
FORCE_INLINE
int32_t
tsdbUidStoreInit
(
STbUidStore
**
pStore
)
{
ASSERT
(
*
pStore
==
NULL
);
*
pStore
=
taosMemoryCalloc
(
1
,
sizeof
(
STbUidStore
));
if
(
*
pStore
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_FAILED
;
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
tsdbUidStorePut
(
STbUidStore
*
pStore
,
tb_uid_t
suid
,
tb_uid_t
*
uid
);
void
tsdbUidStoreDestory
(
STbUidStore
*
pStore
);
void
*
tsdbUidStoreFree
(
STbUidStore
*
pStore
);
int32_t
tsdbRegisterRSma
(
STsdb
*
pTsdb
,
SMeta
*
pMeta
,
SVCreateTbReq
*
pReq
);
int32_t
tsdbFetchTbUidList
(
void
*
pTsdb
,
void
**
result
,
void
*
suid
,
void
*
uid
);
int32_t
tsdbUpdateTbUidList
(
STsdb
*
pTsdb
,
STbUidStore
*
pUidStore
);
int32_t
tsdbTriggerRSma
(
STsdb
*
pTsdb
,
SMeta
*
pMeta
,
void
*
pMsg
,
int32_t
inputType
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_VNODE_TSDB_SMA_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
ba509423
...
@@ -103,6 +103,8 @@ struct SVnode {
...
@@ -103,6 +103,8 @@ struct SVnode {
#define TD_VID(PVNODE) (PVNODE)->config.vgId
#define TD_VID(PVNODE) (PVNODE)->config.vgId
typedef
struct
STbDdlH
STbDdlH
;
// sma
// sma
void
smaHandleRes
(
void
*
pVnode
,
int64_t
smaId
,
const
SArray
*
data
);
void
smaHandleRes
(
void
*
pVnode
,
int64_t
smaId
,
const
SArray
*
data
);
...
@@ -116,6 +118,8 @@ void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data);
...
@@ -116,6 +118,8 @@ void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data);
#include "vnodeSync.h"
#include "vnodeSync.h"
#include "tsdbSma.h"
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/vnode/src/meta/metaTDBImpl.c
浏览文件 @
ba509423
...
@@ -250,7 +250,7 @@ void metaCloseDB(SMeta *pMeta) {
...
@@ -250,7 +250,7 @@ void metaCloseDB(SMeta *pMeta) {
}
}
}
}
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
)
{
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
,
STbDdlH
*
pHandle
)
{
tb_uid_t
uid
;
tb_uid_t
uid
;
SMetaDB
*
pMetaDb
;
SMetaDB
*
pMetaDb
;
void
*
pKey
;
void
*
pKey
;
...
@@ -349,6 +349,12 @@ int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) {
...
@@ -349,6 +349,12 @@ int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) {
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
return
-
1
;
return
-
1
;
}
}
// child table handle for rsma
if
(
pHandle
&&
pHandle
->
fp
)
{
if
(((
*
pHandle
->
fp
)(
pHandle
->
ahandle
,
&
pHandle
->
result
,
&
ctbIdxKey
.
suid
,
&
uid
))
<
0
)
{
return
-
1
;
};
}
}
else
if
(
pTbCfg
->
type
==
META_NORMAL_TABLE
)
{
}
else
if
(
pTbCfg
->
type
==
META_NORMAL_TABLE
)
{
pKey
=
&
uid
;
pKey
=
&
uid
;
kLen
=
sizeof
(
uid
);
kLen
=
sizeof
(
uid
);
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
ba509423
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#include "vnodeInt.h"
#include "vnodeInt.h"
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
)
{
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
,
STbDdlH
*
pHandle
)
{
// Validate the tbOptions
// Validate the tbOptions
// if (metaValidateTbCfg(pMeta, pTbCfg) < 0) {
// if (metaValidateTbCfg(pMeta, pTbCfg) < 0) {
// // TODO: handle error
// // TODO: handle error
...
@@ -24,7 +24,7 @@ int metaCreateTable(SMeta *pMeta, STbCfg *pTbCfg) {
...
@@ -24,7 +24,7 @@ int metaCreateTable(SMeta *pMeta, STbCfg *pTbCfg) {
// TODO: add atomicity
// TODO: add atomicity
if
(
metaSaveTableToDB
(
pMeta
,
pTbCfg
)
<
0
)
{
if
(
metaSaveTableToDB
(
pMeta
,
pTbCfg
,
pHandle
)
<
0
)
{
// TODO: handle error
// TODO: handle error
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
ba509423
...
@@ -411,8 +411,10 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -411,8 +411,10 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
SMqDataBlkRsp
rsp
=
{
0
};
SMqDataBlkRsp
rsp
=
{
0
};
rsp
.
reqOffset
=
pReq
->
currentOffset
;
rsp
.
reqOffset
=
pReq
->
currentOffset
;
rsp
.
withSchema
=
pExec
->
withSchema
;
rsp
.
blockData
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
rsp
.
blockData
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
rsp
.
blockDataLen
=
taosArrayInit
(
0
,
sizeof
(
int32_t
));
rsp
.
blockDataLen
=
taosArrayInit
(
0
,
sizeof
(
int32_t
));
rsp
.
blockSchema
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
while
(
1
)
{
while
(
1
)
{
consumerEpoch
=
atomic_load_32
(
&
pExec
->
epoch
);
consumerEpoch
=
atomic_load_32
(
&
pExec
->
epoch
);
...
@@ -512,6 +514,12 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -512,6 +514,12 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
ASSERT
(
actualLen
<=
dataStrLen
);
ASSERT
(
actualLen
<=
dataStrLen
);
taosArrayPush
(
rsp
.
blockDataLen
,
&
actualLen
);
taosArrayPush
(
rsp
.
blockDataLen
,
&
actualLen
);
taosArrayPush
(
rsp
.
blockData
,
&
buf
);
taosArrayPush
(
rsp
.
blockData
,
&
buf
);
if
(
pExec
->
withSchema
)
{
SSchemaWrapper
*
pSW
=
tCloneSSchemaWrapper
(
pExec
->
pExecReader
[
workerId
]
->
pSchemaWrapper
);
taosArrayPush
(
rsp
.
blockSchema
,
&
pSW
);
}
rsp
.
blockNum
++
;
rsp
.
blockNum
++
;
}
}
// db subscribe
// db subscribe
...
@@ -540,6 +548,10 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -540,6 +548,10 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
ASSERT
(
actualLen
<=
dataStrLen
);
ASSERT
(
actualLen
<=
dataStrLen
);
taosArrayPush
(
rsp
.
blockDataLen
,
&
actualLen
);
taosArrayPush
(
rsp
.
blockDataLen
,
&
actualLen
);
taosArrayPush
(
rsp
.
blockData
,
&
buf
);
taosArrayPush
(
rsp
.
blockData
,
&
buf
);
SSchemaWrapper
*
pSW
=
tCloneSSchemaWrapper
(
pExec
->
pExecReader
[
workerId
]
->
pSchemaWrapper
);
taosArrayPush
(
rsp
.
blockSchema
,
&
pSW
);
rsp
.
blockNum
++
;
rsp
.
blockNum
++
;
}
}
}
else
{
}
else
{
...
@@ -586,6 +598,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -586,6 +598,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
// TODO destroy
// TODO destroy
taosArrayDestroy
(
rsp
.
blockData
);
taosArrayDestroy
(
rsp
.
blockData
);
taosArrayDestroy
(
rsp
.
blockDataLen
);
taosArrayDestroy
(
rsp
.
blockDataLen
);
taosArrayDestroyP
(
rsp
.
blockSchema
,
(
FDelete
)
tDeleteSSchemaWrapper
);
return
0
;
return
0
;
}
}
...
@@ -827,12 +841,16 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -827,12 +841,16 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
pExec
->
pWalReader
=
walOpenReadHandle
(
pTq
->
pVnode
->
pWal
);
pExec
->
pWalReader
=
walOpenReadHandle
(
pTq
->
pVnode
->
pWal
);
for
(
int32_t
i
=
0
;
i
<
5
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
5
;
i
++
)
{
pExec
->
pExecReader
[
i
]
=
tqInitSubmitMsgScanner
(
pTq
->
pVnode
->
pMeta
);
pExec
->
pExecReader
[
i
]
=
tqInitSubmitMsgScanner
(
pTq
->
pVnode
->
pMeta
);
if
(
pExec
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
SReadHandle
handle
=
{
SReadHandle
handle
=
{
.
reader
=
pExec
->
pExecReader
[
i
],
.
reader
=
pExec
->
pExecReader
[
i
],
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
meta
=
pTq
->
pVnode
->
pMeta
,
};
};
pExec
->
task
[
i
]
=
qCreateStreamExecTaskInfo
(
pExec
->
qmsg
,
&
handle
);
pExec
->
task
[
i
]
=
qCreateStreamExecTaskInfo
(
pExec
->
qmsg
,
&
handle
);
ASSERT
(
pExec
->
task
[
i
]);
ASSERT
(
pExec
->
task
[
i
]);
}
else
{
pExec
->
task
[
i
]
=
NULL
;
}
}
}
taosHashPut
(
pTq
->
execs
,
req
.
subKey
,
strlen
(
req
.
subKey
),
pExec
,
sizeof
(
STqExec
));
taosHashPut
(
pTq
->
execs
,
req
.
subKey
,
strlen
(
req
.
subKey
),
pExec
,
sizeof
(
STqExec
));
return
0
;
return
0
;
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
ba509423
...
@@ -65,7 +65,9 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
...
@@ -65,7 +65,9 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
/*pHandle->pBlock->uid = htobe64(pHandle->pBlock->uid);*/
/*pHandle->pBlock->uid = htobe64(pHandle->pBlock->uid);*/
/*if (pHandle->tbUid == pHandle->pBlock->uid) {*/
/*if (pHandle->tbUid == pHandle->pBlock->uid) {*/
ASSERT
(
pHandle
->
tbIdHash
);
if
(
pHandle
->
tbIdHash
==
NULL
)
{
return
true
;
}
void
*
ret
=
taosHashGet
(
pHandle
->
tbIdHash
,
&
pHandle
->
pBlock
->
uid
,
sizeof
(
int64_t
));
void
*
ret
=
taosHashGet
(
pHandle
->
tbIdHash
,
&
pHandle
->
pBlock
->
uid
,
sizeof
(
int64_t
));
if
(
ret
!=
NULL
)
{
if
(
ret
!=
NULL
)
{
/*printf("retrieve one tb %ld\n", pHandle->pBlock->uid);*/
/*printf("retrieve one tb %ld\n", pHandle->pBlock->uid);*/
...
@@ -107,6 +109,27 @@ int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* p
...
@@ -107,6 +109,27 @@ int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* p
*
pNumOfRows
=
pHandle
->
pBlock
->
numOfRows
;
*
pNumOfRows
=
pHandle
->
pBlock
->
numOfRows
;
int32_t
colNumNeed
=
taosArrayGetSize
(
pHandle
->
pColIdList
);
int32_t
colNumNeed
=
taosArrayGetSize
(
pHandle
->
pColIdList
);
if
(
colNumNeed
==
0
)
{
*
ppCols
=
taosArrayInit
(
pSchemaWrapper
->
nCols
,
sizeof
(
SColumnInfoData
));
if
(
*
ppCols
==
NULL
)
{
return
-
1
;
}
int32_t
colMeta
=
0
;
while
(
colMeta
<
pSchemaWrapper
->
nCols
)
{
SSchema
*
pColSchema
=
&
pSchemaWrapper
->
pSchema
[
colMeta
];
SColumnInfoData
colInfo
=
{
0
};
colInfo
.
info
.
bytes
=
pColSchema
->
bytes
;
colInfo
.
info
.
colId
=
pColSchema
->
colId
;
colInfo
.
info
.
type
=
pColSchema
->
type
;
if
(
colInfoDataEnsureCapacity
(
&
colInfo
,
0
,
*
pNumOfRows
)
<
0
)
{
goto
FAIL
;
}
taosArrayPush
(
*
ppCols
,
&
colInfo
);
colMeta
++
;
}
}
else
{
if
(
colNumNeed
>
pSchemaWrapper
->
nCols
)
{
if
(
colNumNeed
>
pSchemaWrapper
->
nCols
)
{
colNumNeed
=
pSchemaWrapper
->
nCols
;
colNumNeed
=
pSchemaWrapper
->
nCols
;
}
}
...
@@ -140,6 +163,7 @@ int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* p
...
@@ -140,6 +163,7 @@ int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* p
colNeed
++
;
colNeed
++
;
}
}
}
}
}
int32_t
colActual
=
taosArrayGetSize
(
*
ppCols
);
int32_t
colActual
=
taosArrayGetSize
(
*
ppCols
);
*
pNumOfCols
=
colActual
;
*
pNumOfCols
=
colActual
;
...
...
source/dnode/vnode/src/tsdb/tsdbMain.c
浏览文件 @
ba509423
...
@@ -81,8 +81,8 @@ static STsdb *tsdbNew(const char *path, SVnode *pVnode, const STsdbCfg *pTsdbCfg
...
@@ -81,8 +81,8 @@ static STsdb *tsdbNew(const char *path, SVnode *pVnode, const STsdbCfg *pTsdbCfg
static
void
tsdbFree
(
STsdb
*
pTsdb
)
{
static
void
tsdbFree
(
STsdb
*
pTsdb
)
{
if
(
pTsdb
)
{
if
(
pTsdb
)
{
//
tsdbFreeSmaEnv(REPO_TSMA_ENV(pTsdb));
tsdbFreeSmaEnv
(
REPO_TSMA_ENV
(
pTsdb
));
//
tsdbFreeSmaEnv(REPO_RSMA_ENV(pTsdb));
tsdbFreeSmaEnv
(
REPO_RSMA_ENV
(
pTsdb
));
tsdbFreeFS
(
pTsdb
->
fs
);
tsdbFreeFS
(
pTsdb
->
fs
);
taosMemoryFreeClear
(
pTsdb
->
path
);
taosMemoryFreeClear
(
pTsdb
->
path
);
taosMemoryFree
(
pTsdb
);
taosMemoryFree
(
pTsdb
);
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
ba509423
...
@@ -3223,8 +3223,13 @@ void tsdbRetrieveDataBlockInfo(tsdbReaderT* pTsdbReadHandle, SDataBlockInfo* pDa
...
@@ -3223,8 +3223,13 @@ void tsdbRetrieveDataBlockInfo(tsdbReaderT* pTsdbReadHandle, SDataBlockInfo* pDa
tsdbDebug
(
"data block generated, uid:%"
PRIu64
" numOfRows:%d, tsrange:%"
PRId64
" - %"
PRId64
" %s"
,
uid
,
cur
->
rows
,
tsdbDebug
(
"data block generated, uid:%"
PRIu64
" numOfRows:%d, tsrange:%"
PRId64
" - %"
PRId64
" %s"
,
uid
,
cur
->
rows
,
cur
->
win
.
skey
,
cur
->
win
.
ekey
,
pHandle
->
idStr
);
cur
->
win
.
skey
,
cur
->
win
.
ekey
,
pHandle
->
idStr
);
// pDataBlockInfo->uid = uid; // block Id may be over write by assigning uid fro this data block. Do NOT assign
pDataBlockInfo
->
uid
=
uid
;
// the table uid
#if 0
// for multi-group data query processing test purpose
pDataBlockInfo->groupId = uid;
#endif
pDataBlockInfo
->
rows
=
cur
->
rows
;
pDataBlockInfo
->
rows
=
cur
->
rows
;
pDataBlockInfo
->
window
=
cur
->
win
;
pDataBlockInfo
->
window
=
cur
->
win
;
pDataBlockInfo
->
numOfCols
=
(
int32_t
)(
QH_GET_NUM_OF_COLS
(
pHandle
));
pDataBlockInfo
->
numOfCols
=
(
int32_t
)(
QH_GET_NUM_OF_COLS
(
pHandle
));
...
@@ -3631,6 +3636,8 @@ int32_t tsdbQuerySTableByTagCond(void* pMeta, uint64_t uid, TSKEY skey, const ch
...
@@ -3631,6 +3636,8 @@ int32_t tsdbQuerySTableByTagCond(void* pMeta, uint64_t uid, TSKEY skey, const ch
tsdbError
(
"%p failed to get stable, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
uid
,
taskId
,
reqId
);
tsdbError
(
"%p failed to get stable, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
uid
,
taskId
,
reqId
);
terrno
=
TSDB_CODE_TDB_INVALID_TABLE_ID
;
terrno
=
TSDB_CODE_TDB_INVALID_TABLE_ID
;
goto
_error
;
goto
_error
;
}
else
{
tsdbDebug
(
"%p succeed to get stable, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
uid
,
taskId
,
reqId
);
}
}
if
(
pTbCfg
->
type
!=
META_SUPER_TABLE
)
{
if
(
pTbCfg
->
type
!=
META_SUPER_TABLE
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbSma.c
浏览文件 @
ba509423
此差异已折叠。
点击以展开。
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
ba509423
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
*/
*/
#include "vnodeInt.h"
#include "vnodeInt.h"
#include "vnodeSync.h"
int
vnodeCreate
(
const
char
*
path
,
SVnodeCfg
*
pCfg
,
STfs
*
pTfs
)
{
int
vnodeCreate
(
const
char
*
path
,
SVnodeCfg
*
pCfg
,
STfs
*
pTfs
)
{
SVnodeInfo
info
=
{
0
};
SVnodeInfo
info
=
{
0
};
...
@@ -171,6 +172,16 @@ void vnodeClose(SVnode *pVnode) {
...
@@ -171,6 +172,16 @@ void vnodeClose(SVnode *pVnode) {
}
}
}
}
// start the sync timer after the queue is ready
int32_t
vnodeStart
(
SVnode
*
pVnode
)
{
vnodeSyncSetQ
(
pVnode
,
NULL
);
vnodeSyncSetRpc
(
pVnode
,
NULL
);
vnodeSyncStart
(
pVnode
);
return
0
;
}
void
vnodeStop
(
SVnode
*
pVnode
)
{}
int64_t
vnodeGetSyncHandle
(
SVnode
*
pVnode
)
{
return
pVnode
->
sync
;
}
int64_t
vnodeGetSyncHandle
(
SVnode
*
pVnode
)
{
return
pVnode
->
sync
;
}
void
vnodeGetSnapshot
(
SVnode
*
pVnode
,
SSnapshot
*
pSnapshot
)
{
pSnapshot
->
lastApplyIndex
=
pVnode
->
state
.
committed
;
}
void
vnodeGetSnapshot
(
SVnode
*
pVnode
,
SSnapshot
*
pSnapshot
)
{
pSnapshot
->
lastApplyIndex
=
pVnode
->
state
.
committed
;
}
\ No newline at end of file
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
ba509423
...
@@ -83,6 +83,7 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg
...
@@ -83,6 +83,7 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg
case
TDMT_VND_SUBMIT
:
case
TDMT_VND_SUBMIT
:
pRsp
->
msgType
=
TDMT_VND_SUBMIT_RSP
;
pRsp
->
msgType
=
TDMT_VND_SUBMIT_RSP
;
vnodeProcessSubmitReq
(
pVnode
,
ptr
,
pRsp
);
vnodeProcessSubmitReq
(
pVnode
,
ptr
,
pRsp
);
tsdbTriggerRSma
(
pVnode
->
pTsdb
,
pVnode
->
pMeta
,
ptr
,
STREAM_DATA_TYPE_SUBMIT_BLOCK
);
break
;
break
;
case
TDMT_VND_MQ_VG_CHANGE
:
case
TDMT_VND_MQ_VG_CHANGE
:
if
(
tqProcessVgChangeReq
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
if
(
tqProcessVgChangeReq
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
...
@@ -101,7 +102,6 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg
...
@@ -101,7 +102,6 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg
}
}
}
break
;
}
break
;
case
TDMT_VND_CREATE_SMA
:
{
// timeRangeSMA
case
TDMT_VND_CREATE_SMA
:
{
// timeRangeSMA
if
(
tsdbCreateTSma
(
pVnode
->
pTsdb
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)))
<
0
)
{
if
(
tsdbCreateTSma
(
pVnode
->
pTsdb
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)))
<
0
)
{
// TODO
// TODO
}
}
...
@@ -277,19 +277,12 @@ int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -277,19 +277,12 @@ int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
static
int
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
void
*
pReq
)
{
static
int
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
void
*
pReq
)
{
SVCreateTbReq
vCreateTbReq
=
{
0
};
SVCreateTbReq
vCreateTbReq
=
{
0
};
tDeserializeSVCreateTbReq
(
pReq
,
&
vCreateTbReq
);
tDeserializeSVCreateTbReq
(
pReq
,
&
vCreateTbReq
);
if
(
metaCreateTable
(
pVnode
->
pMeta
,
&
(
vCreateTbReq
))
<
0
)
{
if
(
metaCreateTable
(
pVnode
->
pMeta
,
&
(
vCreateTbReq
)
,
NULL
)
<
0
)
{
// TODO
// TODO
return
-
1
;
return
-
1
;
}
}
// TODO: remove the debug log
tsdbRegisterRSma
(
pVnode
->
pTsdb
,
pVnode
->
pMeta
,
&
vCreateTbReq
);
SRSmaParam
*
param
=
vCreateTbReq
.
stbCfg
.
pRSmaParam
;
if
(
param
)
{
printf
(
"qmsg1 len = %d, body = %s
\n
"
,
param
->
qmsg1
?
(
int32_t
)
strlen
(
param
->
qmsg1
)
:
0
,
param
->
qmsg1
?
param
->
qmsg1
:
""
);
printf
(
"qmsg1 len = %d, body = %s
\n
"
,
param
->
qmsg2
?
(
int32_t
)
strlen
(
param
->
qmsg2
)
:
0
,
param
->
qmsg2
?
param
->
qmsg2
:
""
);
}
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pSchema
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pSchema
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pTagSchema
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pTagSchema
);
...
@@ -308,6 +301,13 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR
...
@@ -308,6 +301,13 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR
SVCreateTbBatchRsp
vCreateTbBatchRsp
=
{
0
};
SVCreateTbBatchRsp
vCreateTbBatchRsp
=
{
0
};
tDeserializeSVCreateTbBatchReq
(
pReq
,
&
vCreateTbBatchReq
);
tDeserializeSVCreateTbBatchReq
(
pReq
,
&
vCreateTbBatchReq
);
int
reqNum
=
taosArrayGetSize
(
vCreateTbBatchReq
.
pArray
);
int
reqNum
=
taosArrayGetSize
(
vCreateTbBatchReq
.
pArray
);
STbDdlH
ddlHandle
=
{
.
ahandle
=
pVnode
->
pTsdb
,
.
result
=
NULL
,
.
fp
=
tsdbFetchTbUidList
,
};
for
(
int
i
=
0
;
i
<
reqNum
;
i
++
)
{
for
(
int
i
=
0
;
i
<
reqNum
;
i
++
)
{
SVCreateTbReq
*
pCreateTbReq
=
taosArrayGet
(
vCreateTbBatchReq
.
pArray
,
i
);
SVCreateTbReq
*
pCreateTbReq
=
taosArrayGet
(
vCreateTbBatchReq
.
pArray
,
i
);
...
@@ -323,7 +323,7 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR
...
@@ -323,7 +323,7 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR
taosArrayPush
(
vCreateTbBatchRsp
.
rspList
,
&
rsp
);
taosArrayPush
(
vCreateTbBatchRsp
.
rspList
,
&
rsp
);
}
}
if
(
metaCreateTable
(
pVnode
->
pMeta
,
pCreateTbReq
)
<
0
)
{
if
(
metaCreateTable
(
pVnode
->
pMeta
,
pCreateTbReq
,
&
ddlHandle
)
<
0
)
{
// TODO: handle error
// TODO: handle error
vError
(
"vgId:%d, failed to create table: %s"
,
TD_VID
(
pVnode
),
pCreateTbReq
->
name
);
vError
(
"vgId:%d, failed to create table: %s"
,
TD_VID
(
pVnode
),
pCreateTbReq
->
name
);
}
}
...
@@ -345,6 +345,8 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR
...
@@ -345,6 +345,8 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR
}
}
}
}
tsdbUpdateTbUidList
(
pVnode
->
pTsdb
,
ddlHandle
.
result
);
vTrace
(
"vgId:%d process create %"
PRIzu
" tables"
,
TD_VID
(
pVnode
),
taosArrayGetSize
(
vCreateTbBatchReq
.
pArray
));
vTrace
(
"vgId:%d process create %"
PRIzu
" tables"
,
TD_VID
(
pVnode
),
taosArrayGetSize
(
vCreateTbBatchReq
.
pArray
));
taosArrayDestroy
(
vCreateTbBatchReq
.
pArray
);
taosArrayDestroy
(
vCreateTbBatchReq
.
pArray
);
if
(
vCreateTbBatchRsp
.
rspList
)
{
if
(
vCreateTbBatchRsp
.
rspList
)
{
...
...
source/dnode/vnode/test/tsdbSmaTest.cpp
浏览文件 @
ba509423
...
@@ -407,7 +407,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
...
@@ -407,7 +407,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
}
}
}
}
EXPECT_EQ
(
tdScanAndConvertSubmitMsg
(
pMsg
),
TSDB_CODE_SUCCESS
);
//
EXPECT_EQ(tdScanAndConvertSubmitMsg(pMsg), TSDB_CODE_SUCCESS);
EXPECT_EQ
(
tsdbUpdateSmaWindow
(
pTsdb
,
pMsg
,
0
),
0
);
EXPECT_EQ
(
tsdbUpdateSmaWindow
(
pTsdb
,
pMsg
,
0
),
0
);
...
...
source/libs/command/src/explain.c
浏览文件 @
ba509423
...
@@ -305,7 +305,7 @@ int32_t qExplainResAppendRow(SExplainCtx *ctx, char *tbuf, int32_t len, int32_t
...
@@ -305,7 +305,7 @@ int32_t qExplainResAppendRow(SExplainCtx *ctx, char *tbuf, int32_t len, int32_t
memcpy
(
row
.
buf
,
tbuf
,
len
);
memcpy
(
row
.
buf
,
tbuf
,
len
);
row
.
level
=
level
;
row
.
level
=
level
;
row
.
len
=
len
;
row
.
len
=
len
;
ctx
->
dataSize
+=
len
;
ctx
->
dataSize
+=
row
.
len
;
if
(
NULL
==
taosArrayPush
(
ctx
->
rows
,
&
row
))
{
if
(
NULL
==
taosArrayPush
(
ctx
->
rows
,
&
row
))
{
qError
(
"taosArrayPush row to explain res rows failed"
);
qError
(
"taosArrayPush row to explain res rows failed"
);
...
@@ -756,7 +756,7 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) {
...
@@ -756,7 +756,7 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) {
}
}
int32_t
colNum
=
1
;
int32_t
colNum
=
1
;
int32_t
rspSize
=
sizeof
(
SRetrieveTableRsp
)
+
sizeof
(
int32_t
)
*
colNum
+
sizeof
(
int32_t
)
*
rowNum
+
pCtx
->
dataSize
;
int32_t
rspSize
=
sizeof
(
SRetrieveTableRsp
)
+
sizeof
(
int32_t
)
+
sizeof
(
uint64_t
)
+
sizeof
(
int32_t
)
*
colNum
+
sizeof
(
int32_t
)
*
rowNum
+
pCtx
->
dataSize
;
SRetrieveTableRsp
*
rsp
=
(
SRetrieveTableRsp
*
)
taosMemoryCalloc
(
1
,
rspSize
);
SRetrieveTableRsp
*
rsp
=
(
SRetrieveTableRsp
*
)
taosMemoryCalloc
(
1
,
rspSize
);
if
(
NULL
==
rsp
)
{
if
(
NULL
==
rsp
)
{
qError
(
"malloc SRetrieveTableRsp failed, size:%d"
,
rspSize
);
qError
(
"malloc SRetrieveTableRsp failed, size:%d"
,
rspSize
);
...
@@ -766,29 +766,38 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) {
...
@@ -766,29 +766,38 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) {
rsp
->
completed
=
1
;
rsp
->
completed
=
1
;
rsp
->
numOfRows
=
htonl
(
rowNum
);
rsp
->
numOfRows
=
htonl
(
rowNum
);
*
(
int32_t
*
)
rsp
->
data
=
htonl
(
pCtx
->
dataSize
);
// payload length
*
(
int32_t
*
)
rsp
->
data
=
sizeof
(
int32_t
)
+
sizeof
(
uint64_t
)
+
sizeof
(
int32_t
)
*
colNum
+
sizeof
(
int32_t
)
*
rowNum
+
pCtx
->
dataSize
;
int32_t
*
offset
=
(
int32_t
*
)((
char
*
)
rsp
->
data
+
sizeof
(
int32_t
));
// group id
*
(
uint64_t
*
)(
rsp
->
data
+
sizeof
(
int32_t
))
=
0
;
// column length
int32_t
*
colLength
=
(
int32_t
*
)(
rsp
->
data
+
sizeof
(
int32_t
)
+
sizeof
(
uint64_t
));
// varchar column offset segment
int32_t
*
offset
=
(
int32_t
*
)((
char
*
)
colLength
+
sizeof
(
int32_t
));
// varchar data real payload
char
*
data
=
(
char
*
)(
offset
+
rowNum
);
char
*
data
=
(
char
*
)(
offset
+
rowNum
);
int32_t
tOffset
=
0
;
char
*
start
=
data
;
for
(
int32_t
i
=
0
;
i
<
rowNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
rowNum
;
++
i
)
{
SQueryExplainRowInfo
*
row
=
taosArrayGet
(
pCtx
->
rows
,
i
);
SQueryExplainRowInfo
*
row
=
taosArrayGet
(
pCtx
->
rows
,
i
);
*
offset
=
tOffset
;
offset
[
i
]
=
data
-
start
;
tOffset
+=
row
->
len
;
memcpy
(
data
,
row
->
buf
,
row
->
len
);
varDataCopy
(
data
,
row
->
buf
);
ASSERT
(
varDataTLen
(
row
->
buf
)
==
row
->
len
);
++
offset
;
data
+=
row
->
len
;
data
+=
row
->
len
;
}
}
*
pRsp
=
rsp
;
*
colLength
=
htonl
(
data
-
start
);
rsp
->
compLen
=
htonl
(
rspSize
);
*
pRsp
=
rsp
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
qExplainPrepareCtx
(
SQueryPlan
*
pDag
,
SExplainCtx
**
pCtx
)
{
int32_t
qExplainPrepareCtx
(
SQueryPlan
*
pDag
,
SExplainCtx
**
pCtx
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SNodeListNode
*
plans
=
NULL
;
SNodeListNode
*
plans
=
NULL
;
...
@@ -895,9 +904,7 @@ int32_t qExplainAppendPlanRows(SExplainCtx *pCtx) {
...
@@ -895,9 +904,7 @@ int32_t qExplainAppendPlanRows(SExplainCtx *pCtx) {
int32_t
qExplainGenerateRsp
(
SExplainCtx
*
pCtx
,
SRetrieveTableRsp
**
pRsp
)
{
int32_t
qExplainGenerateRsp
(
SExplainCtx
*
pCtx
,
SRetrieveTableRsp
**
pRsp
)
{
QRY_ERR_RET
(
qExplainAppendGroupResRows
(
pCtx
,
pCtx
->
rootGroupId
,
0
));
QRY_ERR_RET
(
qExplainAppendGroupResRows
(
pCtx
,
pCtx
->
rootGroupId
,
0
));
QRY_ERR_RET
(
qExplainAppendPlanRows
(
pCtx
));
QRY_ERR_RET
(
qExplainAppendPlanRows
(
pCtx
));
QRY_ERR_RET
(
qExplainGetRspFromCtx
(
pCtx
,
pRsp
));
QRY_ERR_RET
(
qExplainGetRspFromCtx
(
pCtx
,
pRsp
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -967,13 +974,10 @@ int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp) {
...
@@ -967,13 +974,10 @@ int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp) {
SExplainCtx
*
pCtx
=
NULL
;
SExplainCtx
*
pCtx
=
NULL
;
QRY_ERR_RET
(
qExplainPrepareCtx
(
pDag
,
&
pCtx
));
QRY_ERR_RET
(
qExplainPrepareCtx
(
pDag
,
&
pCtx
));
QRY_ERR_JRET
(
qExplainGenerateRsp
(
pCtx
,
pRsp
));
QRY_ERR_JRET
(
qExplainGenerateRsp
(
pCtx
,
pRsp
));
_return:
_return:
qExplainFreeCtx
(
pCtx
);
qExplainFreeCtx
(
pCtx
);
QRY_RET
(
code
);
QRY_RET
(
code
);
}
}
...
...
source/libs/executor/inc/executil.h
浏览文件 @
ba509423
...
@@ -40,8 +40,6 @@
...
@@ -40,8 +40,6 @@
#define GET_TASKID(_t) (((SExecTaskInfo*)(_t))->id.str)
#define GET_TASKID(_t) (((SExecTaskInfo*)(_t))->id.str)
#define curTimeWindowIndex(_winres) ((_winres)->curIndex)
typedef
struct
SGroupResInfo
{
typedef
struct
SGroupResInfo
{
int32_t
totalGroup
;
int32_t
totalGroup
;
int32_t
currentGroup
;
int32_t
currentGroup
;
...
@@ -68,11 +66,16 @@ typedef struct SResultRowPosition {
...
@@ -68,11 +66,16 @@ typedef struct SResultRowPosition {
int32_t
offset
;
int32_t
offset
;
}
SResultRowPosition
;
}
SResultRowPosition
;
typedef
struct
SResKeyPos
{
SResultRowPosition
pos
;
uint64_t
groupId
;
char
key
[];
}
SResKeyPos
;
typedef
struct
SResultRowInfo
{
typedef
struct
SResultRowInfo
{
SResultRowPosition
*
pPosition
;
SResultRowPosition
*
pPosition
;
int32_t
size
;
// number of result set
int32_t
size
;
// number of result set
int32_t
capacity
;
// max capacity
int32_t
capacity
;
// max capacity
// int32_t curPos; // current active result row index of pResult list
SResultRowPosition
cur
;
SResultRowPosition
cur
;
}
SResultRowInfo
;
}
SResultRowInfo
;
...
@@ -135,7 +138,7 @@ typedef struct {
...
@@ -135,7 +138,7 @@ typedef struct {
int32_t
colId
;
int32_t
colId
;
}
SStddevInterResult
;
}
SStddevInterResult
;
void
initGroup
ResInfo
(
SGroupResInfo
*
pGroupResInfo
,
SResultRowInfo
*
pResultInfo
);
void
initGroup
edResultInfo
(
SGroupResInfo
*
pGroupResInfo
,
SHashObj
*
pHashmap
,
bool
sortGroupResult
);
void
initMultiResInfoFromArrayList
(
SGroupResInfo
*
pGroupResInfo
,
SArray
*
pArrayList
);
void
initMultiResInfoFromArrayList
(
SGroupResInfo
*
pGroupResInfo
,
SArray
*
pArrayList
);
void
cleanupGroupResInfo
(
SGroupResInfo
*
pGroupResInfo
);
void
cleanupGroupResInfo
(
SGroupResInfo
*
pGroupResInfo
);
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
ba509423
...
@@ -347,10 +347,11 @@ typedef struct STableScanInfo {
...
@@ -347,10 +347,11 @@ typedef struct STableScanInfo {
}
STableScanInfo
;
}
STableScanInfo
;
typedef
struct
STagScanInfo
{
typedef
struct
STagScanInfo
{
SColumnInfo
*
pCols
;
SColumnInfo
*
pCols
;
SSDataBlock
*
pRes
;
SSDataBlock
*
pRes
;
int32_t
totalTables
;
int32_t
totalTables
;
int32_t
curPos
;
int32_t
curPos
;
void
*
pReader
;
}
STagScanInfo
;
}
STagScanInfo
;
typedef
struct
SStreamBlockScanInfo
{
typedef
struct
SStreamBlockScanInfo
{
...
@@ -381,8 +382,6 @@ typedef struct SSysTableScanInfo {
...
@@ -381,8 +382,6 @@ typedef struct SSysTableScanInfo {
SNode
*
pCondition
;
// db_name filter condition, to discard data that are not in current database
SNode
*
pCondition
;
// db_name filter condition, to discard data that are not in current database
void
*
pCur
;
// cursor for iterate the local table meta store.
void
*
pCur
;
// cursor for iterate the local table meta store.
SArray
*
scanCols
;
// SArray<int16_t> scan column id list
SArray
*
scanCols
;
// SArray<int16_t> scan column id list
// int32_t type; // show type, TODO remove it
SName
name
;
SName
name
;
SSDataBlock
*
pRes
;
SSDataBlock
*
pRes
;
int32_t
capacity
;
int32_t
capacity
;
...
@@ -400,8 +399,8 @@ typedef struct SOptrBasicInfo {
...
@@ -400,8 +399,8 @@ typedef struct SOptrBasicInfo {
// TODO move the resultrowsiz together with SOptrBasicInfo:rowCellInfoOffset
// TODO move the resultrowsiz together with SOptrBasicInfo:rowCellInfoOffset
typedef
struct
SAggSupporter
{
typedef
struct
SAggSupporter
{
SHashObj
*
pResultRowHashTable
;
// quick locate the window object for each result
SHashObj
*
pResultRowHashTable
;
// quick locate the window object for each result
SHashObj
*
pResultRowListSet
;
// used to check if current ResultRowInfo has ResultRow object or not
//
SHashObj* pResultRowListSet; // used to check if current ResultRowInfo has ResultRow object or not
SArray
*
pResultRowArrayList
;
// The array list that contains the Result rows
//
SArray* pResultRowArrayList; // The array list that contains the Result rows
char
*
keyBuf
;
// window key buffer
char
*
keyBuf
;
// window key buffer
SDiskbasedBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
SDiskbasedBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
int32_t
resultRowSize
;
// the result buffer size for each result row, with the meta data size for each row
int32_t
resultRowSize
;
// the result buffer size for each result row, with the meta data size for each row
...
@@ -628,7 +627,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
...
@@ -628,7 +627,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
SOperatorInfo
*
createExchangeOperatorInfo
(
const
SNodeList
*
pSources
,
SSDataBlock
*
pBlock
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createExchangeOperatorInfo
(
const
SNodeList
*
pSources
,
SSDataBlock
*
pBlock
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableScanOperatorInfo
(
void
*
p
TsdbRead
Handle
,
int32_t
order
,
int32_t
numOfCols
,
int32_t
dataLoadFlag
,
int32_t
repeatTime
,
SOperatorInfo
*
createTableScanOperatorInfo
(
void
*
p
Reader
Handle
,
int32_t
order
,
int32_t
numOfCols
,
int32_t
dataLoadFlag
,
int32_t
repeatTime
,
int32_t
reverseTime
,
SArray
*
pColMatchInfo
,
SSDataBlock
*
pResBlock
,
SNode
*
pCondition
,
int32_t
reverseTime
,
SArray
*
pColMatchInfo
,
SSDataBlock
*
pResBlock
,
SNode
*
pCondition
,
SInterval
*
pInterval
,
double
ratio
,
SExecTaskInfo
*
pTaskInfo
);
SInterval
*
pInterval
,
double
ratio
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SExprInfo
*
pScalarExprInfo
,
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SExprInfo
*
pScalarExprInfo
,
...
@@ -668,12 +667,12 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo*
...
@@ -668,12 +667,12 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo*
SSDataBlock
*
pResultBlock
,
SExecTaskInfo
*
pTaskInfo
);
SSDataBlock
*
pResultBlock
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createJoinOperatorInfo
(
SOperatorInfo
**
pDownstream
,
int32_t
numOfDownstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SNode
*
pOnCondition
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createJoinOperatorInfo
(
SOperatorInfo
**
pDownstream
,
int32_t
numOfDownstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SNode
*
pOnCondition
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTagScanOperatorInfo
(
void
*
pReaderHandle
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
SExecTaskInfo
*
pTaskInfo
);
#if 0
#if 0
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
SExprInfo* pExpr, int32_t numOfOutput);
SExprInfo* pExpr, int32_t numOfOutput);
SOperatorInfo* createTagScanOperatorInfo(SReaderHandle* pReaderHandle, SExprInfo* pExpr, int32_t numOfOutput);
#endif
#endif
void
projectApplyFunctions
(
SExprInfo
*
pExpr
,
SSDataBlock
*
pResult
,
SSDataBlock
*
pSrcBlock
,
SqlFunctionCtx
*
pCtx
,
void
projectApplyFunctions
(
SExprInfo
*
pExpr
,
SSDataBlock
*
pResult
,
SSDataBlock
*
pSrcBlock
,
SqlFunctionCtx
*
pCtx
,
...
...
source/libs/executor/src/dataDispatcher.c
浏览文件 @
ba509423
...
@@ -64,10 +64,10 @@ static bool needCompress(const SSDataBlock* pData, int32_t numOfCols) {
...
@@ -64,10 +64,10 @@ static bool needCompress(const SSDataBlock* pData, int32_t numOfCols) {
}
}
// data format:
// data format:
// +----------------+--------------------------------------+-------------+-----------+-------------+-----------+
// +----------------+--------------
+----------+--------------
------------------------+-------------+-----------+-------------+-----------+
// |SDataCacheEntry | column#1 length, column#2 length ... | col1 bitmap | col1 data | col2 bitmap | col2 data | ....
// |SDataCacheEntry |
total length | group id |
column#1 length, column#2 length ... | col1 bitmap | col1 data | col2 bitmap | col2 data | ....
// | |
sizeof(int32_t) * numOfCols
| actual size | | actual size | |
// | |
(4 bytes) |(8 bytes) | sizeof(int32_t) * numOfCols
| actual size | | actual size | |
// +----------------+--------------------------------------+-------------+-----------+-------------+-----------+
// +----------------+--------------
+----------+--------------
------------------------+-------------+-----------+-------------+-----------+
// The length of bitmap is decided by number of rows of this data block, and the length of each column data is
// The length of bitmap is decided by number of rows of this data block, and the length of each column data is
// recorded in the first segment, next to the struct header
// recorded in the first segment, next to the struct header
static
void
toDataCacheEntry
(
const
SDataDispatchHandle
*
pHandle
,
const
SInputData
*
pInput
,
SDataDispatchBuf
*
pBuf
)
{
static
void
toDataCacheEntry
(
const
SDataDispatchHandle
*
pHandle
,
const
SInputData
*
pInput
,
SDataDispatchBuf
*
pBuf
)
{
...
...
source/libs/executor/src/executil.c
浏览文件 @
ba509423
...
@@ -186,12 +186,50 @@ void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo) {
...
@@ -186,12 +186,50 @@ void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo) {
pGroupResInfo
->
index
=
0
;
pGroupResInfo
->
index
=
0
;
}
}
void
initGroupResInfo
(
SGroupResInfo
*
pGroupResInfo
,
SResultRowInfo
*
pResultInfo
)
{
static
int32_t
resultrowCompar1
(
const
void
*
p1
,
const
void
*
p2
)
{
SResKeyPos
*
pp1
=
*
(
SResKeyPos
**
)
p1
;
SResKeyPos
*
pp2
=
*
(
SResKeyPos
**
)
p2
;
if
(
pp1
->
groupId
==
pp2
->
groupId
)
{
int64_t
pts1
=
*
(
int64_t
*
)
pp1
->
key
;
int64_t
pts2
=
*
(
int64_t
*
)
pp2
->
key
;
if
(
pts1
==
pts2
)
{
return
0
;
}
else
{
return
pts1
<
pts2
?
-
1
:
1
;
}
}
else
{
return
pp1
->
groupId
<
pp2
->
groupId
?
-
1
:
1
;
}
}
void
initGroupedResultInfo
(
SGroupResInfo
*
pGroupResInfo
,
SHashObj
*
pHashmap
,
bool
sortGroupResult
)
{
if
(
pGroupResInfo
->
pRows
!=
NULL
)
{
if
(
pGroupResInfo
->
pRows
!=
NULL
)
{
taosArrayDestroy
(
pGroupResInfo
->
pRows
);
taosArrayDestroy
(
pGroupResInfo
->
pRows
);
}
}
pGroupResInfo
->
pRows
=
taosArrayFromList
(
pResultInfo
->
pPosition
,
pResultInfo
->
size
,
sizeof
(
SResultRowPosition
));
// extract the result rows information from the hash map
void
*
pData
=
NULL
;
pGroupResInfo
->
pRows
=
taosArrayInit
(
10
,
POINTER_BYTES
);
size_t
keyLen
=
0
;
while
((
pData
=
taosHashIterate
(
pHashmap
,
pData
))
!=
NULL
)
{
void
*
key
=
taosHashGetKey
(
pData
,
&
keyLen
);
SResKeyPos
*
p
=
taosMemoryMalloc
(
keyLen
+
sizeof
(
SResultRowPosition
));
p
->
groupId
=
*
(
uint64_t
*
)
key
;
p
->
pos
=
*
(
SResultRowPosition
*
)
pData
;
memcpy
(
p
->
key
,
key
+
sizeof
(
uint64_t
),
keyLen
-
sizeof
(
uint64_t
));
taosArrayPush
(
pGroupResInfo
->
pRows
,
&
p
);
}
if
(
sortGroupResult
)
{
qsort
(
pGroupResInfo
->
pRows
->
pData
,
taosArrayGetSize
(
pGroupResInfo
->
pRows
),
POINTER_BYTES
,
resultrowCompar1
);
}
pGroupResInfo
->
index
=
0
;
pGroupResInfo
->
index
=
0
;
assert
(
pGroupResInfo
->
index
<=
getNumOfTotalRes
(
pGroupResInfo
));
assert
(
pGroupResInfo
->
index
<=
getNumOfTotalRes
(
pGroupResInfo
));
}
}
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
ba509423
此差异已折叠。
点击以展开。
source/libs/executor/src/groupoperator.c
浏览文件 @
ba509423
...
@@ -308,7 +308,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou
...
@@ -308,7 +308,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou
// }
// }
blockDataEnsureCapacity
(
pRes
,
pOperator
->
resultInfo
.
capacity
);
blockDataEnsureCapacity
(
pRes
,
pOperator
->
resultInfo
.
capacity
);
initGroup
ResInfo
(
&
pInfo
->
groupResInfo
,
&
pInfo
->
binfo
.
resultRowInfo
);
initGroup
edResultInfo
(
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultRowHashTable
,
false
);
while
(
1
)
{
while
(
1
)
{
doBuildResultDatablock
(
pRes
,
&
pInfo
->
groupResInfo
,
pOperator
->
pExpr
,
pInfo
->
aggSup
.
pResultBuf
,
pInfo
->
binfo
.
rowCellInfoOffset
,
pInfo
->
binfo
.
pCtx
);
doBuildResultDatablock
(
pRes
,
&
pInfo
->
groupResInfo
,
pOperator
->
pExpr
,
pInfo
->
aggSup
.
pResultBuf
,
pInfo
->
binfo
.
rowCellInfoOffset
,
pInfo
->
binfo
.
pCtx
);
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
ba509423
...
@@ -272,8 +272,6 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) {
...
@@ -272,8 +272,6 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) {
STableScanInfo
*
pTableScanInfo
=
pOperator
->
info
;
STableScanInfo
*
pTableScanInfo
=
pOperator
->
info
;
SSDataBlock
*
pBlock
=
pTableScanInfo
->
pResBlock
;
SSDataBlock
*
pBlock
=
pTableScanInfo
->
pResBlock
;
STableGroupInfo
*
pTableGroupInfo
=
&
pOperator
->
pTaskInfo
->
tableqinfoGroupInfo
;
*
newgroup
=
false
;
*
newgroup
=
false
;
while
(
tsdbNextDataBlock
(
pTableScanInfo
->
dataReader
))
{
while
(
tsdbNextDataBlock
(
pTableScanInfo
->
dataReader
))
{
...
@@ -284,18 +282,6 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) {
...
@@ -284,18 +282,6 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) {
pTableScanInfo
->
numOfBlocks
+=
1
;
pTableScanInfo
->
numOfBlocks
+=
1
;
tsdbRetrieveDataBlockInfo
(
pTableScanInfo
->
dataReader
,
&
pBlock
->
info
);
tsdbRetrieveDataBlockInfo
(
pTableScanInfo
->
dataReader
,
&
pBlock
->
info
);
// todo opt
// if (pTableGroupInfo->numOfTables > 1 || (pRuntimeEnv->current == NULL && pTableGroupInfo->numOfTables == 1)) {
// STableQueryInfo** pTableQueryInfo =
// (STableQueryInfo**)taosHashGet(pTableGroupInfo->map, &pBlock->info.uid, sizeof(pBlock->info.uid));
// if (pTableQueryInfo == NULL) {
// break;
// }
//
// doTableQueryInfoTimeWindowCheck(pTaskInfo, *pTableQueryInfo, pTableScanInfo->order);
// }
// this function never returns error?
uint32_t
status
=
0
;
uint32_t
status
=
0
;
int32_t
code
=
loadDataBlock
(
pOperator
,
pTableScanInfo
,
pBlock
,
&
status
);
int32_t
code
=
loadDataBlock
(
pOperator
,
pTableScanInfo
,
pBlock
,
&
status
);
// int32_t code = loadDataBlockOnDemand(pOperator->pRuntimeEnv, pTableScanInfo, pBlock, &status);
// int32_t code = loadDataBlockOnDemand(pOperator->pRuntimeEnv, pTableScanInfo, pBlock, &status);
...
@@ -308,6 +294,8 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) {
...
@@ -308,6 +294,8 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) {
continue
;
continue
;
}
}
// reset the block to be 0 by default, this blockId is assigned by physical plan and is used by direct upstream operator.
pBlock
->
info
.
blockId
=
0
;
return
pBlock
;
return
pBlock
;
}
}
...
@@ -824,12 +812,12 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
...
@@ -824,12 +812,12 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
int32_t
tableNameSlotId
=
1
;
int32_t
tableNameSlotId
=
1
;
SColumnInfoData
*
pTableNameCol
=
taosArrayGet
(
pInfo
->
pRes
->
pDataBlock
,
tableNameSlotId
);
SColumnInfoData
*
pTableNameCol
=
taosArrayGet
(
pInfo
->
pRes
->
pDataBlock
,
tableNameSlotId
);
char
*
name
=
NULL
;
char
*
tb
=
NULL
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
char
n
[
TSDB_TABLE_NAME_LEN
]
=
{
0
};
char
n
[
TSDB_TABLE_NAME_LEN
]
=
{
0
};
while
((
name
=
metaTbCursorNext
(
pInfo
->
pCur
))
!=
NULL
)
{
while
((
tb
=
metaTbCursorNext
(
pInfo
->
pCur
))
!=
NULL
)
{
STR_TO_VARSTR
(
n
,
name
);
STR_TO_VARSTR
(
n
,
tb
);
colDataAppend
(
pTableNameCol
,
numOfRows
,
n
,
false
);
colDataAppend
(
pTableNameCol
,
numOfRows
,
n
,
false
);
numOfRows
+=
1
;
numOfRows
+=
1
;
if
(
numOfRows
>=
pInfo
->
capacity
)
{
if
(
numOfRows
>=
pInfo
->
capacity
)
{
...
@@ -992,3 +980,167 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataB
...
@@ -992,3 +980,167 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataB
return
pOperator
;
return
pOperator
;
}
}
static
SSDataBlock
*
doTagScan
(
SOperatorInfo
*
pOperator
,
bool
*
newgroup
)
{
#if 0
SOperatorInfo* pOperator = (SOperatorInfo*) param;
if (pOperator->status == OP_EXEC_DONE) {
return NULL;
}
int32_t maxNumOfTables = (int32_t)pResultInfo->capacity;
STagScanInfo *pInfo = pOperator->info;
SSDataBlock *pRes = pInfo->pRes;
*newgroup = false;
int32_t count = 0;
SArray* pa = GET_TABLEGROUP(pRuntimeEnv, 0);
int32_t functionId = getExprFunctionId(&pOperator->pExpr[0]);
if (functionId == FUNCTION_TID_TAG) { // return the tags & table Id
assert(pQueryAttr->numOfOutput == 1);
SExprInfo* pExprInfo = &pOperator->pExpr[0];
int32_t rsize = pExprInfo->base.resSchema.bytes;
count = 0;
int16_t bytes = pExprInfo->base.resSchema.bytes;
int16_t type = pExprInfo->base.resSchema.type;
for(int32_t i = 0; i < pQueryAttr->numOfTags; ++i) {
if (pQueryAttr->tagColList[i].colId == pExprInfo->base.pColumns->info.colId) {
bytes = pQueryAttr->tagColList[i].bytes;
type = pQueryAttr->tagColList[i].type;
break;
}
}
SColumnInfoData* pColInfo = taosArrayGet(pRes->pDataBlock, 0);
while(pInfo->curPos < pInfo->totalTables && count < maxNumOfTables) {
int32_t i = pInfo->curPos++;
STableQueryInfo *item = taosArrayGetP(pa, i);
char *output = pColInfo->pData + count * rsize;
varDataSetLen(output, rsize - VARSTR_HEADER_SIZE);
output = varDataVal(output);
STableId* id = TSDB_TABLEID(item->pTable);
*(int16_t *)output = 0;
output += sizeof(int16_t);
*(int64_t *)output = id->uid; // memory align problem, todo serialize
output += sizeof(id->uid);
*(int32_t *)output = id->tid;
output += sizeof(id->tid);
*(int32_t *)output = pQueryAttr->vgId;
output += sizeof(pQueryAttr->vgId);
char* data = NULL;
if (pExprInfo->base.pColumns->info.colId == TSDB_TBNAME_COLUMN_INDEX) {
data = tsdbGetTableName(item->pTable);
} else {
data = tsdbGetTableTagVal(item->pTable, pExprInfo->base.pColumns->info.colId, type, bytes);
}
doSetTagValueToResultBuf(output, data, type, bytes);
count += 1;
}
//qDebug("QInfo:0x%"PRIx64" create (tableId, tag) info completed, rows:%d", GET_TASKID(pRuntimeEnv), count);
} else if (functionId == FUNCTION_COUNT) {// handle the "count(tbname)" query
SColumnInfoData* pColInfo = taosArrayGet(pRes->pDataBlock, 0);
*(int64_t*)pColInfo->pData = pInfo->totalTables;
count = 1;
pOperator->status = OP_EXEC_DONE;
//qDebug("QInfo:0x%"PRIx64" create count(tbname) query, res:%d rows:1", GET_TASKID(pRuntimeEnv), count);
} else { // return only the tags|table name etc.
SExprInfo* pExprInfo = &pOperator->pExpr[0]; // todo use the column list instead of exprinfo
count = 0;
while(pInfo->curPos < pInfo->totalTables && count < maxNumOfTables) {
int32_t i = pInfo->curPos++;
STableQueryInfo* item = taosArrayGetP(pa, i);
char *data = NULL, *dst = NULL;
int16_t type = 0, bytes = 0;
for(int32_t j = 0; j < pOperator->numOfOutput; ++j) {
// not assign value in case of user defined constant output column
if (TSDB_COL_IS_UD_COL(pExprInfo[j].base.pColumns->flag)) {
continue;
}
SColumnInfoData* pColInfo = taosArrayGet(pRes->pDataBlock, j);
type = pExprInfo[j].base.resSchema.type;
bytes = pExprInfo[j].base.resSchema.bytes;
if (pExprInfo[j].base.pColumns->info.colId == TSDB_TBNAME_COLUMN_INDEX) {
data = tsdbGetTableName(item->pTable);
} else {
data = tsdbGetTableTagVal(item->pTable, pExprInfo[j].base.pColumns->info.colId, type, bytes);
}
dst = pColInfo->pData + count * pExprInfo[j].base.resSchema.bytes;
doSetTagValueToResultBuf(dst, data, type, bytes);
}
count += 1;
}
if (pInfo->curPos >= pInfo->totalTables) {
pOperator->status = OP_EXEC_DONE;
}
//qDebug("QInfo:0x%"PRIx64" create tag values results completed, rows:%d", GET_TASKID(pRuntimeEnv), count);
}
if (pOperator->status == OP_EXEC_DONE) {
setTaskStatus(pOperator->pRuntimeEnv, TASK_COMPLETED);
}
pRes->info.rows = count;
return (pRes->info.rows == 0)? NULL:pInfo->pRes;
#endif
return
TSDB_CODE_SUCCESS
;
}
static
void
destroyTagScanOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
STagScanInfo
*
pInfo
=
(
STagScanInfo
*
)
param
;
pInfo
->
pRes
=
blockDataDestroy
(
pInfo
->
pRes
);
}
SOperatorInfo
*
createTagScanOperatorInfo
(
void
*
pReaderHandle
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
SExecTaskInfo
*
pTaskInfo
)
{
STagScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STagScanInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
goto
_error
;
}
pInfo
->
pReader
=
pReaderHandle
;
pInfo
->
curPos
=
0
;
pOperator
->
name
=
"TagScanOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
;
pOperator
->
blockingOptr
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
getNextFn
=
doTagScan
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
closeFn
=
destroyTagScanOperatorInfo
;
return
pOperator
;
_error:
taosMemoryFree
(
pInfo
);
taosMemoryFree
(
pOperator
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
source/libs/function/inc/builtinsimpl.h
浏览文件 @
ba509423
...
@@ -24,7 +24,7 @@ extern "C" {
...
@@ -24,7 +24,7 @@ extern "C" {
#include "functionMgt.h"
#include "functionMgt.h"
bool
functionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
functionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
functionFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
slotId
);
int32_t
functionFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
EFuncDataRequired
countDataRequired
(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
);
EFuncDataRequired
countDataRequired
(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
);
bool
getCountFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getCountFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
...
@@ -43,17 +43,17 @@ int32_t maxFunction(SqlFunctionCtx *pCtx);
...
@@ -43,17 +43,17 @@ int32_t maxFunction(SqlFunctionCtx *pCtx);
bool
getAvgFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getAvgFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
avgFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
avgFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
avgFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
avgFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
avgFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
slotId
);
int32_t
avgFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
bool
getStddevFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getStddevFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
stddevFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
stddevFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
stddevFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
stddevFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
stddevFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
slotId
);
int32_t
stddevFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
bool
getPercentileFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getPercentileFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
percentileFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
percentileFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
percentileFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
percentileFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
percentileFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
slotId
);
int32_t
percentileFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
bool
getDiffFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getDiffFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
diffFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
bool
diffFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
...
@@ -65,7 +65,7 @@ int32_t lastFunction(SqlFunctionCtx *pCtx);
...
@@ -65,7 +65,7 @@ int32_t lastFunction(SqlFunctionCtx *pCtx);
bool
getTopBotFuncEnv
(
SFunctionNode
*
UNUSED_PARAM
(
pFunc
),
SFuncExecEnv
*
pEnv
);
bool
getTopBotFuncEnv
(
SFunctionNode
*
UNUSED_PARAM
(
pFunc
),
SFuncExecEnv
*
pEnv
);
int32_t
topFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
topFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
topBotFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
slotId
);
int32_t
topBotFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/function/inc/tudf.h
浏览文件 @
ba509423
...
@@ -42,19 +42,7 @@ enum {
...
@@ -42,19 +42,7 @@ enum {
UDFC_CODE_INVALID_STATE
=
-
5
UDFC_CODE_INVALID_STATE
=
-
5
};
};
typedef
void
*
UdfcFuncHandle
;
/**
* create udfd proxy, called once in process that call setupUdf/callUdfxxx/teardownUdf
* @return error code
*/
int32_t
udfcOpen
();
/**
* destroy udfd proxy
* @return error code
*/
int32_t
udfcClose
();
/**
/**
...
...
source/libs/function/src/builtins.c
浏览文件 @
ba509423
...
@@ -355,7 +355,7 @@ static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t l
...
@@ -355,7 +355,7 @@ static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t l
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
2
4
,
.
type
=
TSDB_DATA_TYPE_BINARY
};
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
6
4
,
.
type
=
TSDB_DATA_TYPE_BINARY
};
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
ba509423
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
*/
*/
#include "builtinsimpl.h"
#include "builtinsimpl.h"
#include
<libs/nodes/querynodes.h>
#include
"function.h"
#include "querynodes.h"
#include "querynodes.h"
#include "taggfunction.h"
#include "taggfunction.h"
#include "tdatablock.h"
#include "tdatablock.h"
...
@@ -44,8 +44,6 @@ typedef struct STopBotResItem {
...
@@ -44,8 +44,6 @@ typedef struct STopBotResItem {
}
STopBotResItem
;
}
STopBotResItem
;
typedef
struct
STopBotRes
{
typedef
struct
STopBotRes
{
int32_t
pageId
;
// int32_t num;
STopBotResItem
*
pItems
;
STopBotResItem
*
pItems
;
}
STopBotRes
;
}
STopBotRes
;
...
@@ -92,18 +90,6 @@ typedef struct SDiffInfo {
...
@@ -92,18 +90,6 @@ typedef struct SDiffInfo {
} \
} \
} while (0);
} while (0);
#define DO_UPDATE_SUBSID_RES(ctx, ts) \
do { \
for (int32_t _i = 0; _i < (ctx)->subsidiaryRes.numOfCols; ++_i) { \
SqlFunctionCtx *__ctx = (ctx)->subsidiaryRes.pCtx[_i]; \
if (__ctx->functionId == FUNCTION_TS_DUMMY) { \
__ctx->tag.i = (ts); \
__ctx->tag.nType = TSDB_DATA_TYPE_BIGINT; \
} \
__ctx->fpSet.process(__ctx); \
} \
} while (0)
#define UPDATE_DATA(ctx, left, right, num, sign, _ts) \
#define UPDATE_DATA(ctx, left, right, num, sign, _ts) \
do { \
do { \
if (((left) < (right)) ^ (sign)) { \
if (((left) < (right)) ^ (sign)) { \
...
@@ -139,7 +125,8 @@ bool functionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) {
...
@@ -139,7 +125,8 @@ bool functionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) {
return
true
;
return
true
;
}
}
int32_t
functionFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
slotId
)
{
int32_t
functionFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
int32_t
slotId
=
pCtx
->
pExpr
->
base
.
resSchema
.
slotId
;
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
slotId
);
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
slotId
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
...
@@ -406,7 +393,7 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
...
@@ -406,7 +393,7 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
avgFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
slotId
)
{
int32_t
avgFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
int32_t
type
=
pInput
->
pData
[
0
]
->
info
.
type
;
int32_t
type
=
pInput
->
pData
[
0
]
->
info
.
type
;
SAvgRes
*
pAvgRes
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
SAvgRes
*
pAvgRes
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
...
@@ -416,7 +403,7 @@ int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t slotId) {
...
@@ -416,7 +403,7 @@ int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t slotId) {
pAvgRes
->
result
=
pAvgRes
->
sum
.
dsum
/
((
double
)
pAvgRes
->
count
);
pAvgRes
->
result
=
pAvgRes
->
sum
.
dsum
/
((
double
)
pAvgRes
->
count
);
}
}
return
functionFinalize
(
pCtx
,
pBlock
,
slotId
);
return
functionFinalize
(
pCtx
,
pBlock
);
}
}
EFuncDataRequired
statisDataRequired
(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
){
EFuncDataRequired
statisDataRequired
(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
){
...
@@ -521,6 +508,49 @@ bool getMinmaxFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
...
@@ -521,6 +508,49 @@ bool getMinmaxFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
return
true
;
return
true
;
}
}
#define GET_TS_LIST(x) ((TSKEY*)((x)->ptsList))
#define GET_TS_DATA(x, y) (GET_TS_LIST(x)[(y)])
#define DO_UPDATE_TAG_COLUMNS_WITHOUT_TS(ctx) \
do { \
for (int32_t _i = 0; _i < (ctx)->tagInfo.numOfTagCols; ++_i) { \
SqlFunctionCtx *__ctx = (ctx)->tagInfo.pTagCtxList[_i]; \
__ctx->fpSet.process(__ctx); \
} \
} while (0);
#define DO_UPDATE_SUBSID_RES(ctx, ts) \
do { \
for (int32_t _i = 0; _i < (ctx)->subsidiaries.num; ++_i) { \
SqlFunctionCtx* __ctx = (ctx)->subsidiaries.pCtx[_i]; \
if (__ctx->functionId == FUNCTION_TS_DUMMY) { \
__ctx->tag.i = (ts); \
__ctx->tag.nType = TSDB_DATA_TYPE_BIGINT; \
} \
__ctx->fpSet.process(__ctx); \
} \
} while (0)
#define UPDATE_DATA(ctx, left, right, num, sign, _ts) \
do { \
if (((left) < (right)) ^ (sign)) { \
(left) = (right); \
DO_UPDATE_SUBSID_RES(ctx, _ts); \
(num) += 1; \
} \
} while (0)
#define LOOPCHECK_N(val, _col, ctx, _t, _nrow, _start, sign, num) \
do { \
_t *d = (_t *)((_col)->pData); \
for (int32_t i = (_start); i < (_nrow) + (_start); ++i) { \
if (((_col)->hasNull) && colDataIsNull_f((_col)->nullbitmap, i)) { \
continue; \
} \
TSKEY ts = (ctx)->ptsList != NULL ? GET_TS_DATA(ctx, i) : 0; \
UPDATE_DATA(ctx, val, d[i], num, sign, ts); \
} \
} while (0)
int32_t
doMinMaxHelper
(
SqlFunctionCtx
*
pCtx
,
int32_t
isMinFunc
)
{
int32_t
doMinMaxHelper
(
SqlFunctionCtx
*
pCtx
,
int32_t
isMinFunc
)
{
int32_t
numOfElems
=
0
;
int32_t
numOfElems
=
0
;
...
@@ -564,8 +594,8 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) {
...
@@ -564,8 +594,8 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) {
int64_t
val
=
GET_INT64_VAL
(
tval
);
int64_t
val
=
GET_INT64_VAL
(
tval
);
if
((
prev
<
val
)
^
isMinFunc
)
{
if
((
prev
<
val
)
^
isMinFunc
)
{
*
(
int64_t
*
)
buf
=
val
;
*
(
int64_t
*
)
buf
=
val
;
for
(
int32_t
i
=
0
;
i
<
(
pCtx
)
->
subsidiar
yRes
.
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
(
pCtx
)
->
subsidiar
ies
.
num
;
++
i
)
{
SqlFunctionCtx
*
__ctx
=
pCtx
->
subsidiar
yR
es
.
pCtx
[
i
];
SqlFunctionCtx
*
__ctx
=
pCtx
->
subsidiar
i
es
.
pCtx
[
i
];
if
(
__ctx
->
functionId
==
FUNCTION_TS_DUMMY
)
{
// TODO refactor
if
(
__ctx
->
functionId
==
FUNCTION_TS_DUMMY
)
{
// TODO refactor
__ctx
->
tag
.
i
=
key
;
__ctx
->
tag
.
i
=
key
;
__ctx
->
tag
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
__ctx
->
tag
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
...
@@ -581,8 +611,8 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) {
...
@@ -581,8 +611,8 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) {
uint64_t
val
=
GET_UINT64_VAL
(
tval
);
uint64_t
val
=
GET_UINT64_VAL
(
tval
);
if
((
prev
<
val
)
^
isMinFunc
)
{
if
((
prev
<
val
)
^
isMinFunc
)
{
*
(
uint64_t
*
)
buf
=
val
;
*
(
uint64_t
*
)
buf
=
val
;
for
(
int32_t
i
=
0
;
i
<
(
pCtx
)
->
subsidiar
yRes
.
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
(
pCtx
)
->
subsidiar
ies
.
num
;
++
i
)
{
SqlFunctionCtx
*
__ctx
=
pCtx
->
subsidiar
yR
es
.
pCtx
[
i
];
SqlFunctionCtx
*
__ctx
=
pCtx
->
subsidiar
i
es
.
pCtx
[
i
];
if
(
__ctx
->
functionId
==
FUNCTION_TS_DUMMY
)
{
// TODO refactor
if
(
__ctx
->
functionId
==
FUNCTION_TS_DUMMY
)
{
// TODO refactor
__ctx
->
tag
.
i
=
key
;
__ctx
->
tag
.
i
=
key
;
__ctx
->
tag
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
__ctx
->
tag
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
...
@@ -797,7 +827,7 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) {
...
@@ -797,7 +827,7 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
stddevFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
slotId
)
{
int32_t
stddevFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
int32_t
type
=
pInput
->
pData
[
0
]
->
info
.
type
;
int32_t
type
=
pInput
->
pData
[
0
]
->
info
.
type
;
SStddevRes
*
pStddevRes
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
SStddevRes
*
pStddevRes
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
...
@@ -810,7 +840,7 @@ int32_t stddevFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t slotId
...
@@ -810,7 +840,7 @@ int32_t stddevFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t slotId
pStddevRes
->
result
=
sqrt
(
pStddevRes
->
quadraticDSum
/
((
double
)
pStddevRes
->
count
)
-
avg
*
avg
);
pStddevRes
->
result
=
sqrt
(
pStddevRes
->
quadraticDSum
/
((
double
)
pStddevRes
->
count
)
-
avg
*
avg
);
}
}
return
functionFinalize
(
pCtx
,
pBlock
,
slotId
);
return
functionFinalize
(
pCtx
,
pBlock
);
}
}
bool
getPercentileFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
)
{
bool
getPercentileFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
)
{
...
@@ -923,7 +953,7 @@ int32_t percentileFunction(SqlFunctionCtx *pCtx) {
...
@@ -923,7 +953,7 @@ int32_t percentileFunction(SqlFunctionCtx *pCtx) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
percentileFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
slotId
)
{
int32_t
percentileFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
SVariant
*
pVal
=
&
pCtx
->
param
[
1
].
param
;
SVariant
*
pVal
=
&
pCtx
->
param
[
1
].
param
;
double
v
=
pVal
->
nType
==
TSDB_DATA_TYPE_INT
?
pVal
->
i
:
pVal
->
d
;
double
v
=
pVal
->
nType
==
TSDB_DATA_TYPE_INT
?
pVal
->
i
:
pVal
->
d
;
...
@@ -936,7 +966,7 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t sl
...
@@ -936,7 +966,7 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t sl
}
}
tMemBucketDestroy
(
pMemBucket
);
tMemBucketDestroy
(
pMemBucket
);
return
functionFinalize
(
pCtx
,
pBlock
,
slotId
);
return
functionFinalize
(
pCtx
,
pBlock
);
}
}
bool
getFirstLastFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
)
{
bool
getFirstLastFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
)
{
...
@@ -1353,15 +1383,16 @@ static STopBotRes *getTopBotOutputInfo(SqlFunctionCtx *pCtx) {
...
@@ -1353,15 +1383,16 @@ static STopBotRes *getTopBotOutputInfo(SqlFunctionCtx *pCtx) {
return
pRes
;
return
pRes
;
}
}
static
void
doAddIntoResult
(
S
TopBotRes
*
pRes
,
int32_t
maxSize
,
void
*
pData
,
int32_t
rowIndex
,
SSDataBlock
*
pSrcBlock
,
static
void
doAddIntoResult
(
S
qlFunctionCtx
*
pCtx
,
void
*
pData
,
int32_t
rowIndex
,
SSDataBlock
*
pSrcBlock
,
uint16_t
type
,
uint64_t
uid
,
SResultRowEntryInfo
*
pEntryInfo
);
uint16_t
type
,
uint64_t
uid
,
SResultRowEntryInfo
*
pEntryInfo
);
static
void
saveTupleData
(
SqlFunctionCtx
*
pCtx
,
int32_t
rowIndex
,
const
SSDataBlock
*
pSrcBlock
,
STopBotResItem
*
pItem
);
static
void
copyTupleData
(
SqlFunctionCtx
*
pCtx
,
int32_t
rowIndex
,
const
SSDataBlock
*
pSrcBlock
,
STopBotResItem
*
pItem
);
int32_t
topFunction
(
SqlFunctionCtx
*
pCtx
)
{
int32_t
topFunction
(
SqlFunctionCtx
*
pCtx
)
{
int32_t
numOfElems
=
0
;
int32_t
numOfElems
=
0
;
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STopBotRes
*
pRes
=
getTopBotOutputInfo
(
pCtx
);
// if ((void *)pRes->res[0] != (void *)((char *)pRes + sizeof(STopBotRes) + POINTER_BYTES * pCtx->param[0].i)) {
// if ((void *)pRes->res[0] != (void *)((char *)pRes + sizeof(STopBotRes) + POINTER_BYTES * pCtx->param[0].i)) {
// buildTopBotStruct(pRes, pCtx);
// buildTopBotStruct(pRes, pCtx);
// }
// }
...
@@ -1381,7 +1412,7 @@ int32_t topFunction(SqlFunctionCtx *pCtx) {
...
@@ -1381,7 +1412,7 @@ int32_t topFunction(SqlFunctionCtx *pCtx) {
numOfElems
++
;
numOfElems
++
;
char
*
data
=
colDataGetData
(
pCol
,
i
);
char
*
data
=
colDataGetData
(
pCol
,
i
);
doAddIntoResult
(
p
Res
,
pCtx
->
param
[
1
].
param
.
i
,
data
,
i
,
NULL
,
type
,
pInput
->
uid
,
pResInfo
);
doAddIntoResult
(
p
Ctx
,
data
,
i
,
pCtx
->
pSrcBlock
,
type
,
pInput
->
uid
,
pResInfo
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1414,9 +1445,11 @@ static int32_t topBotResComparFn(const void *p1, const void *p2, const void *par
...
@@ -1414,9 +1445,11 @@ static int32_t topBotResComparFn(const void *p1, const void *p2, const void *par
return
(
val1
->
v
.
d
>
val2
->
v
.
d
)
?
1
:
-
1
;
return
(
val1
->
v
.
d
>
val2
->
v
.
d
)
?
1
:
-
1
;
}
}
void
doAddIntoResult
(
SqlFunctionCtx
*
pCtx
,
void
*
pData
,
int32_t
rowIndex
,
SSDataBlock
*
pSrcBlock
,
uint16_t
type
,
void
doAddIntoResult
(
STopBotRes
*
pRes
,
int32_t
maxSize
,
void
*
pData
,
int32_t
rowIndex
,
SSDataBlock
*
pSrcBlock
,
uint16_t
type
,
uint64_t
uid
,
SResultRowEntryInfo
*
pEntryInfo
)
{
uint64_t
uid
,
SResultRowEntryInfo
*
pEntryInfo
)
{
STopBotRes
*
pRes
=
getTopBotOutputInfo
(
pCtx
);
int32_t
maxSize
=
pCtx
->
param
[
1
].
param
.
i
;
SVariant
val
=
{
0
};
SVariant
val
=
{
0
};
taosVariantCreateFromBinary
(
&
val
,
pData
,
tDataTypes
[
type
].
bytes
,
type
);
taosVariantCreateFromBinary
(
&
val
,
pData
,
tDataTypes
[
type
].
bytes
,
type
);
...
@@ -1428,22 +1461,9 @@ void doAddIntoResult(STopBotRes *pRes, int32_t maxSize, void *pData, int32_t row
...
@@ -1428,22 +1461,9 @@ void doAddIntoResult(STopBotRes *pRes, int32_t maxSize, void *pData, int32_t row
STopBotResItem
*
pItem
=
&
pItems
[
pEntryInfo
->
numOfRes
];
STopBotResItem
*
pItem
=
&
pItems
[
pEntryInfo
->
numOfRes
];
pItem
->
v
=
val
;
pItem
->
v
=
val
;
pItem
->
uid
=
uid
;
pItem
->
uid
=
uid
;
pItem
->
tuplePos
.
pageId
=
-
1
;
// todo set the corresponding tuple data in the disk-based buffer
if
(
pRes
->
pageId
==
-
1
)
{
// save the data of this tuple
SFilePage
*
pPage
=
getNewBufPage
(
NULL
,
0
,
&
pRes
->
pageId
);
saveTupleData
(
pCtx
,
rowIndex
,
pSrcBlock
,
pItem
);
pPage
->
num
=
sizeof
(
SFilePage
);
// keep the current row data
for
(
int32_t
i
=
0
;
i
<
pSrcBlock
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
pCol
=
taosArrayGet
(
pSrcBlock
->
pDataBlock
,
i
);
bool
isNull
=
colDataIsNull_s
(
pCol
,
rowIndex
);
colDataGetData
(
pCol
,
rowIndex
);
}
}
// allocate the buffer and keep the data of this row into the new allocated buffer
// allocate the buffer and keep the data of this row into the new allocated buffer
pEntryInfo
->
numOfRes
++
;
pEntryInfo
->
numOfRes
++
;
...
@@ -1452,22 +1472,100 @@ void doAddIntoResult(STopBotRes *pRes, int32_t maxSize, void *pData, int32_t row
...
@@ -1452,22 +1472,100 @@ void doAddIntoResult(STopBotRes *pRes, int32_t maxSize, void *pData, int32_t row
if
((
IS_SIGNED_NUMERIC_TYPE
(
type
)
&&
val
.
i
>
pItems
[
0
].
v
.
i
)
||
if
((
IS_SIGNED_NUMERIC_TYPE
(
type
)
&&
val
.
i
>
pItems
[
0
].
v
.
i
)
||
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
)
&&
val
.
u
>
pItems
[
0
].
v
.
u
)
||
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
)
&&
val
.
u
>
pItems
[
0
].
v
.
u
)
||
(
IS_FLOAT_TYPE
(
type
)
&&
val
.
d
>
pItems
[
0
].
v
.
d
))
{
(
IS_FLOAT_TYPE
(
type
)
&&
val
.
d
>
pItems
[
0
].
v
.
d
))
{
// replace the old data and the coresponding tuple data
STopBotResItem
*
pItem
=
&
pItems
[
0
];
STopBotResItem
*
pItem
=
&
pItems
[
0
];
pItem
->
v
=
val
;
pItem
->
v
=
val
;
pItem
->
uid
=
uid
;
pItem
->
uid
=
uid
;
pItem
->
tuplePos
.
pageId
=
-
1
;
// todo set the corresponding tuple data in the disk-based buffer
// save the data of this tuple by over writing the old data
copyTupleData
(
pCtx
,
rowIndex
,
pSrcBlock
,
pItem
);
taosheapadjust
((
void
*
)
pItems
,
sizeof
(
STopBotResItem
),
0
,
pEntryInfo
->
numOfRes
-
1
,
(
const
void
*
)
&
type
,
topBotResComparFn
,
NULL
,
false
);
taosheapadjust
((
void
*
)
pItems
,
sizeof
(
STopBotResItem
),
0
,
pEntryInfo
->
numOfRes
-
1
,
(
const
void
*
)
&
type
,
topBotResComparFn
,
NULL
,
false
);
}
}
}
}
}
}
int32_t
topBotFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
slotId
)
{
void
saveTupleData
(
SqlFunctionCtx
*
pCtx
,
int32_t
rowIndex
,
const
SSDataBlock
*
pSrcBlock
,
STopBotResItem
*
pItem
)
{
SFilePage
*
pPage
=
NULL
;
int32_t
completeRowSize
=
pSrcBlock
->
info
.
rowSize
+
pSrcBlock
->
info
.
numOfCols
*
sizeof
(
bool
);
if
(
pCtx
->
curBufPage
==
-
1
)
{
pPage
=
getNewBufPage
(
pCtx
->
pBuf
,
0
,
&
pCtx
->
curBufPage
);
pPage
->
num
=
sizeof
(
SFilePage
);
}
else
{
pPage
=
getBufPage
(
pCtx
->
pBuf
,
pCtx
->
curBufPage
);
if
(
pPage
->
num
+
completeRowSize
>
getBufPageSize
(
pCtx
->
pBuf
))
{
pPage
=
getNewBufPage
(
pCtx
->
pBuf
,
0
,
&
pCtx
->
curBufPage
);
pPage
->
num
=
sizeof
(
SFilePage
);
}
}
pItem
->
tuplePos
.
pageId
=
pCtx
->
curBufPage
;
// keep the current row data, extract method
int32_t
offset
=
0
;
bool
*
nullList
=
(
bool
*
)((
char
*
)
pPage
+
pPage
->
num
);
char
*
pStart
=
(
char
*
)(
nullList
+
sizeof
(
bool
)
*
pSrcBlock
->
info
.
numOfCols
);
for
(
int32_t
i
=
0
;
i
<
pSrcBlock
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
pCol
=
taosArrayGet
(
pSrcBlock
->
pDataBlock
,
i
);
bool
isNull
=
colDataIsNull_s
(
pCol
,
rowIndex
);
if
(
isNull
)
{
nullList
[
i
]
=
true
;
continue
;
}
char
*
p
=
colDataGetData
(
pCol
,
rowIndex
);
if
(
IS_VAR_DATA_TYPE
(
pCol
->
info
.
type
))
{
memcpy
(
pStart
+
offset
,
p
,
varDataTLen
(
p
));
}
else
{
memcpy
(
pStart
+
offset
,
p
,
pCol
->
info
.
bytes
);
}
offset
+=
pCol
->
info
.
bytes
;
}
pItem
->
tuplePos
.
offset
=
pPage
->
num
;
pPage
->
num
+=
completeRowSize
;
setBufPageDirty
(
pPage
,
true
);
releaseBufPage
(
pCtx
->
pBuf
,
pPage
);
}
void
copyTupleData
(
SqlFunctionCtx
*
pCtx
,
int32_t
rowIndex
,
const
SSDataBlock
*
pSrcBlock
,
STopBotResItem
*
pItem
)
{
SFilePage
*
pPage
=
getBufPage
(
pCtx
->
pBuf
,
pItem
->
tuplePos
.
pageId
);
bool
*
nullList
=
(
bool
*
)((
char
*
)
pPage
+
pItem
->
tuplePos
.
offset
);
char
*
pStart
=
(
char
*
)(
nullList
+
pSrcBlock
->
info
.
numOfCols
*
sizeof
(
bool
));
int32_t
offset
=
0
;
for
(
int32_t
i
=
0
;
i
<
pSrcBlock
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
pCol
=
taosArrayGet
(
pSrcBlock
->
pDataBlock
,
i
);
if
((
nullList
[
i
]
=
colDataIsNull_s
(
pCol
,
rowIndex
))
==
true
)
{
continue
;
}
char
*
p
=
colDataGetData
(
pCol
,
rowIndex
);
if
(
IS_VAR_DATA_TYPE
(
pCol
->
info
.
type
))
{
memcpy
(
pStart
+
offset
,
p
,
varDataTLen
(
p
));
}
else
{
memcpy
(
pStart
+
offset
,
p
,
pCol
->
info
.
bytes
);
}
offset
+=
pCol
->
info
.
bytes
;
}
setBufPageDirty
(
pPage
,
true
);
releaseBufPage
(
pCtx
->
pBuf
,
pPage
);
}
int32_t
topBotFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
SResultRowEntryInfo
*
pEntryInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pEntryInfo
=
GET_RES_INFO
(
pCtx
);
STopBotRes
*
pRes
=
GET_ROWCELL_INTERBUF
(
pEntryInfo
);
STopBotRes
*
pRes
=
GET_ROWCELL_INTERBUF
(
pEntryInfo
);
pEntryInfo
->
complete
=
true
;
pEntryInfo
->
complete
=
true
;
int32_t
type
=
pCtx
->
input
.
pData
[
0
]
->
info
.
type
;
int32_t
type
=
pCtx
->
input
.
pData
[
0
]
->
info
.
type
;
int32_t
slotId
=
pCtx
->
pExpr
->
base
.
resSchema
.
slotId
;
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
slotId
);
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
slotId
);
// todo assign the tag value and the corresponding row data
// todo assign the tag value and the corresponding row data
...
@@ -1476,19 +1574,45 @@ int32_t topBotFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t slotId
...
@@ -1476,19 +1574,45 @@ int32_t topBotFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t slotId
case
TSDB_DATA_TYPE_INT
:
{
case
TSDB_DATA_TYPE_INT
:
{
for
(
int32_t
i
=
0
;
i
<
pEntryInfo
->
numOfRes
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pEntryInfo
->
numOfRes
;
++
i
)
{
STopBotResItem
*
pItem
=
&
pRes
->
pItems
[
i
];
STopBotResItem
*
pItem
=
&
pRes
->
pItems
[
i
];
colDataAppendInt32
(
pCol
,
currentRow
++
,
(
int32_t
*
)
&
pItem
->
v
.
i
);
colDataAppendInt32
(
pCol
,
currentRow
,
(
int32_t
*
)
&
pItem
->
v
.
i
);
int32_t
pageId
=
pItem
->
tuplePos
.
pageId
;
int32_t
pageId
=
pItem
->
tuplePos
.
pageId
;
int32_t
offset
=
pItem
->
tuplePos
.
offset
;
int32_t
offset
=
pItem
->
tuplePos
.
offset
;
if
(
pageId
!=
-
1
)
{
if
(
pItem
->
tuplePos
.
pageId
!=
-
1
)
{
// todo
SFilePage
*
pPage
=
getBufPage
(
pCtx
->
pBuf
,
pageId
);
bool
*
nullList
=
(
bool
*
)((
char
*
)
pPage
+
offset
);
char
*
pStart
=
(
char
*
)(
nullList
+
pCtx
->
pSrcBlock
->
info
.
numOfCols
*
sizeof
(
bool
));
// todo set the offset value to optimize the performance.
for
(
int32_t
j
=
0
;
j
<
pCtx
->
subsidiaries
.
num
;
++
j
)
{
SqlFunctionCtx
*
pc
=
pCtx
->
subsidiaries
.
pCtx
[
j
];
SFunctParam
*
pFuncParam
=
&
pc
->
pExpr
->
base
.
pParam
[
0
];
int32_t
srcSlotId
=
pFuncParam
->
pCol
->
slotId
;
int32_t
dstSlotId
=
pCtx
->
pExpr
->
base
.
resSchema
.
slotId
;
int32_t
ps
=
0
;
for
(
int32_t
k
=
0
;
k
<
srcSlotId
;
++
k
)
{
SColumnInfoData
*
pSrcCol
=
taosArrayGet
(
pCtx
->
pSrcBlock
->
pDataBlock
,
k
);
ps
+=
pSrcCol
->
info
.
bytes
;
}
SColumnInfoData
*
pDstCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
dstSlotId
);
if
(
nullList
[
srcSlotId
])
{
colDataAppendNULL
(
pDstCol
,
currentRow
);
}
else
{
colDataAppend
(
pDstCol
,
currentRow
,
(
pStart
+
ps
),
false
);
}
}
}
}
}
currentRow
+=
1
;
}
break
;
break
;
}
}
}
}
return
pEntryInfo
->
numOfRes
;
return
pEntryInfo
->
numOfRes
;
// return functionFinalize(pCtx, pBlock, slotId);
}
}
source/libs/function/src/udfd.c
浏览文件 @
ba509423
...
@@ -548,7 +548,7 @@ static int32_t udfdParseArgs(int32_t argc, char *argv[]) {
...
@@ -548,7 +548,7 @@ static int32_t udfdParseArgs(int32_t argc, char *argv[]) {
static
int32_t
udfdInitLog
()
{
static
int32_t
udfdInitLog
()
{
char
logName
[
12
]
=
{
0
};
char
logName
[
12
]
=
{
0
};
snprintf
(
logName
,
sizeof
(
logName
),
"%slog"
,
"udfd"
);
snprintf
(
logName
,
sizeof
(
logName
),
"%slog"
,
"udfd"
);
return
taosCreateLog
(
logName
,
1
,
configDir
,
NULL
,
NULL
,
NULL
,
0
);
return
taosCreateLog
(
logName
,
1
,
configDir
,
NULL
,
NULL
,
NULL
,
NULL
,
0
);
}
}
void
udfdCtrlAllocBufCb
(
uv_handle_t
*
handle
,
size_t
suggested_size
,
uv_buf_t
*
buf
)
{
void
udfdCtrlAllocBufCb
(
uv_handle_t
*
handle
,
size_t
suggested_size
,
uv_buf_t
*
buf
)
{
...
@@ -656,7 +656,7 @@ int main(int argc, char *argv[]) {
...
@@ -656,7 +656,7 @@ int main(int argc, char *argv[]) {
return
-
1
;
return
-
1
;
}
}
if
(
taosInitCfg
(
configDir
,
NULL
,
NULL
,
NULL
,
0
)
!=
0
)
{
if
(
taosInitCfg
(
configDir
,
NULL
,
NULL
,
NULL
,
NULL
,
0
)
!=
0
)
{
fnError
(
"failed to start since read config error"
);
fnError
(
"failed to start since read config error"
);
return
-
1
;
return
-
1
;
}
}
...
...
source/libs/function/test/runUdf.c
浏览文件 @
ba509423
...
@@ -31,13 +31,13 @@ static int32_t parseArgs(int32_t argc, char *argv[]) {
...
@@ -31,13 +31,13 @@ static int32_t parseArgs(int32_t argc, char *argv[]) {
static
int32_t
initLog
()
{
static
int32_t
initLog
()
{
char
logName
[
12
]
=
{
0
};
char
logName
[
12
]
=
{
0
};
snprintf
(
logName
,
sizeof
(
logName
),
"%slog"
,
"udfc"
);
snprintf
(
logName
,
sizeof
(
logName
),
"%slog"
,
"udfc"
);
return
taosCreateLog
(
logName
,
1
,
configDir
,
NULL
,
NULL
,
NULL
,
0
);
return
taosCreateLog
(
logName
,
1
,
configDir
,
NULL
,
NULL
,
NULL
,
NULL
,
0
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
parseArgs
(
argc
,
argv
);
parseArgs
(
argc
,
argv
);
initLog
();
initLog
();
if
(
taosInitCfg
(
configDir
,
NULL
,
NULL
,
NULL
,
0
)
!=
0
)
{
if
(
taosInitCfg
(
configDir
,
NULL
,
NULL
,
NULL
,
NULL
,
0
)
!=
0
)
{
fnError
(
"failed to start since read config error"
);
fnError
(
"failed to start since read config error"
);
return
-
1
;
return
-
1
;
}
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
ba509423
...
@@ -3711,8 +3711,10 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
...
@@ -3711,8 +3711,10 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
nodeType
(
pQuery
->
pRoot
)
==
QUERY_NODE_SELECT_STMT
)
{
pQuery
->
precision
=
extractResultTsPrecision
((
SSelectStmt
*
)
pQuery
->
pRoot
);
pQuery
->
precision
=
extractResultTsPrecision
((
SSelectStmt
*
)
pQuery
->
pRoot
);
}
}
}
if
(
NULL
!=
pCxt
->
pDbs
)
{
if
(
NULL
!=
pCxt
->
pDbs
)
{
pQuery
->
pDbList
=
taosArrayInit
(
taosHashGetSize
(
pCxt
->
pDbs
),
TSDB_DB_FNAME_LEN
);
pQuery
->
pDbList
=
taosArrayInit
(
taosHashGetSize
(
pCxt
->
pDbs
),
TSDB_DB_FNAME_LEN
);
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
ba509423
...
@@ -519,8 +519,8 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) {
...
@@ -519,8 +519,8 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) {
res
->
node
.
resType
=
node
->
node
.
resType
;
res
->
node
.
resType
=
node
->
node
.
resType
;
int32_t
type
=
output
.
columnData
->
info
.
type
;
int32_t
type
=
output
.
columnData
->
info
.
type
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
if
(
IS_VAR_DATA_TYPE
(
type
))
{
res
->
datum
.
p
=
output
.
columnData
->
pData
;
res
->
datum
.
p
=
taosMemoryCalloc
(
res
->
node
.
resType
.
bytes
+
VARSTR_HEADER_SIZE
+
1
,
1
)
;
output
.
columnData
->
pData
=
NULL
;
memcpy
(
res
->
datum
.
p
,
output
.
columnData
->
pData
,
varDataTLen
(
output
.
columnData
->
pData
))
;
}
else
{
}
else
{
memcpy
(
nodesGetValueFromNode
(
res
),
output
.
columnData
->
pData
,
tDataTypes
[
type
].
bytes
);
memcpy
(
nodesGetValueFromNode
(
res
),
output
.
columnData
->
pData
,
tDataTypes
[
type
].
bytes
);
}
}
...
...
source/libs/scalar/src/sclfunc.c
浏览文件 @
ba509423
...
@@ -1265,8 +1265,11 @@ int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOut
...
@@ -1265,8 +1265,11 @@ int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOut
}
}
int32_t
timezoneFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
int32_t
timezoneFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
char
output
[
TD_TIMEZONE_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
memcpy
(
varDataVal
(
output
),
tsTimezoneStr
,
TD_TIMEZONE_LEN
);
varDataSetLen
(
output
,
strlen
(
tsTimezoneStr
));
for
(
int32_t
i
=
0
;
i
<
pInput
->
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInput
->
numOfRows
;
++
i
)
{
colDataAppend
(
pOutput
->
columnData
,
i
,
tsTimezoneStr
,
false
);
colDataAppend
(
pOutput
->
columnData
,
i
,
output
,
false
);
}
}
pOutput
->
numOfRows
=
pInput
->
numOfRows
;
pOutput
->
numOfRows
=
pInput
->
numOfRows
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/sync/CMakeLists.txt
浏览文件 @
ba509423
...
@@ -11,7 +11,7 @@ target_link_libraries(
...
@@ -11,7 +11,7 @@ target_link_libraries(
target_include_directories
(
target_include_directories
(
sync
sync
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
PUBLIC
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
)
...
...
source/libs/sync/test/CMakeLists.txt
浏览文件 @
ba509423
...
@@ -199,197 +199,197 @@ target_sources(syncApplyMsgTest
...
@@ -199,197 +199,197 @@ target_sources(syncApplyMsgTest
target_include_directories
(
syncTest
target_include_directories
(
syncTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncEnvTest
target_include_directories
(
syncEnvTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncPingTimerTest
target_include_directories
(
syncPingTimerTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncIOTickQTest
target_include_directories
(
syncIOTickQTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncIOTickPingTest
target_include_directories
(
syncIOTickPingTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncIOSendMsgTest
target_include_directories
(
syncIOSendMsgTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncIOClientTest
target_include_directories
(
syncIOClientTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncIOServerTest
target_include_directories
(
syncIOServerTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncRaftStoreTest
target_include_directories
(
syncRaftStoreTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncEnqTest
target_include_directories
(
syncEnqTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncIndexTest
target_include_directories
(
syncIndexTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncInitTest
target_include_directories
(
syncInitTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncUtilTest
target_include_directories
(
syncUtilTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncVotesGrantedTest
target_include_directories
(
syncVotesGrantedTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncVotesRespondTest
target_include_directories
(
syncVotesRespondTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncIndexMgrTest
target_include_directories
(
syncIndexMgrTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncLogStoreTest
target_include_directories
(
syncLogStoreTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncEntryTest
target_include_directories
(
syncEntryTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncRequestVoteTest
target_include_directories
(
syncRequestVoteTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncRequestVoteReplyTest
target_include_directories
(
syncRequestVoteReplyTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncAppendEntriesTest
target_include_directories
(
syncAppendEntriesTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncAppendEntriesReplyTest
target_include_directories
(
syncAppendEntriesReplyTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncClientRequestTest
target_include_directories
(
syncClientRequestTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncTimeoutTest
target_include_directories
(
syncTimeoutTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncPingTest
target_include_directories
(
syncPingTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncPingReplyTest
target_include_directories
(
syncPingReplyTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncRpcMsgTest
target_include_directories
(
syncRpcMsgTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncPingTimerTest2
target_include_directories
(
syncPingTimerTest2
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncPingSelfTest
target_include_directories
(
syncPingSelfTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncElectTest
target_include_directories
(
syncElectTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncEncodeTest
target_include_directories
(
syncEncodeTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncWriteTest
target_include_directories
(
syncWriteTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncReplicateTest
target_include_directories
(
syncReplicateTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncRefTest
target_include_directories
(
syncRefTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncLogStoreCheck
target_include_directories
(
syncLogStoreCheck
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncRaftCfgTest
target_include_directories
(
syncRaftCfgTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncRespMgrTest
target_include_directories
(
syncRespMgrTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncSnapshotTest
target_include_directories
(
syncSnapshotTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncApplyMsgTest
target_include_directories
(
syncApplyMsgTest
PUBLIC
PUBLIC
"
${
CMAKE
_SOURCE_DIR
}
/include/libs/sync"
"
${
TD
_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
...
...
source/util/src/tarray.c
浏览文件 @
ba509423
...
@@ -476,6 +476,7 @@ void* taosDecodeArray(const void* buf, SArray** pArray, FDecode decode, int32_t
...
@@ -476,6 +476,7 @@ void* taosDecodeArray(const void* buf, SArray** pArray, FDecode decode, int32_t
return
(
void
*
)
buf
;
return
(
void
*
)
buf
;
}
}
// todo remove it
// order array<type *>
// order array<type *>
void
taosArraySortPWithExt
(
SArray
*
pArray
,
__ext_compar_fn_t
fn
,
const
void
*
param
)
{
void
taosArraySortPWithExt
(
SArray
*
pArray
,
__ext_compar_fn_t
fn
,
const
void
*
param
)
{
taosArrayGetSize
(
pArray
)
>
8
?
taosArrayQuickSort
(
pArray
,
fn
,
param
)
:
taosArrayInsertSort
(
pArray
,
fn
,
param
);
taosArrayGetSize
(
pArray
)
>
8
?
taosArrayQuickSort
(
pArray
,
fn
,
param
)
:
taosArrayInsertSort
(
pArray
,
fn
,
param
);
...
...
source/util/src/tconfig.c
浏览文件 @
ba509423
此差异已折叠。
点击以展开。
source/util/src/tenv.c
0 → 100644
浏览文件 @
ba509423
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "tenv.h"
#include "tconfig.h"
static
char
toLowChar
(
char
c
)
{
return
(
c
>
'Z'
||
c
<
'A'
?
c
:
(
c
-
'A'
+
'a'
));
}
int32_t
taosEnvNameToCfgName
(
const
char
*
envNameStr
,
char
*
cfgNameStr
,
int32_t
cfgNameMaxLen
)
{
if
(
envNameStr
==
NULL
||
cfgNameStr
==
NULL
)
return
-
1
;
char
*
p
=
cfgNameStr
;
if
(
envNameStr
[
0
]
!=
'T'
||
envNameStr
[
1
]
!=
'A'
||
envNameStr
[
2
]
!=
'O'
||
envNameStr
[
3
]
!=
'S'
||
envNameStr
[
4
]
!=
'_'
)
{
// if(p != envNameStr) strncpy(p, envNameStr, cfgNameMaxLen - 1);
// p[cfgNameMaxLen - 1] = '\0';
// return strlen(cfgNameStr);
cfgNameStr
[
0
]
=
'\0'
;
return
-
1
;
}
envNameStr
+=
5
;
if
(
*
envNameStr
!=
'\0'
)
{
*
p
=
toLowChar
(
*
envNameStr
);
p
++
;
envNameStr
++
;
}
for
(
size_t
i
=
1
;
i
<
cfgNameMaxLen
&&
*
envNameStr
!=
'\0'
;
i
++
)
{
if
(
*
envNameStr
==
'_'
)
{
envNameStr
++
;
*
p
=
*
envNameStr
;
if
(
*
envNameStr
==
'\0'
)
break
;
}
else
{
*
p
=
toLowChar
(
*
envNameStr
);
}
p
++
;
envNameStr
++
;
}
*
p
=
'\0'
;
return
strlen
(
cfgNameStr
);
}
int32_t
taosEnvToCfg
(
const
char
*
envStr
,
char
*
cfgStr
)
{
if
(
envStr
==
NULL
&&
cfgStr
==
NULL
)
{
return
-
1
;
}
if
(
cfgStr
!=
envStr
)
strcpy
(
cfgStr
,
envStr
);
char
*
p
=
strchr
(
cfgStr
,
'='
);
if
(
p
!=
NULL
)
{
char
buf
[
CFG_NAME_MAX_LEN
];
if
(
*
(
p
+
1
)
==
'\''
)
{
*
(
p
+
1
)
=
' '
;
char
*
pEnd
=
&
cfgStr
[
strlen
(
cfgStr
)
-
1
];
if
(
*
pEnd
==
'\''
)
*
pEnd
=
'\0'
;
}
*
p
=
'\0'
;
int32_t
cfgNameLen
=
taosEnvNameToCfgName
(
cfgStr
,
buf
,
CFG_NAME_MAX_LEN
);
if
(
cfgNameLen
>
0
)
{
memcpy
(
cfgStr
,
buf
,
cfgNameLen
);
memset
(
&
cfgStr
[
cfgNameLen
],
' '
,
p
-
cfgStr
-
cfgNameLen
+
1
);
}
}
return
strlen
(
cfgStr
);
}
\ No newline at end of file
source/util/src/terror.c
浏览文件 @
ba509423
...
@@ -258,7 +258,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_ALREADY_EXIST, "Column already exists
...
@@ -258,7 +258,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_ALREADY_EXIST, "Column already exists
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_COLUMN_NOT_EXIST
,
"Column does not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_COLUMN_NOT_EXIST
,
"Column does not exist"
)
// mnode-infoSchema
// mnode-infoSchema
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_
INFOS_TBL
,
"Invalid information schema
table name"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_
SYS_TABLENAME
,
"Invalid system
table name"
)
// mnode-func
// mnode-func
...
@@ -403,6 +403,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_CHECKSUM, "Invalid msg checksum"
...
@@ -403,6 +403,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_CHECKSUM, "Invalid msg checksum"
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_INVALID_MSGLEN
,
"Invalid msg length"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_INVALID_MSGLEN
,
"Invalid msg length"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_INVALID_MSGTYPE
,
"Invalid msg type"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_INVALID_MSGTYPE
,
"Invalid msg type"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_NOT_LEADER
,
"Sync not leader"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_INTERNAL_ERROR
,
"Sync internal error"
)
// wal
// wal
TAOS_DEFINE_ERROR
(
TSDB_CODE_WAL_APP_ERROR
,
"Unexpected generic error in wal"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_WAL_APP_ERROR
,
"Unexpected generic error in wal"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_WAL_FILE_CORRUPTED
,
"WAL file is corrupted"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_WAL_FILE_CORRUPTED
,
"WAL file is corrupted"
)
...
...
source/util/src/tjson.c
浏览文件 @
ba509423
...
@@ -144,6 +144,22 @@ char* tjsonToUnformattedString(const SJson* pJson) { return cJSON_PrintUnformatt
...
@@ -144,6 +144,22 @@ char* tjsonToUnformattedString(const SJson* pJson) { return cJSON_PrintUnformatt
SJson
*
tjsonGetObjectItem
(
const
SJson
*
pJson
,
const
char
*
pName
)
{
return
cJSON_GetObjectItem
(
pJson
,
pName
);
}
SJson
*
tjsonGetObjectItem
(
const
SJson
*
pJson
,
const
char
*
pName
)
{
return
cJSON_GetObjectItem
(
pJson
,
pName
);
}
int32_t
tjsonGetObjectName
(
const
SJson
*
pJson
,
char
**
pName
)
{
*
pName
=
((
cJSON
*
)
pJson
)
->
string
;
if
(
NULL
==
*
pName
)
{
return
TSDB_CODE_FAILED
;
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
tjsonGetObjectValueString
(
const
SJson
*
pJson
,
char
**
pValueString
)
{
*
pValueString
=
((
cJSON
*
)
pJson
)
->
valuestring
;
if
(
NULL
==
*
pValueString
)
{
return
TSDB_CODE_FAILED
;
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
tjsonGetStringValue
(
const
SJson
*
pJson
,
const
char
*
pName
,
char
*
pVal
)
{
int32_t
tjsonGetStringValue
(
const
SJson
*
pJson
,
const
char
*
pName
,
char
*
pVal
)
{
char
*
p
=
cJSON_GetStringValue
(
tjsonGetObjectItem
((
cJSON
*
)
pJson
,
pName
));
char
*
p
=
cJSON_GetStringValue
(
tjsonGetObjectItem
((
cJSON
*
)
pJson
,
pName
));
if
(
NULL
==
p
)
{
if
(
NULL
==
p
)
{
...
@@ -310,3 +326,5 @@ bool tjsonValidateJson(const char *jIn) {
...
@@ -310,3 +326,5 @@ bool tjsonValidateJson(const char *jIn) {
}
}
return
true
;
return
true
;
}
}
const
char
*
tjsonGetError
()
{
return
cJSON_GetErrorPtr
();
}
\ No newline at end of file
source/util/test/CMakeLists.txt
浏览文件 @
ba509423
...
@@ -31,7 +31,7 @@ ENDIF()
...
@@ -31,7 +31,7 @@ ENDIF()
# TARGET_LINK_LIBRARIES(trefTest util common)
# TARGET_LINK_LIBRARIES(trefTest util common)
#ENDIF ()
#ENDIF ()
INCLUDE_DIRECTORIES
(
${
TD_
COMMUNITY
_DIR
}
/src/util/inc
)
INCLUDE_DIRECTORIES
(
${
TD_
SOURCE
_DIR
}
/src/util/inc
)
# freelistTest
# freelistTest
add_executable
(
freelistTest
""
)
add_executable
(
freelistTest
""
)
...
...
source/util/test/cfgTest.cpp
浏览文件 @
ba509423
...
@@ -32,6 +32,7 @@ TEST_F(CfgTest, 01_Str) {
...
@@ -32,6 +32,7 @@ TEST_F(CfgTest, 01_Str) {
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_CFG_FILE
),
"cfg_file"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_CFG_FILE
),
"cfg_file"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_ENV_FILE
),
"env_file"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_ENV_FILE
),
"env_file"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_ENV_VAR
),
"env_var"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_ENV_VAR
),
"env_var"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_ENV_CMD
),
"env_cmd"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_APOLLO_URL
),
"apollo_url"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_APOLLO_URL
),
"apollo_url"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_ARG_LIST
),
"arg_list"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_ARG_LIST
),
"arg_list"
);
EXPECT_STREQ
(
cfgStypeStr
(
ECfgSrcType
(
1024
)),
"invalid"
);
EXPECT_STREQ
(
cfgStypeStr
(
ECfgSrcType
(
1024
)),
"invalid"
);
...
...
tests/script/sh/massiveTable/compileVersion.sh
浏览文件 @
ba509423
...
@@ -58,6 +58,7 @@ function compileTDengineVersion() {
...
@@ -58,6 +58,7 @@ function compileTDengineVersion() {
cd
${
debugDir
}
cd
${
debugDir
}
cmake ..
cmake ..
make
-j24
make
-j24
make
install
}
}
########################################################################################
########################################################################################
############################### main process ##########################################
############################### main process ##########################################
...
@@ -67,20 +68,5 @@ cd ${projectDir}
...
@@ -67,20 +68,5 @@ cd ${projectDir}
gitPullBranchInfo
$TDengineBrVer
gitPullBranchInfo
$TDengineBrVer
compileTDengineVersion
compileTDengineVersion
taos_dir
=
${
projectDir
}
/debug/build/bin
taosd_dir
=
${
projectDir
}
/debug/build/bin
exec_process_dir
=
${
projectDir
}
/debug/build/bin
rm
-f
/usr/bin/taos
rm
-f
/usr/bin/taosd
rm
-f
/usr/bin/create_table
rm
-f
/usr/bin/tmq_demo
rm
-f
/usr/bin/tmq_sim
ln
-s
$taos_dir
/taos /usr/bin/taos
ln
-s
$taosd_dir
/taosd /usr/bin/taosd
ln
-s
$exec_process_dir
/create_table /usr/bin/create_table
ln
-s
$exec_process_dir
/tmq_demo /usr/bin/tmq_demo
ln
-s
$exec_process_dir
/tmq_sim /usr/bin/tmq_sim
tests/script/tsim/parser/groupby-basic.sim
浏览文件 @
ba509423
...
@@ -115,19 +115,19 @@ endi
...
@@ -115,19 +115,19 @@ endi
if $data00 != 10 then
if $data00 != 10 then
return -1
return -1
endi
endi
if $data
01 !=
0 then
if $data
10 != 1
0 then
return -1
return -1
endi
endi
if $data
1
0 != 10 then
if $data
9
0 != 10 then
return -1
return -1
endi
endi
if $data
11 != 1
then
if $data
01 != 7
then
return -1
return -1
endi
endi
if $data
90 != 10
then
if $data
11 != 6
then
return -1
return -1
endi
endi
if $data91 !=
9
then
if $data91 !=
3
then
return -1
return -1
endi
endi
...
@@ -143,16 +143,16 @@ if $row != 10 then
...
@@ -143,16 +143,16 @@ if $row != 10 then
return -1
return -1
endi
endi
if $data00 != @22-01-01 00:00:00.00
0
@ then
if $data00 != @22-01-01 00:00:00.00
7
@ then
return -1
return -1
endi
endi
if $data01 !=
0
then
if $data01 !=
7
then
return -1
return -1
endi
endi
if $data90 != @22-01-01 00:00:00.00
9
@ then
if $data90 != @22-01-01 00:00:00.00
3
@ then
return -1
return -1
endi
endi
if $data91 !=
9
then
if $data91 !=
3
then
return -1
return -1
endi
endi
...
...
tests/script/tsim/stable/disk.sim
浏览文件 @
ba509423
...
@@ -53,6 +53,7 @@ endi
...
@@ -53,6 +53,7 @@ endi
sql select count(tbcol) from $mt
sql select count(tbcol) from $mt
print select count(tbcol) from $mt ===> $data00
print select count(tbcol) from $mt ===> $data00
if $data00 != $totalNum then
if $data00 != $totalNum then
print expect $totalNum , actual: $data00
return -1
return -1
endi
endi
...
...
tests/tsim/src/simSystem.c
浏览文件 @
ba509423
...
@@ -28,8 +28,8 @@ char simScriptDir[PATH_MAX] = {0};
...
@@ -28,8 +28,8 @@ char simScriptDir[PATH_MAX] = {0};
extern
bool
simExecSuccess
;
extern
bool
simExecSuccess
;
int32_t
simInitCfg
()
{
int32_t
simInitCfg
()
{
taosCreateLog
(
"simlog"
,
1
,
configDir
,
NULL
,
NULL
,
NULL
,
1
);
taosCreateLog
(
"simlog"
,
1
,
configDir
,
NULL
,
NULL
,
NULL
,
NULL
,
1
);
taosInitCfg
(
configDir
,
NULL
,
NULL
,
NULL
,
1
);
taosInitCfg
(
configDir
,
NULL
,
NULL
,
NULL
,
NULL
,
1
);
SConfig
*
pCfg
=
taosGetCfg
();
SConfig
*
pCfg
=
taosGetCfg
();
simDebugFlag
=
cfgGetItem
(
pCfg
,
"simDebugFlag"
)
->
i32
;
simDebugFlag
=
cfgGetItem
(
pCfg
,
"simDebugFlag"
)
->
i32
;
...
...
tools/shell/CMakeLists.txt
浏览文件 @
ba509423
...
@@ -3,7 +3,7 @@ aux_source_directory(src SHELL_SRC)
...
@@ -3,7 +3,7 @@ aux_source_directory(src SHELL_SRC)
add_executable
(
shell
${
SHELL_SRC
}
)
add_executable
(
shell
${
SHELL_SRC
}
)
target_link_libraries
(
target_link_libraries
(
shell
shell
PUBLIC taos
_static
PUBLIC taos
PRIVATE os common transport util
PRIVATE os common transport util
)
)
target_include_directories
(
target_include_directories
(
...
...
tools/shell/src/shellCommand.c
浏览文件 @
ba509423
...
@@ -395,7 +395,7 @@ void shellClearScreen(int32_t ecmd_pos, int32_t cursor_pos) {
...
@@ -395,7 +395,7 @@ void shellClearScreen(int32_t ecmd_pos, int32_t cursor_pos) {
void
shellShowOnScreen
(
SShellCmd
*
cmd
)
{
void
shellShowOnScreen
(
SShellCmd
*
cmd
)
{
struct
winsize
w
;
struct
winsize
w
;
if
(
ioctl
(
0
,
TIOCGWINSZ
,
&
w
)
<
0
||
w
.
ws_col
==
0
||
w
.
ws_row
==
0
)
{
if
(
ioctl
(
0
,
TIOCGWINSZ
,
&
w
)
<
0
||
w
.
ws_col
==
0
||
w
.
ws_row
==
0
)
{
fprintf
(
stderr
,
"No stream device
\n
"
);
//
fprintf(stderr, "No stream device\n");
w
.
ws_col
=
120
;
w
.
ws_col
=
120
;
w
.
ws_row
=
30
;
w
.
ws_row
=
30
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录