Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
560c91d
day commit
lpf4254302 Jul 4, 2022
c42ea80
day commit
lpf4254302 Jul 4, 2022
54fa5eb
day commit
lpf4254302 Jul 4, 2022
bbf834b
day commit
lpf4254302 Jul 5, 2022
a442d72
day commit
lpf4254302 Jul 7, 2022
4d376f0
spotless formate
lpf4254302 Jul 7, 2022
e8c5493
1、fix npe
lpf4254302 Jul 7, 2022
e52f407
fix bugs
lpf4254302 Jul 8, 2022
c47ba4d
Fix:AlterTimeseriesPlan serialize falid
lpf4254302 Jul 8, 2022
44ad307
day commit
lpf4254302 Jul 13, 2022
8fb0e1d
Fix:old chunk writer use old type
lpf4254302 Jul 18, 2022
aa1a5f5
1、TsFileManager add rewrite lock
lpf4254302 Jul 21, 2022
07ae4f5
1、style check
lpf4254302 Jul 22, 2022
4171573
support aligned
lpf4254302 Jul 22, 2022
f4a3f7b
add AlteringLogAnalyzer
lpf4254302 Jul 25, 2022
409f1c2
day commit
lpf4254302 Jul 26, 2022
ff284f4
day commit
lpf4254302 Jul 28, 2022
1b148c1
day commit
lpf4254302 Jul 28, 2022
1519814
spotless:apply
lpf4254302 Jul 28, 2022
6aba760
1、log less
lpf4254302 Jul 28, 2022
0fcdd1c
Misspelling
lpf4254302 Jul 28, 2022
6cd5944
If alter fails, stop the process
lpf4254302 Jul 28, 2022
9bebe16
spotless:apply
lpf4254302 Jul 28, 2022
e291e31
add TODO
lpf4254302 Jul 28, 2022
5dfe662
day commit
lpf4254302 Aug 2, 2022
cfe6b49
add alter timeseries IT
lpf4254302 Aug 3, 2022
418b5d0
spotless:apply
lpf4254302 Aug 3, 2022
3d84215
1、Formatting of comments
lpf4254302 Aug 3, 2022
014a299
Merge branch 'master' of github.com:lpf4254302/iotdb
lpf4254302 Aug 3, 2022
95cad76
Merge remote-tracking branch 'origin/master' into support_alter_times…
lpf4254302 Aug 3, 2022
2de9c79
add license
lpf4254302 Aug 4, 2022
45c27d4
add license
lpf4254302 Aug 4, 2022
56eaaba
TsFileResourceStatus has been removed
lpf4254302 Aug 4, 2022
b0a1b3e
Merge branch 'master' of github.com:lpf4254302/iotdb
lpf4254302 Aug 5, 2022
4d70916
Merge branch 'master' into support_alter_timeseries
lpf4254302 Aug 5, 2022
40141fb
The process cannot access the file because it is being used by anothe…
lpf4254302 Aug 5, 2022
af8622a
In the user manual Timeseries. Md, add the section "Alter Timeseries"
lpf4254302 Aug 11, 2022
6130850
remove new ArrayList<>()
lpf4254302 Aug 11, 2022
eb7fe7e
Fix:These two steps result in two more IO operations before starting …
lpf4254302 Aug 11, 2022
84faef8
spotless:apply
lpf4254302 Aug 11, 2022
a3dd5ff
1、How about using seqFile.remove() to delete TsFiles, mods file and r…
lpf4254302 Aug 12, 2022
2e86984
Phase II development: daily push
lpf4254302 Aug 24, 2022
24fa6a1
1、alter schema - done
lpf4254302 Aug 26, 2022
921202d
Again fix: Merging chunks can be problematic when the same measuremen…
lpf4254302 Aug 31, 2022
9ee1e7e
Merge encoding/compression uses altering records
lpf4254302 Aug 31, 2022
736328d
1、unseq files are followed, and encoding is read from ordered files f…
lpf4254302 Sep 7, 2022
313a6ba
1、spotless:apply
lpf4254302 Sep 8, 2022
7acef86
daily commit
lpf4254302 Sep 13, 2022
851ff78
daily commit
lpf4254302 Sep 14, 2022
55f3858
daily commit
lpf4254302 Sep 14, 2022
36bc5a9
daily commit
lpf4254302 Sep 15, 2022
d1ebb3c
During DataRegion Recover, storageGroupName cannot be obtained by ful…
lpf4254302 Sep 16, 2022
dbc7e62
AlteringRecordsCache.isStorageGroupExsist logic changes:receive stora…
lpf4254302 Sep 16, 2022
39aeb1f
daily commit
lpf4254302 Sep 16, 2022
5c6695d
Merge remote-tracking branch 'origin/master' into support_alter_times…
lpf4254302 Sep 19, 2022
6027240
spotless:apply
lpf4254302 Sep 19, 2022
4a5bde7
spotless:apply
lpf4254302 Sep 19, 2022
61c60e2
merge master
lpf4254302 Sep 19, 2022
2ee7bf2
merge two test
lpf4254302 Sep 21, 2022
0b849bf
Merge remote-tracking branch 'origin/master' into support_alter_times…
lpf4254302 Sep 21, 2022
50ea31d
Replace countdownlauch with Future
lpf4254302 Sep 21, 2022
abc7757
the first case of RewriteTimeseriesTaskTest
lpf4254302 Sep 22, 2022
73582f3
RewriteTimeseriesTask passed
lpf4254302 Sep 23, 2022
7d00300
RewriteTimeseriesTask adds "No rewriting" test case
lpf4254302 Sep 23, 2022
26d5315
add step "REWRITE TIMESERIES" to IoTDBAlterTimeSeriesIT
lpf4254302 Sep 23, 2022
b7673fb
add test case "half align rewrite & half not align rewrite" to Rewrit…
lpf4254302 Sep 23, 2022
aa7d404
rename class TsFileRewriteExcutor->TsFileRewritePerformer
lpf4254302 Sep 23, 2022
d45e7b0
spotless
lpf4254302 Sep 23, 2022
9195936
add lisence
lpf4254302 Sep 23, 2022
09e0dd0
add doc for "rewrite timeseries"
lpf4254302 Sep 26, 2022
1729e43
Fix
lpf4254302 Sep 26, 2022
5de7c0a
Merge remote-tracking branch 'origin/master' into support_alter_times…
lpf4254302 Sep 27, 2022
9baafb8
Fix:resovle merge conflicts
lpf4254302 Sep 27, 2022
72a6481
spotless:apply
lpf4254302 Sep 27, 2022
e9f947a
spotless:apply
lpf4254302 Sep 27, 2022
86225cd
resolve the confict
lpf4254302 Sep 28, 2022
62a4986
Merge branch 'master' into support_alter_timeseries
lpf4254302 Sep 30, 2022
f137e04
spotless:apply
lpf4254302 Sep 30, 2022
d0e7af1
resolve the confict
lpf4254302 Sep 30, 2022
e16d259
Merge remote-tracking branch 'origin/master' into support_alter_times…
lpf4254302 Dec 9, 2022
a2d91a7
daily commit
lpf4254302 Dec 12, 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 @@ -38,7 +38,7 @@ statement
ddlStatement
: createStorageGroup | createTimeseries | createSchemaTemplate | createTimeseriesOfSchemaTemplate
| createFunction | createTrigger | createContinuousQuery
| alterTimeseries | deleteStorageGroup | deleteTimeseries | deletePartition | deleteTimeseriesOfSchemaTemplate
| alterTimeseries |rewriteTimeseries | deleteStorageGroup | deleteTimeseries | deletePartition | deleteTimeseriesOfSchemaTemplate
| dropFunction | dropTrigger | dropContinuousQuery | dropSchemaTemplate
| setTTL | unsetTTL | startTrigger | stopTrigger | setSchemaTemplate | unsetSchemaTemplate
| showStorageGroup | showDevices | showTimeseries | showChildPaths | showChildNodes
Expand All @@ -49,6 +49,9 @@ ddlStatement
| getRegionId | getTimeSlotList | getSeriesSlotList
;

rewriteTimeseries
: REWRITE TIMESERIES prefixPath;

dmlStatement
: selectStatement | insertStatement | deleteStatement;

Expand Down Expand Up @@ -185,6 +188,7 @@ alterClause
| ADD TAGS attributePair (COMMA attributePair)*
| ADD ATTRIBUTES attributePair (COMMA attributePair)*
| UPSERT aliasClause? tagClause? attributeClause?
| SETTYPE attributePair (COMMA attributePair)*
;

aliasClause
Expand Down
8 changes: 8 additions & 0 deletions antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ CLEAR
: C L E A R
;

REWRITE
: R E W R I T E
;

CLUSTER
: C L U S T E R
;
Expand Down Expand Up @@ -666,6 +670,10 @@ UPSERT
: U P S E R T
;

SETTYPE
: S E T T Y P E
;

URI
: U R I
;
Expand Down
12 changes: 12 additions & 0 deletions docs/UserGuide/Operate-Metadata/Timeseries.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ You can set different datatype, encoding, and compression for the timeseries in

It is also supported to set an alias, tag, and attribute for aligned timeseries.

## Alter Timeseries

To alter the encoding and compression of the timeseries we created before, we can use`ALTER TimeSeries <Path> SETTYPE encoding=<Encoding>,compression=<Compression>` statement.

The usage are as follows:

```
IoTDB> ALTER TimeSeries root.ln.wf01.wt01.status SETTYPE encoding=RLE
IoTDB> ALTER TimeSeries root.ln.wf01.wt01.status SETTYPE compression=SNAPPY
IoTDB> ALTER TimeSeries root.ln.wf01.wt01.status SETTYPE encoding=RLE,compression=SNAPPY
```

## Delete Timeseries

To delete the timeseries we created before, we are able to use `(DELETE | DROP) TimeSeries <PathPattern>` statement.
Expand Down
25 changes: 19 additions & 6 deletions docs/UserGuide/Reference/SQL-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,13 @@ Eg: IoTDB > DROP TIMESERIES root.ln.wf01.wt01.*
```
ALTER TIMESERIES fullPath alterClause
alterClause
: RENAME beforeName=ID TO currentName=ID
| SET property (COMMA property)*
| DROP ID (COMMA ID)*
| ADD TAGS property (COMMA property)*
| ADD ATTRIBUTES property (COMMA property)*
| UPSERT tagClause attributeClause
: RENAME beforeName=attributeKey TO currentName=attributeKey
| SET attributePair (COMMA attributePair)*
| DROP attributeKey (COMMA attributeKey)*
| ADD TAGS attributePair (COMMA attributePair)*
| ADD ATTRIBUTES attributePair (COMMA attributePair)*
| UPSERT aliasClause? tagClause? attributeClause?
| SETTYPE attributePair (COMMA attributePair)*
;
attributeClause
: (ATTRIBUTES LR_BRACKET property (COMMA property)* RR_BRACKET)?
Expand All @@ -207,6 +208,18 @@ Eg: ALTER timeseries root.turbine.d1.s1 DROP tag1, tag2
Eg: ALTER timeseries root.turbine.d1.s1 ADD TAGS tag3=v3, tag4=v4
Eg: ALTER timeseries root.turbine.d1.s1 ADD ATTRIBUTES attr3=v3, attr4=v4
EG: ALTER timeseries root.turbine.d1.s1 UPSERT TAGS(tag2=newV2, tag3=v3) ATTRIBUTES(attr3=v3, attr4=v4)
Eg: ALTER timeseries root.turbine.d1.s1 SETTYPE encoding=plain, compression=SNAPPY
```

* Rewrite Timeseries Statement
```
REWRITE TIMESERIES prefixPath
prefixPath
: ROOT (DOT nodeName)*
;
Eg: Rewrite Timeseries root.ln
Note: This statement can be used when "ALTER timeseries" has been called
Note: prefixPath is a storageGroup path
```

* Show All Timeseries Statement
Expand Down
27 changes: 20 additions & 7 deletions docs/zh/UserGuide/Reference/SQL-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,18 @@ Eg: IoTDB > DELETE TIMESERIES root.ln.wf01.wt01.*
Eg: IoTDB > DROP TIMESERIES root.ln.wf01.wt01.*
```

* 修改时间序列标签属性语句
* 修改时间序列标签属性、编码类型和压缩类型语句

```
ALTER TIMESERIES fullPath alterClause
alterClause
: RENAME beforeName=ID TO currentName=ID
| SET property (COMMA property)*
| DROP ID (COMMA ID)*
| ADD TAGS property (COMMA property)*
| ADD ATTRIBUTES property (COMMA property)*
| UPSERT tagClause attributeClause
: RENAME beforeName=attributeKey TO currentName=attributeKey
| SET attributePair (COMMA attributePair)*
| DROP attributeKey (COMMA attributeKey)*
| ADD TAGS attributePair (COMMA attributePair)*
| ADD ATTRIBUTES attributePair (COMMA attributePair)*
| UPSERT aliasClause? tagClause? attributeClause?
| SETTYPE attributePair (COMMA attributePair)*
;
attributeClause
: (ATTRIBUTES LR_BRACKET property (COMMA property)* RR_BRACKET)?
Expand All @@ -197,6 +198,18 @@ Eg: ALTER timeseries root.turbine.d1.s1 DROP tag1, tag2
Eg: ALTER timeseries root.turbine.d1.s1 ADD TAGS tag3=v3, tag4=v4
Eg: ALTER timeseries root.turbine.d1.s1 ADD ATTRIBUTES attr3=v3, attr4=v4
EG: ALTER timeseries root.turbine.d1.s1 UPSERT TAGS(tag2=newV2, tag3=v3) ATTRIBUTES(attr3=v3, attr4=v4)
Eg: ALTER timeseries root.turbine.d1.s1 SETTYPE encoding=plain, compression=SNAPPY
```

* 重写时间序列语句
```
REWRITE TIMESERIES prefixPath
prefixPath
: ROOT (DOT nodeName)*
;
Eg: Rewrite Timeseries root.ln
Note: This statement can be used when "ALTER timeseries" has been called
Note: prefixPath is a storageGroup path
```

* 显示所有时间序列语句
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* 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.db.integration;

import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.integration.env.ConfigFactory;
import org.apache.iotdb.integration.env.EnvFactory;
import org.apache.iotdb.itbase.category.ClusterTest;
import org.apache.iotdb.itbase.category.LocalStandaloneTest;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import static org.junit.Assert.assertEquals;

@Category({LocalStandaloneTest.class, ClusterTest.class})
public class IoTDBAlterTimeSeriesIT {

private static final Logger logger = LoggerFactory.getLogger(IoTDBAlterTimeSeriesIT.class);
private long prevPartitionInterval;

@Before
public void setUp() throws Exception {
prevPartitionInterval = IoTDBDescriptor.getInstance().getConfig().getPartitionInterval();
ConfigFactory.getConfig().setPartitionInterval(1);
EnvFactory.getEnv().initBeforeTest();
}

@After
public void tearDown() throws Exception {
EnvFactory.getEnv().cleanAfterTest();
ConfigFactory.getConfig().setPartitionInterval(prevPartitionInterval);
}

@Test
public void testAlter() throws SQLException {
logger.info("test...");
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("SET STORAGE GROUP TO root.alterTimeSeriesTest");
try {
statement.execute(
"CREATE TIMESERIES root.alterTimeSeriesTest.s1 WITH DATATYPE=INT64,ENCODING=PLAIN");
statement.execute(
"CREATE TIMESERIES root.alterTimeSeriesTest.s2 WITH DATATYPE=INT64,ENCODING=PLAIN");
} catch (SQLException e) {
// ignore
}

for (int i = 1; i <= 1000; i++) {
statement.execute(
String.format(
"INSERT INTO root.alterTimeSeriesTest(timestamp,s1,s2) VALUES (%d,%d,%d)",
i, i, i));
}
statement.execute("FLUSH");
ResultSet resultSetP = statement.executeQuery("show timeseries root.alterTimeSeriesTest.s1");
while (resultSetP.next()) {
assertEquals(resultSetP.getString("encoding"), "PLAIN");
assertEquals(resultSetP.getString("compression"), "SNAPPY");
}
statement.execute(
"alter timeseries root.alterTimeSeriesTest.s1 settype encoding=gorilla,compression=gzip");

ResultSet resultSetAL = statement.executeQuery("show timeseries root.alterTimeSeriesTest.s1");
while (resultSetAL.next()) {
assertEquals(resultSetAL.getString("encoding"), "GORILLA");
assertEquals(resultSetAL.getString("compression"), "GZIP");
}
for (int i = 1001; i <= 1010; i++) {
statement.execute(
String.format(
"INSERT INTO root.alterTimeSeriesTest(timestamp,s1,s2) VALUES (%d,%d,%d)",
i, i, i));
}

try (ResultSet resultSet = statement.executeQuery("SELECT * FROM root.alterTimeSeriesTest")) {
int cur = 1;
int count = 0;
while (resultSet.next()) {
long time = resultSet.getLong("Time");
long s1 = resultSet.getLong("root.alterTimeSeriesTest.s1");
long s2 = resultSet.getLong("root.alterTimeSeriesTest.s2");

assertEquals(cur, time);
assertEquals(cur, s1);
assertEquals(cur, s2);
cur++;
count++;
}
assertEquals(1010, count);
}

statement.execute("REWRITE TIMESERIES root.alterTimeSeriesTest");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ private IoTDBConstant() {}
// compaction mods of previous version (<0.13)
public static final String COMPACTION_MODIFICATION_FILE_NAME_FROM_OLD = "merge.mods";

// alter timeseries temp file
public static final String ALTER_TMP_FILE_SUFFIX = ".alter";
public static final String ALTER_OLD_TMP_FILE_SUFFIX = ".alter.old";
public static final String ALTER_TMP_FILE_RESOURCE_SUFFIX = ".alter.resource";
public static final String ALTER_OLD_TMP_FILE_RESOURCE_SUFFIX = ".alter.old.resource";

// write ahead log
public static final String WAL_FILE_PREFIX = "_";
public static final String WAL_FILE_SUFFIX = ".wal";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1827,6 +1827,13 @@ public long countPathsUsingTemplate(int templateId, PathPatternTree patternTree)
throw new UnsupportedOperationException();
}

@Override
public Pair<TSEncoding, CompressionType> alterTimeseriesEncodingCompressionType(
PartialPath fullPath, TSEncoding curEncoding, CompressionType curCompressionType)
throws MetadataException, IOException {
throw new UnsupportedOperationException();
}

@Override
public String toString() {
return String.format("database:[%s]", storageGroupFullPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
import org.apache.iotdb.db.metadata.schemaregion.rocksdb.RSchemaConstants;
import org.apache.iotdb.db.metadata.schemaregion.rocksdb.RSchemaReadWriteHandler;
import org.apache.iotdb.db.metadata.schemaregion.rocksdb.RSchemaUtils;
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.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
Expand Down Expand Up @@ -127,6 +129,16 @@ public void setAlias(String alias) {
this.alias = alias;
}

@Override
public void updateSchemaInfo(
String measurementId,
TSEncoding encoding,
CompressionType compressionType,
Map<String, String> props) {
// TODO not support now
throw new UnsupportedOperationException("only for alter timeSeries");
}

@Override
public boolean isPreDeleted() {
return false;
Expand Down
21 changes: 21 additions & 0 deletions server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,11 @@ public class IoTDBConfig {
// customizedProperties, this should be empty by default.
private Properties customizedProperties = new Properties();

/** TsFileManager Rewrite lock timeout */
private long rewriteLockWaitTimeoutInMS = (int) TimeUnit.MINUTES.toMillis(1);

private long rewriteCandidateStatusWaitTimeoutInMs = TimeUnit.MINUTES.toMillis(10);

IoTDBConfig() {}

public float getUdfMemoryBudgetInMB() {
Expand Down Expand Up @@ -3329,6 +3334,22 @@ public String getConfigMessage() {
return configMessage;
}

public long getRewriteLockWaitTimeoutInMS() {
return rewriteLockWaitTimeoutInMS;
}

public void setRewriteLockWaitTimeoutInMS(long rewriteLockWaitTimeoutInMS) {
this.rewriteLockWaitTimeoutInMS = rewriteLockWaitTimeoutInMS;
}

public long getRewriteCandidateStatusWaitTimeoutInMs() {
return rewriteCandidateStatusWaitTimeoutInMs;
}

public void setRewriteCandidateStatusWaitTimeoutInMs(long rewriteCandidateStatusWaitTimeoutInMs) {
this.rewriteCandidateStatusWaitTimeoutInMs = rewriteCandidateStatusWaitTimeoutInMs;
}

public long getDataRatisConsensusSnapshotTriggerThreshold() {
return dataRatisConsensusSnapshotTriggerThreshold;
}
Expand Down
Loading