Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
1e0933bb
I
Iotdb
项目概览
apache
/
Iotdb
11 个月 前同步成功
通知
25
Star
3344
Fork
916
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iotdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1e0933bb
编写于
9月 08, 2020
作者:
Y
yhwang-hbl
提交者:
GitHub
9月 08, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[IOTDB-856] Clear up the IoTDBSessionIT (#1670)
上级
00141433
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
1051 addition
and
0 deletion
+1051
-0
session/src/test/java/org/apache/iotdb/session/IoTDBSessionComplexIT.java
.../java/org/apache/iotdb/session/IoTDBSessionComplexIT.java
+790
-0
session/src/test/java/org/apache/iotdb/session/IoTDBSessionSimpleIT.java
...t/java/org/apache/iotdb/session/IoTDBSessionSimpleIT.java
+261
-0
未找到文件。
session/src/test/java/org/apache/iotdb/session/IoTDBSessionIT.java
→
session/src/test/java/org/apache/iotdb/session/IoTDBSession
Complex
IT.java
浏览文件 @
1e0933bb
此差异已折叠。
点击以展开。
session/src/test/java/org/apache/iotdb/session/IoTDBSessionSimpleIT.java
0 → 100644
浏览文件 @
1e0933bb
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package
org.apache.iotdb.session
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.iotdb.db.conf.IoTDBConstant
;
import
org.apache.iotdb.db.conf.IoTDBDescriptor
;
import
org.apache.iotdb.db.exception.metadata.MetadataException
;
import
org.apache.iotdb.db.metadata.MManager
;
import
org.apache.iotdb.db.metadata.PartialPath
;
import
org.apache.iotdb.db.metadata.mnode.MeasurementMNode
;
import
org.apache.iotdb.db.utils.EnvironmentUtils
;
import
org.apache.iotdb.rpc.BatchExecutionException
;
import
org.apache.iotdb.rpc.IoTDBConnectionException
;
import
org.apache.iotdb.rpc.StatementExecutionException
;
import
org.apache.iotdb.tsfile.common.constant.TsFileConstant
;
import
org.apache.iotdb.tsfile.file.metadata.enums.CompressionType
;
import
org.apache.iotdb.tsfile.file.metadata.enums.TSDataType
;
import
org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding
;
import
org.junit.After
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
IoTDBSessionSimpleIT
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
IoTDBSessionSimpleIT
.
class
);
private
Session
session
;
@Before
public
void
setUp
()
{
System
.
setProperty
(
IoTDBConstant
.
IOTDB_CONF
,
"src/test/resources/"
);
EnvironmentUtils
.
closeStatMonitor
();
EnvironmentUtils
.
envSetUp
();
}
@After
public
void
tearDown
()
throws
Exception
{
session
.
close
();
EnvironmentUtils
.
cleanEnv
();
}
@Test
public
void
testInsertByBlankStrAndInferType
()
throws
IoTDBConnectionException
,
StatementExecutionException
{
session
=
new
Session
(
"127.0.0.1"
,
6667
,
"root"
,
"root"
);
session
.
open
();
String
deviceId
=
"root.sg1.d1"
;
List
<
String
>
measurements
=
new
ArrayList
<>();
measurements
.
add
(
"s1 "
);
List
<
String
>
values
=
new
ArrayList
<>();
values
.
add
(
"1.0"
);
session
.
insertRecord
(
deviceId
,
1L
,
measurements
,
values
);
String
[]
expected
=
new
String
[]{
"root.sg1.d1.s1 "
};
assertFalse
(
session
.
checkTimeseriesExists
(
"root.sg1.d1.s1 "
));
SessionDataSet
dataSet
=
session
.
executeQueryStatement
(
"show timeseries"
);
int
i
=
0
;
while
(
dataSet
.
hasNext
())
{
assertEquals
(
expected
[
i
],
dataSet
.
next
().
getFields
().
get
(
0
).
toString
());
i
++;
}
session
.
close
();
}
@Test
public
void
testInsertByStrAndInferType
()
throws
IoTDBConnectionException
,
StatementExecutionException
{
session
=
new
Session
(
"127.0.0.1"
,
6667
,
"root"
,
"root"
);
session
.
open
();
String
deviceId
=
"root.sg1.d1"
;
List
<
String
>
measurements
=
new
ArrayList
<>();
measurements
.
add
(
"s1"
);
measurements
.
add
(
"s2"
);
measurements
.
add
(
"s3"
);
measurements
.
add
(
"s4"
);
List
<
String
>
values
=
new
ArrayList
<>();
values
.
add
(
"1"
);
values
.
add
(
"1.2"
);
values
.
add
(
"true"
);
values
.
add
(
"dad"
);
session
.
insertRecord
(
deviceId
,
1L
,
measurements
,
values
);
String
[]
expected
=
new
String
[]{
IoTDBDescriptor
.
getInstance
().
getConfig
().
getIntegerStringInferType
().
name
(),
IoTDBDescriptor
.
getInstance
().
getConfig
().
getFloatingStringInferType
().
name
(),
IoTDBDescriptor
.
getInstance
().
getConfig
().
getBooleanStringInferType
().
name
(),
TSDataType
.
TEXT
.
name
()
};
SessionDataSet
dataSet
=
session
.
executeQueryStatement
(
"show timeseries root"
);
int
i
=
0
;
while
(
dataSet
.
hasNext
())
{
assertEquals
(
expected
[
i
],
dataSet
.
next
().
getFields
().
get
(
3
).
getStringValue
());
i
++;
}
session
.
close
();
}
@Test
public
void
testInsertByObjAndNotInferType
()
throws
IoTDBConnectionException
,
StatementExecutionException
{
session
=
new
Session
(
"127.0.0.1"
,
6667
,
"root"
,
"root"
);
session
.
open
();
String
deviceId
=
"root.sg1.d1"
;
List
<
String
>
measurements
=
new
ArrayList
<>();
measurements
.
add
(
"s1"
);
measurements
.
add
(
"s2"
);
measurements
.
add
(
"s3"
);
measurements
.
add
(
"s4"
);
List
<
TSDataType
>
dataTypes
=
new
ArrayList
<>();
dataTypes
.
add
(
TSDataType
.
INT64
);
dataTypes
.
add
(
TSDataType
.
DOUBLE
);
dataTypes
.
add
(
TSDataType
.
TEXT
);
dataTypes
.
add
(
TSDataType
.
TEXT
);
List
<
Object
>
values
=
new
ArrayList
<>();
values
.
add
(
1L
);
values
.
add
(
1.2d
);
values
.
add
(
"true"
);
values
.
add
(
"dad"
);
session
.
insertRecord
(
deviceId
,
1L
,
measurements
,
dataTypes
,
values
);
String
[]
expected
=
new
String
[]{
TSDataType
.
INT64
.
name
(),
TSDataType
.
DOUBLE
.
name
(),
TSDataType
.
TEXT
.
name
(),
TSDataType
.
TEXT
.
name
()
};
SessionDataSet
dataSet
=
session
.
executeQueryStatement
(
"show timeseries root"
);
int
i
=
0
;
while
(
dataSet
.
hasNext
())
{
assertEquals
(
expected
[
i
],
dataSet
.
next
().
getFields
().
get
(
3
).
getStringValue
());
i
++;
}
session
.
close
();
}
@Test
public
void
testCreateMultiTimeseries
()
throws
IoTDBConnectionException
,
BatchExecutionException
,
StatementExecutionException
,
MetadataException
{
session
=
new
Session
(
"127.0.0.1"
,
6667
,
"root"
,
"root"
);
session
.
open
();
List
<
String
>
paths
=
new
ArrayList
<>();
paths
.
add
(
"root.sg1.d1.s1"
);
paths
.
add
(
"root.sg1.d1.s2"
);
List
<
TSDataType
>
tsDataTypes
=
new
ArrayList
<>();
tsDataTypes
.
add
(
TSDataType
.
DOUBLE
);
tsDataTypes
.
add
(
TSDataType
.
DOUBLE
);
List
<
TSEncoding
>
tsEncodings
=
new
ArrayList
<>();
tsEncodings
.
add
(
TSEncoding
.
RLE
);
tsEncodings
.
add
(
TSEncoding
.
RLE
);
List
<
CompressionType
>
compressionTypes
=
new
ArrayList
<>();
compressionTypes
.
add
(
CompressionType
.
SNAPPY
);
compressionTypes
.
add
(
CompressionType
.
SNAPPY
);
List
<
Map
<
String
,
String
>>
tagsList
=
new
ArrayList
<>();
Map
<
String
,
String
>
tags
=
new
HashMap
<>();
tags
.
put
(
"tag1"
,
"v1"
);
tagsList
.
add
(
tags
);
tagsList
.
add
(
tags
);
session
.
createMultiTimeseries
(
paths
,
tsDataTypes
,
tsEncodings
,
compressionTypes
,
null
,
tagsList
,
null
,
null
);
Assert
.
assertTrue
(
session
.
checkTimeseriesExists
(
"root.sg1.d1.s1"
));
Assert
.
assertTrue
(
session
.
checkTimeseriesExists
(
"root.sg1.d1.s2"
));
MeasurementMNode
mNode
=
(
MeasurementMNode
)
MManager
.
getInstance
().
getNodeByPath
(
new
PartialPath
(
"root.sg1.d1.s1"
));
assertNull
(
mNode
.
getSchema
().
getProps
());
session
.
close
();
}
@Test
public
void
testChineseCharacter
()
throws
IoTDBConnectionException
,
StatementExecutionException
{
session
=
new
Session
(
"127.0.0.1"
,
6667
,
"root"
,
"root"
);
session
.
open
();
if
(!
System
.
getProperty
(
"sun.jnu.encoding"
).
contains
(
"UTF-8"
))
{
logger
.
error
(
"The system does not support UTF-8, so skip Chinese test..."
);
session
.
close
();
return
;
}
String
storageGroup
=
"root.存储组1"
;
String
[]
devices
=
new
String
[]{
"设备1.指标1"
,
"设备1.s2"
,
"d2.s1"
,
"d2.指标2"
};
session
.
setStorageGroup
(
storageGroup
);
for
(
String
path
:
devices
)
{
String
fullPath
=
storageGroup
+
TsFileConstant
.
PATH_SEPARATOR
+
path
;
session
.
createTimeseries
(
fullPath
,
TSDataType
.
INT64
,
TSEncoding
.
RLE
,
CompressionType
.
SNAPPY
);
}
for
(
String
path
:
devices
)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
String
[]
ss
=
path
.
split
(
"\\."
);
String
deviceId
=
storageGroup
;
for
(
int
j
=
0
;
j
<
ss
.
length
-
1
;
j
++)
{
deviceId
+=
(
TsFileConstant
.
PATH_SEPARATOR
+
ss
[
j
]);
}
String
sensorId
=
ss
[
ss
.
length
-
1
];
List
<
String
>
measurements
=
new
ArrayList
<>();
List
<
Object
>
values
=
new
ArrayList
<>();
List
<
TSDataType
>
types
=
new
ArrayList
<>();
measurements
.
add
(
sensorId
);
types
.
add
(
TSDataType
.
INT64
);
values
.
add
(
100L
);
session
.
insertRecord
(
deviceId
,
i
,
measurements
,
types
,
values
);
}
}
SessionDataSet
dataSet
=
session
.
executeQueryStatement
(
"select * from root.存储组1"
);
int
count
=
0
;
while
(
dataSet
.
hasNext
())
{
count
++;
}
Assert
.
assertEquals
(
10
,
count
);
session
.
deleteStorageGroup
(
storageGroup
);
session
.
close
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录