This is an automated email from the ASF dual-hosted git repository. jackietien pushed a commit to branch ShowTimeseriesSort in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit 8bea06346acfdd01c4ca36da2c5abb5be0bdbbdd Merge: 88e2118 6a927f4 Author: JackieTien97 <[email protected]> AuthorDate: Wed Jun 10 15:34:26 2020 +0800 resolve conflicts docs/UserGuide/Server/Config Manual.md | 55 ++++++ docs/zh/UserGuide/Server/Config Manual.md | 58 ++++++ .../resources/conf/iotdb-engine.properties | 3 + .../org/apache/iotdb/db/qp/strategy/SqlBase.g4 | 4 + .../java/org/apache/iotdb/db/conf/IoTDBConfig.java | 18 ++ .../org/apache/iotdb/db/conf/IoTDBDescriptor.java | 2 + .../iotdb/db/engine/merge/task/MergeTask.java | 4 +- .../engine/storagegroup/StorageGroupProcessor.java | 6 +- .../org/apache/iotdb/db/metadata/MManager.java | 81 ++++---- .../java/org/apache/iotdb/db/metadata/MTree.java | 110 ++++++----- .../iotdb/db/metadata/mnode/InternalMNode.java | 2 +- .../{LeafMNode.java => MeasurementMNode.java} | 57 +----- .../apache/iotdb/db/qp/executor/PlanExecutor.java | 10 +- .../iotdb/db/query/executor/LastQueryExecutor.java | 6 +- .../apache/iotdb/db/utils/TypeInferenceUtils.java | 6 +- .../iotdb/db/integration/IoTDBAddSubDeviceIT.java | 203 +++++++++++++++++++++ .../iotdb/db/integration/IoTDBInsertNaNIT.java | 139 ++++++++++++++ .../apache/iotdb/db/integration/IoTDBLastIT.java | 12 +- .../iotdb/db/metadata/MManagerAdvancedTest.java | 14 +- .../iotdb/db/metadata/MManagerImproveTest.java | 4 +- .../org/apache/iotdb/db/metadata/MTreeTest.java | 77 ++++---- .../java/org/apache/iotdb/db/qp/PlannerTest.java | 13 ++ 22 files changed, 679 insertions(+), 205 deletions(-) diff --cc server/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4 index 3f18bd5,d6ef3dd..21a84f2 --- a/server/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4 +++ b/server/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4 @@@ -881,13 -878,6 +882,14 @@@ FALS : F A L S E ; +ORDER + : O R D E R + ; + +HEAT + : H E A T + ; ++ //============================ // End of the keywords list //============================ diff --cc server/src/main/java/org/apache/iotdb/db/metadata/MManager.java index 1b89926,ec46b77..67694dc --- a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java @@@ -773,11 -782,9 +783,10 @@@ public class MManager if (value2Node.isEmpty()) { throw new MetadataException("The key " + plan.getKey() + " is not a tag."); } - Set<MeasurementMNode> allMatchedNodes = new TreeSet<>(Comparator.comparing(MNode::getFullPath)); + - List<LeafMNode> allMatchedNodes = new ArrayList<>(); - ++ List<MeasurementMNode> allMatchedNodes = new ArrayList<>(); if (plan.isContains()) { - for (Entry<String, Set<LeafMNode>> entry : value2Node.entrySet()) { + for (Entry<String, Set<MeasurementMNode>> entry : value2Node.entrySet()) { String tagValue = entry.getKey(); if (tagValue.contains(plan.getValue())) { allMatchedNodes.addAll(entry.getValue()); diff --cc server/src/main/java/org/apache/iotdb/db/metadata/MTree.java index 530594e,bfb2398..df27cd7 --- a/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java @@@ -18,32 -18,9 +18,34 @@@ */ package org.apache.iotdb.db.metadata; +import static java.util.stream.Collectors.toList; +import static org.apache.iotdb.db.conf.IoTDBConstant.PATH_SEPARATOR; +import static org.apache.iotdb.db.conf.IoTDBConstant.PATH_WILDCARD; +import static org.apache.iotdb.db.query.executor.LastQueryExecutor.calculateLastPairForOneSeries; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import java.io.Serializable; +import java.util.ArrayDeque; +import java.util.ArrayList; - import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.Deque; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Queue; +import java.util.Set; +import java.util.TreeSet; +import java.util.regex.Pattern; +import java.util.stream.Stream; + import com.alibaba.fastjson.JSON; + import com.alibaba.fastjson.JSONObject; + import com.alibaba.fastjson.serializer.SerializerFeature; import org.apache.iotdb.db.conf.IoTDBConstant; import org.apache.iotdb.db.conf.IoTDBDescriptor; import org.apache.iotdb.db.exception.metadata.AliasAlreadyExistException; @@@ -697,37 -657,34 +713,36 @@@ public class MTree implements Serializa /** * Iterate through MTree to fetch metadata info of all leaf nodes under the given seriesPath * - * @param timeseriesSchemas Collection<timeseriesSchema> result: [name, alias, storage group, - * @param timeseriesSchemaList List<timeseriesSchema> ++ * @param timeseriesSchemaList Collection<timeseriesSchema> result: [name, alias, storage group, + * dataType, encoding, compression, offset, lastTimeStamp] */ private void findPath(MNode node, String[] nodes, int idx, String parent, - Collection<String[]> timeseriesSchemas, boolean hasLimit) throws MetadataException { - if (node instanceof LeafMNode) { - if (nodes.length <= idx) { - if (hasLimit) { - curOffset.set(curOffset.get() + 1); - if (curOffset.get() < offset.get() || count.get().intValue() == limit.get().intValue()) { - return; - } + List<String[]> timeseriesSchemaList, boolean hasLimit) throws MetadataException { + if (node instanceof MeasurementMNode && nodes.length <= idx) { + if (hasLimit) { + curOffset.set(curOffset.get() + 1); + if (curOffset.get() < offset.get() || count.get().intValue() == limit.get().intValue()) { + return; } - String nodeName; - if (node.getName().contains(TsFileConstant.PATH_SEPARATOR)) { - nodeName = "\"" + node + "\""; - } else { + } + String nodeName; + if (node.getName().contains(TsFileConstant.PATH_SEPARATOR)) { + nodeName = "\"" + node + "\""; + } else { nodeName = node.getName(); } String nodePath = parent + nodeName; - String[] tsRow = new String[7]; + String[] tsRow = new String[8]; tsRow[0] = nodePath; - tsRow[1] = ((LeafMNode) node).getAlias(); - MeasurementSchema measurementSchema = ((LeafMNode) node).getSchema(); + tsRow[1] = ((MeasurementMNode) node).getAlias(); + MeasurementSchema measurementSchema = ((MeasurementMNode) node).getSchema(); tsRow[2] = getStorageGroupName(nodePath); tsRow[3] = measurementSchema.getType().toString(); tsRow[4] = measurementSchema.getEncodingType().toString(); tsRow[5] = measurementSchema.getCompressor().toString(); - tsRow[6] = String.valueOf(((LeafMNode) node).getOffset()); - tsRow[7] = String.valueOf(getLastTimeStamp((LeafMNode) node)); - timeseriesSchemas.add(tsRow); + tsRow[6] = String.valueOf(((MeasurementMNode) node).getOffset()); - timeseriesSchemaList.add(tsRow); ++ tsRow[7] = String.valueOf(getLastTimeStamp((MeasurementMNode) node)); ++ timeseriesSchemaList.add(tsRow); if (hasLimit) { count.set(count.get() + 1); @@@ -752,21 -707,6 +765,21 @@@ } } - static long getLastTimeStamp(LeafMNode node) { ++ static long getLastTimeStamp(MeasurementMNode node) { + TimeValuePair last = node.getCachedLast(); + if (last != null) { + return node.getCachedLast().getTimestamp(); + } else { + try { + last = calculateLastPairForOneSeries(new Path(node.getFullPath()), + node.getSchema().getType(), new QueryContext(-1), Collections.emptySet()); + return last.getTimestamp(); + } catch (Exception e) { + return Long.MIN_VALUE; + } + } + } + /** * Get child node path in the next level of the given path. *
