Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
535724a5
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看板
未验证
提交
535724a5
编写于
3月 29, 2022
作者:
X
xiaolei li
提交者:
GitHub
3月 29, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-14356]<fix>:csharp remove stream_open() && stream_close() (#11083)
上级
338d542d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
0 addition
and
140 deletion
+0
-140
src/connector/C#/examples/Main.cs
src/connector/C#/examples/Main.cs
+0
-3
src/connector/C#/examples/StreamSample.cs
src/connector/C#/examples/StreamSample.cs
+0
-107
src/connector/C#/src/TDengineDriver/TDengineDriver.cs
src/connector/C#/src/TDengineDriver/TDengineDriver.cs
+0
-30
未找到文件。
src/connector/C#/examples/Main.cs
浏览文件 @
535724a5
...
@@ -20,9 +20,6 @@ namespace AsyncQueryExample
...
@@ -20,9 +20,6 @@ namespace AsyncQueryExample
subscribeSample
.
RunSubscribeWithCallback
(
conn
,
"subscribe_with_callback"
);
subscribeSample
.
RunSubscribeWithCallback
(
conn
,
"subscribe_with_callback"
);
subscribeSample
.
RunSubscribeWithoutCallback
(
conn
,
"subscribe_without_callback"
);
subscribeSample
.
RunSubscribeWithoutCallback
(
conn
,
"subscribe_without_callback"
);
StreamSample
streamSample
=
new
StreamSample
();
streamSample
.
RunStreamOption1
(
conn
,
"stream_sample_option1"
);
UtilsTools
.
CloseConnection
(
conn
);
UtilsTools
.
CloseConnection
(
conn
);
}
}
}
}
...
...
src/connector/C#/examples/StreamSample.cs
已删除
100644 → 0
浏览文件 @
338d542d
using
System
;
using
TDengineDriver
;
using
Sample.UtilsTools
;
using
System.Runtime.InteropServices
;
using
System.Threading
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Example
{
public
class
StreamSample
{
public
void
RunStreamOption1
(
IntPtr
conn
,
string
table
)
{
PrepareData
(
conn
,
table
);
StreamOpenCallback
streamOpenCallback
=
new
StreamOpenCallback
(
StreamCallback
);
IntPtr
stream
=
TDengine
.
OpenStream
(
conn
,
$"select count(*) from
{
table
}
interval(1m) sliding(30s)"
,
streamOpenCallback
,
0
,
IntPtr
.
Zero
,
null
);
if
(
stream
==
IntPtr
.
Zero
)
{
throw
new
Exception
(
"OPenStream failed"
);
}
else
{
Thread
.
Sleep
(
100000
);
AddNewData
(
conn
,
table
,
5
,
true
);
Thread
.
Sleep
(
100000
);
TDengine
.
CloseStream
(
stream
);
Console
.
WriteLine
(
"stream done"
);
}
}
public
void
StreamCallback
(
IntPtr
param
,
IntPtr
taosRes
,
IntPtr
taosRow
)
{
if
(
taosRes
==
IntPtr
.
Zero
||
taosRow
==
IntPtr
.
Zero
)
{
return
;
}
else
{
var
rowData
=
new
List
<
Object
>();
rowData
=
UtilsTools
.
FetchRow
(
taosRow
,
taosRes
);
int
count
=
0
;
rowData
.
ForEach
((
item
)
=>
{
Console
.
Write
(
"{0} \t|\t"
,
item
.
ToString
());
count
++;
if
(
count
%
rowData
.
Count
==
0
)
{
Console
.
WriteLine
(
""
);
}
});
}
}
public
void
PrepareData
(
IntPtr
conn
,
string
tableName
)
{
string
createTable
=
$"create table if not exists
{
tableName
}
(ts timestamp,i8 tinyint,i16 smallint,i32 int,i64 bigint);"
;
UtilsTools
.
ExecuteUpdate
(
conn
,
createTable
);
AddNewData
(
conn
,
tableName
,
5
);
}
public
void
AddNewData
(
IntPtr
conn
,
string
tableName
,
int
numRows
,
bool
interval
=
false
)
{
long
ts
=
1646150410100
;
Random
rs
=
new
Random
();
StringBuilder
insert
=
new
StringBuilder
();
Random
rd
=
new
Random
();
for
(
int
i
=
0
;
i
<
numRows
;
i
++)
{
insert
.
Append
(
"insert into "
);
insert
.
Append
(
tableName
);
insert
.
Append
(
" values "
);
insert
.
Append
(
'('
);
insert
.
Append
(
ts
);
insert
.
Append
(
','
);
insert
.
Append
(
rs
.
Next
(
sbyte
.
MinValue
+
1
,
sbyte
.
MaxValue
));
insert
.
Append
(
','
);
insert
.
Append
(
rs
.
Next
(
short
.
MinValue
+
1
,
short
.
MaxValue
));
insert
.
Append
(
','
);
insert
.
Append
(
rs
.
Next
(
int
.
MinValue
+
1
,
int
.
MaxValue
));
insert
.
Append
(
','
);
insert
.
Append
(
rs
.
Next
(
int
.
MinValue
+
1
,
int
.
MaxValue
));
insert
.
Append
(
')'
);
UtilsTools
.
ExecuteUpdate
(
conn
,
insert
.
ToString
());
insert
.
Clear
();
ts
+=
rd
.
Next
(
10000
,
100000
);
if
(
interval
)
{
Thread
.
Sleep
(
rs
.
Next
(
100
,
300
)
*
i
);
}
else
{
continue
;
}
}
}
}
}
\ No newline at end of file
src/connector/C#/src/TDengineDriver/TDengineDriver.cs
浏览文件 @
535724a5
...
@@ -179,8 +179,6 @@ namespace TDengineDriver
...
@@ -179,8 +179,6 @@ namespace TDengineDriver
/// <param name="param"> Additional parameters supplied by the client when taos_subscribe is called.</param>
/// <param name="param"> Additional parameters supplied by the client when taos_subscribe is called.</param>
/// <param name="code"> Error code.</param>
/// <param name="code"> Error code.</param>
public
delegate
void
SubscribeCallback
(
IntPtr
subscribe
,
IntPtr
tasRes
,
IntPtr
param
,
int
code
);
public
delegate
void
SubscribeCallback
(
IntPtr
subscribe
,
IntPtr
tasRes
,
IntPtr
param
,
int
code
);
public
delegate
void
StreamOpenCallback
(
IntPtr
param
,
IntPtr
taosRes
,
IntPtr
taosRow
);
public
delegate
void
StreamOpenCallback2
(
IntPtr
ptr
);
public
class
TDengine
public
class
TDengine
{
{
...
@@ -561,33 +559,5 @@ namespace TDengineDriver
...
@@ -561,33 +559,5 @@ namespace TDengineDriver
}
}
}
}
// Stream
/// <summary>
/// Used to open an stream, which can do continuous query.
/// </summary>
/// <param name="taos"> taos connection return by <see cref = "Connect"></param>
/// <param name="sql"> Query statement( query only)</param>
/// <param name="fp"> User defined callback.</param>
/// <param name="stime"> The time when stream computing starts. If it is 0, it means starting from now.
/// If it is not zero, it means starting from the specified time (the number of
/// milliseconds from 1970/1/1 UTC time).
/// </param>
/// <param name="param">First parameter provide by application for callback usage.
/// While callback,this parameter is provided to the application.</param>
/// <param name="callback2">The second callback function which will be called when the continuous query
/// stop automatically.</param>
/// <returns> Return null indicate creation failed, not null for success.</returns>
[
DllImport
(
"taos"
,
EntryPoint
=
"taos_open_stream"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
IntPtr
OpenStream
(
IntPtr
taos
,
string
sql
,
StreamOpenCallback
fp
,
Int64
stime
,
IntPtr
param
,
StreamOpenCallback2
callback2
);
/// <summary>
/// Used too stop data flow.
/// Remember to stop data flow when you stopped steam computing.
/// </summary>
/// <param name="stream"> Value returned by <see cref = "OpenStream"></param>
[
DllImport
(
"taos"
,
EntryPoint
=
"taos_close_stream"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
void
CloseStream
(
IntPtr
stream
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录