Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ statement
;

ddlStatement
: createStorageGroup | createTimeseries | createSchemaTemplate | createTimeseriesOfSchemaTemplate
: createStorageGroup | createTimeseries | createSchemaTemplate | createTimeseriesUsingSchemaTemplate
| createFunction | createTrigger | createContinuousQuery
| alterTimeseries | alterStorageGroup | deleteStorageGroup | deleteTimeseries | deletePartition | deleteTimeseriesOfSchemaTemplate
| dropFunction | dropTrigger | dropContinuousQuery | dropSchemaTemplate
Expand Down Expand Up @@ -113,8 +113,8 @@ templateMeasurementClause
;

// Create Timeseries Of Schema Template
createTimeseriesOfSchemaTemplate
: CREATE TIMESERIES OF SCHEMA TEMPLATE ON prefixPath
createTimeseriesUsingSchemaTemplate
: CREATE TIMESERIES (OF | USING) SCHEMA TEMPLATE ON prefixPath
;

// Create Function
Expand Down
93 changes: 40 additions & 53 deletions docs/UserGuide/API/Programming-Java-Native-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Here we show the commonly used interfaces and their parameters in the Native API

* Initialize a Session

```java
``` java
// use default configuration
session = new Session.Builder.build();

Expand Down Expand Up @@ -95,21 +95,21 @@ Version represents the SQL semantic version used by the client, which is used to

* Open a Session

```java
``` java
void open()
```

* Open a session, with a parameter to specify whether to enable RPC compression

```java
``` java
void open(boolean enableRPCCompression)
```

Notice: this RPC compression status of client must comply with that of IoTDB server

* Close a Session

```java
``` java
void close()
```

Expand All @@ -119,13 +119,13 @@ void close()

* CREATE DATABASE

```java
``` java
void setStorageGroup(String storageGroupId)
```

* Delete one or several databases

```java
``` java
void deleteStorageGroup(String storageGroup)
void deleteStorageGroups(List<String> storageGroups)
```
Expand All @@ -134,7 +134,7 @@ void deleteStorageGroups(List<String> storageGroups)

* Create one or multiple timeseries

```java
``` java
void createTimeseries(String path, TSDataType dataType,
TSEncoding encoding, CompressionType compressor, Map<String, String> props,
Map<String, String> tags, Map<String, String> attributes, String measurementAlias)
Expand All @@ -156,14 +156,14 @@ Attention: Alias of measurements are **not supported** currently.

* Delete one or several timeseries

```java
``` java
void deleteTimeseries(String path)
void deleteTimeseries(List<String> paths)
```

* Check whether the specific timeseries exists.

```java
``` java
boolean checkTimeseriesExists(String path)
```

Expand All @@ -172,7 +172,7 @@ boolean checkTimeseriesExists(String path)

Create a schema template for massive identical devices will help to improve memory performance. You can use Template, InternalNode and MeasurementNode to depict the structure of the template, and use belowed interface to create it inside session.

```java
``` java
public void createSchemaTemplate(Template template);

Class Template {
Expand Down Expand Up @@ -207,7 +207,7 @@ We strongly suggest you implement templates only with flat-measurement (like obj

A snippet of using above Method and Class:

```java
``` java
MeasurementNode nodeX = new MeasurementNode("x", TSDataType.FLOAT, TSEncoding.RLE, CompressionType.SNAPPY);
MeasurementNode nodeY = new MeasurementNode("y", TSDataType.FLOAT, TSEncoding.RLE, CompressionType.SNAPPY);
MeasurementNode nodeSpeed = new MeasurementNode("speed", TSDataType.DOUBLE, TSEncoding.GORILLA, CompressionType.SNAPPY);
Expand All @@ -221,25 +221,6 @@ template.addToTemplate(nodeSpeed);
createSchemaTemplate(flatTemplate);
```

You can query measurement inside templates with these APIS:

```java
// Return the amount of measurements inside a template
public int countMeasurementsInTemplate(String templateName);

// Return true if path points to a measurement, otherwise returne false
public boolean isMeasurementInTemplate(String templateName, String path);

// Return true if path exists in template, otherwise return false
public boolean isPathExistInTemplate(String templateName, String path);

// Return all measurements paths inside template
public List<String> showMeasurementsInTemplate(String templateName);

// Return all measurements paths under the designated patter inside template
public List<String> showMeasurementsInTemplate(String templateName, String pattern);
```

To implement schema template, you can set the measurement template named 'templateName' at path 'prefixPath'.

**Please notice that, we strongly recommend not setting templates on the nodes above the database to accommodate future updates and collaboration between modules.**
Expand All @@ -250,13 +231,19 @@ void setSchemaTemplate(String templateName, String prefixPath)

Before setting template, you should firstly create the template using

```java
``` java
void createSchemaTemplate(Template template)
```

After setting template to a certain path, you can use the template to create timeseries on given device paths through the following interface, or you can write data directly to trigger timeseries auto creation using schema template under target devices.

``` java
void createTimeseriesUsingSchemaTemplate(List<String> devicePathList)
```

After setting template to a certain path, you can query for info about template using belowed interface in session:

```java
``` java
/** @return All template names. */
public List<String> showAllTemplates();

Expand All @@ -269,7 +256,7 @@ public List<String> showPathsTemplateUsingOn(String templateName)

If you are ready to get rid of schema template, you can drop it with belowed interface. Make sure the template to drop has been unset from MTree.

```java
``` java
void unsetSchemaTemplate(String prefixPath, String templateName);
public void dropSchemaTemplate(String templateName);
```
Expand All @@ -289,7 +276,7 @@ It is recommended to use insertTablet to help improve write efficiency.
* **Better Write Performance**
* **Support null values**: fill the null value with any value, and then mark the null value via BitMap

```java
``` java
void insertTablet(Tablet tablet)

public class Tablet {
Expand All @@ -314,7 +301,7 @@ public class Tablet {

* Insert multiple Tablets

```java
``` java
void insertTablets(Map<String, Tablet> tablet)
```

Expand All @@ -331,22 +318,22 @@ void insertTablets(Map<String, Tablet> tablet)
| DOUBLE | Double |
| TEXT | String, Binary |

```java
``` java
void insertRecord(String deviceId, long time, List<String> measurements,
List<TSDataType> types, List<Object> values)
```

* Insert multiple Records

```java
``` java
void insertRecords(List<String> deviceIds, List<Long> times,
List<List<String>> measurementsList, List<List<TSDataType>> typesList,
List<List<Object>> valuesList)
```
* Insert multiple Records that belong to the same device.
With type info the server has no need to do type inference, which leads a better performance

```java
``` java
void insertRecordsOfOneDevice(String deviceId, List<Long> times,
List<List<String>> measurementsList, List<List<TSDataType>> typesList,
List<List<Object>> valuesList)
Expand All @@ -358,20 +345,20 @@ When the data is of String type, we can use the following interface to perform t

* Insert a Record, which contains multiple measurement value of a device at a timestamp

```java
``` java
void insertRecord(String prefixPath, long time, List<String> measurements, List<String> values)
```

* Insert multiple Records

```java
``` java
void insertRecords(List<String> deviceIds, List<Long> times,
List<List<String>> measurementsList, List<List<String>> valuesList)
```

* Insert multiple Records that belong to the same device.

```java
``` java
void insertStringRecordsOfOneDevice(String deviceId, List<Long> times,
List<List<String>> measurementsList, List<List<String>> valuesList)
```
Expand All @@ -391,7 +378,7 @@ The Insert of aligned timeseries uses interfaces like insertAlignedXXX, and othe

* Delete data before or equal to a timestamp of one or several timeseries

```java
``` java
void deleteData(String path, long time)
void deleteData(List<String> paths, long time)
```
Expand All @@ -401,22 +388,22 @@ void deleteData(List<String> paths, long time)
* Time-series raw data query with time range:
- The specified query time range is a left-closed right-open interval, including the start time but excluding the end time.

```java
``` java
SessionDataSet executeRawDataQuery(List<String> paths, long startTime, long endTime);
```

* Last query:
- Query the last data, whose timestamp is greater than or equal LastTime.

```java
``` java
SessionDataSet executeLastDataQuery(List<String> paths, long LastTime);
```

* Aggregation query:
- Support specified query time range: The specified query time range is a left-closed right-open interval, including the start time but not the end time.
- Support GROUP BY TIME.

```java
``` java
SessionDataSet executeAggregationQuery(List<String> paths, List<Aggregation> aggregations);

SessionDataSet executeAggregationQuery(
Expand All @@ -442,13 +429,13 @@ SessionDataSet executeAggregationQuery(

* Execute query statement

```java
``` java
SessionDataSet executeQueryStatement(String sql)
```

* Execute non query statement

```java
``` java
void executeNonQueryStatement(String sql)
```

Expand All @@ -458,7 +445,7 @@ These methods **don't** insert data into database and server just return after a

* Test the network and client cost of insertRecord

```java
``` java
void testInsertRecord(String deviceId, long time, List<String> measurements, List<String> values)

void testInsertRecord(String deviceId, long time, List<String> measurements,
Expand All @@ -467,7 +454,7 @@ void testInsertRecord(String deviceId, long time, List<String> measurements,

* Test the network and client cost of insertRecords

```java
``` java
void testInsertRecords(List<String> deviceIds, List<Long> times,
List<List<String>> measurementsList, List<List<String>> valuesList)

Expand All @@ -478,13 +465,13 @@ void testInsertRecords(List<String> deviceIds, List<Long> times,

* Test the network and client cost of insertTablet

```java
``` java
void testInsertTablet(Tablet tablet)
```

* Test the network and client cost of insertTablets

```java
``` java
void testInsertTablets(Map<String, Tablet> tablets)
```

Expand Down Expand Up @@ -579,7 +566,7 @@ APIs in `ClusterInfoService.Client`:

* Get the physical hash ring of the cluster:

```java
``` java
list<Node> getRing();
```

Expand All @@ -604,7 +591,7 @@ list<Node> getMetaPartition(1:string path);
```

* Get the status (alive or not) of all nodes:
```java
``` java
/**
* @return key: node, value: live or not
*/
Expand Down
6 changes: 3 additions & 3 deletions docs/UserGuide/Operate-Metadata/Template.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ After setting the schema template, with the system enabled to auto create schema
**Attention**: Before inserting data or the system not enabled to auto create schema, timeseries defined by the schema template will not be created. You can use the following SQL statement to create the timeseries or activate the schema template, act before inserting data:

```shell
IoTDB> create timeseries of schema template on root.sg1.d1
IoTDB> create timeseries using schema template on root.sg1.d1
```

**Example:** Execute the following statement
```shell
IoTDB> set schema template t1 to root.sg1.d1
IoTDB> set schema template t2 to root.sg1.d2
IoTDB> create timeseries of schema template on root.sg1.d1
IoTDB> create timeseries of schema template on root.sg1.d2
IoTDB> create timeseries using schema template on root.sg1.d1
IoTDB> create timeseries using schema template on root.sg1.d2
```

Show the time series:
Expand Down
Loading