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 adb5926 [IOTDB-870] change tags and attributes output format to two
columns with json values(#1731)
adb5926 is described below
commit adb592624ad98e5b885ac701d3c2f3e680b24279
Author: Haimei Guo <[email protected]>
AuthorDate: Sun Sep 27 11:01:38 2020 +0800
[IOTDB-870] change tags and attributes output format to two columns with
json values(#1731)
---
.../org/apache/iotdb/db/conf/IoTDBConstant.java | 2 +
.../org/apache/iotdb/db/metadata/MManager.java | 30 +--
.../apache/iotdb/db/qp/executor/PlanExecutor.java | 10 +-
.../db/query/dataset/ShowTimeSeriesResult.java | 81 ++++---
.../db/query/dataset/ShowTimeseriesDataSet.java | 81 +++++--
.../java/org/apache/iotdb/db/utils/QueryUtils.java | 107 ---------
.../iotdb/db/integration/IoTDBAddSubDeviceIT.java | 9 +-
.../iotdb/db/integration/IoTDBMetadataFetchIT.java | 22 +-
.../integration/IoTDBSortedShowTimeseriesIT.java | 127 +++++-----
.../iotdb/db/integration/IoTDBTagAlterIT.java | 132 +++++------
.../apache/iotdb/db/integration/IoTDBTagIT.java | 259 ++++++++++++---------
11 files changed, 425 insertions(+), 435 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConstant.java
b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConstant.java
index 3e8b4df..e8ac636 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConstant.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConstant.java
@@ -70,6 +70,8 @@ public class IoTDBConstant {
public static final String COLUMN_DEVICES = "devices";
public static final String COLUMN_COLUMN = "column";
public static final String COLUMN_COUNT = "count";
+ public static final String COLUMN_TAGS = "tags";
+ public static final String COLUMN_ATTRIBUTES = "attributes";
public static final String COLUMN_ROLE = "role";
public static final String COLUMN_USER = "user";
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
index 353cfff..8d079eb 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
@@ -936,15 +936,13 @@ public class MManager {
}
}
try {
- Pair<Map<String, String>, Map<String, String>> pair =
+ Pair<Map<String, String>, Map<String, String>> tagAndAttributePair
=
tagLogFile.read(config.getTagAttributeTotalSize(),
leaf.getOffset());
- pair.left.putAll(pair.right);
MeasurementSchema measurementSchema = leaf.getSchema();
res.add(new ShowTimeSeriesResult(leaf.getFullPath(),
leaf.getAlias(),
- getStorageGroupPath(leaf.getPartialPath()).getFullPath(),
- measurementSchema.getType().toString(),
- measurementSchema.getEncodingType().toString(),
- measurementSchema.getCompressor().toString(), pair.left));
+ getStorageGroupPath(leaf.getPartialPath()).getFullPath(),
measurementSchema.getType(),
+ measurementSchema.getEncodingType(),
+ measurementSchema.getCompressor(), tagAndAttributePair.left,
tagAndAttributePair.right));
if (limit != 0) {
count++;
}
@@ -1005,20 +1003,14 @@ public class MManager {
for (Pair<PartialPath, String[]> ansString : ans) {
long tagFileOffset = Long.parseLong(ansString.right[5]);
try {
- if (tagFileOffset < 0) {
- // no tags/attributes
- res.add(new ShowTimeSeriesResult(ansString.left.getFullPath(),
ansString.right[0],
- ansString.right[1], ansString.right[2],
- ansString.right[3], ansString.right[4],
Collections.emptyMap()));
- } else {
- // has tags/attributes
- Pair<Map<String, String>, Map<String, String>> pair =
- tagLogFile.read(config.getTagAttributeTotalSize(),
tagFileOffset);
- pair.left.putAll(pair.right);
- res.add(new ShowTimeSeriesResult(ansString.left.getFullPath(),
ansString.right[0],
- ansString.right[1], ansString.right[2],
- ansString.right[3], ansString.right[4], pair.left));
+ Pair<Map<String, String>, Map<String, String>> tagAndAttributePair =
+ new Pair<>(Collections.emptyMap(),Collections.emptyMap());
+ if (tagFileOffset >= 0) {
+ tagAndAttributePair =
tagLogFile.read(config.getTagAttributeTotalSize(), tagFileOffset);
}
+ res.add(new ShowTimeSeriesResult(ansString.left.getFullPath(),
ansString.right[0], ansString.right[1],
+ TSDataType.valueOf(ansString.right[2]),
TSEncoding.valueOf(ansString.right[3]),
+ CompressionType.valueOf(ansString.right[4]),
tagAndAttributePair.left, tagAndAttributePair.right));
} catch (IOException e) {
throw new MetadataException(
"Something went wrong while deserialize tag info of " +
ansString.left.getFullPath(),
diff --git
a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
index 1085074..6146ccc 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
@@ -122,13 +122,13 @@ import org.apache.iotdb.db.query.context.QueryContext;
import org.apache.iotdb.db.query.dataset.AlignByDeviceDataSet;
import org.apache.iotdb.db.query.dataset.ListDataSet;
import org.apache.iotdb.db.query.dataset.ShowTimeSeriesResult;
+import org.apache.iotdb.db.query.dataset.ShowTimeseriesDataSet;
import org.apache.iotdb.db.query.dataset.SingleDataSet;
import org.apache.iotdb.db.query.executor.IQueryRouter;
import org.apache.iotdb.db.query.executor.QueryRouter;
import org.apache.iotdb.db.service.IoTDB;
import org.apache.iotdb.db.utils.AuthUtils;
import org.apache.iotdb.db.utils.FileLoaderUtils;
-import org.apache.iotdb.db.utils.QueryUtils;
import org.apache.iotdb.db.utils.UpgradeUtils;
import org.apache.iotdb.tsfile.common.constant.TsFileConstant;
import
org.apache.iotdb.tsfile.exception.filter.QueryFilterOptimizationException;
@@ -565,13 +565,7 @@ public class PlanExecutor implements IPlanExecutor {
private QueryDataSet processShowTimeseries(ShowTimeSeriesPlan
showTimeSeriesPlan,
QueryContext context) throws MetadataException {
- List<ShowTimeSeriesResult> timeseriesList =
showTimeseries(showTimeSeriesPlan, context);
- return QueryUtils.getQueryDataSet(timeseriesList, showTimeSeriesPlan,
context);
- }
-
- protected List<ShowTimeSeriesResult> showTimeseries(ShowTimeSeriesPlan plan,
QueryContext context)
- throws MetadataException {
- return IoTDB.metaManager.showTimeseries(plan, context);
+ return new ShowTimeseriesDataSet(showTimeSeriesPlan, context);
}
protected List<StorageGroupMNode> getAllStorageGroupNodes() {
diff --git
a/server/src/main/java/org/apache/iotdb/db/query/dataset/ShowTimeSeriesResult.java
b/server/src/main/java/org/apache/iotdb/db/query/dataset/ShowTimeSeriesResult.java
index f36cbb1..ee34ebe 100644
---
a/server/src/main/java/org/apache/iotdb/db/query/dataset/ShowTimeSeriesResult.java
+++
b/server/src/main/java/org/apache/iotdb/db/query/dataset/ShowTimeSeriesResult.java
@@ -25,6 +25,9 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
+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;
public class ShowTimeSeriesResult implements Comparable<ShowTimeSeriesResult> {
@@ -32,20 +35,22 @@ public class ShowTimeSeriesResult implements
Comparable<ShowTimeSeriesResult> {
private String name;
private String alias;
private String sgName;
- private String dataType;
- private String encoding;
- private String compressor;
- private Map<String, String> tagAndAttribute;
-
- public ShowTimeSeriesResult(String name, String alias, String sgName, String
dataType,
- String encoding, String compressor, Map<String, String> tagAndAttribute)
{
+ private TSDataType dataType;
+ private TSEncoding encoding;
+ private CompressionType compressor;
+ private Map<String, String> tags;
+ private Map<String, String> attributes;
+
+ public ShowTimeSeriesResult(String name, String alias, String sgName,
TSDataType dataType,
+ TSEncoding encoding, CompressionType compressor, Map<String, String>
tags, Map<String, String> attributes) {
this.name = name;
this.alias = alias;
this.sgName = sgName;
this.dataType = dataType;
this.encoding = encoding;
this.compressor = compressor;
- this.tagAndAttribute = tagAndAttribute;
+ this.tags = tags;
+ this.attributes = attributes;
}
public ShowTimeSeriesResult() {
@@ -64,20 +69,24 @@ public class ShowTimeSeriesResult implements
Comparable<ShowTimeSeriesResult> {
return sgName;
}
- public String getDataType() {
+ public TSDataType getDataType() {
return dataType;
}
- public String getEncoding() {
+ public TSEncoding getEncoding() {
return encoding;
}
- public String getCompressor() {
+ public CompressionType getCompressor() {
return compressor;
}
- public Map<String, String> getTagAndAttribute() {
- return tagAndAttribute;
+ public Map<String, String> getTag() {
+ return tags;
+ }
+
+ public Map<String, String> getAttribute() {
+ return attributes;
}
@Override
@@ -102,6 +111,17 @@ public class ShowTimeSeriesResult implements
Comparable<ShowTimeSeriesResult> {
return Objects.hash(name);
}
+ private void writeNullable(Map<String,String> param, OutputStream
outputStream) throws IOException {
+ ReadWriteIOUtils.write(param != null, outputStream);
+ if (param != null) {
+ ReadWriteIOUtils.write(tags.size(), outputStream);
+ for (Entry<String, String> entry : param.entrySet()) {
+ ReadWriteIOUtils.write(entry.getKey(), outputStream);
+ ReadWriteIOUtils.write(entry.getValue(), outputStream);
+ }
+ }
+ }
+
public void serialize(OutputStream outputStream) throws IOException {
ReadWriteIOUtils.write(name, outputStream);
ReadWriteIOUtils.write(alias != null, outputStream); //flag
@@ -113,14 +133,9 @@ public class ShowTimeSeriesResult implements
Comparable<ShowTimeSeriesResult> {
ReadWriteIOUtils.write(encoding, outputStream);
ReadWriteIOUtils.write(compressor, outputStream);
- ReadWriteIOUtils.write(tagAndAttribute != null, outputStream); //flag
- if (tagAndAttribute != null) {
- ReadWriteIOUtils.write(tagAndAttribute.size(), outputStream);
- for (Entry<String, String> stringStringEntry :
tagAndAttribute.entrySet()) {
- ReadWriteIOUtils.write(stringStringEntry.getKey(), outputStream);
- ReadWriteIOUtils.write(stringStringEntry.getValue(), outputStream);
- }
- }
+ //flag for tags and attributes
+ writeNullable(tags, outputStream);
+ writeNullable(attributes, outputStream);
}
public static ShowTimeSeriesResult deserialize(ByteBuffer buffer) {
@@ -130,17 +145,29 @@ public class ShowTimeSeriesResult implements
Comparable<ShowTimeSeriesResult> {
result.alias = ReadWriteIOUtils.readString(buffer);
}
result.sgName = ReadWriteIOUtils.readString(buffer);
- result.dataType = ReadWriteIOUtils.readString(buffer);
- result.encoding = ReadWriteIOUtils.readString(buffer);
- result.compressor = ReadWriteIOUtils.readString(buffer);
+ result.dataType = ReadWriteIOUtils.readDataType(buffer);
+ result.encoding = ReadWriteIOUtils.readEncoding(buffer);
+ result.compressor = ReadWriteIOUtils.readCompressionType(buffer);
- if (buffer.get() == 1) { //flag
+ //flag for tag
+ if (buffer.get() == 1) {
int tagSize = buffer.getInt();
- result.tagAndAttribute = new HashMap<>(tagSize);
+ result.tags = new HashMap<>(tagSize);
for (int i = 0; i < tagSize; i++) {
String key = ReadWriteIOUtils.readString(buffer);
String value = ReadWriteIOUtils.readString(buffer);
- result.tagAndAttribute.put(key, value);
+ result.tags.put(key, value);
+ }
+ }
+
+ //flag for attribute
+ if (buffer.get() == 1) {
+ int attributeSize = buffer.getInt();
+ result.attributes = new HashMap<>(attributeSize);
+ for (int i = 0; i < attributeSize; i++) {
+ String key = ReadWriteIOUtils.readString(buffer);
+ String value = ReadWriteIOUtils.readString(buffer);
+ result.attributes.put(key, value);
}
}
return result;
diff --git
a/server/src/main/java/org/apache/iotdb/db/query/dataset/ShowTimeseriesDataSet.java
b/server/src/main/java/org/apache/iotdb/db/query/dataset/ShowTimeseriesDataSet.java
index a283a11..c8b0ad0 100644
---
a/server/src/main/java/org/apache/iotdb/db/query/dataset/ShowTimeseriesDataSet.java
+++
b/server/src/main/java/org/apache/iotdb/db/query/dataset/ShowTimeseriesDataSet.java
@@ -19,20 +19,31 @@
package org.apache.iotdb.db.query.dataset;
-import static
org.apache.iotdb.db.utils.QueryUtils.transferShowTimeSeriesResultToRecordList;
-
+import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_ATTRIBUTES;
+import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_STORAGE_GROUP;
+import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TAGS;
+import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TIMESERIES;
+import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TIMESERIES_ALIAS;
+import static
org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TIMESERIES_COMPRESSION;
+import static
org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TIMESERIES_DATATYPE;
+import static
org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TIMESERIES_ENCODING;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
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.qp.physical.sys.ShowTimeSeriesPlan;
import org.apache.iotdb.db.query.context.QueryContext;
+import org.apache.iotdb.db.service.IoTDB;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.read.common.Field;
import org.apache.iotdb.tsfile.read.common.Path;
import org.apache.iotdb.tsfile.read.common.RowRecord;
import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
+import org.apache.iotdb.tsfile.utils.Binary;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,29 +51,73 @@ public class ShowTimeseriesDataSet extends QueryDataSet {
private static final Logger logger =
LoggerFactory.getLogger(ShowTimeseriesDataSet.class);
-
private final ShowTimeSeriesPlan plan;
private List<RowRecord> result = new ArrayList<>();
private int index = 0;
private QueryContext context;
- public boolean hasLimit = true;
+ public boolean hasLimit;
+
+ private static Path[] resourcePaths = {new PartialPath(COLUMN_TIMESERIES,
false),
+ new PartialPath(COLUMN_TIMESERIES_ALIAS, false), new
PartialPath(COLUMN_STORAGE_GROUP, false),
+ new PartialPath(COLUMN_TIMESERIES_DATATYPE, false), new
PartialPath(COLUMN_TIMESERIES_ENCODING, false),
+ new PartialPath(COLUMN_TIMESERIES_COMPRESSION, false), new
PartialPath(COLUMN_TAGS, false),
+ new PartialPath(COLUMN_ATTRIBUTES, false)};
+ private static TSDataType[] resourceTypes = {TSDataType.TEXT,
TSDataType.TEXT, TSDataType.TEXT,
+ TSDataType.TEXT, TSDataType.TEXT, TSDataType.TEXT, TSDataType.TEXT,
TSDataType.TEXT};
- public ShowTimeseriesDataSet(List<PartialPath> paths, List<TSDataType>
dataTypes,
- ShowTimeSeriesPlan showTimeSeriesPlan, QueryContext context) {
- super(new ArrayList<>(paths), dataTypes);
+ public ShowTimeseriesDataSet(ShowTimeSeriesPlan showTimeSeriesPlan,
QueryContext context)
+ throws MetadataException {
+ super(Arrays.asList(resourcePaths), Arrays.asList(resourceTypes));
this.plan = showTimeSeriesPlan;
this.context = context;
+ hasLimit = plan.hasLimit();
+ getQueryDataSet();
+ }
+
+ public List<RowRecord> getQueryDataSet() throws MetadataException {
+ List<ShowTimeSeriesResult> timeseriesList =
IoTDB.metaManager.showTimeseries(plan, context);
+ List<RowRecord> records = new ArrayList<>();
+ for (ShowTimeSeriesResult result : timeseriesList) {
+ RowRecord record = new RowRecord(0);
+ updateRecord(record, result.getName());
+ updateRecord(record, result.getAlias());
+ updateRecord(record, result.getSgName());
+ updateRecord(record, result.getDataType().toString());
+ updateRecord(record, result.getEncoding().toString());
+ updateRecord(record, result.getCompressor().toString());
+ updateRecord(record, result.getTag());
+ updateRecord(record, result.getAttribute());
+ records.add(record);
+ putRecord(record);
+ }
+ return records;
+ }
+
+ private void updateRecord(RowRecord record, Map<String, String> map) {
+ String text = map.entrySet().stream()
+ .map(e -> "\"" + e.getKey() + "\"" + ":" + "\"" + e.getValue() + "\"")
+ .collect(Collectors.joining(","));
+
+ updateRecord(record, text.length() == 0 ? null : "{" + text + "}");
+ }
+
+ private void updateRecord(RowRecord record, String s) {
+ if (s == null) {
+ record.addField(null);
+ return;
+ }
+ Field field = new Field(TSDataType.TEXT);
+ field.setBinaryV(new Binary(s));
+ record.addField(field);
}
@Override
protected boolean hasNextWithoutConstraint() throws IOException {
- if (index == result.size() && !hasLimit) {
+ if (index == result.size() && !hasLimit && result.size() ==
plan.getLimit()) {
plan.setOffset(plan.getOffset() + plan.getLimit());
try {
- List<ShowTimeSeriesResult> showTimeSeriesResults =
MManager.getInstance()
- .showTimeseries(plan, context);
- result =
transferShowTimeSeriesResultToRecordList(showTimeSeriesResults);
+ result = getQueryDataSet();
index = 0;
} catch (MetadataException e) {
logger.error("Something wrong happened while showing {}",
paths.stream().map(
@@ -78,7 +133,7 @@ public class ShowTimeseriesDataSet extends QueryDataSet {
return result.get(index++);
}
- public void putRecord(RowRecord newRecord) {
+ private void putRecord(RowRecord newRecord) {
result.add(newRecord);
}
}
diff --git a/server/src/main/java/org/apache/iotdb/db/utils/QueryUtils.java
b/server/src/main/java/org/apache/iotdb/db/utils/QueryUtils.java
index b34b421..7e90db2 100644
--- a/server/src/main/java/org/apache/iotdb/db/utils/QueryUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/utils/QueryUtils.java
@@ -19,35 +19,14 @@
package org.apache.iotdb.db.utils;
-import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_STORAGE_GROUP;
-import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TIMESERIES;
-import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TIMESERIES_ALIAS;
-import static
org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TIMESERIES_COMPRESSION;
-import static
org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TIMESERIES_DATATYPE;
-import static
org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TIMESERIES_ENCODING;
-
-import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
import org.apache.iotdb.db.engine.modification.Deletion;
import org.apache.iotdb.db.engine.modification.Modification;
import org.apache.iotdb.db.engine.querycontext.QueryDataSource;
import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
-import org.apache.iotdb.db.metadata.PartialPath;
-import org.apache.iotdb.db.qp.physical.sys.ShowTimeSeriesPlan;
-import org.apache.iotdb.db.query.context.QueryContext;
-import org.apache.iotdb.db.query.dataset.ShowTimeSeriesResult;
-import org.apache.iotdb.db.query.dataset.ShowTimeseriesDataSet;
import org.apache.iotdb.db.query.filter.TsFileFilter;
import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.read.common.Field;
-import org.apache.iotdb.tsfile.read.common.RowRecord;
import org.apache.iotdb.tsfile.read.common.TimeRange;
-import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
-import org.apache.iotdb.tsfile.utils.Binary;
public class QueryUtils {
@@ -111,90 +90,4 @@ public class QueryUtils {
seqResources.removeIf(fileFilter::fileNotSatisfy);
unseqResources.removeIf(fileFilter::fileNotSatisfy);
}
-
- public static void constructPathAndDataTypes(List<PartialPath> paths,
List<TSDataType> dataTypes,
- List<ShowTimeSeriesResult> timeseriesList) {
- paths.add(new PartialPath(COLUMN_TIMESERIES, false));
- dataTypes.add(TSDataType.TEXT);
- paths.add(new PartialPath(COLUMN_TIMESERIES_ALIAS, false));
- dataTypes.add(TSDataType.TEXT);
- paths.add(new PartialPath(COLUMN_STORAGE_GROUP, false));
- dataTypes.add(TSDataType.TEXT);
- paths.add(new PartialPath(COLUMN_TIMESERIES_DATATYPE, false));
- dataTypes.add(TSDataType.TEXT);
- paths.add(new PartialPath(COLUMN_TIMESERIES_ENCODING, false));
- dataTypes.add(TSDataType.TEXT);
- paths.add(new PartialPath(COLUMN_TIMESERIES_COMPRESSION, false));
- dataTypes.add(TSDataType.TEXT);
-
- Set<String> tagAndAttributeName = new TreeSet<>();
- for (ShowTimeSeriesResult result : timeseriesList) {
- tagAndAttributeName.addAll(result.getTagAndAttribute().keySet());
- }
- for (String key : tagAndAttributeName) {
- paths.add(new PartialPath(key, false));
- dataTypes.add(TSDataType.TEXT);
- }
- }
-
- public static QueryDataSet getQueryDataSet(List<ShowTimeSeriesResult>
timeseriesList,
- ShowTimeSeriesPlan showTimeSeriesPlan, QueryContext context) {
- List<PartialPath> paths = new ArrayList<>();
- List<TSDataType> dataTypes = new ArrayList<>();
- constructPathAndDataTypes(paths, dataTypes, timeseriesList);
- ShowTimeseriesDataSet showTimeseriesDataSet = new
ShowTimeseriesDataSet(paths, dataTypes,
- showTimeSeriesPlan, context);
-
- showTimeseriesDataSet.hasLimit = showTimeSeriesPlan.hasLimit();
-
- for (ShowTimeSeriesResult result : timeseriesList) {
- RowRecord record = new RowRecord(0);
- updateRecord(record, result.getName());
- updateRecord(record, result.getAlias());
- updateRecord(record, result.getSgName());
- updateRecord(record, result.getDataType());
- updateRecord(record, result.getEncoding());
- updateRecord(record, result.getCompressor());
- updateRecord(record, result.getTagAndAttribute(), paths);
- showTimeseriesDataSet.putRecord(record);
- }
- return showTimeseriesDataSet;
- }
-
- public static List<RowRecord> transferShowTimeSeriesResultToRecordList(
- List<ShowTimeSeriesResult> timeseriesList) {
- List<RowRecord> records = new ArrayList<>();
- List<PartialPath> paths = new ArrayList<>();
- List<TSDataType> dataTypes = new ArrayList<>();
- constructPathAndDataTypes(paths, dataTypes, timeseriesList);
- for (ShowTimeSeriesResult result : timeseriesList) {
- RowRecord record = new RowRecord(0);
- updateRecord(record, result.getName());
- updateRecord(record, result.getAlias());
- updateRecord(record, result.getSgName());
- updateRecord(record, result.getDataType());
- updateRecord(record, result.getEncoding());
- updateRecord(record, result.getCompressor());
- updateRecord(record, result.getTagAndAttribute(), paths);
- records.add(record);
- }
- return records;
- }
-
- private static void updateRecord(
- RowRecord record, Map<String, String> tagAndAttribute, List<PartialPath>
paths) {
- for (int i = 6; i < paths.size(); i++) {
- updateRecord(record, tagAndAttribute.get(paths.get(i).getFullPath()));
- }
- }
-
- private static void updateRecord(RowRecord record, String s) {
- if (s == null) {
- record.addField(null);
- return;
- }
- Field field = new Field(TSDataType.TEXT);
- field.setBinaryV(new Binary(s));
- record.addField(field);
- }
}
diff --git
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAddSubDeviceIT.java
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAddSubDeviceIT.java
index e01772d..c458a01 100644
---
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAddSubDeviceIT.java
+++
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAddSubDeviceIT.java
@@ -116,9 +116,9 @@ public class IoTDBAddSubDeviceIT {
@Test
public void showTimeseries() throws ClassNotFoundException {
String[] retArray = new String[]{
- "root.sg1.d1.s1,null,root.sg1,INT32,RLE,SNAPPY,",
- "root.sg1.d1.s1.s1,null,root.sg1,INT32,RLE,SNAPPY,",
- "root.sg1.d1.s1.s2,null,root.sg1,INT32,RLE,SNAPPY,",
+ "root.sg1.d1.s1,null,root.sg1,INT32,RLE,SNAPPY,null,null,",
+ "root.sg1.d1.s1.s1,null,root.sg1,INT32,RLE,SNAPPY,null,null,",
+ "root.sg1.d1.s1.s2,null,root.sg1,INT32,RLE,SNAPPY,null,null,",
};
Class.forName(Config.JDBC_DRIVER_NAME);
@@ -135,7 +135,8 @@ public class IoTDBAddSubDeviceIT {
for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
header.append(resultSetMetaData.getColumnName(i)).append(",");
}
- Assert.assertEquals("timeseries,alias,storage
group,dataType,encoding,compression,", header.toString());
+ Assert.assertEquals("timeseries,alias,storage
group,dataType,encoding,compression,tags,attributes,",
+ header.toString());
Assert.assertEquals(Types.VARCHAR, resultSetMetaData.getColumnType(1));
int cnt = 0;
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 59853e8..24dd276 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
@@ -90,20 +90,20 @@ public class IoTDBMetadataFetchIT {
"show timeseries root.a.b", // nonexistent timeseries, thus
returning ""
};
String[] standards = new String[]{
-
"root.ln.wf01.wt01.status,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,\n"
- +
"root.ln.wf01.wt01.status.s1,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,\n",
+
"root.ln.wf01.wt01.status,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,null,null,\n"
+ +
"root.ln.wf01.wt01.status.s1,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,null,null,\n",
-
"root.ln.wf01.wt01.status,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,\n"
- +
"root.ln.wf01.wt01.status.s1,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,\n"
- +
"root.ln.wf01.wt01.temperature,null,root.ln.wf01.wt01,FLOAT,RLE,SNAPPY,\n",
+
"root.ln.wf01.wt01.status,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,null,null,\n"
+ +
"root.ln.wf01.wt01.status.s1,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,null,null,\n"
+ +
"root.ln.wf01.wt01.temperature,null,root.ln.wf01.wt01,FLOAT,RLE,SNAPPY,null,null,\n",
-
"root.ln.wf01.wt01.status,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,\n"
- +
"root.ln.wf01.wt01.status.s1,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,\n"
- +
"root.ln.wf01.wt01.temperature,null,root.ln.wf01.wt01,FLOAT,RLE,SNAPPY,\n",
+
"root.ln.wf01.wt01.status,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,null,null,\n"
+ +
"root.ln.wf01.wt01.status.s1,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,null,null,\n"
+ +
"root.ln.wf01.wt01.temperature,null,root.ln.wf01.wt01,FLOAT,RLE,SNAPPY,null,null,\n",
-
"root.ln.wf01.wt01.status,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,\n"
- +
"root.ln.wf01.wt01.status.s1,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,\n"
- +
"root.ln.wf01.wt01.temperature,null,root.ln.wf01.wt01,FLOAT,RLE,SNAPPY,\n",
+
"root.ln.wf01.wt01.status,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,null,null,\n"
+ +
"root.ln.wf01.wt01.status.s1,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,null,null,\n"
+ +
"root.ln.wf01.wt01.temperature,null,root.ln.wf01.wt01,FLOAT,RLE,SNAPPY,null,null,\n",
""
};
diff --git
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBSortedShowTimeseriesIT.java
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBSortedShowTimeseriesIT.java
index 8ad275d..c320606 100644
---
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBSortedShowTimeseriesIT.java
+++
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBSortedShowTimeseriesIT.java
@@ -97,33 +97,57 @@ public class IoTDBSortedShowTimeseriesIT {
@Test
public void showTimeseriesOrderByHeatTest1() throws ClassNotFoundException {
String[] retArray1 = new String[]{
- "root.turbine.d0.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,turbine
this is a test1,100,50,null,null,f",
- "root.turbine.d0.s1,power,root.turbine,FLOAT,RLE,SNAPPY,turbine this
is a test2,99.9,44.4,null,null,kw",
- "root.turbine.d0.s2,cpu,root.turbine,FLOAT,RLE,SNAPPY,turbine this is
a cpu,99.9,44.4,null,null,cores",
- "root.turbine.d0.s3,gpu0,root.turbine,FLOAT,RLE,SNAPPY,turbine this is
a gpu,99.9,44.4,null,null,cores",
- "root.turbine.d0.s4,tpu0,root.turbine,FLOAT,RLE,SNAPPY,turbine this is
a tpu,99.9,44.4,null,null,cores",
- "root.turbine.d1.s0,status,root.turbine,INT32,RLE,SNAPPY,turbine this
is a test3,9,5,null,null,null",
- "root.turbine.d2.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,turbine
d2 this is a test1,null,null,100,1,f",
- "root.turbine.d2.s1,power,root.turbine,FLOAT,RLE,SNAPPY,turbine d2
this is a test2,null,null,99.9,44.4,kw",
- "root.turbine.d2.s3,status,root.turbine,INT32,RLE,SNAPPY,turbine d2
this is a test3,null,null,9,5,null",
- "root.ln.d0.s0,temperature,root.ln,FLOAT,RLE,SNAPPY,ln this is a
test1,1000,500,null,null,c",
- "root.ln.d0.s1,power,root.ln,FLOAT,RLE,SNAPPY,ln this is a
test2,9.9,4.4,null,null,w",
- "root.ln.d1.s0,status,root.ln,INT32,RLE,SNAPPY,ln this is a
test3,90,50,null,null,null"
+
"root.turbine.d0.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\""
+ + "turbine this is a
test1\",\"unit\":\"f\"},{\"H_Alarm\":\"100\",\"M_Alarm\":\"50\"}",
+
"root.turbine.d0.s1,power,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
"
+ + "this is a
test2\",\"unit\":\"kw\"},{\"H_Alarm\":\"99.9\",\"M_Alarm\":\"44.4\"}",
+
"root.turbine.d0.s2,cpu,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
this "
+ + "is a
cpu\",\"unit\":\"cores\"},{\"H_Alarm\":\"99.9\",\"M_Alarm\":\"44.4\"}",
+
"root.turbine.d0.s3,gpu0,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
this "
+ + "is a
gpu\",\"unit\":\"cores\"},{\"H_Alarm\":\"99.9\",\"M_Alarm\":\"44.4\"}",
+
"root.turbine.d0.s4,tpu0,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
this "
+ + "is a
tpu\",\"unit\":\"cores\"},{\"H_Alarm\":\"99.9\",\"M_Alarm\":\"44.4\"}",
+
"root.turbine.d1.s0,status,root.turbine,INT32,RLE,SNAPPY,{\"description\":\"turbine
this "
+ + "is a test3\"},{\"H_Alarm\":\"9\",\"M_Alarm\":\"5\"}",
+
"root.turbine.d2.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine"
+ + " d2 this is a
test1\",\"unit\":\"f\"},{\"MinValue\":\"1\",\"MaxValue\":\"100\"}",
+
"root.turbine.d2.s1,power,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
d2 this"
+ + " is a
test2\",\"unit\":\"kw\"},{\"MinValue\":\"44.4\",\"MaxValue\":\"99.9\"}",
+
"root.turbine.d2.s3,status,root.turbine,INT32,RLE,SNAPPY,{\"description\":\"turbine
d2"
+ + " this is a test3\"},{\"MinValue\":\"5\",\"MaxValue\":\"9\"}",
+
"root.ln.d0.s0,temperature,root.ln,FLOAT,RLE,SNAPPY,{\"description\":\"ln this
is a "
+ +
"test1\",\"unit\":\"c\"},{\"H_Alarm\":\"1000\",\"M_Alarm\":\"500\"}",
+ "root.ln.d0.s1,power,root.ln,FLOAT,RLE,SNAPPY,{\"description\":\"ln
this is a test2\",\""
+ + "unit\":\"w\"},{\"H_Alarm\":\"9.9\",\"M_Alarm\":\"4.4\"}",
+ "root.ln.d1.s0,status,root.ln,INT32,RLE,SNAPPY,{\"description\":\"ln
this is a test3\"},"
+ + "{\"H_Alarm\":\"90\",\"M_Alarm\":\"50\"}"
};
String[] retArray2 = new String[]{
- "root.turbine.d2.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,turbine
d2 this is a test1,null,null,100,1,f",
- "root.turbine.d2.s1,power,root.turbine,FLOAT,RLE,SNAPPY,turbine d2
this is a test2,null,null,99.9,44.4,kw",
- "root.turbine.d2.s3,status,root.turbine,INT32,RLE,SNAPPY,turbine d2
this is a test3,null,null,9,5,null",
- "root.turbine.d0.s4,tpu0,root.turbine,FLOAT,RLE,SNAPPY,turbine this is
a tpu,99.9,44.4,null,null,cores",
- "root.turbine.d0.s3,gpu0,root.turbine,FLOAT,RLE,SNAPPY,turbine this is
a gpu,99.9,44.4,null,null,cores",
- "root.turbine.d0.s2,cpu,root.turbine,FLOAT,RLE,SNAPPY,turbine this is
a cpu,99.9,44.4,null,null,cores",
- "root.turbine.d0.s1,power,root.turbine,FLOAT,RLE,SNAPPY,turbine this
is a test2,99.9,44.4,null,null,kw",
- "root.turbine.d0.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,turbine
this is a test1,100,50,null,null,f",
- "root.turbine.d1.s0,status,root.turbine,INT32,RLE,SNAPPY,turbine this
is a test3,9,5,null,null,null",
- "root.ln.d0.s0,temperature,root.ln,FLOAT,RLE,SNAPPY,ln this is a
test1,1000,500,null,null,c",
- "root.ln.d0.s1,power,root.ln,FLOAT,RLE,SNAPPY,ln this is a
test2,9.9,4.4,null,null,w",
- "root.ln.d1.s0,status,root.ln,INT32,RLE,SNAPPY,ln this is a
test3,90,50,null,null,null",
+
"root.turbine.d2.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
d2 "
+ + "this is a
test1\",\"unit\":\"f\"},{\"MinValue\":\"1\",\"MaxValue\":\"100\"}",
+
"root.turbine.d2.s1,power,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
d2 this "
+ + "is a
test2\",\"unit\":\"kw\"},{\"MinValue\":\"44.4\",\"MaxValue\":\"99.9\"}",
+
"root.turbine.d2.s3,status,root.turbine,INT32,RLE,SNAPPY,{\"description\":\"turbine
d2 this "
+ + "is a test3\"},{\"MinValue\":\"5\",\"MaxValue\":\"9\"}",
+
"root.turbine.d0.s4,tpu0,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
this is a"
+ + "
tpu\",\"unit\":\"cores\"},{\"H_Alarm\":\"99.9\",\"M_Alarm\":\"44.4\"}",
+
"root.turbine.d0.s3,gpu0,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
this is a"
+ + "
gpu\",\"unit\":\"cores\"},{\"H_Alarm\":\"99.9\",\"M_Alarm\":\"44.4\"}",
+
"root.turbine.d0.s2,cpu,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
this is a "
+ +
"cpu\",\"unit\":\"cores\"},{\"H_Alarm\":\"99.9\",\"M_Alarm\":\"44.4\"}",
+
"root.turbine.d0.s1,power,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
this is a "
+ +
"test2\",\"unit\":\"kw\"},{\"H_Alarm\":\"99.9\",\"M_Alarm\":\"44.4\"}",
+
"root.turbine.d0.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine"
+ + " this is a
test1\",\"unit\":\"f\"},{\"H_Alarm\":\"100\",\"M_Alarm\":\"50\"}",
+
"root.turbine.d1.s0,status,root.turbine,INT32,RLE,SNAPPY,{\"description\":\"turbine
this is a "
+ + "test3\"},{\"H_Alarm\":\"9\",\"M_Alarm\":\"5\"}",
+
"root.ln.d0.s0,temperature,root.ln,FLOAT,RLE,SNAPPY,{\"description\":\"ln this
is a test1\""
+ + ",\"unit\":\"c\"},{\"H_Alarm\":\"1000\",\"M_Alarm\":\"500\"}",
+ "root.ln.d0.s1,power,root.ln,FLOAT,RLE,SNAPPY,{\"description\":\"ln
this is a test2\",\""
+ + "unit\":\"w\"},{\"H_Alarm\":\"9.9\",\"M_Alarm\":\"4.4\"}",
+ "root.ln.d1.s0,status,root.ln,INT32,RLE,SNAPPY,{\"description\":\"ln
this is a test3\"},"
+ + "{\"H_Alarm\":\"90\",\"M_Alarm\":\"50\"}",
};
Class.forName(Config.JDBC_DRIVER_NAME);
@@ -142,12 +166,8 @@ public class IoTDBSortedShowTimeseriesIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("description")
- + "," + resultSet.getString("H_Alarm")
- + "," + resultSet.getString("M_Alarm")
- + "," + resultSet.getString("MaxValue")
- + "," + resultSet.getString("MinValue")
- + "," + resultSet.getString("unit");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(retArray1[count], ans);
count++;
@@ -165,13 +185,8 @@ public class IoTDBSortedShowTimeseriesIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("description")
- + "," + resultSet.getString("H_Alarm")
- + "," + resultSet.getString("M_Alarm")
- + "," + resultSet.getString("MaxValue")
- + "," + resultSet.getString("MinValue")
- + "," + resultSet.getString("unit");
-
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
System.out.println("\"" + ans + "\",");
assertEquals(retArray2[count], ans);
count++;
@@ -188,11 +203,16 @@ public class IoTDBSortedShowTimeseriesIT {
public void showTimeseriesOrderByHeatWithLimitTest() throws
ClassNotFoundException {
String[] retArray = new String[]{
- "root.turbine.d2.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,turbine
d2 this is a test1,null,null,100,1,f",
- "root.turbine.d2.s1,power,root.turbine,FLOAT,RLE,SNAPPY,turbine d2
this is a test2,null,null,99.9,44.4,kw",
- "root.turbine.d2.s3,status,root.turbine,INT32,RLE,SNAPPY,turbine d2
this is a test3,null,null,9,5,null",
- "root.turbine.d0.s4,tpu0,root.turbine,FLOAT,RLE,SNAPPY,turbine this is
a tpu,99.9,44.4,null,null,cores",
- "root.turbine.d0.s3,gpu0,root.turbine,FLOAT,RLE,SNAPPY,turbine this is
a gpu,99.9,44.4,null,null,cores",
+
"root.turbine.d2.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
d2"
+ + " this is a
test1\",\"unit\":\"f\"},{\"MinValue\":\"1\",\"MaxValue\":\"100\"}",
+
"root.turbine.d2.s1,power,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
d2 this "
+ + "is a
test2\",\"unit\":\"kw\"},{\"MinValue\":\"44.4\",\"MaxValue\":\"99.9\"}",
+
"root.turbine.d2.s3,status,root.turbine,INT32,RLE,SNAPPY,{\"description\":\"turbine
d2 this "
+ + "is a test3\"},{\"MinValue\":\"5\",\"MaxValue\":\"9\"}",
+
"root.turbine.d0.s4,tpu0,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
this is a "
+ +
"tpu\",\"unit\":\"cores\"},{\"H_Alarm\":\"99.9\",\"M_Alarm\":\"44.4\"}",
+
"root.turbine.d0.s3,gpu0,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
this is a "
+ +
"gpu\",\"unit\":\"cores\"},{\"H_Alarm\":\"99.9\",\"M_Alarm\":\"44.4\"}",
};
Class.forName(Config.JDBC_DRIVER_NAME);
@@ -211,12 +231,8 @@ public class IoTDBSortedShowTimeseriesIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("description")
- + "," + resultSet.getString("H_Alarm")
- + "," + resultSet.getString("M_Alarm")
- + "," + resultSet.getString("MaxValue")
- + "," + resultSet.getString("MinValue")
- + "," + resultSet.getString("unit");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(retArray[count], ans);
count++;
@@ -233,9 +249,12 @@ public class IoTDBSortedShowTimeseriesIT {
public void showTimeseriesOrderByHeatWithWhereTest() throws
ClassNotFoundException {
String[] retArray = new String[]{
- "root.turbine.d0.s4,tpu0,root.turbine,FLOAT,RLE,SNAPPY,turbine this is
a tpu,99.9,44.4,cores",
- "root.turbine.d0.s3,gpu0,root.turbine,FLOAT,RLE,SNAPPY,turbine this is
a gpu,99.9,44.4,cores",
- "root.turbine.d0.s2,cpu,root.turbine,FLOAT,RLE,SNAPPY,turbine this is
a cpu,99.9,44.4,cores",
+
"root.turbine.d0.s4,tpu0,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
this is a"
+ + "
tpu\",\"unit\":\"cores\"},{\"H_Alarm\":\"99.9\",\"M_Alarm\":\"44.4\"}",
+
"root.turbine.d0.s3,gpu0,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
this is a "
+ +
"gpu\",\"unit\":\"cores\"},{\"H_Alarm\":\"99.9\",\"M_Alarm\":\"44.4\"}",
+
"root.turbine.d0.s2,cpu,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
this is a"
+ + "
cpu\",\"unit\":\"cores\"},{\"H_Alarm\":\"99.9\",\"M_Alarm\":\"44.4\"}",
};
Class.forName(Config.JDBC_DRIVER_NAME);
@@ -254,10 +273,8 @@ public class IoTDBSortedShowTimeseriesIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("description")
- + "," + resultSet.getString("H_Alarm")
- + "," + resultSet.getString("M_Alarm")
- + "," + resultSet.getString("unit");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(retArray[count], ans);
count++;
diff --git
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTagAlterIT.java
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTagAlterIT.java
index 11f9454..cbb7e62 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTagAlterIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTagAlterIT.java
@@ -48,9 +48,12 @@ public class IoTDBTagAlterIT {
@Test
public void renameTest() throws ClassNotFoundException {
- String[] ret =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,v1,v2,v1,v2"};
- String sql = "create timeseries root.turbine.d1.s1(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
- "tags(tag1=v1, tag2=v2) attributes(attr1=v1, attr2=v2)";
+ String[] ret1 =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"v1\",\"tag2\":\"v2\"},{\"attr2\":\"v2\",\"attr1\":\"v1\"}"};
+ String[] ret2 =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag2\":\"v2\",\"tagNew1\":\"v1\"},{\"attr2\":\"v2\",\"attr1\":\"v1\"}"};
+ String sql = "create timeseries root.turbine.d1.s1(temperature) with
datatype=FLOAT,"
+ + " encoding=RLE, compression=SNAPPY tags(tag1=v1, tag2=v2)
attributes(attr1=v1, attr2=v2)";
Class.forName(Config.JDBC_DRIVER_NAME);
try (Connection connection = DriverManager
.getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/",
"root", "root");
@@ -68,17 +71,15 @@ public class IoTDBTagAlterIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2");
- assertEquals(ret[count], ans);
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
+ assertEquals(ret1[count], ans);
count++;
}
} finally {
resultSet.close();
}
- assertEquals(ret.length, count);
+ assertEquals(ret1.length, count);
try {
statement.execute("ALTER timeseries root.turbine.d1.s1 RENAME tag3 TO
tagNew3");
@@ -107,17 +108,15 @@ public class IoTDBTagAlterIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tagNew1")
- + "," + resultSet.getString("tag2");
- assertEquals(ret[count], ans);
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
+ assertEquals(ret2[count], ans);
count++;
}
} finally {
resultSet.close();
}
- assertEquals(ret.length, count);
+ assertEquals(ret2.length, count);
} catch (Exception e) {
e.printStackTrace();
fail();
@@ -126,8 +125,10 @@ public class IoTDBTagAlterIT {
@Test
public void setTest() throws ClassNotFoundException {
- String[] ret =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,v1,v2,v1,v2"};
- String[] ret2 =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,v1,newV2,newV1,v2"};
+ String[] ret =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"v1\",\"tag2\":\"v2\"},{\"attr2\":\"v2\",\"attr1\":\"v1\"}"};
+ String[] ret2 =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"newV1\",\"tag2\":\"v2\"},{\"attr2\":\"newV2\",\"attr1\":\"v1\"}"};
String sql = "create timeseries root.turbine.d1.s1(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
"tags(tag1=v1, tag2=v2) attributes(attr1=v1, attr2=v2)";
@@ -148,10 +149,8 @@ public class IoTDBTagAlterIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret[count], ans);
count++;
}
@@ -180,10 +179,8 @@ public class IoTDBTagAlterIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret2[count], ans);
count++;
}
@@ -199,8 +196,9 @@ public class IoTDBTagAlterIT {
@Test
public void dropTest() throws ClassNotFoundException {
- String[] ret =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,v1,v2,v1,v2"};
- String[] ret2 =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,v2,v2"};
+ String[] ret =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"v1\",\"tag2\":\"v2\"},{\"attr2\":\"v2\",\"attr1\":\"v1\"}"};
+ String[] ret2 =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"tag2\":\"v2\"},{\"attr2\":\"v2\"}"};
String sql = "create timeseries root.turbine.d1.s1(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
"tags(tag1=v1, tag2=v2) attributes(attr1=v1, attr2=v2)";
@@ -221,10 +219,8 @@ public class IoTDBTagAlterIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret[count], ans);
count++;
}
@@ -246,8 +242,8 @@ public class IoTDBTagAlterIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tag2");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret2[count], ans);
count++;
}
@@ -270,8 +266,10 @@ public class IoTDBTagAlterIT {
@Test
public void addTagTest() throws ClassNotFoundException {
- String[] ret =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,v1,v2,v1,v2"};
- String[] ret2 =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,v1,v2,v1,v2,v3,v4"};
+ String[] ret =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"v1\",\"tag2\":\"v2\"},{\"attr2\":\"v2\",\"attr1\":\"v1\"}"};
+ String[] ret2 =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"v1\",\"tag4\":\"v4\",\"tag2\":\"v2\",\"tag3\":\"v3\"},{\"attr2\":\"v2\",\"attr1\":\"v1\"}"};
String sql = "create timeseries root.turbine.d1.s1(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
"tags(tag1=v1, tag2=v2) attributes(attr1=v1, attr2=v2)";
@@ -292,10 +290,8 @@ public class IoTDBTagAlterIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret[count], ans);
count++;
}
@@ -317,12 +313,8 @@ public class IoTDBTagAlterIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2")
- + "," + resultSet.getString("tag3")
- + "," + resultSet.getString("tag4");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret2[count], ans);
count++;
}
@@ -338,8 +330,10 @@ public class IoTDBTagAlterIT {
@Test
public void addAttributeTest() throws ClassNotFoundException {
- String[] ret =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,v1,v2,v1,v2"};
- String[] ret2 =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,v1,v2,v3,v4,v1,v2"};
+ String[] ret =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"v1\",\"tag2\":\"v2\"},{\"attr2\":\"v2\",\"attr1\":\"v1\"}"};
+ String[] ret2 =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"v1\",\"tag2\":\"v2\"},{\"attr2\":\"v2\",\"attr1\":\"v1\",\"attr4\":\"v4\",\"attr3\":\"v3\"}"};
String sql = "create timeseries root.turbine.d1.s1(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
"tags(tag1=v1, tag2=v2) attributes(attr1=v1, attr2=v2)";
@@ -360,10 +354,8 @@ public class IoTDBTagAlterIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret[count], ans);
count++;
}
@@ -385,12 +377,8 @@ public class IoTDBTagAlterIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("attr3")
- + "," + resultSet.getString("attr4")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret2[count], ans);
count++;
}
@@ -406,9 +394,12 @@ public class IoTDBTagAlterIT {
@Test
public void upsertTest() throws ClassNotFoundException {
- String[] ret =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,v1,v2,v1,v2"};
- String[] ret2 =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,v1,v2,v1,newV2,v3"};
- String[] ret3 =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,newA1,v2,v3,newV1,newV2,newV3"};
+ String[] ret =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"v1\",\"tag2\":\"v2\"},{\"attr2\":\"v2\",\"attr1\":\"v1\"}"};
+ String[] ret2 =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"tag1\":\"v1\",\"tag2\":\""
+ + "newV2\",\"tag3\":\"v3\"},{\"attr2\":\"v2\",\"attr1\":\"v1\"}"};
+ String[] ret3 =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"tag1\":\"newV1\",\"tag2\":\""
+ +
"newV2\",\"tag3\":\"newV3\"},{\"attr2\":\"v2\",\"attr1\":\"newA1\",\"attr3\":\"v3\"}"};
String sql = "create timeseries root.turbine.d1.s1(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
@@ -430,10 +421,8 @@ public class IoTDBTagAlterIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret[count], ans);
count++;
}
@@ -455,11 +444,8 @@ public class IoTDBTagAlterIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2")
- + "," + resultSet.getString("tag3");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret2[count], ans);
count++;
}
@@ -481,12 +467,8 @@ public class IoTDBTagAlterIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("attr3")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2")
- + "," + resultSet.getString("tag3");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret3[count], ans);
count++;
}
diff --git
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTagIT.java
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTagIT.java
index cb47145..705b060 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTagIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTagIT.java
@@ -50,7 +50,8 @@ public class IoTDBTagIT {
@Test
public void createOneTimeseriesTest() throws ClassNotFoundException {
- String[] ret =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,v1,v2,v1,v2"};
+ String[] ret =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"v1\",\"tag2\":\"v2\"},{\"attr2\":\"v2\",\"attr1\":\"v1\"}"};
String sql = "create timeseries root.turbine.d1.s1(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
"tags(tag1=v1, tag2=v2) attributes(attr1=v1, attr2=v2)";
Class.forName(Config.JDBC_DRIVER_NAME);
@@ -70,10 +71,8 @@ public class IoTDBTagIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret[count], ans);
count++;
}
@@ -90,8 +89,10 @@ public class IoTDBTagIT {
@Test
public void createMultiTimeseriesTest() throws ClassNotFoundException {
String[] ret = {
-
"root.turbine.d2.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,a1,a2,null,null,t1,t2,null",
-
"root.turbine.d2.s2,status,root.turbine,INT32,RLE,SNAPPY,null,null,a3,a4,null,t2,t3"
+
"root.turbine.d2.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"tag1\":\"t1\","
+ + "\"tag2\":\"t2\"},{\"attr2\":\"a2\",\"attr1\":\"a1\"}",
+
"root.turbine.d2.s2,status,root.turbine,INT32,RLE,SNAPPY,{\"tag2\":\"t2\","
+ + "\"tag3\":\"t3\"},{\"attr4\":\"a4\",\"attr3\":\"a3\"}"
};
String sql1 = "create timeseries root.turbine.d2.s1(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
"tags(tag1=t1, tag2=t2) attributes(attr1=a1, attr2=a2)";
@@ -115,13 +116,8 @@ public class IoTDBTagIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("attr3")
- + "," + resultSet.getString("attr4")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2")
- + "," + resultSet.getString("tag3");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret[count], ans);
count++;
@@ -137,6 +133,51 @@ public class IoTDBTagIT {
}
@Test
+ public void showTimeseriesTest() throws ClassNotFoundException {
+ String[] ret = {
+
"root.turbine.d2.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"tag1\":\"t1\",\""
+ + "tag2\":\"t2\"},{\"attr2\":\"a2\",\"attr1\":\"a1\"}",
+
"root.turbine.d2.s2,status,root.turbine,INT32,RLE,SNAPPY,{\"tag2\":\"t2\",\"tag3\""
+ + ":\"t3\"},{\"attr4\":\"a4\",\"attr3\":\"a3\"}"
+ };
+ String sql1 = "create timeseries root.turbine.d2.s1(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
+ "tags(tag1=t1, tag2=t2) attributes(attr1=a1, attr2=a2)";
+ String sql2 = "create timeseries root.turbine.d2.s2(status) with
datatype=INT32, encoding=RLE " +
+ "tags(tag2=t2, tag3=t3) attributes(attr3=a3, attr4=a4)";
+ 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()) {
+ statement.execute(sql1);
+ statement.execute(sql2);
+ boolean hasResult = statement.execute("show timeseries");
+ assertTrue(hasResult);
+ ResultSet resultSet = statement.getResultSet();
+ int count = 0;
+ try {
+ while (resultSet.next()) {
+ String ans = resultSet.getString("timeseries")
+ + "," + resultSet.getString("alias")
+ + "," + resultSet.getString("storage group")
+ + "," + resultSet.getString("dataType")
+ + "," + resultSet.getString("encoding")
+ + "," + resultSet.getString("compression")
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
+ assertEquals(ret[count], ans);
+ count++;
+ }
+ } finally {
+ resultSet.close();
+ }
+ assertEquals(ret.length, count);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ @Test
public void createDuplicateAliasTimeseriesTest1() throws
ClassNotFoundException {
String sql1 = "create timeseries root.turbine.d3.s1(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
"tags(tag1=t1, tag2=t2) attributes(attr1=a1, attr2=a2)";
@@ -201,12 +242,14 @@ public class IoTDBTagIT {
}
} catch (Exception e) {
e.printStackTrace();
- fail(); }
+ fail();
+ }
}
@Test
public void queryWithAliasTest() throws ClassNotFoundException {
- String[] ret =
{"root.turbine.d6.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,v1,v2,v1,v2"};
+ String[] ret =
{"root.turbine.d6.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"v1\",\"tag2\":\"v2\"},{\"attr2\":\"v2\",\"attr1\":\"v1\"}"};
String sql = "create timeseries root.turbine.d6.s1(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
"tags(tag1=v1, tag2=v2) attributes(attr1=v1, attr2=v2)";
Class.forName(Config.JDBC_DRIVER_NAME);
@@ -225,10 +268,8 @@ public class IoTDBTagIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret[count], ans);
count++;
}
@@ -243,8 +284,10 @@ public class IoTDBTagIT {
@Test
public void queryWithLimitTest() throws ClassNotFoundException {
- String[] ret =
{"root.turbine.d1.s2,temperature2,root.turbine,FLOAT,RLE,SNAPPY,v1,v2,v1,v2",
-
"root.turbine.d1.s3,temperature3,root.turbine,FLOAT,RLE,SNAPPY,v1,v2,v1,v2"};
+ String[] ret =
{"root.turbine.d1.s2,temperature2,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"v1\",\"tag2\":\"v2\"},{\"attr2\":\"v2\",\"attr1\":\"v1\"}",
+ "root.turbine.d1.s3,temperature3,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"v1\",\"tag2\":\"v2\"},{\"attr2\":\"v2\",\"attr1\":\"v1\"}"};
Class.forName(Config.JDBC_DRIVER_NAME);
try (Connection connection = DriverManager
.getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",
"root");
@@ -267,10 +310,8 @@ public class IoTDBTagIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret[count], ans);
count++;
}
@@ -285,10 +326,13 @@ public class IoTDBTagIT {
@Test
public void deleteTest() throws ClassNotFoundException {
String[] ret1 = {
-
"root.turbine.d7.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,a1,a2,null,null,t1,t2,null",
-
"root.turbine.d7.s2,status,root.turbine,INT32,RLE,SNAPPY,null,null,a3,a4,null,t2,t3"
+ "root.turbine.d7.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"t1\",\"tag2\":\"t2\"},{\"attr2\":\"a2\",\"attr1\":\"a1\"}",
+ "root.turbine.d7.s2,status,root.turbine,INT32,RLE,SNAPPY,{\"tag2\""
+ +
":\"t2\",\"tag3\":\"t3\"},{\"attr4\":\"a4\",\"attr3\":\"a3\"}"
};
- String[] ret2 =
{"root.turbine.d7.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,a1,a2,t1,t2"};
+ String[] ret2 =
{"root.turbine.d7.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"t1\",\"tag2\":\"t2\"},{\"attr2\":\"a2\",\"attr1\":\"a1\"}"};
String sql1 = "create timeseries root.turbine.d7.s1(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
"tags(tag1=t1, tag2=t2) attributes(attr1=a1, attr2=a2)";
@@ -311,13 +355,8 @@ public class IoTDBTagIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("attr3")
- + "," + resultSet.getString("attr4")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2")
- + "," + resultSet.getString("tag3");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret1[count], ans);
count++;
@@ -337,10 +376,8 @@ public class IoTDBTagIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret2[count], ans);
count++;
@@ -357,10 +394,13 @@ public class IoTDBTagIT {
@Test
public void deleteWithAliasTest() throws ClassNotFoundException {
String[] ret1 = {
-
"root.turbine.d7.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,a1,a2,null,null,t1,t2,null",
-
"root.turbine.d7.s2,status,root.turbine,INT32,RLE,SNAPPY,null,null,a3,a4,null,t2,t3"
+ "root.turbine.d7.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"t1\",\"tag2\":\"t2\"},{\"attr2\":\"a2\",\"attr1\":\"a1\"}",
+ "root.turbine.d7.s2,status,root.turbine,INT32,RLE,SNAPPY,"
+ +
"{\"tag2\":\"t2\",\"tag3\":\"t3\"},{\"attr4\":\"a4\",\"attr3\":\"a3\"}"
};
- String[] ret2 =
{"root.turbine.d7.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,a1,a2,t1,t2"};
+ String[] ret2 =
{"root.turbine.d7.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"t1\",\"tag2\":\"t2\"},{\"attr2\":\"a2\",\"attr1\":\"a1\"}"};
String sql1 = "create timeseries root.turbine.d7.s1(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
"tags(tag1=t1, tag2=t2) attributes(attr1=a1, attr2=a2)";
@@ -383,13 +423,8 @@ public class IoTDBTagIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("attr3")
- + "," + resultSet.getString("attr4")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2")
- + "," + resultSet.getString("tag3");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret1[count], ans);
count++;
@@ -409,10 +444,8 @@ public class IoTDBTagIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret2[count], ans);
count++;
@@ -430,20 +463,31 @@ public class IoTDBTagIT {
@Test
public void queryWithWhereTest1() throws ClassNotFoundException {
String[] ret1 = {
-
"root.turbine.d0.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,turbine this is a
test1,100,50,null,null,f",
- "root.turbine.d0.s1,power,root.turbine,FLOAT,RLE,SNAPPY,turbine
this is a test2,99.9,44.4,null,null,kw",
- "root.turbine.d1.s0,status,root.turbine,INT32,RLE,SNAPPY,turbine
this is a test3,9,5,null,null,null",
-
"root.turbine.d2.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,turbine d2 this
is a test1,null,null,100,1,f",
- "root.turbine.d2.s1,power,root.turbine,FLOAT,RLE,SNAPPY,turbine d2
this is a test2,null,null,99.9,44.4,kw",
- "root.turbine.d2.s3,status,root.turbine,INT32,RLE,SNAPPY,turbine
d2 this is a test3,null,null,9,5,null",
- "root.ln.d0.s0,temperature,root.ln,FLOAT,RLE,SNAPPY,ln this is a
test1,1000,500,null,null,c",
- "root.ln.d0.s1,power,root.ln,FLOAT,RLE,SNAPPY,ln this is a
test2,9.9,4.4,null,null,w",
- "root.ln.d1.s0,status,root.ln,INT32,RLE,SNAPPY,ln this is a
test3,90,50,null,null,null",
+
"root.turbine.d0.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
"
+ + "this is a
test1\",\"unit\":\"f\"},{\"H_Alarm\":\"100\",\"M_Alarm\":\"50\"}",
+
"root.turbine.d0.s1,power,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
this "
+ + "is a
test2\",\"unit\":\"kw\"},{\"H_Alarm\":\"99.9\",\"M_Alarm\":\"44.4\"}",
+
"root.turbine.d1.s0,status,root.turbine,INT32,RLE,SNAPPY,{\"description\":\"turbine
this "
+ + "is a test3\"},{\"H_Alarm\":\"9\",\"M_Alarm\":\"5\"}",
+
"root.turbine.d2.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
"
+ + "d2 this is a
test1\",\"unit\":\"f\"},{\"MinValue\":\"1\",\"MaxValue\":\"100\"}",
+
"root.turbine.d2.s1,power,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
d2 this"
+ + " is a
test2\",\"unit\":\"kw\"},{\"MinValue\":\"44.4\",\"MaxValue\":\"99.9\"}",
+
"root.turbine.d2.s3,status,root.turbine,INT32,RLE,SNAPPY,{\"description\":\"turbine
d2 "
+ + "this is a test3\"},{\"MinValue\":\"5\",\"MaxValue\":\"9\"}",
+
"root.ln.d0.s0,temperature,root.ln,FLOAT,RLE,SNAPPY,{\"description\":\"ln this
is a "
+ +
"test1\",\"unit\":\"c\"},{\"H_Alarm\":\"1000\",\"M_Alarm\":\"500\"}",
+
"root.ln.d0.s1,power,root.ln,FLOAT,RLE,SNAPPY,{\"description\":\"ln this is a "
+ +
"test2\",\"unit\":\"w\"},{\"H_Alarm\":\"9.9\",\"M_Alarm\":\"4.4\"}",
+
"root.ln.d1.s0,status,root.ln,INT32,RLE,SNAPPY,{\"description\":\"ln this is a
test3\"},"
+ + "{\"H_Alarm\":\"90\",\"M_Alarm\":\"50\"}"
};
Set<String> ret2 = new HashSet<>();
-
ret2.add("root.turbine.d0.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,turbine
this is a test1,100,50,null,null,f");
-
ret2.add("root.turbine.d2.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,turbine
d2 this is a test1,null,null,100,1,f");
+
ret2.add("root.turbine.d2.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
"
+ + "d2 this is a
test1\",\"unit\":\"f\"},{\"MinValue\":\"1\",\"MaxValue\":\"100\"}");
+
ret2.add("root.turbine.d0.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\""
+ + "turbine this is a
test1\",\"unit\":\"f\"},{\"H_Alarm\":\"100\",\"M_Alarm\":\"50\"}");
String[] sqls = {
"create timeseries root.turbine.d0.s0(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
@@ -491,12 +535,8 @@ public class IoTDBTagIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("description")
- + "," + resultSet.getString("H_Alarm")
- + "," + resultSet.getString("M_Alarm")
- + "," + resultSet.getString("MaxValue")
- + "," + resultSet.getString("MinValue")
- + "," + resultSet.getString("unit");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret1[count], ans);
count++;
@@ -516,12 +556,8 @@ public class IoTDBTagIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("description")
- + "," + resultSet.getString("H_Alarm")
- + "," + resultSet.getString("M_Alarm")
- + "," + resultSet.getString("MaxValue")
- + "," + resultSet.getString("MinValue")
- + "," + resultSet.getString("unit");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
res.add(ans);
count++;
}
@@ -537,8 +573,10 @@ public class IoTDBTagIT {
@Test
public void queryWithWhereTest2() throws ClassNotFoundException {
Set<String> ret = new HashSet<>();
-
ret.add("root.turbine.d0.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,turbine
this is a test1,100,50,null,null,f");
-
ret.add("root.turbine.d2.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,turbine
d2 this is a test1,null,null,100,1,f");
+
ret.add("root.turbine.d2.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
"
+ + "d2 this is a
test1\",\"unit\":\"f\"},{\"MinValue\":\"1\",\"MaxValue\":\"100\"}");
+
ret.add("root.turbine.d0.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
"
+ + "this is a
test1\",\"unit\":\"f\"},{\"H_Alarm\":\"100\",\"M_Alarm\":\"50\"}");
String[] sqls = {
"create timeseries root.turbine.d0.s0(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
@@ -589,12 +627,8 @@ public class IoTDBTagIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("description")
- + "," + resultSet.getString("H_Alarm")
- + "," + resultSet.getString("M_Alarm")
- + "," + resultSet.getString("MaxValue")
- + "," + resultSet.getString("MinValue")
- + "," + resultSet.getString("unit");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
res.add(ans);
count++;
@@ -616,12 +650,8 @@ public class IoTDBTagIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("description")
- + "," + resultSet.getString("H_Alarm")
- + "," + resultSet.getString("M_Alarm")
- + "," + resultSet.getString("MaxValue")
- + "," + resultSet.getString("MinValue")
- + "," + resultSet.getString("unit");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
res.add(ans);
count++;
@@ -648,8 +678,10 @@ public class IoTDBTagIT {
@Test
public void queryWithWhereAndDeleteTest() throws ClassNotFoundException {
Set<String> ret = new HashSet<>();
-
ret.add("root.turbine.d0.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,turbine
this is a test1,100,50,f");
- ret.add("root.ln.d0.s0,temperature,root.ln,FLOAT,RLE,SNAPPY,ln this is a
test1,1000,500,f");
+
ret.add("root.turbine.d0.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\""
+ + "turbine this is a
test1\",\"unit\":\"f\"},{\"H_Alarm\":\"100\",\"M_Alarm\":\"50\"}");
+
ret.add("root.ln.d0.s0,temperature,root.ln,FLOAT,RLE,SNAPPY,{\"description\":\"ln
this "
+ + "is a
test1\",\"unit\":\"f\"},{\"H_Alarm\":\"1000\",\"M_Alarm\":\"500\"}");
String[] sqls = {
"create timeseries root.turbine.d0.s0(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
@@ -702,10 +734,8 @@ public class IoTDBTagIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("description")
- + "," + resultSet.getString("H_Alarm")
- + "," + resultSet.getString("M_Alarm")
- + "," + resultSet.getString("unit");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
res.add(ans);
count++;
@@ -723,12 +753,16 @@ public class IoTDBTagIT {
@Test
public void queryWithWhereContainsTest() throws ClassNotFoundException {
Set<String> ret = new HashSet<>();
-
ret.add("root.turbine.d0.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,turbine
this is a test1,100,50,null,null,f");
-
ret.add("root.turbine.d2.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,turbine
d2 this is a test1,null,null,100,1,f");
- ret.add("root.ln.d0.s0,temperature,root.ln,FLOAT,RLE,SNAPPY,ln this is a
test1,1000,500,null,null,f");
+
ret.add("root.turbine.d2.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
"
+ + "d2 this is a
test1\",\"unit\":\"f\"},{\"MinValue\":\"1\",\"MaxValue\":\"100\"}");
+
ret.add("root.turbine.d0.s0,temperature,root.turbine,FLOAT,RLE,SNAPPY,{\"description\":\"turbine
"
+ + "this is a
test1\",\"unit\":\"f\"},{\"H_Alarm\":\"100\",\"M_Alarm\":\"50\"}");
+
ret.add("root.ln.d0.s0,temperature,root.ln,FLOAT,RLE,SNAPPY,{\"description\":\"ln
this "
+ + "is a
test1\",\"unit\":\"f\"},{\"H_Alarm\":\"1000\",\"M_Alarm\":\"500\"}");
Set<String> ret2 = new HashSet<>();
- ret2.add("root.ln.d0.s0,temperature,root.ln,FLOAT,RLE,SNAPPY,ln this is a
test1,1000,500,f");
+
ret2.add("root.ln.d0.s0,temperature,root.ln,FLOAT,RLE,SNAPPY,{\"description\":\"ln
this"
+ + " is a
test1\",\"unit\":\"f\"},{\"H_Alarm\":\"1000\",\"M_Alarm\":\"500\"}");
String[] sqls = {
"create timeseries root.turbine.d0.s0(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
@@ -778,12 +812,8 @@ public class IoTDBTagIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("description")
- + "," + resultSet.getString("H_Alarm")
- + "," + resultSet.getString("M_Alarm")
- + "," + resultSet.getString("MaxValue")
- + "," + resultSet.getString("MinValue")
- + "," + resultSet.getString("unit");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
System.out.println(ans);
res.add(ans);
@@ -805,10 +835,8 @@ public class IoTDBTagIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("description")
- + "," + resultSet.getString("H_Alarm")
- + "," + resultSet.getString("M_Alarm")
- + "," + resultSet.getString("unit");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
res.add(ans);
count++;
@@ -890,7 +918,8 @@ public class IoTDBTagIT {
@Test
public void deleteStorageGroupTest() throws ClassNotFoundException {
- String[] ret =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,v1,v2,v1,v2"};
+ String[] ret =
{"root.turbine.d1.s1,temperature,root.turbine,FLOAT,RLE,SNAPPY,"
+ +
"{\"tag1\":\"v1\",\"tag2\":\"v2\"},{\"attr2\":\"v2\",\"attr1\":\"v1\"}"};
String sql = "create timeseries root.turbine.d1.s1(temperature) with
datatype=FLOAT, encoding=RLE, compression=SNAPPY " +
"tags(tag1=v1, tag2=v2) attributes(attr1=v1, attr2=v2)";
@@ -910,10 +939,8 @@ public class IoTDBTagIT {
+ "," + resultSet.getString("dataType")
+ "," + resultSet.getString("encoding")
+ "," + resultSet.getString("compression")
- + "," + resultSet.getString("attr1")
- + "," + resultSet.getString("attr2")
- + "," + resultSet.getString("tag1")
- + "," + resultSet.getString("tag2");
+ + "," + resultSet.getString("tags")
+ + "," + resultSet.getString("attributes");
assertEquals(ret[count], ans);
count++;
}