Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f3eaca04
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看板
提交
f3eaca04
编写于
5月 14, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into feat--tag-index
上级
422f65ab
9dc392d3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
152 addition
and
133 deletion
+152
-133
source/libs/executor/test/index_executor_tests.cpp
source/libs/executor/test/index_executor_tests.cpp
+26
-0
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+65
-65
source/libs/index/src/index.c
source/libs/index/src/index.c
+28
-61
source/libs/index/test/jsonUT.cc
source/libs/index/test/jsonUT.cc
+13
-0
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+6
-6
tests/script/tsim/query/udf.sim
tests/script/tsim/query/udf.sim
+14
-1
未找到文件。
source/libs/executor/test/index_executor_tests.cpp
浏览文件 @
f3eaca04
...
@@ -200,11 +200,37 @@ TEST(testCase, index_filter) {
...
@@ -200,11 +200,37 @@ TEST(testCase, index_filter) {
doFilterTag
(
opNode
,
result
);
doFilterTag
(
opNode
,
result
);
EXPECT_EQ
(
1
,
taosArrayGetSize
(
result
));
EXPECT_EQ
(
1
,
taosArrayGetSize
(
result
));
taosArrayDestroy
(
result
);
nodesDestroyNode
(
res
);
}
{
SNode
*
pLeft
=
NULL
,
*
pRight
=
NULL
,
*
opNode
=
NULL
,
*
res
=
NULL
;
sifMakeColumnNode
(
&
pLeft
,
"test"
,
"col"
,
COLUMN_TYPE_TAG
,
TSDB_DATA_TYPE_INT
);
sifMakeValueNode
(
&
pRight
,
TSDB_DATA_TYPE_INT
,
&
sifRightV
);
sifMakeOpNode
(
&
opNode
,
OP_TYPE_GREATER_THAN
,
TSDB_DATA_TYPE_INT
,
pLeft
,
pRight
);
SArray
*
result
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
doFilterTag
(
opNode
,
result
);
EXPECT_EQ
(
0
,
taosArrayGetSize
(
result
));
taosArrayDestroy
(
result
);
nodesDestroyNode
(
res
);
}
{
SNode
*
pLeft
=
NULL
,
*
pRight
=
NULL
,
*
opNode
=
NULL
,
*
res
=
NULL
;
sifMakeColumnNode
(
&
pLeft
,
"test"
,
"col"
,
COLUMN_TYPE_TAG
,
TSDB_DATA_TYPE_INT
);
sifMakeValueNode
(
&
pRight
,
TSDB_DATA_TYPE_INT
,
&
sifRightV
);
sifMakeOpNode
(
&
opNode
,
OP_TYPE_GREATER_EQUAL
,
TSDB_DATA_TYPE_DOUBLE
,
pLeft
,
pRight
);
SArray
*
result
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
doFilterTag
(
opNode
,
result
);
EXPECT_EQ
(
0
,
taosArrayGetSize
(
result
));
taosArrayDestroy
(
result
);
taosArrayDestroy
(
result
);
nodesDestroyNode
(
res
);
nodesDestroyNode
(
res
);
}
}
}
}
// add other greater/lower/equal/in compare func test
TEST
(
testCase
,
index_filter_varify
)
{
TEST
(
testCase
,
index_filter_varify
)
{
{
{
SNode
*
pLeft
=
NULL
,
*
pRight
=
NULL
,
*
opNode
=
NULL
,
*
res
=
NULL
;
SNode
*
pLeft
=
NULL
,
*
pRight
=
NULL
,
*
opNode
=
NULL
,
*
res
=
NULL
;
...
...
source/libs/function/src/tudf.c
浏览文件 @
f3eaca04
...
@@ -310,28 +310,28 @@ enum {
...
@@ -310,28 +310,28 @@ enum {
};
};
int64_t
gUdfTaskSeqNum
=
0
;
int64_t
gUdfTaskSeqNum
=
0
;
typedef
struct
SUdf
d
Proxy
{
typedef
struct
SUdf
c
Proxy
{
char
udfdPipeName
[
PATH_MAX
+
UDF_LISTEN_PIPE_NAME_LEN
+
2
];
char
udfdPipeName
[
PATH_MAX
+
UDF_LISTEN_PIPE_NAME_LEN
+
2
];
uv_barrier_t
gUdfI
nitBarrier
;
uv_barrier_t
i
nitBarrier
;
uv_loop_t
gUdfd
Loop
;
uv_loop_t
uv
Loop
;
uv_thread_t
gUdfL
oopThread
;
uv_thread_t
l
oopThread
;
uv_async_t
gUdfL
oopTaskAync
;
uv_async_t
l
oopTaskAync
;
uv_async_t
gUdfL
oopStopAsync
;
uv_async_t
l
oopStopAsync
;
uv_mutex_t
gUdfT
askQueueMutex
;
uv_mutex_t
t
askQueueMutex
;
int8_t
gU
dfcState
;
int8_t
u
dfcState
;
QUEUE
gUdfT
askQueue
;
QUEUE
t
askQueue
;
QUEUE
gU
vProcTaskQueue
;
QUEUE
u
vProcTaskQueue
;
int8_t
initialized
;
int8_t
initialized
;
}
SUdf
d
Proxy
;
}
SUdf
c
Proxy
;
SUdf
d
Proxy
gUdfdProxy
=
{
0
};
SUdf
c
Proxy
gUdfdProxy
=
{
0
};
typedef
struct
SClientUdfUvSession
{
typedef
struct
SClientUdfUvSession
{
SUdf
d
Proxy
*
udfc
;
SUdf
c
Proxy
*
udfc
;
int64_t
severHandle
;
int64_t
severHandle
;
uv_pipe_t
*
udfUvPipe
;
uv_pipe_t
*
udfUvPipe
;
...
@@ -341,7 +341,7 @@ typedef struct SClientUdfUvSession {
...
@@ -341,7 +341,7 @@ typedef struct SClientUdfUvSession {
}
SClientUdfUvSession
;
}
SClientUdfUvSession
;
typedef
struct
SClientUvTaskNode
{
typedef
struct
SClientUvTaskNode
{
SUdf
d
Proxy
*
udfc
;
SUdf
c
Proxy
*
udfc
;
int8_t
type
;
int8_t
type
;
int
errCode
;
int
errCode
;
...
@@ -1055,11 +1055,11 @@ int32_t udfcCreateUvTask(SClientUdfTask *task, int8_t uvTaskType, SClientUvTaskN
...
@@ -1055,11 +1055,11 @@ int32_t udfcCreateUvTask(SClientUdfTask *task, int8_t uvTaskType, SClientUvTaskN
int32_t
udfcQueueUvTask
(
SClientUvTaskNode
*
uvTask
)
{
int32_t
udfcQueueUvTask
(
SClientUvTaskNode
*
uvTask
)
{
fnTrace
(
"queue uv task to event loop, task: %d, %p"
,
uvTask
->
type
,
uvTask
);
fnTrace
(
"queue uv task to event loop, task: %d, %p"
,
uvTask
->
type
,
uvTask
);
SUdf
d
Proxy
*
udfc
=
uvTask
->
udfc
;
SUdf
c
Proxy
*
udfc
=
uvTask
->
udfc
;
uv_mutex_lock
(
&
udfc
->
gUdfT
askQueueMutex
);
uv_mutex_lock
(
&
udfc
->
t
askQueueMutex
);
QUEUE_INSERT_TAIL
(
&
udfc
->
gUdfT
askQueue
,
&
uvTask
->
recvTaskQueue
);
QUEUE_INSERT_TAIL
(
&
udfc
->
t
askQueue
,
&
uvTask
->
recvTaskQueue
);
uv_mutex_unlock
(
&
udfc
->
gUdfT
askQueueMutex
);
uv_mutex_unlock
(
&
udfc
->
t
askQueueMutex
);
uv_async_send
(
&
udfc
->
gUdfL
oopTaskAync
);
uv_async_send
(
&
udfc
->
l
oopTaskAync
);
uv_sem_wait
(
&
uvTask
->
taskSem
);
uv_sem_wait
(
&
uvTask
->
taskSem
);
fnInfo
(
"udfc uv task finished. task: %d, %p"
,
uvTask
->
type
,
uvTask
);
fnInfo
(
"udfc uv task finished. task: %d, %p"
,
uvTask
->
type
,
uvTask
);
...
@@ -1073,7 +1073,7 @@ int32_t udfcStartUvTask(SClientUvTaskNode *uvTask) {
...
@@ -1073,7 +1073,7 @@ int32_t udfcStartUvTask(SClientUvTaskNode *uvTask) {
switch
(
uvTask
->
type
)
{
switch
(
uvTask
->
type
)
{
case
UV_TASK_CONNECT
:
{
case
UV_TASK_CONNECT
:
{
uv_pipe_t
*
pipe
=
taosMemoryMalloc
(
sizeof
(
uv_pipe_t
));
uv_pipe_t
*
pipe
=
taosMemoryMalloc
(
sizeof
(
uv_pipe_t
));
uv_pipe_init
(
&
uvTask
->
udfc
->
gUdfd
Loop
,
pipe
,
0
);
uv_pipe_init
(
&
uvTask
->
udfc
->
uv
Loop
,
pipe
,
0
);
uvTask
->
pipe
=
pipe
;
uvTask
->
pipe
=
pipe
;
SClientUvConn
*
conn
=
taosMemoryCalloc
(
1
,
sizeof
(
SClientUvConn
));
SClientUvConn
*
conn
=
taosMemoryCalloc
(
1
,
sizeof
(
SClientUvConn
));
...
@@ -1113,46 +1113,46 @@ int32_t udfcStartUvTask(SClientUvTaskNode *uvTask) {
...
@@ -1113,46 +1113,46 @@ int32_t udfcStartUvTask(SClientUvTaskNode *uvTask) {
}
}
void
udfClientAsyncCb
(
uv_async_t
*
async
)
{
void
udfClientAsyncCb
(
uv_async_t
*
async
)
{
SUdf
d
Proxy
*
udfc
=
async
->
data
;
SUdf
c
Proxy
*
udfc
=
async
->
data
;
QUEUE
wq
;
QUEUE
wq
;
uv_mutex_lock
(
&
udfc
->
gUdfT
askQueueMutex
);
uv_mutex_lock
(
&
udfc
->
t
askQueueMutex
);
QUEUE_MOVE
(
&
udfc
->
gUdfT
askQueue
,
&
wq
);
QUEUE_MOVE
(
&
udfc
->
t
askQueue
,
&
wq
);
uv_mutex_unlock
(
&
udfc
->
gUdfT
askQueueMutex
);
uv_mutex_unlock
(
&
udfc
->
t
askQueueMutex
);
while
(
!
QUEUE_EMPTY
(
&
wq
))
{
while
(
!
QUEUE_EMPTY
(
&
wq
))
{
QUEUE
*
h
=
QUEUE_HEAD
(
&
wq
);
QUEUE
*
h
=
QUEUE_HEAD
(
&
wq
);
QUEUE_REMOVE
(
h
);
QUEUE_REMOVE
(
h
);
SClientUvTaskNode
*
task
=
QUEUE_DATA
(
h
,
SClientUvTaskNode
,
recvTaskQueue
);
SClientUvTaskNode
*
task
=
QUEUE_DATA
(
h
,
SClientUvTaskNode
,
recvTaskQueue
);
udfcStartUvTask
(
task
);
udfcStartUvTask
(
task
);
QUEUE_INSERT_TAIL
(
&
udfc
->
gU
vProcTaskQueue
,
&
task
->
procTaskQueue
);
QUEUE_INSERT_TAIL
(
&
udfc
->
u
vProcTaskQueue
,
&
task
->
procTaskQueue
);
}
}
}
}
void
cleanUpUvTasks
(
SUdf
d
Proxy
*
udfc
)
{
void
cleanUpUvTasks
(
SUdf
c
Proxy
*
udfc
)
{
fnDebug
(
"clean up uv tasks"
)
fnDebug
(
"clean up uv tasks"
)
QUEUE
wq
;
QUEUE
wq
;
uv_mutex_lock
(
&
udfc
->
gUdfT
askQueueMutex
);
uv_mutex_lock
(
&
udfc
->
t
askQueueMutex
);
QUEUE_MOVE
(
&
udfc
->
gUdfT
askQueue
,
&
wq
);
QUEUE_MOVE
(
&
udfc
->
t
askQueue
,
&
wq
);
uv_mutex_unlock
(
&
udfc
->
gUdfT
askQueueMutex
);
uv_mutex_unlock
(
&
udfc
->
t
askQueueMutex
);
while
(
!
QUEUE_EMPTY
(
&
wq
))
{
while
(
!
QUEUE_EMPTY
(
&
wq
))
{
QUEUE
*
h
=
QUEUE_HEAD
(
&
wq
);
QUEUE
*
h
=
QUEUE_HEAD
(
&
wq
);
QUEUE_REMOVE
(
h
);
QUEUE_REMOVE
(
h
);
SClientUvTaskNode
*
task
=
QUEUE_DATA
(
h
,
SClientUvTaskNode
,
recvTaskQueue
);
SClientUvTaskNode
*
task
=
QUEUE_DATA
(
h
,
SClientUvTaskNode
,
recvTaskQueue
);
if
(
udfc
->
gU
dfcState
==
UDFC_STATE_STOPPING
)
{
if
(
udfc
->
u
dfcState
==
UDFC_STATE_STOPPING
)
{
task
->
errCode
=
TSDB_CODE_UDF_STOPPING
;
task
->
errCode
=
TSDB_CODE_UDF_STOPPING
;
}
}
uv_sem_post
(
&
task
->
taskSem
);
uv_sem_post
(
&
task
->
taskSem
);
}
}
while
(
!
QUEUE_EMPTY
(
&
udfc
->
gU
vProcTaskQueue
))
{
while
(
!
QUEUE_EMPTY
(
&
udfc
->
u
vProcTaskQueue
))
{
QUEUE
*
h
=
QUEUE_HEAD
(
&
udfc
->
gU
vProcTaskQueue
);
QUEUE
*
h
=
QUEUE_HEAD
(
&
udfc
->
u
vProcTaskQueue
);
QUEUE_REMOVE
(
h
);
QUEUE_REMOVE
(
h
);
SClientUvTaskNode
*
task
=
QUEUE_DATA
(
h
,
SClientUvTaskNode
,
procTaskQueue
);
SClientUvTaskNode
*
task
=
QUEUE_DATA
(
h
,
SClientUvTaskNode
,
procTaskQueue
);
if
(
udfc
->
gU
dfcState
==
UDFC_STATE_STOPPING
)
{
if
(
udfc
->
u
dfcState
==
UDFC_STATE_STOPPING
)
{
task
->
errCode
=
TSDB_CODE_UDF_STOPPING
;
task
->
errCode
=
TSDB_CODE_UDF_STOPPING
;
}
}
uv_sem_post
(
&
task
->
taskSem
);
uv_sem_post
(
&
task
->
taskSem
);
...
@@ -1160,28 +1160,28 @@ void cleanUpUvTasks(SUdfdProxy *udfc) {
...
@@ -1160,28 +1160,28 @@ void cleanUpUvTasks(SUdfdProxy *udfc) {
}
}
void
udfStopAsyncCb
(
uv_async_t
*
async
)
{
void
udfStopAsyncCb
(
uv_async_t
*
async
)
{
SUdf
d
Proxy
*
udfc
=
async
->
data
;
SUdf
c
Proxy
*
udfc
=
async
->
data
;
cleanUpUvTasks
(
udfc
);
cleanUpUvTasks
(
udfc
);
if
(
udfc
->
gU
dfcState
==
UDFC_STATE_STOPPING
)
{
if
(
udfc
->
u
dfcState
==
UDFC_STATE_STOPPING
)
{
uv_stop
(
&
udfc
->
gUdfd
Loop
);
uv_stop
(
&
udfc
->
uv
Loop
);
}
}
}
}
void
constructUdfService
(
void
*
argsThread
)
{
void
constructUdfService
(
void
*
argsThread
)
{
SUdf
dProxy
*
udfc
=
(
SUdfdProxy
*
)
argsThread
;
SUdf
cProxy
*
udfc
=
(
SUdfcProxy
*
)
argsThread
;
uv_loop_init
(
&
udfc
->
gUdfd
Loop
);
uv_loop_init
(
&
udfc
->
uv
Loop
);
uv_async_init
(
&
udfc
->
gUdfdLoop
,
&
udfc
->
gUdfL
oopTaskAync
,
udfClientAsyncCb
);
uv_async_init
(
&
udfc
->
uvLoop
,
&
udfc
->
l
oopTaskAync
,
udfClientAsyncCb
);
udfc
->
gUdfL
oopTaskAync
.
data
=
udfc
;
udfc
->
l
oopTaskAync
.
data
=
udfc
;
uv_async_init
(
&
udfc
->
gUdfdLoop
,
&
udfc
->
gUdfL
oopStopAsync
,
udfStopAsyncCb
);
uv_async_init
(
&
udfc
->
uvLoop
,
&
udfc
->
l
oopStopAsync
,
udfStopAsyncCb
);
udfc
->
gUdfL
oopStopAsync
.
data
=
udfc
;
udfc
->
l
oopStopAsync
.
data
=
udfc
;
uv_mutex_init
(
&
udfc
->
gUdfT
askQueueMutex
);
uv_mutex_init
(
&
udfc
->
t
askQueueMutex
);
QUEUE_INIT
(
&
udfc
->
gUdfT
askQueue
);
QUEUE_INIT
(
&
udfc
->
t
askQueue
);
QUEUE_INIT
(
&
udfc
->
gU
vProcTaskQueue
);
QUEUE_INIT
(
&
udfc
->
u
vProcTaskQueue
);
uv_barrier_wait
(
&
udfc
->
gUdfI
nitBarrier
);
uv_barrier_wait
(
&
udfc
->
i
nitBarrier
);
//TODO return value of uv_run
//TODO return value of uv_run
uv_run
(
&
udfc
->
gUdfd
Loop
,
UV_RUN_DEFAULT
);
uv_run
(
&
udfc
->
uv
Loop
,
UV_RUN_DEFAULT
);
uv_loop_close
(
&
udfc
->
gUdfd
Loop
);
uv_loop_close
(
&
udfc
->
uv
Loop
);
}
}
int32_t
udfcOpen
()
{
int32_t
udfcOpen
()
{
...
@@ -1189,14 +1189,14 @@ int32_t udfcOpen() {
...
@@ -1189,14 +1189,14 @@ int32_t udfcOpen() {
if
(
old
==
1
)
{
if
(
old
==
1
)
{
return
0
;
return
0
;
}
}
SUdf
d
Proxy
*
proxy
=
&
gUdfdProxy
;
SUdf
c
Proxy
*
proxy
=
&
gUdfdProxy
;
getUdfdPipeName
(
proxy
->
udfdPipeName
,
sizeof
(
proxy
->
udfdPipeName
));
getUdfdPipeName
(
proxy
->
udfdPipeName
,
sizeof
(
proxy
->
udfdPipeName
));
proxy
->
gU
dfcState
=
UDFC_STATE_STARTNG
;
proxy
->
u
dfcState
=
UDFC_STATE_STARTNG
;
uv_barrier_init
(
&
proxy
->
gUdfI
nitBarrier
,
2
);
uv_barrier_init
(
&
proxy
->
i
nitBarrier
,
2
);
uv_thread_create
(
&
proxy
->
gUdfL
oopThread
,
constructUdfService
,
proxy
);
uv_thread_create
(
&
proxy
->
l
oopThread
,
constructUdfService
,
proxy
);
atomic_store_8
(
&
proxy
->
gU
dfcState
,
UDFC_STATE_READY
);
atomic_store_8
(
&
proxy
->
u
dfcState
,
UDFC_STATE_READY
);
proxy
->
gU
dfcState
=
UDFC_STATE_READY
;
proxy
->
u
dfcState
=
UDFC_STATE_READY
;
uv_barrier_wait
(
&
proxy
->
gUdfI
nitBarrier
);
uv_barrier_wait
(
&
proxy
->
i
nitBarrier
);
fnInfo
(
"udfc initialized"
)
fnInfo
(
"udfc initialized"
)
return
0
;
return
0
;
}
}
...
@@ -1207,13 +1207,13 @@ int32_t udfcClose() {
...
@@ -1207,13 +1207,13 @@ int32_t udfcClose() {
return
0
;
return
0
;
}
}
SUdf
d
Proxy
*
udfc
=
&
gUdfdProxy
;
SUdf
c
Proxy
*
udfc
=
&
gUdfdProxy
;
udfc
->
gU
dfcState
=
UDFC_STATE_STOPPING
;
udfc
->
u
dfcState
=
UDFC_STATE_STOPPING
;
uv_async_send
(
&
udfc
->
gUdfL
oopStopAsync
);
uv_async_send
(
&
udfc
->
l
oopStopAsync
);
uv_thread_join
(
&
udfc
->
gUdfL
oopThread
);
uv_thread_join
(
&
udfc
->
l
oopThread
);
uv_mutex_destroy
(
&
udfc
->
gUdfT
askQueueMutex
);
uv_mutex_destroy
(
&
udfc
->
t
askQueueMutex
);
uv_barrier_destroy
(
&
udfc
->
gUdfI
nitBarrier
);
uv_barrier_destroy
(
&
udfc
->
i
nitBarrier
);
udfc
->
gU
dfcState
=
UDFC_STATE_INITAL
;
udfc
->
u
dfcState
=
UDFC_STATE_INITAL
;
fnInfo
(
"udfc cleaned up"
);
fnInfo
(
"udfc cleaned up"
);
return
0
;
return
0
;
}
}
...
@@ -1236,7 +1236,7 @@ int32_t udfcRunUdfUvTask(SClientUdfTask *task, int8_t uvTaskType) {
...
@@ -1236,7 +1236,7 @@ int32_t udfcRunUdfUvTask(SClientUdfTask *task, int8_t uvTaskType) {
int32_t
setupUdf
(
char
udfName
[],
UdfcFuncHandle
*
funcHandle
)
{
int32_t
setupUdf
(
char
udfName
[],
UdfcFuncHandle
*
funcHandle
)
{
fnInfo
(
"udfc setup udf. udfName: %s"
,
udfName
);
fnInfo
(
"udfc setup udf. udfName: %s"
,
udfName
);
if
(
gUdfdProxy
.
gU
dfcState
!=
UDFC_STATE_READY
)
{
if
(
gUdfdProxy
.
u
dfcState
!=
UDFC_STATE_READY
)
{
return
TSDB_CODE_UDF_INVALID_STATE
;
return
TSDB_CODE_UDF_INVALID_STATE
;
}
}
SClientUdfTask
*
task
=
taosMemoryCalloc
(
1
,
sizeof
(
SClientUdfTask
));
SClientUdfTask
*
task
=
taosMemoryCalloc
(
1
,
sizeof
(
SClientUdfTask
));
...
@@ -1484,7 +1484,7 @@ int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) {
...
@@ -1484,7 +1484,7 @@ int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) {
SSDataBlock
tempBlock
=
{
0
};
SSDataBlock
tempBlock
=
{
0
};
tempBlock
.
info
.
numOfCols
=
numOfCols
;
tempBlock
.
info
.
numOfCols
=
numOfCols
;
tempBlock
.
info
.
rows
=
numOf
Rows
;
tempBlock
.
info
.
rows
=
pInput
->
total
Rows
;
tempBlock
.
info
.
uid
=
pInput
->
uid
;
tempBlock
.
info
.
uid
=
pInput
->
uid
;
bool
hasVarCol
=
false
;
bool
hasVarCol
=
false
;
tempBlock
.
pDataBlock
=
taosArrayInit
(
numOfCols
,
sizeof
(
SColumnInfoData
));
tempBlock
.
pDataBlock
=
taosArrayInit
(
numOfCols
,
sizeof
(
SColumnInfoData
));
...
...
source/libs/index/src/index.c
浏览文件 @
f3eaca04
...
@@ -27,10 +27,33 @@
...
@@ -27,10 +27,33 @@
#endif
#endif
#define INDEX_NUM_OF_THREADS 4
#define INDEX_NUM_OF_THREADS 4
#define INDEX_QUEUE_SIZE
200
#define INDEX_QUEUE_SIZE 200
void
*
indexQhandle
=
NULL
;
void
*
indexQhandle
=
NULL
;
#define INDEX_DATA_BOOL_NULL 0x02
#define INDEX_DATA_TINYINT_NULL 0x80
#define INDEX_DATA_SMALLINT_NULL 0x8000
#define INDEX_DATA_INT_NULL 0x80000000L
#define INDEX_DATA_BIGINT_NULL 0x8000000000000000L
#define INDEX_DATA_TIMESTAMP_NULL TSDB_DATA_BIGINT_NULL
#define INDEX_DATA_FLOAT_NULL 0x7FF00000 // it is an NAN
#define INDEX_DATA_DOUBLE_NULL 0x7FFFFF0000000000L // an NAN
#define INDEX_DATA_NCHAR_NULL 0xFFFFFFFF
#define INDEX_DATA_BINARY_NULL 0xFF
#define INDEX_DATA_JSON_NULL 0xFFFFFFFF
#define INDEX_DATA_JSON_null 0xFFFFFFFE
#define INDEX_DATA_JSON_NOT_NULL 0x01
#define INDEX_DATA_UTINYINT_NULL 0xFF
#define INDEX_DATA_USMALLINT_NULL 0xFFFF
#define INDEX_DATA_UINT_NULL 0xFFFFFFFF
#define INDEX_DATA_UBIGINT_NULL 0xFFFFFFFFFFFFFFFFL
#define INDEX_DATA_NULL_STR "NULL"
#define INDEX_DATA_NULL_STR_L "null"
void
indexInit
()
{
void
indexInit
()
{
// refactor later
// refactor later
indexQhandle
=
taosInitScheduler
(
INDEX_QUEUE_SIZE
,
INDEX_NUM_OF_THREADS
,
"index"
);
indexQhandle
=
taosInitScheduler
(
INDEX_QUEUE_SIZE
,
INDEX_NUM_OF_THREADS
,
"index"
);
...
@@ -67,12 +90,6 @@ int indexOpen(SIndexOpts* opts, const char* path, SIndex** index) {
...
@@ -67,12 +90,6 @@ int indexOpen(SIndexOpts* opts, const char* path, SIndex** index) {
return
-
1
;
return
-
1
;
}
}
#ifdef USE_LUCENE
index_t
*
index
=
index_open
(
path
);
sIdx
->
index
=
index
;
#endif
#ifdef USE_INVERTED_INDEX
// sIdx->cache = (void*)indexCacheCreate(sIdx);
// sIdx->cache = (void*)indexCacheCreate(sIdx);
sIdx
->
tindex
=
indexTFileCreate
(
path
);
sIdx
->
tindex
=
indexTFileCreate
(
path
);
if
(
sIdx
->
tindex
==
NULL
)
{
if
(
sIdx
->
tindex
==
NULL
)
{
...
@@ -85,7 +102,6 @@ int indexOpen(SIndexOpts* opts, const char* path, SIndex** index) {
...
@@ -85,7 +102,6 @@ int indexOpen(SIndexOpts* opts, const char* path, SIndex** index) {
taosThreadMutexInit
(
&
sIdx
->
mtx
,
NULL
);
taosThreadMutexInit
(
&
sIdx
->
mtx
,
NULL
);
*
index
=
sIdx
;
*
index
=
sIdx
;
return
0
;
return
0
;
#endif
END:
END:
if
(
sIdx
!=
NULL
)
{
if
(
sIdx
!=
NULL
)
{
...
@@ -97,12 +113,6 @@ END:
...
@@ -97,12 +113,6 @@ END:
}
}
void
indexClose
(
SIndex
*
sIdx
)
{
void
indexClose
(
SIndex
*
sIdx
)
{
#ifdef USE_LUCENE
index_close
(
sIdex
->
index
);
sIdx
->
index
=
NULL
;
#endif
#ifdef USE_INVERTED_INDEX
void
*
iter
=
taosHashIterate
(
sIdx
->
colObj
,
NULL
);
void
*
iter
=
taosHashIterate
(
sIdx
->
colObj
,
NULL
);
while
(
iter
)
{
while
(
iter
)
{
IndexCache
**
pCache
=
iter
;
IndexCache
**
pCache
=
iter
;
...
@@ -114,31 +124,12 @@ void indexClose(SIndex* sIdx) {
...
@@ -114,31 +124,12 @@ void indexClose(SIndex* sIdx) {
taosHashCleanup
(
sIdx
->
colObj
);
taosHashCleanup
(
sIdx
->
colObj
);
taosThreadMutexDestroy
(
&
sIdx
->
mtx
);
taosThreadMutexDestroy
(
&
sIdx
->
mtx
);
indexTFileDestroy
(
sIdx
->
tindex
);
indexTFileDestroy
(
sIdx
->
tindex
);
#endif
taosMemoryFree
(
sIdx
->
path
);
taosMemoryFree
(
sIdx
->
path
);
taosMemoryFree
(
sIdx
);
taosMemoryFree
(
sIdx
);
return
;
return
;
}
}
int
indexPut
(
SIndex
*
index
,
SIndexMultiTerm
*
fVals
,
uint64_t
uid
)
{
int
indexPut
(
SIndex
*
index
,
SIndexMultiTerm
*
fVals
,
uint64_t
uid
)
{
#ifdef USE_LUCENE
index_document_t
*
doc
=
index_document_create
();
char
buf
[
16
]
=
{
0
};
sprintf
(
buf
,
"%d"
,
uid
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
fVals
);
i
++
)
{
SIndexTerm
*
p
=
taosArrayGetP
(
fVals
,
i
);
index_document_add
(
doc
,
(
const
char
*
)(
p
->
key
),
p
->
nKey
,
(
const
char
*
)(
p
->
val
),
p
->
nVal
,
1
);
}
index_document_add
(
doc
,
NULL
,
0
,
buf
,
strlen
(
buf
),
0
);
index_put
(
index
->
index
,
doc
);
index_document_destroy
(
doc
);
#endif
#ifdef USE_INVERTED_INDEX
// TODO(yihao): reduce the lock range
// TODO(yihao): reduce the lock range
taosThreadMutexLock
(
&
index
->
mtx
);
taosThreadMutexLock
(
&
index
->
mtx
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
fVals
);
i
++
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
fVals
);
i
++
)
{
...
@@ -170,12 +161,9 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
...
@@ -170,12 +161,9 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
return
ret
;
return
ret
;
}
}
}
}
#endif
return
0
;
return
0
;
}
}
int
indexSearch
(
SIndex
*
index
,
SIndexMultiTermQuery
*
multiQuerys
,
SArray
*
result
)
{
int
indexSearch
(
SIndex
*
index
,
SIndexMultiTermQuery
*
multiQuerys
,
SArray
*
result
)
{
#ifdef USE_INVERTED_INDEX
EIndexOperatorType
opera
=
multiQuerys
->
opera
;
// relation of querys
EIndexOperatorType
opera
=
multiQuerys
->
opera
;
// relation of querys
SArray
*
iRslts
=
taosArrayInit
(
4
,
POINTER_BYTES
);
SArray
*
iRslts
=
taosArrayInit
(
4
,
POINTER_BYTES
);
...
@@ -188,35 +176,14 @@ int indexSearch(SIndex* index, SIndexMultiTermQuery* multiQuerys, SArray* result
...
@@ -188,35 +176,14 @@ int indexSearch(SIndex* index, SIndexMultiTermQuery* multiQuerys, SArray* result
}
}
indexMergeFinalResults
(
iRslts
,
opera
,
result
);
indexMergeFinalResults
(
iRslts
,
opera
,
result
);
indexInterResultsDestroy
(
iRslts
);
indexInterResultsDestroy
(
iRslts
);
#endif
return
0
;
return
0
;
}
}
int
indexDelete
(
SIndex
*
index
,
SIndexMultiTermQuery
*
query
)
{
int
indexDelete
(
SIndex
*
index
,
SIndexMultiTermQuery
*
query
)
{
return
1
;
}
#ifdef USE_INVERTED_INDEX
int
indexRebuild
(
SIndex
*
index
,
SIndexOpts
*
opts
)
{
return
0
;
}
#endif
return
1
;
SIndexOpts
*
indexOptsCreate
()
{
return
NULL
;
}
}
void
indexOptsDestroy
(
SIndexOpts
*
opts
)
{
return
;
}
int
indexRebuild
(
SIndex
*
index
,
SIndexOpts
*
opts
)
{
#ifdef USE_INVERTED_INDEX
#endif
return
0
;
}
SIndexOpts
*
indexOptsCreate
()
{
#ifdef USE_LUCENE
#endif
return
NULL
;
}
void
indexOptsDestroy
(
SIndexOpts
*
opts
)
{
#ifdef USE_LUCENE
#endif
return
;
}
/*
/*
* @param: oper
* @param: oper
*
*
...
...
source/libs/index/test/jsonUT.cc
浏览文件 @
f3eaca04
...
@@ -403,6 +403,19 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache) {
...
@@ -403,6 +403,19 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache) {
EXPECT_EQ
(
1000
,
taosArrayGetSize
(
result
));
EXPECT_EQ
(
1000
,
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
indexMultiTermQueryDestroy
(
mq
);
}
}
{
std
::
string
colName
(
"other_column"
);
std
::
string
colVal
(
"100"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
1000
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
{
std
::
string
colName
(
"test1"
);
std
::
string
colName
(
"test1"
);
std
::
string
colVal
(
"10"
);
std
::
string
colVal
(
"10"
);
...
...
source/libs/transport/src/transCli.c
浏览文件 @
f3eaca04
...
@@ -145,9 +145,9 @@ static void cliWalkCb(uv_handle_t* handle, void* arg);
...
@@ -145,9 +145,9 @@ static void cliWalkCb(uv_handle_t* handle, void* arg);
} while (0)
} while (0)
#define CONN_HOST_THREAD_INDEX(conn) (conn ? ((SCliConn*)conn)->hThrdIdx : -1)
#define CONN_HOST_THREAD_INDEX(conn) (conn ? ((SCliConn*)conn)->hThrdIdx : -1)
#define CONN_PERSIST_TIME(para)
(para * 1000 * 10)
#define CONN_PERSIST_TIME(para) (para * 1000 * 10)
#define CONN_GET_HOST_THREAD(conn)
(conn ? ((SCliConn*)conn)->hostThrd : NULL)
#define CONN_GET_HOST_THREAD(conn) (conn ? ((SCliConn*)conn)->hostThrd : NULL)
#define CONN_GET_INST_LABEL(conn)
(((STrans*)(((SCliThrdObj*)(conn)->hostThrd)->pTransInst))->label)
#define CONN_GET_INST_LABEL(conn) (((STrans*)(((SCliThrdObj*)(conn)->hostThrd)->pTransInst))->label)
#define CONN_SHOULD_RELEASE(conn, head) \
#define CONN_SHOULD_RELEASE(conn, head) \
do { \
do { \
if ((head)->release == 1 && (head->msgLen) == sizeof(*head)) { \
if ((head)->release == 1 && (head->msgLen) == sizeof(*head)) { \
...
@@ -223,11 +223,11 @@ static void cliWalkCb(uv_handle_t* handle, void* arg);
...
@@ -223,11 +223,11 @@ static void cliWalkCb(uv_handle_t* handle, void* arg);
#define CONN_RELEASE_BY_SERVER(conn) \
#define CONN_RELEASE_BY_SERVER(conn) \
(((conn)->status == ConnRelease || (conn)->status == ConnInPool) && T_REF_VAL_GET(conn) == 1)
(((conn)->status == ConnRelease || (conn)->status == ConnInPool) && T_REF_VAL_GET(conn) == 1)
#define REQUEST_NO_RESP(msg)
((msg)->noResp == 1)
#define REQUEST_NO_RESP(msg) ((msg)->noResp == 1)
#define REQUEST_PERSIS_HANDLE(msg)
((msg)->persistHandle == 1)
#define REQUEST_PERSIS_HANDLE(msg) ((msg)->persistHandle == 1)
#define REQUEST_RELEASE_HANDLE(cmsg) ((cmsg)->type == Release)
#define REQUEST_RELEASE_HANDLE(cmsg) ((cmsg)->type == Release)
#define EPSET_GET_INUSE_IP(epSet)
((epSet)->eps[(epSet)->inUse].fqdn)
#define EPSET_GET_INUSE_IP(epSet) ((epSet)->eps[(epSet)->inUse].fqdn)
#define EPSET_GET_INUSE_PORT(epSet) ((epSet)->eps[(epSet)->inUse].port)
#define EPSET_GET_INUSE_PORT(epSet) ((epSet)->eps[(epSet)->inUse].port)
static
void
*
cliWorkThread
(
void
*
arg
);
static
void
*
cliWorkThread
(
void
*
arg
);
...
...
tests/script/tsim/query/udf.sim
浏览文件 @
f3eaca04
...
@@ -109,6 +109,7 @@ if $data01 != 18.547236991 then
...
@@ -109,6 +109,7 @@ if $data01 != 18.547236991 then
endi
endi
sql select udf2(udf1(f2-f1)), udf2(udf1(f2/f1)) from t2;
sql select udf2(udf1(f2-f1)), udf2(udf1(f2/f1)) from t2;
print $rows , $data00 , $data01
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
...
@@ -118,7 +119,19 @@ endi
...
@@ -118,7 +119,19 @@ endi
if $data01 != 152.420471066 then
if $data01 != 152.420471066 then
return -1
return -1
endi
endi
print $rows , $data00 , $data01
sql select udf2(f2) from udf.t2 group by 1-udf1(f1);
print $rows , $data00 , $data10
if $rows != 2 then
return -1
endi
if $data00 != 2.000000000 then
return -1
endi
if $data10 != 12.083045974 then
return -1
endi
sql drop function udf1;
sql drop function udf1;
sql show functions;
sql show functions;
if $rows != 1 then
if $rows != 1 then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录