Skip to content

Tag schema region #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
498facd
Influxdb protocol adapts tag schema region
Sep 18, 2022
2b28f3a
Implement mock tag schema region
Sep 18, 2022
4a8e2b3
spotless apply
Sep 18, 2022
69a9414
lsm
Sep 7, 2022
d147f35
parent pom add lsm
Sep 7, 2022
27f12fb
lsm preOrder level fix
Sep 7, 2022
0e6e452
lsm preOrder level fix
Sep 7, 2022
3935efc
lsm add levelUpperBound
Sep 8, 2022
35efe55
add TagInvertedIndex
Sep 9, 2022
a157158
add TagInvertedIndex
Sep 9, 2022
f20a6cd
impl TagInvertedIndex
Sep 13, 2022
3164fd5
impl TagInvertedIndex
Sep 13, 2022
793e7c8
impl wal
Sep 14, 2022
d23d8ca
impl RecoverManager
Sep 14, 2022
b770521
impl RecoverManager
Sep 14, 2022
9e25cc5
impl RecoverManager
Sep 14, 2022
7675953
impl RecoverManager
Sep 14, 2022
f96336d
impl RecoverManager
Sep 14, 2022
53c3f4a
spotless apply
Sep 19, 2022
dfb56b0
add TagSchemaDescriptor
Sep 21, 2022
1a649dc
add DeviceIDList
Sep 22, 2022
33dc78c
add SchemaTreeVisitorFactory
Sep 22, 2022
f08f7a6
add SchemaTreeVisitorFactory
Sep 22, 2022
88399fc
mod getDeviceSchemaInfoWithAutoCreate
Sep 22, 2022
4838571
mod Licensed
Sep 23, 2022
db42af5
mod Licensed
Sep 23, 2022
4283b26
add README.md
Sep 23, 2022
60038d5
add README.md
Sep 23, 2022
b2f5bfd
add README.md
Sep 23, 2022
f6fe85d
add README.md
Sep 23, 2022
e77eadf
move lsm module to tag schema region
Oct 15, 2022
11d05a2
Modify the abstract class WalRecord to an interface
Oct 15, 2022
24a041a
IDTableWithDeviceIDListImpl
Oct 15, 2022
23ec097
add LevelProcessChain and TagSchemaRegionTest
Oct 15, 2022
15d779e
Merge remote-tracking branch 'origin/master' into tag_schema_region
Oct 15, 2022
c981031
merge
Oct 16, 2022
afe53ec
Separate request and context
Oct 22, 2022
9555298
LSMEngine and MemTableGroup
Oct 23, 2022
d094cb5
LSMEngine and MemTableGroup
Oct 23, 2022
162c17b
LSMEngine and MemTableGroup
Oct 23, 2022
3da61b7
LSMEngine and MemTableGroup
Oct 23, 2022
52c6912
add Property
Oct 23, 2022
38b3080
rename WalRecord
Oct 23, 2022
e824d2c
add annotation
Oct 23, 2022
7230b58
iotdb-datanode.properties
Oct 24, 2022
47dbc11
make Request as interface
Oct 24, 2022
168f0a6
rename to ILevelProcessor
Oct 24, 2022
00a8240
remove Exception
Oct 24, 2022
a5b7f33
delete LSMEngineDirector.java
Oct 24, 2022
41e49ee
add javadoc
Oct 25, 2022
d6ccc84
Merge remote-tracking branch 'origin/master' into tag_schema_region
Oct 25, 2022
c7f1813
add javadoc
Oct 25, 2022
a53f52b
Remove invalid exception catch code
Oct 25, 2022
79bfc6e
add response
Oct 26, 2022
01c424e
Remove unnecessary response
Oct 26, 2022
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 @@ -102,7 +102,7 @@ private static void queryData() {

query =
new Query(
"select count(temperature),first(temperature),last(temperature),max(temperature),mean(temperature),median(temperature),min(temperature),mode(temperature),spread(temperature),stddev(temperature),sum(temperature) from student where ((workshop=\"A1\" and production=\"B1\" and cell =\"C1\" ) or temperature< 15 )",
"select count(temperature),first(temperature),last(temperature),max(temperature),mean(temperature),median(temperature),min(temperature),mode(temperature),spread(temperature),stddev(temperature),sum(temperature) from factory where ((workshop=\"A1\" and production=\"B1\" and cell =\"C1\" ) or temperature< 15 )",
database);
result = influxDB.query(query);
System.out.println("query2 result:" + result.getResults().get(0).getSeries().get(0).toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.utility.DockerImageName;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class IoTDBInfluxDBIT {

Expand Down Expand Up @@ -164,8 +168,9 @@ public void testCommonQueryColumn() {
QueryResult.Series series = result.getResults().get(0).getSeries().get(0);

String[] retArray = new String[] {"time", "name", "sex", "province", "country", "score", "tel"};
Set<String> columnNames = new HashSet<>(Arrays.asList(retArray));
for (int i = 0; i < series.getColumns().size(); i++) {
assertEquals(retArray[i], series.getColumns().get(i));
assertTrue(columnNames.contains(series.getColumns().get(i)));
}
}

Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
<module>trigger-api</module>
<module>rewrite-tsfile-tool</module>
<module>external-api</module>
<module>schema-engine-tag</module>
</modules>
<!-- Properties Management -->
<properties>
Expand Down
190 changes: 190 additions & 0 deletions schema-engine-tag/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
<!--

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.

-->

# Tag Schema Region
`TagSchemaRegion` is an implementation of `SchemaRegion`
<pre>
_____ _____ _ ______ _
|_ _| / ___| | | | ___ \ (_)
| | __ _ __ _ \ `--. ___| |__ ___ _ __ ___ __ _ | |_/ /___ __ _ _ ___ _ __
| |/ _` |/ _` | `--. \/ __| '_ \ / _ \ '_ ` _ \ / _` | | // _ \/ _` | |/ _ \| '_ \
| | (_| | (_| | /\__/ / (__| | | | __/ | | | | | (_| | | |\ \ __/ (_| | | (_) | | | |
\_/\__,_|\__, | \____/ \___|_| |_|\___|_| |_| |_|\__,_| \_| \_\___|\__, |_|\___/|_| |_|
__/ | __/ |
|___/ |___/ > version 0.14.0-SNAPSHOT
</pre>

# How To Use

Firstly, you should package **schema-engine-tag** by the following command:

```shell
mvn clean package -pl schema-engine-tag -am -DskipTests
```

After that, you can get a **conf** directory and a **lib** directory in
schema-engine-tag/target/schema-engine-tag. Copy the file in the conf directory to the conf directory of server,
and copy the files in the lib directory to the lib directory of server.

Then, open the **iotdb-datanode.properties** in the conf directory of server, and set the `schema_engine_mode` to
**Tag**, set the `enable_id_table` to **true**. Restart the IoTDB, the system will use `TagSchemaRegion` to manage
the metadata.

## Use Cli

IoTDB offers different ways to interact with server, here we introduce the basic steps of using Cli tool to insert and query data.
The command line cli is interactive, so you should see the welcome logo and statements if everything is ready:
```sql
---------------------
Starting IoTDB Cli
---------------------
_____ _________ ______ ______
|_ _| | _ _ ||_ _ `.|_ _ \
| | .--.|_/ | | \_| | | `. \ | |_) |
| | / .'`\ \ | | | | | | | __'.
_| |_| \__. | _| |_ _| |_.' /_| |__) |
|_____|'.__.' |_____| |______.'|_______/ version 0.14.0-SNAPSHOT


IoTDB> login successfully
```
### create timeseries

- create timeseries

```sql
IoTDB> create timeseries root.ln.tag1.a.tag2.b.status with datatype=BOOLEAN,encoding=PLAIN
Msg: The statement is executed successfully.
```
- create aligned timeseries

```sql
IoTDB> CREATE ALIGNED TIMESERIES root.ln.tag1.a.tag2.c(latitude FLOAT encoding=PLAIN compressor=SNAPPY, longitude FLOAT encoding=PLAIN compressor=SNAPPY)

Msg: The statement is executed successfully.
```

### show timeserie

- point query

enter a full path

```sql
IoTDB> show timeseries root.ln.tag2.c.tag1.a
+-------------------------------+-----+-------------+--------+--------+-----------+----+----------+
| timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|
+-------------------------------+-----+-------------+--------+--------+-----------+----+----------+
| root.ln.tag1.a.tag2.c.latitude| null| root.ln| FLOAT| PLAIN| SNAPPY|null| null|
|root.ln.tag1.a.tag2.c.longitude| null| root.ln| FLOAT| PLAIN| SNAPPY|null| null|
+-------------------------------+-----+-------------+--------+--------+-----------+----+----------+
```

- batch query

paths ending in ".**" indicate batch query

```sql
IoTDB> show timeseries root.ln.tag1.a.**
+-------------------------------+-----+-------------+--------+--------+-----------+----+----------+
| timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|
+-------------------------------+-----+-------------+--------+--------+-----------+----+----------+
| root.ln.tag1.a.tag2.b.status| null| root.ln| BOOLEAN| PLAIN| SNAPPY|null| null|
| root.ln.tag1.a.tag2.c.latitude| null| root.ln| FLOAT| PLAIN| SNAPPY|null| null|
|root.ln.tag1.a.tag2.c.longitude| null| root.ln| FLOAT| PLAIN| SNAPPY|null| null|
+-------------------------------+-----+-------------+--------+--------+-----------+----+----------+

IoTDB> show timeseries root.ln.tag2.c.**
+-------------------------------+-----+-------------+--------+--------+-----------+----+----------+
| timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|
+-------------------------------+-----+-------------+--------+--------+-----------+----+----------+
| root.ln.tag1.a.tag2.c.latitude| null| root.ln| FLOAT| PLAIN| SNAPPY|null| null|
|root.ln.tag1.a.tag2.c.longitude| null| root.ln| FLOAT| PLAIN| SNAPPY|null| null|
+-------------------------------+-----+-------------+--------+--------+-----------+----+----------+

IoTDB> show timeseries root.ln.tag2.b.**
+----------------------------+-----+-------------+--------+--------+-----------+----+----------+
| timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|
+----------------------------+-----+-------------+--------+--------+-----------+----+----------+
|root.ln.tag1.a.tag2.b.status| null| root.ln| BOOLEAN| PLAIN| SNAPPY|null| null|
+----------------------------+-----+-------------+--------+--------+-----------+----+----------+
```

### insert

- insert a single column of data

```sql
IoTDB> insert into root.ln.tag2.d(timestamp,status) values(1,true)
Msg: The statement is executed successfully.
IoTDB> insert into root.ln.tag2.d(timestamp,status) values(2,false)
Msg: The statement is executed successfully.
IoTDB> insert into root.ln.tag2.d(timestamp,status) values(3,true)
Msg: The statement is executed successfully.
IoTDB> insert into root.ln.tag1.a.tag2.d(timestamp,status) values(1,true)
Msg: The statement is executed successfully.
```

- insert alignment data

```sql
IoTDB> insert into root.sg1.tag1.a(time, s1, s2) aligned values(2, 2, 2), (3, 3, 3)
Msg: The statement is executed successfully.
```

### select

- point query

```sql
IoTDB> select * from root.sg1.tag1.a
+-----------------------------+------------------+------------------+
| Time|root.sg1.tag1.a.s1|root.sg1.tag1.a.s2|
+-----------------------------+------------------+------------------+
|1970-01-01T08:00:00.002+08:00| 2.0| 2.0|
|1970-01-01T08:00:00.003+08:00| 3.0| 3.0|
+-----------------------------+------------------+------------------+
```

- align by device

```sql
IoTDB> select * from root.sg1.tag1.a align by device
+-----------------------------+---------------+---+---+
| Time| Device| s1| s2|
+-----------------------------+---------------+---+---+
|1970-01-01T08:00:00.002+08:00|root.sg1.tag1.a|2.0|2.0|
|1970-01-01T08:00:00.003+08:00|root.sg1.tag1.a|3.0|3.0|
+-----------------------------+---------------+---+---+
```

- batch query

```sql
IoTDB> select status from root.ln.tag2.d.** where time < 2017-11-01T00:08:00.000
+-----------------------------+----------------------------+---------------------+
| Time|root.ln.tag1.a.tag2.d.status|root.ln.tag2.d.status|
+-----------------------------+----------------------------+---------------------+
|1970-01-01T08:00:00.001+08:00| true| true|
|1970-01-01T08:00:00.002+08:00| null| false|
|1970-01-01T08:00:00.003+08:00| null| true|
+-----------------------------+----------------------------+---------------------+
```
81 changes: 81 additions & 0 deletions schema-engine-tag/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

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.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>iotdb-parent</artifactId>
<groupId>org.apache.iotdb</groupId>
<version>0.14.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>schema-engine-tag</artifactId>
<name>schema-engine-tag</name>
<dependencies>
<dependency>
<groupId>org.roaringbitmap</groupId>
<artifactId>RoaringBitmap</artifactId>
<version>0.9.32</version>
</dependency>
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>iotdb-server</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.10.2</version>
</dependency>
</dependencies>
<build>
<finalName>schema-engine-tag</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven.assembly.version}</version>
<executions>
<!-- Package binaries-->
<execution>
<id>schema-engine-tag-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/assembly/schema-engine-tag.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# 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.
#

####################
### tag schema region Configuration
####################

# This configuration takes effect only when the schema engine mode is Tag.
# The mode is configured in the 'iotdb-datanode.properties'(schema_engine_mode=Tag).

# Datatype: int
# The size of wal buffer used to store a wal record.(unit: byte)
# wal_buffer_size = 1024*1024

# Datatype: int
# How many device ids a memtable can insert, beyond which the memtable will become immutable
# num_of_deviceIds_in_memTable = 65536
44 changes: 44 additions & 0 deletions schema-engine-tag/src/assembly/schema-engine-tag.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

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.

-->
<assembly>
<id>schema-engine-tag</id>
<formats>
<format>dir</format>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/lib/tag-schema-region</outputDirectory>
<includes>
<include>org.roaringbitmap:RoaringBitmap</include>
<include>org.apache.iotdb:schema-engine-tag</include>
</includes>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>src/assembly/resources</directory>
<outputDirectory>${file.separator}</outputDirectory>
</fileSet>
</fileSets>
</assembly>
Loading