Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a98ff93c
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
a98ff93c
编写于
2月 26, 2023
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into fix/TD-22762
上级
2aa41b76
e4e7f1ec
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
164 addition
and
5 deletion
+164
-5
examples/JDBC/springbootdemo/readme.md
examples/JDBC/springbootdemo/readme.md
+7
-0
examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
...com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
+8
-2
examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java
...a/com/taosdata/example/springbootdemo/domain/Weather.java
+30
-0
examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java
...osdata/example/springbootdemo/service/WeatherService.java
+2
-0
include/os/osMemory.h
include/os/osMemory.h
+4
-1
source/client/jni/com_taosdata_jdbc_tmq_TMQConnector.h
source/client/jni/com_taosdata_jdbc_tmq_TMQConnector.h
+3
-0
source/client/src/clientJniConnector.c
source/client/src/clientJniConnector.c
+1
-0
source/client/src/clientTmqConnector.c
source/client/src/clientTmqConnector.c
+66
-0
source/util/src/tutil.c
source/util/src/tutil.c
+1
-1
source/util/test/utilTests.cpp
source/util/test/utilTests.cpp
+5
-1
tests/parallel_test/cases.task
tests/parallel_test/cases.task
+1
-0
tests/script/tsim/query/tagLikeFilter.sim
tests/script/tsim/query/tagLikeFilter.sim
+36
-0
未找到文件。
examples/JDBC/springbootdemo/readme.md
浏览文件 @
a98ff93c
## TDengine SpringBoot + Mybatis Demo
## 需要提前创建 test 数据库
```
$ taos -s 'create database if not exists test'
$ curl http://localhost:8080/weather/init
```
### 配置 application.properties
```
properties
# datasource config
...
...
examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
浏览文件 @
a98ff93c
...
...
@@ -7,6 +7,7 @@
<id
column=
"ts"
jdbcType=
"TIMESTAMP"
property=
"ts"
/>
<result
column=
"temperature"
jdbcType=
"FLOAT"
property=
"temperature"
/>
<result
column=
"humidity"
jdbcType=
"FLOAT"
property=
"humidity"
/>
<result
column=
"bytes"
jdbcType=
"BINARY"
property=
"bytes"
/>
</resultMap>
<select
id=
"lastOne"
resultType=
"java.util.Map"
>
...
...
@@ -36,6 +37,11 @@
binary
(
64
),
bytes
binary
(
64
)) tags
(
location nchar
...
...
@@ -63,8 +69,8 @@
</select>
<insert
id=
"insert"
parameterType=
"com.taosdata.example.springbootdemo.domain.Weather"
>
insert into test.t#{groupId} (ts, temperature, humidity, note)
values (#{ts}, ${temperature}, ${humidity}, #{note})
insert into test.t#{groupId} (ts, temperature, humidity, note
, bytes
)
values (#{ts}, ${temperature}, ${humidity}, #{note}
, #{bytes}
)
</insert>
<select
id=
"getSubTables"
resultType=
"String"
>
...
...
examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java
浏览文件 @
a98ff93c
...
...
@@ -2,6 +2,7 @@ package com.taosdata.example.springbootdemo.domain;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
java.nio.charset.StandardCharsets
;
import
java.sql.Timestamp
;
public
class
Weather
{
...
...
@@ -12,6 +13,9 @@ public class Weather {
private
Float
humidity
;
private
String
location
;
private
String
note
;
// In rest mode, the byte[] type is not recommended.
// UTF-8 is used to encode the byte arrays, that result may affect the SQL correctness
private
byte
[]
bytes
;
private
int
groupId
;
public
Weather
()
{
...
...
@@ -70,4 +74,30 @@ public class Weather {
public
void
setNote
(
String
note
)
{
this
.
note
=
note
;
}
public
byte
[]
getBytes
()
{
return
bytes
;
}
public
void
setBytes
(
byte
[]
bytes
)
{
this
.
bytes
=
bytes
;
}
@Override
public
String
toString
()
{
final
StringBuilder
sb
=
new
StringBuilder
(
"Weather{"
);
sb
.
append
(
"ts="
).
append
(
ts
);
sb
.
append
(
", temperature="
).
append
(
temperature
);
sb
.
append
(
", humidity="
).
append
(
humidity
);
sb
.
append
(
", location='"
).
append
(
location
).
append
(
'\''
);
sb
.
append
(
", note='"
).
append
(
note
).
append
(
'\''
);
sb
.
append
(
", bytes -> string="
);
if
(
bytes
==
null
)
sb
.
append
(
"null"
);
else
{
sb
.
append
(
new
String
(
bytes
,
StandardCharsets
.
UTF_8
));
}
sb
.
append
(
", groupId="
).
append
(
groupId
);
sb
.
append
(
'}'
);
return
sb
.
toString
();
}
}
examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java
浏览文件 @
a98ff93c
...
...
@@ -5,6 +5,7 @@ import com.taosdata.example.springbootdemo.domain.Weather;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.nio.charset.StandardCharsets
;
import
java.sql.Timestamp
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -30,6 +31,7 @@ public class WeatherService {
weather
.
setLocation
(
locations
[
random
.
nextInt
(
locations
.
length
)]);
weather
.
setGroupId
(
i
%
locations
.
length
);
weather
.
setNote
(
"note-"
+
i
);
weather
.
setBytes
(
locations
[
random
.
nextInt
(
locations
.
length
)].
getBytes
(
StandardCharsets
.
UTF_8
));
weatherMapper
.
createTable
(
weather
);
count
+=
weatherMapper
.
insert
(
weather
);
}
...
...
include/os/osMemory.h
浏览文件 @
a98ff93c
...
...
@@ -29,9 +29,12 @@ extern "C" {
#define calloc CALLOC_FUNC_TAOS_FORBID
#define realloc REALLOC_FUNC_TAOS_FORBID
#define free FREE_FUNC_TAOS_FORBID
#ifdef strdup
#undef strdup
#define strdup STRDUP_FUNC_TAOS_FORBID
#endif
// ifndef ALLOW_FORBID_FUNC
#endif
#endif // ifndef ALLOW_FORBID_FUNC
#endif // if !defined(WINDOWS)
int32_t
taosMemoryDbgInit
();
...
...
source/client/jni/com_taosdata_jdbc_tmq_TMQConnector.h
浏览文件 @
a98ff93c
...
...
@@ -99,6 +99,9 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqCommitSync(JNI
*/
JNIEXPORT
void
JNICALL
Java_com_taosdata_jdbc_tmq_TMQConnector_tmqCommitAsync
(
JNIEnv
*
,
jobject
,
jlong
,
jlong
,
jobject
);
JNIEXPORT
void
JNICALL
Java_com_taosdata_jdbc_tmq_TMQConnector_consumerCommitAsync
(
JNIEnv
*
,
jobject
,
jlong
,
jlong
,
jobject
);
/*
* Class: com_taosdata_jdbc_tmq_TMQConnector
* Method: tmqUnsubscribeImp
...
...
source/client/src/clientJniConnector.c
浏览文件 @
a98ff93c
...
...
@@ -56,6 +56,7 @@ jmethodID g_createConsumerErrorCallback;
jmethodID
g_topicListCallback
;
jclass
g_consumerClass
;
// deprecated
jmethodID
g_commitCallback
;
void
jniGetGlobalMethod
(
JNIEnv
*
env
)
{
...
...
source/client/src/clientTmqConnector.c
浏览文件 @
a98ff93c
...
...
@@ -17,6 +17,36 @@
#include "jniCommon.h"
#include "taos.h"
int
__init_tmq
=
0
;
jmethodID
g_offsetCallback
;
void
tmqGlobalMethod
(
JNIEnv
*
env
)
{
// make sure init function executed once
switch
(
atomic_val_compare_exchange_32
(
&
__init_tmq
,
0
,
1
))
{
case
0
:
break
;
case
1
:
do
{
taosMsleep
(
0
);
}
while
(
atomic_load_32
(
&
__init_tmq
)
==
1
);
case
2
:
return
;
}
if
(
g_vm
==
NULL
)
{
(
*
env
)
->
GetJavaVM
(
env
,
&
g_vm
);
}
jclass
offset
=
(
*
env
)
->
FindClass
(
env
,
"com/taosdata/jdbc/tmq/OffsetWaitCallback"
);
jclass
g_offsetCallbackClass
=
(
*
env
)
->
NewGlobalRef
(
env
,
offset
);
g_offsetCallback
=
(
*
env
)
->
GetMethodID
(
env
,
g_offsetCallbackClass
,
"commitCallbackHandler"
,
"(I)V"
);
(
*
env
)
->
DeleteLocalRef
(
env
,
offset
);
atomic_store_32
(
&
__init_tmq
,
2
);
jniDebug
(
"tmq method register finished"
);
}
// deprecated
void
commit_cb
(
tmq_t
*
tmq
,
int32_t
code
,
void
*
param
)
{
JNIEnv
*
env
=
NULL
;
int
status
=
(
*
g_vm
)
->
GetEnv
(
g_vm
,
(
void
**
)
&
env
,
JNI_VERSION_1_6
);
...
...
@@ -40,6 +70,28 @@ void commit_cb(tmq_t *tmq, int32_t code, void *param) {
env
=
NULL
;
}
void
consumer_callback
(
tmq_t
*
tmq
,
int32_t
code
,
void
*
param
)
{
JNIEnv
*
env
=
NULL
;
int
status
=
(
*
g_vm
)
->
GetEnv
(
g_vm
,
(
void
**
)
&
env
,
JNI_VERSION_1_6
);
bool
needDetach
=
false
;
if
(
status
<
0
)
{
if
((
*
g_vm
)
->
AttachCurrentThread
(
g_vm
,
(
void
**
)
&
env
,
NULL
)
!=
0
)
{
return
;
}
needDetach
=
true
;
}
jobject
obj
=
(
jobject
)
param
;
(
*
env
)
->
CallVoidMethod
(
env
,
obj
,
g_offsetCallback
,
code
);
(
*
env
)
->
DeleteGlobalRef
(
env
,
obj
);
param
=
NULL
;
if
(
needDetach
)
{
(
*
g_vm
)
->
DetachCurrentThread
(
g_vm
);
}
env
=
NULL
;
}
JNIEXPORT
jlong
JNICALL
Java_com_taosdata_jdbc_tmq_TMQConnector_tmqConfNewImp
(
JNIEnv
*
env
,
jobject
jobj
)
{
tmq_conf_t
*
conf
=
tmq_conf_new
();
jniGetGlobalMethod
(
env
);
...
...
@@ -201,6 +253,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqCommitSync(JNI
return
tmq_commit_sync
(
tmq
,
res
);
}
// deprecated
JNIEXPORT
void
JNICALL
Java_com_taosdata_jdbc_tmq_TMQConnector_tmqCommitAsync
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jtmq
,
jlong
jres
,
jobject
consumer
)
{
tmq_t
*
tmq
=
(
tmq_t
*
)
jtmq
;
...
...
@@ -213,6 +266,19 @@ JNIEXPORT void JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqCommitAsync(JN
tmq_commit_async
(
tmq
,
res
,
commit_cb
,
consumer
);
}
JNIEXPORT
void
JNICALL
Java_com_taosdata_jdbc_tmq_TMQConnector_consumerCommitAsync
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jtmq
,
jlong
jres
,
jobject
offset
)
{
tmqGlobalMethod
(
env
);
tmq_t
*
tmq
=
(
tmq_t
*
)
jtmq
;
if
(
tmq
==
NULL
)
{
jniError
(
"jobj:%p, tmq is closed"
,
jobj
);
return
;
}
TAOS_RES
*
res
=
(
TAOS_RES
*
)
jres
;
offset
=
(
*
env
)
->
NewGlobalRef
(
env
,
offset
);
tmq_commit_async
(
tmq
,
res
,
consumer_callback
,
offset
);
}
JNIEXPORT
jint
JNICALL
Java_com_taosdata_jdbc_tmq_TMQConnector_tmqUnsubscribeImp
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jtmq
)
{
tmq_t
*
tmq
=
(
tmq_t
*
)
jtmq
;
...
...
source/util/src/tutil.c
浏览文件 @
a98ff93c
...
...
@@ -468,7 +468,7 @@ size_t tstrncspn(const char *str, size_t size, const char *reject, size_t rsize)
c3
=
p
[
s
[
j
+
3
]];
if
((
c0
|
c1
|
c2
|
c3
)
!=
0
)
{
size_t
count
=
((
i
+
1
)
>>
2
)
;
size_t
count
=
i
*
4
;
return
(
c0
|
c1
)
!=
0
?
count
-
c0
+
1
:
count
-
c2
+
3
;
}
}
...
...
source/util/test/utilTests.cpp
浏览文件 @
a98ff93c
...
...
@@ -294,6 +294,10 @@ TEST(utilTest, tstrncspn) {
const
char
*
reject5
=
"911"
;
v
=
tstrncspn
(
p2
,
strlen
(
p2
),
reject5
,
0
);
ASSERT_EQ
(
v
,
14
);
const
char
*
reject6
=
"Kk"
;
v
=
tstrncspn
(
p2
,
strlen
(
p2
),
reject6
,
2
);
ASSERT_EQ
(
v
,
10
);
}
TEST
(
utilTest
,
intToHextStr
)
{
...
...
tests/parallel_test/cases.task
浏览文件 @
a98ff93c
...
...
@@ -168,6 +168,7 @@
,,y,script,./test.sh -f tsim/parser/union.sim
,,y,script,./test.sh -f tsim/parser/union_sysinfo.sim
,,y,script,./test.sh -f tsim/parser/where.sim
,,y,script,./test.sh -f tsim/query/tagLikeFilter.sim
,,y,script,./test.sh -f tsim/query/charScalarFunction.sim
,,y,script,./test.sh -f tsim/query/explain.sim
,,y,script,./test.sh -f tsim/query/interval-offset.sim
...
...
tests/script/tsim/query/tagLikeFilter.sim
0 → 100644
浏览文件 @
a98ff93c
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
sql drop database if exists db1;
sql create database if not exists db1 vgroups 10;
sql use db1;
sql create stable sta (ts timestamp, f1 double, f2 binary(200)) tags(t1 binary(100));
sql create table tba1 using sta tags('ZQMPvstuzZVzCRjFTQawILuGSqZKSqlJwcBtZMxrAEqBbzChHWVDMiAZJwESzJAf');
sql create table tba2 using sta tags('ieofwehughkreghughuerugu34jf9340aieefjalie28ffj8fj8fafjaekdfjfii');
sql create table tba3 using sta tags('ZQMPvstuzZVzCRjFTQawILuGSqabSqlJwcBtZMxrAEqBbzChHWVDMiAZJwESzJAf');
sql insert into tba1 values ('2022-04-26 15:15:01', 1.0, "a");
sql insert into tba2 values ('2022-04-26 15:15:01', 1.0, "a");
sql insert into tba2 values ('2022-04-26 15:15:02', 1.0, "a");
sql insert into tba3 values ('2022-04-26 15:15:01', 1.0, "a");
sql insert into tba3 values ('2022-04-26 15:15:02', 1.0, "a");
sql insert into tba3 values ('2022-04-26 15:15:03', 1.0, "a");
sql select t1 from sta where t1 like '%ab%';
if $rows != 3 then
return -1
endi
sql select t1 from sta where t1 like '%ax%';
if $rows != 0 then
return -1
endi
sql select t1 from sta where t1 like '%cd%';
if $rows != 0 then
return -1
endi
sql select t1 from sta where t1 like '%ii';
if $rows != 2 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录