You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2019/09/12 09:03:03 UTC
[incubator-iotdb] branch master updated: [IOTDB-180] Get rid of
JSON format in "show timeseries" (#387)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new d3966e4 [IOTDB-180] Get rid of JSON format in "show timeseries" (#387)
d3966e4 is described below
commit d3966e4cd247990f561ad3613edda937d1df325e
Author: Yi Tao <th...@163.com>
AuthorDate: Thu Sep 12 17:02:58 2019 +0800
[IOTDB-180] Get rid of JSON format in "show timeseries" (#387)
* Merging the default 'show timeseries' into 'show timeseries <path>'
* Modify the quickstart and the readme
---
README.md | 222 ++++++++++++++----
.../org/apache/iotdb/client/AbstractClient.java | 13 --
.../org/apache/iotdb/client/AbstractClientIT.java | 5 -
docs/Documentation-CHN/QuickStart.md | 259 +++++++++++----------
docs/Documentation/QuickStart.md | 189 +++++++++++----
.../java/org/apache/iotdb/jdbc/IoTDBStatement.java | 20 +-
.../org/apache/iotdb/jdbc/IoTDBStatementTest.java | 59 ++++-
.../iotdb/db/integration/IoTDBMetadataFetchIT.java | 16 +-
8 files changed, 528 insertions(+), 255 deletions(-)
diff --git a/README.md b/README.md
index 22c113d..1a5e3fc 100644
--- a/README.md
+++ b/README.md
@@ -48,29 +48,57 @@ IoTDB's features are as following:
For the latest information about IoTDB, please visit our [IoTDB official website](https://iotdb.apache.org/).
-# Prerequisites
+<!-- TOC -->
+
+## Outline
+
+- Quick Start
+ - Prerequisites
+ - Installation
+ - Build from source
+ - Configurations
+ - Start
+ - Start IoTDB
+ - Use IoTDB
+ - Use Cli
+ - Basic commands for IoTDB
+ - Stop IoTDB
+ - Only build server
+ - Only build client
+
+<!-- /TOC -->
-IoTDB requires Java (>= 1.8).
-To use IoTDB, JRE should be installed. To compile IoTDB, JDK should be installed.
+# Quick Start
-If you want to compile and install IoTDB from source code, JDK and Maven (>= 3.1) are required.
-While Maven is not mandatory to be installed standalone, you can use the provided Maven wrapper, `./mvnw.sh` on Linux/OS X or `.\mvnw.cmd` on Windows, to facilitate development.
+This short guide will walk you through the basic process of using IoTDB. For a more-complete guide, please visit our website's [User Guide](https://iotdb.apache.org/#/Documents/0.8.0/chap1/sec1).
-Set the max open files num as 65535 to avoid "too many open files" problem.
+## Prerequisites
-If you want to use Hadoop or Spark to analyze IoTDB data file (called as TsFile), you need to compile the hadoop and spark modules.
+To use IoTDB, you need to have:
-# Quick Start
+1. Java >= 1.8 (Please make sure the environment path has been set)
+2. Maven >= 3.1 (If you want to compile and install IoTDB from source code)
+3. Set the max open files num as 65535 to avoid "too many open files" problem.
-This short guide will walk you through the basic process of using IoTDB. For a more-complete guide, please visit our website's [User Guide](https://iotdb.apache.org/#/Documents/0.8.0/chap1/sec1).
+## Installation
+
+IoTDB provides you three installation methods, you can refer to the following suggestions, choose one of them:
-## Get source code
+* Installation from source code. If you need to modify the code yourself, you can use this method.
+* Installation from binary files. Download the binary files from the official website. This is the recommended method, in which you will get a binary released package which is out-of-the-box.(Comming Soon...)
+* Using Docker:The path to the dockerfile is https://github.com/apache/incubator-iotdb/blob/master/docker/Dockerfile
-* https://iotdb.apache.org/#/Download
-* https://github.com/apache/incubator-iotdb/tree/master
+
+Here in the Quick Start, we give a brief introduction of using source code to install IoTDB. For further information, please refer to Chapter 4 of the User Guide.
## Build from source
+You can download the source code from:
+
+```
+git clone https://github.com/apache/incubator-iotdb.git
+```
+
Under the root path of incubator-iotdb:
```
@@ -85,13 +113,19 @@ Then the binary version (including both server and client) can be found at **dis
configuration files are under "conf" folder
- * environment config module (`iotdb-env.bat`, `iotdb-env.sh`),
+ * environment config module (`iotdb-env.bat`, `iotdb-env.sh`),
* system config module (`tsfile-format.properties`, `iotdb-engine.properties`)
- * log config module (`logback.xml`).
+ * log config module (`logback.xml`).
For more, see [Chapter4: Deployment and Management](https://iotdb.apache.org/#/Documents/0.8.0/chap4/sec1) in detail.
-### Start server
+## Start
+
+You can go through the following step to test the installation, if there is no error after execution, the installation is completed.
+
+### Start IoTDB
+
+Users can start IoTDB by the start-server script under the sbin folder.
```
# Unix/OS X
@@ -101,54 +135,134 @@ For more, see [Chapter4: Deployment and Management](https://iotdb.apache.org/#/D
> sbin\start-server.bat
```
-### Stop Server
-The server can be stopped with ctrl-C or the following script:
+### Use IoTDB
+
+#### Use Cli
+
+IoTDB offers different ways to interact with server, here we introduce basic steps of using Cli tool to insrert and query data.
+
+After installing IoTDB, there is a default user 'root', its default password is also 'root'. Users can use this
+default user to login Cli to use IoTDB. The startup script of Cli is the start-client script in the folder sbin. When executing the script, user should assign
+IP, PORT, USER_NAME and PASSWORD. The default parameters are "-h 127.0.0.1 -p 6667 -u root -pw -root".
+
+Here is the command for starting the Cli:
```
# Unix/OS X
-> sbin/stop-server.sh
+> sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root
# Windows
-> sbin\stop-server.bat
+> sbin\start-cli.bat -h 127.0.0.1 -p 6667 -u root -pw root
```
-### Using client
+The command line client is interactive so if everything is ready you should see the welcome logo and statements:
```
-# Unix/OS X
-> sbin/start-cli.sh -h <IP> -p <PORT> -u <USER_NAME>
+ _____ _________ ______ ______
+|_ _| | _ _ ||_ _ `.|_ _ \
+ | | .--.|_/ | | \_| | | `. \ | |_) |
+ | | / .'`\ \ | | | | | | | __'.
+ _| |_| \__. | _| |_ _| |_.' /_| |__) |
+|_____|'.__.' |_____| |______.'|_______/ version x.x.x
-# Windows
-> sbin\start-cli.bat -h <IP> -p <PORT> -u <USER_NAME>
+
+IoTDB> login successfully
+IoTDB>
```
-> The default user is 'root'. The default password for 'root' is 'root'.
+#### Basic commands for IoTDB
+
+Now, let us introduce the way of creating timeseries, inserting data and querying data.
+
+The data in IoTDB is organized as timeseries, in each timeseries there are some data-time pairs, and every timeseries is owned by a storage group. Before defining a timeseries, we should difine a storage group using SET STORAGE GROUP, and here is an example:
-> The default parameters are "-h 127.0.0.1 -p 6667 -u root -pw root".
+```
+IoTDB> SET STORAGE GROUP TO root.ln
+```
-```
-IoTDB> set storage group to root.vehicle
+We can also use SHOW STORAGE GROUP to check created storage group:
+
+```
+IoTDB> SHOW STORAGE GROUP
++-----------------------------------+
+| Storage Group|
++-----------------------------------+
+| root.ln|
++-----------------------------------+
+storage group number = 1
+```
-IoTDB> create timeseries root.vehicle.d0.s0 with datatype=INT32, encoding=RLE
+After the storage group is set, we can use CREATE TIMESERIES to create new timeseries. When we create a timeseries, we should define its data type and the encoding scheme. We create two timeseries as follow:
-IoTDB> show timeseries root
-+-----------------------------+---------------------+--------+--------+
-| Timeseries| Storage Group|DataType|Encoding|
-+-----------------------------+---------------------+--------+--------+
-| root.vehicle.d0.s0| root.vehicle| INT32| RLE|
-+-----------------------------+---------------------+--------+--------+
+```
+IoTDB> CREATE TIMESERIES root.ln.wf01.wt01.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN
+IoTDB> CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE=FLOAT, ENCODING=RLE
+```
-IoTDB> insert into root.vehicle.d0(timestamp,s0) values(1,101);
+Inorder to query the specific timeseries, we can use SHOW TIMESERIES <Path>. <Path> represent the path of the timeseries. Its default value is null, which means quering all the timeseries in the system(the same as using "SHOW TIMESERIES root"). Here are the examples:
-IoTDB> SELECT d0.s0 FROM root.vehicle
-+-----------------------------+------------------+
-| Time|root.vehicle.d0.s0|
-+-----------------------------+------------------+
-|1970-01-01T08:00:00.001+08:00| 101|
-+-----------------------------+------------------+
-Total line number = 1
+1. Querying all timeseries in the system:
+```
+IoTDB> SHOW TIMESERIES
++-------------------------------+---------------+--------+--------+
+| Timeseries| Storage Group|DataType|Encoding|
++-------------------------------+---------------+--------+--------+
+| root.ln.wf01.wt01.status| root.ln| BOOLEAN| PLAIN|
+| root.ln.wf01.wt01.temperature| root.ln| FLOAT| RLE|
++-------------------------------+---------------+--------+--------+
+Total timeseries number = 2
+```
+
+2. Querying a specific timeseries(root.ln.wf01.wt01.status):
+
+```
+IoTDB> SHOW TIMESERIES root.ln.wf01.wt01.status
++------------------------------+--------------+--------+--------+
+| Timeseries| Storage Group|DataType|Encoding|
++------------------------------+--------------+--------+--------+
+| root.ln.wf01.wt01.status| root.ln| BOOLEAN| PLAIN|
++------------------------------+--------------+--------+--------+
+Total timeseries number = 1
+```
+
+Insert timeseries data is the basic operation of IoTDB, you can use ‘INSERT’ command to finish this. Before inserting you should assign the timestamp and the suffix path name:
+
+```
+IoTDB> INSERT INTO root.ln.wf01.wt01(timestamp,status) values(100,true);
+IoTDB> INSERT INTO root.ln.wf01.wt01(timestamp,status,temperature) values(200,false,20.71)
+```
+
+The data we’ve just inserted displays like this:
+
+```
+IoTDB> SELECT status FROM root.ln.wf01.wt01
++-----------------------+------------------------+
+| Time|root.ln.wf01.wt01.status|
++-----------------------+------------------------+
+|1970-01-01T08:00:00.100| true|
+|1970-01-01T08:00:00.200| false|
++-----------------------+------------------------+
+Total line number = 2
+```
+
+We can also query several timeseries data at once like this:
+
+```
+IoTDB> SELECT * FROM root.ln.wf01.wt01
++-----------------------+--------------------------+-----------------------------+
+| Time| root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
++-----------------------+--------------------------+-----------------------------+
+|1970-01-01T08:00:00.100| true| null|
+|1970-01-01T08:00:00.200| false| 20.71|
++-----------------------+--------------------------+-----------------------------+
+Total line number = 2
+```
+
+The commands to exit the Cli is:
+
+```
IoTDB> quit
or
IoTDB> exit
@@ -156,23 +270,35 @@ IoTDB> exit
For more on what commands are supported by IoTDB SQL, see [Chapter 5: IoTDB SQL Documentation](https://iotdb.apache.org/#/Documents/0.8.0/chap5/sec1).
+### Stop IoTDB
+
+The server can be stopped with ctrl-C or the following script:
+
+```
+# Unix/OS X
+> sbin/stop-server.sh
+
+# Windows
+> sbin\stop-server.bat
+```
+
## Only build server
Under the root path of incubator-iotdb:
```
-> mvn clean package -pl server -am -DskipTests=true
+> mvn clean package -pl server -am -DskipTests
```
-After build, the IoTDB server will be at the folder "server/target/iotdb-server-{project.version}".
-
+After build, the IoTDB server will be at the folder "server/target/iotdb-server-{project.version}".
+
-## Only build client
+## Only build client
Under the root path of incubator-iotdb:
```
-> mvn clean package -pl client -am -DskipTests=true
+> mvn clean package -pl client -am -DskipTests
```
After build, the IoTDB client will be at the folder "client/target/iotdb-client-{project.version}".
\ No newline at end of file
diff --git a/client/src/main/java/org/apache/iotdb/client/AbstractClient.java b/client/src/main/java/org/apache/iotdb/client/AbstractClient.java
index c35cb08..eb0dabd 100644
--- a/client/src/main/java/org/apache/iotdb/client/AbstractClient.java
+++ b/client/src/main/java/org/apache/iotdb/client/AbstractClient.java
@@ -599,10 +599,6 @@ public abstract class AbstractClient {
showHelp();
return OperationResult.CONTINUE_OPER;
}
- if (SHOW_METADATA_COMMAND.equals(specialCmd)) {
- showMetaData(connection);
- return OperationResult.CONTINUE_OPER;
- }
if (specialCmd.startsWith(SET_TIMESTAMP_DISPLAY)) {
setTimestampDisplay(specialCmd, cmd);
return OperationResult.CONTINUE_OPER;
@@ -663,15 +659,6 @@ public abstract class AbstractClient {
SET_MAX_DISPLAY_NUM));
}
- private static void showMetaData(IoTDBConnection connection) {
- try {
- println(((IoTDBDatabaseMetadata) connection.getMetaData()).getMetadataInJson());
- } catch (SQLException e) {
- println("Failed to show timeseries because: " + e.getMessage());
- handleException(e);
- }
- }
-
private static void setTimestampDisplay(String specialCmd, String cmd) {
String[] values = specialCmd.split("=");
if (values.length != 2) {
diff --git a/client/src/test/java/org/apache/iotdb/client/AbstractClientIT.java b/client/src/test/java/org/apache/iotdb/client/AbstractClientIT.java
index e9c6f15..78acb79 100644
--- a/client/src/test/java/org/apache/iotdb/client/AbstractClientIT.java
+++ b/client/src/test/java/org/apache/iotdb/client/AbstractClientIT.java
@@ -52,7 +52,6 @@ public class AbstractClientIT {
MockitoAnnotations.initMocks(this);
when(connection.getMetaData()).thenReturn(databaseMetadata);
when(connection.getTimeZone()).thenReturn("Asia/Shanghai");
- when(databaseMetadata.getMetadataInJson()).thenReturn("test metadata");
}
@After
@@ -147,10 +146,6 @@ public class AbstractClientIT {
.handleInputCmd(AbstractClient.EXIT_COMMAND, connection));
assertEquals(OperationResult.STOP_OPER, AbstractClient
.handleInputCmd(AbstractClient.QUIT_COMMAND, connection));
-
- assertEquals(OperationResult.CONTINUE_OPER, AbstractClient
- .handleInputCmd(AbstractClient.SHOW_METADATA_COMMAND, connection));
-
assertEquals(OperationResult.CONTINUE_OPER, AbstractClient
.handleInputCmd(String.format("%s=", AbstractClient.SET_TIMESTAMP_DISPLAY), connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractClient
diff --git a/docs/Documentation-CHN/QuickStart.md b/docs/Documentation-CHN/QuickStart.md
index 7c209d9..d06c515 100755
--- a/docs/Documentation-CHN/QuickStart.md
+++ b/docs/Documentation-CHN/QuickStart.md
@@ -7,9 +7,9 @@
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
@@ -25,19 +25,24 @@
- 快速入门
- 安装环境
- - IoTDB安装
- - IoTDB试用
- - 启动IoTDB
- - 操作IoTDB
- - 使用Cli/Shell工具
- - IoTDB的基本操作
- - 停止IoTDB
- - 使用stop-server脚本强制停止
+ - IoTDB安装
+ - 从源代码生成
+ - 配置文件
+ - IoTDB试用
+ - 启动IoTDB
+ - 操作IoTDB
+ - 使用Cli工具
+ - IoTDB的基本操作
+ - 停止IoTDB
+ - 单独打包服务器
+ - 单独打包客户端
<!-- /TOC -->
# 快速入门
+本文将介绍关于IoTDB使用的基本流程,如果需要更多信息,请浏览我们官网的[指引](https://iotdb.apache.org/#/Documents/0.8.0/chap1/sec1).
+
## 安装环境
安装前需要保证设备上配有JDK>=1.8的运行环境,并配置好JAVA_HOME环境变量。
@@ -50,56 +55,86 @@
IoTDB支持多种安装途径。用户可以使用三种方式对IoTDB进行安装——下载二进制可运行程序、使用源码、使用docker镜像。
+* 使用源码:您可以从代码仓库下载源码并编译,具体编译方法见下方。
+
* 二进制可运行程序:请从Download页面下载最新的安装包,解压后即完成安装。
-* 使用源码:您可以从代码仓库下载源码并编译:`git clone https://github.com/apache/incubator-iotdb.git`, 并通过`mvn package -DskipTests` 进行编译。
+* 使用Docker镜像: dockerfile文件位于 https://github.com/apache/incubator-iotdb/blob/master/docker/Dockerfile
+
+### 从源代码生成
+
+您可以从代码仓库下载源码:
+
+```
+git clone https://github.com/apache/incubator-iotdb.git
+```
+
+接下来在incubator-iotdb的根目录下执行以下命令:
+
+```
+> mvn clean package -DskipTests
+```
+
+执行完成后对应的二进制文件(包括服务器和客户端)都可以在**distribution/target/apache-iotdb-{project.version}-incubating-bin.zip**位置找到。
+
+> 注意需要在源代码根目录添加目录"service-rpc/target/generated-sources/thrift"与"server/target/generated-sources/antlr3",以避免在IDE中的编译错误。
+
+### 配置文件
+
+配置文件在"conf"文件夹下,包括:
-* 使用Docker: dockerfile文件位于 https://github.com/apache/incubator-iotdb/blob/master/docker/Dockerfile
+ * 环境配置模块 (`iotdb-env.bat`, `iotdb-env.sh`),
+ * 系统配置模块 (`tsfile-format.properties`, `iotdb-engine.properties`)
+ * 日志配置模块 (`logback.xml`).
+
+想要了解更多,请浏览[Chapter4: Deployment and Management](https://iotdb.apache.org/#/Documents/0.8.0/chap4/sec1)
+
## IoTDB试用
用户可以根据以下操作对IoTDB进行简单的试用,若以下操作均无误,则说明IoTDB安装成功。
-在后文中,记$IOTDB_HOME为IoTDB的安装目录路径,即上述iotdb子文件夹路径。
### 启动IoTDB
-用户可以使用$IOTDB_HOME/bin文件夹下的start-server脚本启动IoTDB。
+用户可以使用sbin文件夹下的start-server脚本启动IoTDB。
Linux系统与MacOS系统启动命令如下:
```
-> $IOTDB_HOME/sbin/start-server.sh
+> sbin/start-server.sh
```
Windows系统启动命令如下:
+
```
-> $IOTDB_HOME\sbin\start-server.bat
+> sbin\start-server.bat
```
-当服务器输出log中包含ERROR输出时,服务器启动不成功。
### 操作IoTDB
-#### 使用Cli/Shell工具
+#### 使用Cli工具
-IoTDB为用户提供多种与服务器交互的方式,您可以选择使用Cli/Shell工具、Grafana可视化工具或JAVA API与IoTDB服务器进行数据写入与查询的交互操作。在此我们介绍使用Cli/Shell工具进行写入、查询数据的基本步骤。
+IoTDB为用户提供多种与服务器交互的方式,在此我们介绍使用Cli工具进行写入、查询数据的基本步骤。
-初始安装后的IoTDB中有一个默认用户:root,默认密码为root。用户可以使用该用户运行Cli/Shell工具操作IoTDB。Cli/Shell工具启动脚本为$IOTDB_HOME/bin文件夹下的start-client脚本。启动脚本时需要指定运行IP和PORT。
+初始安装后的IoTDB中有一个默认用户:root,默认密码为root。用户可以使用该用户运行Cli工具操作IoTDB。Cli工具启动脚本为sbin文件夹下的start-client脚本。启动脚本时需要指定运行ip、port、username和password。若脚本未给定对应参数,则默认参数为"-h 127.0.0.1 -p 6667 -u root -pw -root"
以下启动语句为服务器在本机运行,且用户未更改运行端口号的示例。
Linux系统与MacOS系统启动命令如下:
+
```
-> $IOTDB_HOME/sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root
+> sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root
```
Windows系统启动命令如下:
+
```
-> $IOTDB_HOME\sbin\start-cli.bat -h 127.0.0.1 -p 6667 -u root
+> sbin\start-cli.bat -h 127.0.0.1 -p 6667 -u root -pw root
```
-回车后输入root用户的密码,即可成功启动客户端。启动后出现如图提示即为启动成功。
+启动后出现如图提示即为启动成功。
```
_____ _________ ______ ______
@@ -116,153 +151,96 @@ IoTDB>
#### IoTDB的基本操作
-Cli/Shell启动成功后,用户可使用该工具输入SQL命令操作IoTDB Server。
+在这里,我们首先介绍一下使用Cli工具创建时间序列、插入数据并查看数据的方法。
-在这里,我们首先介绍一下使用Cli/Shell工具创建时间序列、插入数据并查看数据的方法。
+数据在IoTDB中的组织形式是以时间序列为单位,每一个时间序列中有若干个数据-时间点对,每一个时间序列属于一个存储组。在定义时间序列之前,要首先使用SET STORAGE GROUP语句定义存储组。SQL语句如下:
-数据在IoTDB中的组织形式是以时间序列为单位,每一个时间序列中有若干个数据-时间点对,存储结构为存储组。在定义时间序列之前,要首先使用SET STORAGE GROUP语句定义存储组。SQL语句如下:
```
IoTDB> SET STORAGE GROUP TO root.ln
```
-执行成功后,Cli/Shell返回execute successfully表示执行成功。
+我们可以使用SHOW STORAGE GROUP语句来查看系统当前所有的存储组,SQL语句如下:
-存储组设定后,使用CREATE TIMESERIES语句可以创建新的时间序列,创建时间序列时需要定义数据的类型和编码形式。SQL语句如下:
```
-IoTDB> CREATE TIMESERIES root.ln.wf01.wt01.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN
+IoTDB> SHOW STORAGE GROUP
```
-执行成功后,Cli/Shell返回execute successfully表示执行成功。
-如果系统中已有被创建的存储组和时间序列,则系统会提示该部分已存在。如以下提示表示存储组已存在:
+执行结果为:
+
```
-IoTDB> SET STORAGE GROUP TO root.ln
-error: The path of root.ln already exist, it can't be set to the storage group
++-----------------------------------+
+| Storage Group|
++-----------------------------------+
+| root.ln|
++-----------------------------------+
+storage group number = 1
```
-如下提示表示时间序列已存在:
+存储组设定后,使用CREATE TIMESERIES语句可以创建新的时间序列,创建时间序列时需要定义数据的类型和编码方式。此处我们创建两个时间序列,SQL语句如下:
+
```
IoTDB> CREATE TIMESERIES root.ln.wf01.wt01.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN
-error: Timeseries root.ln.wf01.wt01.status already exist
+IoTDB> CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE=FLOAT, ENCODING=RLE
```
-创建时间序列后,我们使用SHOW TIMESERIES语句查看系统中存在的所有时间序列,SQL语句如下:
+为了查看指定的时间序列,我们可以使用SHOW TIMESERIES <Path>语句,其中<Path>表示时间序列对应的路径,默认值为空,表示查看系统中所有的时间序列。下面是两个例子:
-```
-IoTDB> SHOW TIMESERIES
-```
+使用SHOW TIMESERIES语句查看系统中存在的所有时间序列,SQL语句如下:
-执行结果为:
```
-=== Timeseries Tree ===
-
-{
- "root":{
- "ln":{
- "wf01":{
- "wt01":{
- "status":{
- "args":"{}",
- "StorageGroup":"root.ln",
- "DataType":"BOOLEAN",
- "Compressor":"UNCOMPRESSED",
- "Encoding":"PLAIN"
- }
- }
- }
- }
- }
-}
-```
-
-我们可以尝试再创建一个时间序列,查看SHOW TIMESERIES的返回情况。SQL语句如下:
-```
-IoTDB> CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE=FLOAT, ENCODING=RLE
IoTDB> SHOW TIMESERIES
-```
+```
执行结果为:
+
```
-=== Timeseries Tree ===
-
-{
- "root":{
- "ln":{
- "wf01":{
- "wt01":{
- "temperature":{
- "args":"{}",
- "StorageGroup":"root.ln",
- "DataType":"FLOAT",
- "Compressor":"UNCOMPRESSED",
- "Encoding":"RLE"
- },
- "status":{
- "args":"{}",
- "StorageGroup":"root.ln",
- "DataType":"BOOLEAN",
- "Compressor":"UNCOMPRESSED",
- "Encoding":"PLAIN"
- }
- }
- }
- }
- }
-}
-```
-
-为了查看指定的时间序列,我们可以使用SHOW TIMESERIES <Path>语句,查看时间序列root.ln.wf01.wt01.status的SQL语句如下:
++-------------------------------+---------------+--------+--------+
+| Timeseries| Storage Group|DataType|Encoding|
++-------------------------------+---------------+--------+--------+
+| root.ln.wf01.wt01.status| root.ln| BOOLEAN| PLAIN|
+| root.ln.wf01.wt01.temperature| root.ln| FLOAT| RLE|
++-------------------------------+---------------+--------+--------+
+Total timeseries number = 2
+```
+
+查看具体的时间序列root.ln.wf01.wt01.status的SQL语句如下:
+
```
IoTDB> SHOW TIMESERIES root.ln.wf01.wt01.status
-```
+```
执行结果为:
+
```
+------------------------------+--------------+--------+--------+
| Timeseries| Storage Group|DataType|Encoding|
+------------------------------+--------------+--------+--------+
| root.ln.wf01.wt01.status| root.ln| BOOLEAN| PLAIN|
+------------------------------+--------------+--------+--------+
-timeseries number = 1
-Execute successfully.
-It costs 0.02s.
+Total timeseries number = 1
```
-我们还可以使用SHOW STORAGE GROUP语句来查看系统当前所有的存储组,SQL语句如下:
-```
-IoTDB> SHOW STORAGE GROUP
-```
-
-执行结果为:
-```
-+-----------------------------------+
-| Storage Group|
-+-----------------------------------+
-| root.ln|
-+-----------------------------------+
-storage group number = 1
-Execute successfully.
-It costs 0.001s
-```
+接下来,我们使用INSERT语句向root.ln.wf01.wt01.status时间序列中插入数据,在插入数据时需要首先指定时间戳和路径后缀名称:
-接下来,我们使用INSERT语句向root.ln.wf01.wt01.status时间序列中插入数据,在插入数据时需要首先指定时间戳和插入的传感器路径名称:
```
IoTDB> INSERT INTO root.ln.wf01.wt01(timestamp,status) values(100,true);
-execute successfully.
```
-我们也可以向多个传感器中同时插入数据,这些传感器同属于一个时间戳:
+我们也可以向多个时间序列中同时插入数据,这些时间序列同属于一个时间戳:
+
```
IoTDB> INSERT INTO root.ln.wf01.wt01(timestamp,status,temperature) values(200,false,20.71)
-
execute successfully.
```
最后,我们查询之前插入的数据。使用SELECT语句我们可以查询指定的时间序列的数据结果,SQL语句如下:
+
```
IoTDB> SELECT status FROM root.ln.wf01.wt01
```
查询结果如下:
+
```
+-----------------------+------------------------+
| Time|root.ln.wf01.wt01.status|
@@ -270,16 +248,17 @@ IoTDB> SELECT status FROM root.ln.wf01.wt01
|1970-01-01T08:00:00.100| true|
|1970-01-01T08:00:00.200| false|
+-----------------------+------------------------+
-record number = 1
-execute successfully.
+Total line number = 2
```
我们也可以查询多个时间序列的数据结果,SQL语句如下:
+
```
IoTDB> SELECT * FROM root.ln.wf01.wt01
```
查询结果如下:
+
```
+-----------------------+--------------------------+-----------------------------+
| Time| root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
@@ -287,24 +266,54 @@ IoTDB> SELECT * FROM root.ln.wf01.wt01
|1970-01-01T08:00:00.100| true| null|
|1970-01-01T08:00:00.200| false| 20.71|
+-----------------------+--------------------------+-----------------------------+
+Total line number = 2
```
-输入quit或exit可退出Cli结束本次会话,Cli输出quit normally表示退出成功,操作语句与返回结果如下:
+输入quit或exit可退出Cli结束本次会话。
+
```
IoTDB> quit
-quit normally
```
+或
+
+```
+IoTDB> exit
+```
+
+想要浏览更多IoTDB数据库支持的命令,请浏览[Chapter 5: IoTDB SQL Documentation](https://iotdb.apache.org/#/Documents/0.8.0/chap5/sec1).
### 停止IoTDB
-#### 使用stop-server脚本强制停止
+
用户可以使用$IOTDB_HOME/sbin文件夹下的stop-server脚本停止IoTDB(注意,此停止方式为强制停止,若希望安全停止IoTDB,请使用Jconsole工具的停止方法)。
Linux系统与MacOS系统停止命令如下:
+
```
-> $IOTDB_HOME/sbin/stop-server.sh
+> $sbin/stop-server.sh
```
Windows系统停止命令如下:
+
```
-> $IOTDB_HOME\sbin\stop-server.bat
+> $sbin\stop-server.bat
```
+
+##单独打包服务器
+
+在incubator-iotdb的根目录下执行
+
+```
+> mvn clean package -pl server -am -DskipTests
+```
+在生成完毕之后,IoTDB服务器位于文件夹"server/target/iotdb-server-{project.version}"中。
+
+
+##单独打包客户端
+
+在incubator-iotdb的根目录下执行
+
+```
+> mvn clean package -pl client -am -DskipTests
+```
+
+在生成完毕之后,IoTDB的cli工具位于文件夹"client/target/iotdb-client-{project.version}"中。
\ No newline at end of file
diff --git a/docs/Documentation/QuickStart.md b/docs/Documentation/QuickStart.md
index 64605dc..a2da23c 100755
--- a/docs/Documentation/QuickStart.md
+++ b/docs/Documentation/QuickStart.md
@@ -25,15 +25,18 @@
- Quick Start
- Prerequisites
- - Installation
- - Installation from source code
- - Configure
- - Start
- - Start Server
- - Start Cli
- - Have a try
- - Stop Server
-
+ - Installation
+ - Build from source
+ - Configurations
+ - Start
+ - Start IoTDB
+ - Use IoTDB
+ - Use Cli
+ - Basic commands for IoTDB
+ - Stop IoTDB
+ - Only build server
+ - Only build client
+
<!-- /TOC -->
# Quick Start
@@ -50,15 +53,23 @@ To use IoTDB, you need to have:
## Installation
-IoTDB provides you two installation methods, you can refer to the following suggestions, choose one of them:
+IoTDB provides you three installation methods, you can refer to the following suggestions, choose one of them:
* Installation from source code. If you need to modify the code yourself, you can use this method.
* Installation from binary files. Download the binary files from the official website. This is the recommended method, in which you will get a binary released package which is out-of-the-box.(Comming Soon...)
+* Using Docker:The path to the dockerfile is https://github.com/apache/incubator-iotdb/blob/master/docker/Dockerfile
+
Here in the Quick Start, we give a brief introduction of using source code to install IoTDB. For further information, please refer to Chapter 4 of the User Guide.
## Build from source
+You can download the source code from:
+
+```
+git clone https://github.com/apache/incubator-iotdb.git
+```
+
Under the root path of incubator-iotdb:
```
@@ -79,7 +90,13 @@ configuration files are under "conf" folder
For more, see [Chapter4: Deployment and Management](https://iotdb.apache.org/#/Documents/0.8.0/chap4/sec1) in detail.
-### Start server
+## Start
+
+You can go through the following step to test the installation, if there is no error after execution, the installation is completed.
+
+### Start IoTDB
+
+Users can start IoTDB by the start-server script under the sbin folder.
```
# Unix/OS X
@@ -89,54 +106,134 @@ For more, see [Chapter4: Deployment and Management](https://iotdb.apache.org/#/D
> sbin\start-server.bat
```
-### Stop Server
-The server can be stopped with ctrl-C or the following script:
+### Use IoTDB
+
+#### Use Cli
+
+IoTDB offers different ways to interact with server, here we introduce basic steps of using Cli tool to insrert and query data.
+
+After installing IoTDB, there is a default user 'root', its default password is also 'root'. Users can use this
+default user to login Cli to use IoTDB. The startup script of Cli is the start-client script in the folder sbin. When executing the script, user should assign
+IP, PORT, USER_NAME and PASSWORD. The default parameters are "-h 127.0.0.1 -p 6667 -u root -pw -root".
+
+Here is the command for starting the Cli:
```
# Unix/OS X
-> sbin/stop-server.sh
+> sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root
# Windows
-> sbin\stop-server.bat
+> sbin\start-cli.bat -h 127.0.0.1 -p 6667 -u root -pw root
```
-### Using client
+The command line client is interactive so if everything is ready you should see the welcome logo and statements:
```
-# Unix/OS X
-> sbin/start-cli.sh -h <IP> -p <PORT> -u <USER_NAME>
+ _____ _________ ______ ______
+|_ _| | _ _ ||_ _ `.|_ _ \
+ | | .--.|_/ | | \_| | | `. \ | |_) |
+ | | / .'`\ \ | | | | | | | __'.
+ _| |_| \__. | _| |_ _| |_.' /_| |__) |
+|_____|'.__.' |_____| |______.'|_______/ version x.x.x
-# Windows
-> sbin\start-cli.bat -h <IP> -p <PORT> -u <USER_NAME>
+
+IoTDB> login successfully
+IoTDB>
```
-> The default user is 'root'. The default password for 'root' is 'root'.
+#### Basic commands for IoTDB
+
+Now, let us introduce the way of creating timeseries, inserting data and querying data.
-> The default parameters are "-h 127.0.0.1 -p 6667 -u root -pw root".
+The data in IoTDB is organized as timeseries, in each timeseries there are some data-time pairs, and every timeseries is owned by a storage group. Before defining a timeseries, we should difine a storage group using SET STORAGE GROUP, and here is an example:
```
-IoTDB> set storage group to root.vehicle
+IoTDB> SET STORAGE GROUP TO root.ln
+```
+
+We can also use SHOW STORAGE GROUP to check created storage group:
+
+```
+IoTDB> SHOW STORAGE GROUP
++-----------------------------------+
+| Storage Group|
++-----------------------------------+
+| root.ln|
++-----------------------------------+
+storage group number = 1
+```
+
+After the storage group is set, we can use CREATE TIMESERIES to create new timeseries. When we create a timeseries, we should define its data type and the encoding scheme. We create two timeseries as follow:
+
+```
+IoTDB> CREATE TIMESERIES root.ln.wf01.wt01.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN
+IoTDB> CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE=FLOAT, ENCODING=RLE
+```
-IoTDB> create timeseries root.vehicle.d0.s0 with datatype=INT32, encoding=RLE
+Inorder to query the specific timeseries, we can use SHOW TIMESERIES <Path>. <Path> represent the path of the timeseries. Its default value is null, which means quering all the timeseries in the system(the same as using "SHOW TIMESERIES root"). Here are the examples:
-IoTDB> show timeseries root
-+-----------------------------+---------------------+--------+--------+
-| Timeseries| Storage Group|DataType|Encoding|
-+-----------------------------+---------------------+--------+--------+
-| root.vehicle.d0.s0| root.vehicle| INT32| RLE|
-+-----------------------------+---------------------+--------+--------+
+1. Querying all timeseries in the system:
-IoTDB> insert into root.vehicle.d0(timestamp,s0) values(1,101);
+```
+IoTDB> SHOW TIMESERIES
++-------------------------------+---------------+--------+--------+
+| Timeseries| Storage Group|DataType|Encoding|
++-------------------------------+---------------+--------+--------+
+| root.ln.wf01.wt01.status| root.ln| BOOLEAN| PLAIN|
+| root.ln.wf01.wt01.temperature| root.ln| FLOAT| RLE|
++-------------------------------+---------------+--------+--------+
+Total timeseries number = 2
+```
+
+2. Querying a specific timeseries(root.ln.wf01.wt01.status):
+
+```
+IoTDB> SHOW TIMESERIES root.ln.wf01.wt01.status
++------------------------------+--------------+--------+--------+
+| Timeseries| Storage Group|DataType|Encoding|
++------------------------------+--------------+--------+--------+
+| root.ln.wf01.wt01.status| root.ln| BOOLEAN| PLAIN|
++------------------------------+--------------+--------+--------+
+Total timeseries number = 1
+```
+
+Insert timeseries data is the basic operation of IoTDB, you can use ‘INSERT’ command to finish this. Before inserting you should assign the timestamp and the suffix path name:
+
+```
+IoTDB> INSERT INTO root.ln.wf01.wt01(timestamp,status) values(100,true);
+IoTDB> INSERT INTO root.ln.wf01.wt01(timestamp,status,temperature) values(200,false,20.71)
+```
+
+The data we’ve just inserted displays like this:
+
+```
+IoTDB> SELECT status FROM root.ln.wf01.wt01
++-----------------------+------------------------+
+| Time|root.ln.wf01.wt01.status|
++-----------------------+------------------------+
+|1970-01-01T08:00:00.100| true|
+|1970-01-01T08:00:00.200| false|
++-----------------------+------------------------+
+Total line number = 2
+```
+
+We can also query several timeseries data at once like this:
-IoTDB> SELECT d0.s0 FROM root.vehicle
-+-----------------------------+------------------+
-| Time|root.vehicle.d0.s0|
-+-----------------------------+------------------+
-|1970-01-01T08:00:00.001+08:00| 101|
-+-----------------------------+------------------+
-Total line number = 1
+```
+IoTDB> SELECT * FROM root.ln.wf01.wt01
++-----------------------+--------------------------+-----------------------------+
+| Time| root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
++-----------------------+--------------------------+-----------------------------+
+|1970-01-01T08:00:00.100| true| null|
+|1970-01-01T08:00:00.200| false| 20.71|
++-----------------------+--------------------------+-----------------------------+
+Total line number = 2
+```
+The commands to exit the Cli is:
+
+```
IoTDB> quit
or
IoTDB> exit
@@ -144,12 +241,24 @@ IoTDB> exit
For more on what commands are supported by IoTDB SQL, see [Chapter 5: IoTDB SQL Documentation](https://iotdb.apache.org/#/Documents/0.8.0/chap5/sec1).
+### Stop IoTDB
+
+The server can be stopped with ctrl-C or the following script:
+
+```
+# Unix/OS X
+> sbin/stop-server.sh
+
+# Windows
+> sbin\stop-server.bat
+```
+
## Only build server
Under the root path of incubator-iotdb:
```
-> mvn clean package -pl server -am -DskipTests=true
+> mvn clean package -pl server -am -DskipTests
```
After build, the IoTDB server will be at the folder "server/target/iotdb-server-{project.version}".
@@ -160,7 +269,7 @@ After build, the IoTDB server will be at the folder "server/target/iotdb-server-
Under the root path of incubator-iotdb:
```
-> mvn clean package -pl client -am -DskipTests=true
+> mvn clean package -pl client -am -DskipTests
```
After build, the IoTDB client will be at the folder "client/target/iotdb-client-{project.version}".
\ No newline at end of file
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
index 35b2361..35a3bf2 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
@@ -217,7 +217,7 @@ public class IoTDBStatement implements Statement {
}
/**
- * There are four kinds of sql here: (1) show timeseries path (2) show storage group (3) query sql
+ * There are four kinds of sql here: (1) show timeseries path/show timeseries (2) show storage group (3) query sql
* (4) update sql . <p></p> (1) and (2) return new TsfileMetadataResultSet (3) return new
* TsfileQueryResultSet (4) simply get executed
*/
@@ -225,14 +225,20 @@ public class IoTDBStatement implements Statement {
isCancelled = false;
String sqlToLowerCase = sql.toLowerCase().trim();
if (sqlToLowerCase.startsWith(SHOW_TIMESERIES_COMMAND_LOWERCASE)) {
- String[] cmdSplited = sql.split("\\s+");
- if (cmdSplited.length != 3) {
- throw new SQLException("Error format of \'SHOW TIMESERIES <PATH>\'");
- } else {
- String path = cmdSplited[2];
+ if (sqlToLowerCase.equals(SHOW_TIMESERIES_COMMAND_LOWERCASE)) {
DatabaseMetaData databaseMetaData = connection.getMetaData();
- resultSet = databaseMetaData.getColumns(Constant.CATALOG_TIMESERIES, path, null, null);
+ resultSet = databaseMetaData.getColumns(Constant.CATALOG_TIMESERIES, "root", null, null);
return true;
+ } else {
+ String[] cmdSplited = sql.split("\\s+");
+ if (cmdSplited.length != 3) {
+ throw new SQLException("Error format of \'SHOW TIMESERIES <PATH>\'");
+ } else {
+ String path = cmdSplited[2];
+ DatabaseMetaData databaseMetaData = connection.getMetaData();
+ resultSet = databaseMetaData.getColumns(Constant.CATALOG_TIMESERIES, path, null, null);
+ return true;
+ }
}
} else if (sqlToLowerCase.equals(SHOW_STORAGE_GROUP_COMMAND_LOWERCASE)) {
DatabaseMetaData databaseMetaData = connection.getMetaData();
diff --git a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBStatementTest.java b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBStatementTest.java
index 44fd2f4..195654c 100644
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBStatementTest.java
+++ b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBStatementTest.java
@@ -74,11 +74,60 @@ public class IoTDBStatementTest {
public void tearDown() throws Exception {
}
- @SuppressWarnings("resource")
- @Test(expected = SQLException.class)
- public void testExecuteSQL1() throws SQLException {
+ @SuppressWarnings({"resource", "serial"})
+ @Test
+ public void testExecuteSQL1() throws SQLException, TException {
IoTDBStatement stmt = new IoTDBStatement(connection, client, sessHandle, zoneID);
- stmt.execute("show timeseries");
+ List<List<String>> tslist = new ArrayList<>();
+ tslist.add(new ArrayList<String>(4) {
+ {
+ add("root.vehicle.d0.s0");
+ add("root.vehicle");
+ add("INT32");
+ add("RLE");
+ }
+ });
+ tslist.add(new ArrayList<String>(4) {
+ {
+ add("root.vehicle.d0.s1");
+ add("root.vehicle");
+ add("INT64");
+ add("RLE");
+ }
+ });
+ tslist.add(new ArrayList<String>(4) {
+ {
+ add("root.vehicle.d0.s2");
+ add("root.vehicle");
+ add("FLOAT");
+ add("RLE");
+ }
+ });
+ String standard = "Timeseries,Storage Group,DataType,Encoding,\n"
+ + "root.vehicle.d0.s0,root.vehicle,INT32,RLE,\n"
+ + "root.vehicle.d0.s1,root.vehicle,INT64,RLE,\n"
+ + "root.vehicle.d0.s2,root.vehicle,FLOAT,RLE,\n";
+ when(fetchMetadataResp.getShowTimeseriesList()).thenReturn(tslist);
+ boolean res = stmt.execute("show timeseries");
+ assertTrue(res);
+ try (ResultSet resultSet = stmt.getResultSet()) {
+ ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
+ int colCount = resultSetMetaData.getColumnCount();
+ StringBuilder resultStr = new StringBuilder();
+ for (int i = 1; i < colCount + 1; i++) {
+ resultStr.append(resultSetMetaData.getColumnName(i)).append(",");
+ }
+ resultStr.append("\n");
+ while (resultSet.next()) {
+ for (int i = 1; i <= colCount; i++) {
+ resultStr.append(resultSet.getString(i)).append(",");
+ }
+ resultStr.append("\n");
+ }
+ Assert.assertEquals(resultStr.toString(), standard);
+ } catch (SQLException e) {
+ System.out.println(e);
+ }
}
@SuppressWarnings({"resource", "serial"})
@@ -115,7 +164,7 @@ public class IoTDBStatementTest {
+ "root.vehicle.d0.s1,root.vehicle,INT64,RLE,\n"
+ "root.vehicle.d0.s2,root.vehicle,FLOAT,RLE,\n";
when(fetchMetadataResp.getShowTimeseriesList()).thenReturn(tslist);
- boolean res = stmt.execute("show timeseries root");
+ boolean res = stmt.execute("show timeseries root.vehicle.d0");
assertTrue(res);
try (ResultSet resultSet = stmt.getResultSet()) {
ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java
index f50ab02..379d663 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java
@@ -94,7 +94,7 @@ public class IoTDBMetadataFetchIT {
String[] sqls = new String[]{"show timeseries root.ln.wf01.wt01.status", // full seriesPath
"show timeseries root.ln", // prefix seriesPath
"show timeseries root.ln.*.wt01", // seriesPath with stars
-
+ "show timeseries", // the same as root
"show timeseries root.a.b", // nonexistent timeseries, thus returning ""
"show timeseries root.ln,root.ln",
// SHOW TIMESERIES <PATH> only accept single seriesPath, thus
@@ -109,6 +109,9 @@ public class IoTDBMetadataFetchIT {
"root.ln.wf01.wt01.status,root.ln.wf01.wt01,BOOLEAN,PLAIN,\n"
+ "root.ln.wf01.wt01.temperature,root.ln.wf01.wt01,FLOAT,RLE,\n",
+ "root.ln.wf01.wt01.status,root.ln.wf01.wt01,BOOLEAN,PLAIN,\n"
+ + "root.ln.wf01.wt01.temperature,root.ln.wf01.wt01,FLOAT,RLE,\n",
+
"",
""};
@@ -138,17 +141,6 @@ public class IoTDBMetadataFetchIT {
}
}
- @Test(expected = SQLException.class)
- public void showTimeseriesTest2() throws ClassNotFoundException, SQLException {
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection = DriverManager
- .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",
- "root"); Statement statement = connection.createStatement()) {
- String sql = "show timeseries"; // not supported in jdbc, thus expecting SQLException
- statement.execute(sql);
- }
- }
-
@Test
public void showStorageGroupTest() throws ClassNotFoundException, SQLException {
Class.forName(Config.JDBC_DRIVER_NAME);