This is an automated email from the ASF dual-hosted git repository. jackietien pushed a commit to branch DeadLockTryFix in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit a5273bee69d85317ca2f7c056108ca9efb2a83f5 Author: JackieTien97 <[email protected]> AuthorDate: Fri Jun 4 15:18:15 2021 +0800 add sql support --- .../org/apache/iotdb/db/conf/IoTDBConstant.java | 1 + .../org/apache/iotdb/db/engine/StorageEngine.java | 20 +++ .../engine/storagegroup/StorageGroupProcessor.java | 66 +++++----- .../apache/iotdb/db/qp/constant/SQLConstant.java | 2 + .../apache/iotdb/db/qp/executor/PlanExecutor.java | 134 +++++++++++++-------- .../db/qp/logical/sys/ShowLockInfoOperator.java | 36 ++++++ .../iotdb/db/qp/physical/sys/ShowLockInfoPlan.java | 36 ++++++ .../apache/iotdb/db/qp/physical/sys/ShowPlan.java | 3 +- .../apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java | 12 ++ .../iotdb/db/qp/strategy/PhysicalGenerator.java | 6 + 10 files changed, 233 insertions(+), 83 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 f2dac0e..eb0ecf7 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 @@ -80,6 +80,7 @@ public class IoTDBConstant { public static final String COLUMN_PRIVILEGE = "privilege"; public static final String COLUMN_STORAGE_GROUP = "storage group"; + public static final String COLUMN_LOCK_INFO = "lock holder"; public static final String COLUMN_TTL = "ttl"; public static final String COLUMN_TASK_NAME = "task name"; diff --git a/server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java b/server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java index e7ed671..4727b7f 100644 --- a/server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java +++ b/server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java @@ -408,6 +408,26 @@ public class StorageEngine implements IService { } /** + * get lock holder for each sg + * + * @return storage group processor + */ + public List<String> getLockInfo(List<PartialPath> pathList) throws StorageEngineException { + try { + List<String> lockHolderList = new ArrayList<>(pathList.size()); + for (PartialPath path : pathList) { + StorageGroupMNode storageGroupMNode = IoTDB.metaManager.getStorageGroupNodeByPath(path); + StorageGroupProcessor storageGroupProcessor = + getStorageGroupProcessorByPath(path, storageGroupMNode); + lockHolderList.add(storageGroupProcessor.getInsertWriteLockHolder()); + } + return lockHolderList; + } catch (StorageGroupProcessorException | MetadataException e) { + throw new StorageEngineException(e); + } + } + + /** * get storage group processor by device path * * @param devicePath path of the device diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java index 8ae58b2..d5cab67 100755 --- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java +++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java @@ -18,38 +18,6 @@ */ package org.apache.iotdb.db.engine.storagegroup; -import static org.apache.iotdb.db.conf.IoTDBConstant.FILE_NAME_SEPARATOR; -import static org.apache.iotdb.db.engine.merge.task.MergeTask.MERGE_SUFFIX; -import static org.apache.iotdb.db.engine.storagegroup.TsFileResource.TEMP_SUFFIX; -import static org.apache.iotdb.tsfile.common.constant.TsFileConstant.TSFILE_SUFFIX; - -import java.io.File; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.MappedByteBuffer; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.Deque; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.TreeMap; -import java.util.concurrent.Executors; -import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; -import org.apache.commons.io.FileUtils; import org.apache.iotdb.db.conf.IoTDBConfig; import org.apache.iotdb.db.conf.IoTDBConstant; import org.apache.iotdb.db.conf.IoTDBDescriptor; @@ -109,9 +77,43 @@ import org.apache.iotdb.tsfile.read.filter.basic.Filter; import org.apache.iotdb.tsfile.utils.Pair; import org.apache.iotdb.tsfile.write.schema.MeasurementSchema; import org.apache.iotdb.tsfile.write.writer.RestorableTsFileIOWriter; + +import org.apache.commons.io.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.MappedByteBuffer; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.Deque; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.TreeMap; +import java.util.concurrent.Executors; +import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +import static org.apache.iotdb.db.conf.IoTDBConstant.FILE_NAME_SEPARATOR; +import static org.apache.iotdb.db.engine.merge.task.MergeTask.MERGE_SUFFIX; +import static org.apache.iotdb.db.engine.storagegroup.TsFileResource.TEMP_SUFFIX; +import static org.apache.iotdb.tsfile.common.constant.TsFileConstant.TSFILE_SUFFIX; + /** * For sequence data, a StorageGroupProcessor has some TsFileProcessors, in which there is only one * TsFileProcessor in the working status. <br> diff --git a/server/src/main/java/org/apache/iotdb/db/qp/constant/SQLConstant.java b/server/src/main/java/org/apache/iotdb/db/qp/constant/SQLConstant.java index 35dcdec..7cbdfff 100644 --- a/server/src/main/java/org/apache/iotdb/db/qp/constant/SQLConstant.java +++ b/server/src/main/java/org/apache/iotdb/db/qp/constant/SQLConstant.java @@ -178,6 +178,8 @@ public class SQLConstant { public static final int TOK_TRIGGER_STOP = 103; public static final int TOK_SHOW_TRIGGERS = 104; + public static final int TOK_LOCK_INFO = 105; + public static final Map<Integer, String> tokenSymbol = new HashMap<>(); public static final Map<Integer, String> tokenNames = new HashMap<>(); public static final Map<Integer, Integer> reverseWords = new HashMap<>(); 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 6063796..1fe07df 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 @@ -18,6 +18,55 @@ */ package org.apache.iotdb.db.qp.executor; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CANCELLED; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CHILD_NODES; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CHILD_PATHS; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_COLUMN; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_COUNT; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CREATED_TIME; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_DEVICES; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_DONE; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_FUNCTION_CLASS; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_FUNCTION_NAME; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_FUNCTION_TYPE; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_ITEM; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_LOCK_INFO; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_PRIVILEGE; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_PROGRESS; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_ROLE; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_STORAGE_GROUP; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TASK_NAME; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TRIGGER_ATTRIBUTES; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TRIGGER_CLASS; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TRIGGER_EVENT; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TRIGGER_NAME; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TRIGGER_PATH; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TRIGGER_STATUS; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TTL; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_USER; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_VALUE; +import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_BUILTIN_UDAF; +import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_BUILTIN_UDTF; +import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_EXTERNAL_UDAF; +import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_EXTERNAL_UDTF; +import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_NATIVE; +import static org.apache.iotdb.db.conf.IoTDBConstant.QUERY_ID; +import static org.apache.iotdb.db.conf.IoTDBConstant.STATEMENT; +import static org.apache.iotdb.tsfile.common.constant.TsFileConstant.TSFILE_SUFFIX; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; import org.apache.iotdb.db.auth.AuthException; import org.apache.iotdb.db.auth.AuthorityChecker; import org.apache.iotdb.db.auth.authorizer.BasicAuthorizer; @@ -95,6 +144,7 @@ import org.apache.iotdb.db.qp.physical.sys.ShowChildNodesPlan; import org.apache.iotdb.db.qp.physical.sys.ShowChildPathsPlan; import org.apache.iotdb.db.qp.physical.sys.ShowDevicesPlan; import org.apache.iotdb.db.qp.physical.sys.ShowFunctionsPlan; +import org.apache.iotdb.db.qp.physical.sys.ShowLockInfoPlan; import org.apache.iotdb.db.qp.physical.sys.ShowPlan; import org.apache.iotdb.db.qp.physical.sys.ShowStorageGroupPlan; import org.apache.iotdb.db.qp.physical.sys.ShowTTLPlan; @@ -138,59 +188,9 @@ import org.apache.iotdb.tsfile.utils.Binary; import org.apache.iotdb.tsfile.utils.Pair; import org.apache.iotdb.tsfile.write.schema.MeasurementSchema; import org.apache.iotdb.tsfile.write.writer.RestorableTsFileIOWriter; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CANCELLED; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CHILD_NODES; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CHILD_PATHS; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_COLUMN; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_COUNT; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CREATED_TIME; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_DEVICES; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_DONE; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_FUNCTION_CLASS; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_FUNCTION_NAME; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_FUNCTION_TYPE; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_ITEM; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_PRIVILEGE; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_PROGRESS; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_ROLE; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_STORAGE_GROUP; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TASK_NAME; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TRIGGER_ATTRIBUTES; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TRIGGER_CLASS; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TRIGGER_EVENT; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TRIGGER_NAME; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TRIGGER_PATH; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TRIGGER_STATUS; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TTL; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_USER; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_VALUE; -import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_BUILTIN_UDAF; -import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_BUILTIN_UDTF; -import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_EXTERNAL_UDAF; -import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_EXTERNAL_UDTF; -import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_NATIVE; -import static org.apache.iotdb.db.conf.IoTDBConstant.QUERY_ID; -import static org.apache.iotdb.db.conf.IoTDBConstant.STATEMENT; -import static org.apache.iotdb.tsfile.common.constant.TsFileConstant.TSFILE_SUFFIX; - @SuppressWarnings("java:S1135") // ignore todos public class PlanExecutor implements IPlanExecutor { @@ -531,6 +531,8 @@ public class PlanExecutor implements IPlanExecutor { return processShowTimeseries((ShowTimeSeriesPlan) showPlan, context); case STORAGE_GROUP: return processShowStorageGroup((ShowStorageGroupPlan) showPlan); + case LOCK_INFO: + return processShowLockInfo((ShowLockInfoPlan) showPlan); case DEVICES: return processShowDevices((ShowDevicesPlan) showPlan); case CHILD_PATH: @@ -736,6 +738,38 @@ public class PlanExecutor implements IPlanExecutor { } } + private QueryDataSet processShowLockInfo(ShowLockInfoPlan showLockInfoPlan) + throws MetadataException { + ListDataSet listDataSet = + new ListDataSet( + Arrays.asList( + new PartialPath(COLUMN_STORAGE_GROUP, false), + new PartialPath(COLUMN_LOCK_INFO, false)), + Arrays.asList(TSDataType.TEXT, TSDataType.TEXT)); + try { + List<PartialPath> storageGroupList = getStorageGroupNames(showLockInfoPlan.getPath()); + List<String> lockHolderList = StorageEngine.getInstance().getLockInfo(storageGroupList); + addLockInfoToDataSet(storageGroupList, lockHolderList, listDataSet); + } catch (StorageEngineException e) { + throw new MetadataException(e); + } + return listDataSet; + } + + private void addLockInfoToDataSet( + List<PartialPath> paths, List<String> lockHolderList, ListDataSet dataSet) { + for (int i = 0; i < paths.size(); i++) { + RowRecord record = new RowRecord(0); + Field field = new Field(TSDataType.TEXT); + field.setBinaryV(new Binary(paths.get(i).getFullPath())); + record.addField(field); + field = new Field(TSDataType.TEXT); + field.setBinaryV(new Binary(lockHolderList.get(i))); + record.addField(field); + dataSet.putRecord(record); + } + } + private QueryDataSet processShowTimeseries( ShowTimeSeriesPlan showTimeSeriesPlan, QueryContext context) throws MetadataException { return new ShowTimeseriesDataSet(showTimeSeriesPlan, context); diff --git a/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/ShowLockInfoOperator.java b/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/ShowLockInfoOperator.java new file mode 100644 index 0000000..aa2a8d0 --- /dev/null +++ b/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/ShowLockInfoOperator.java @@ -0,0 +1,36 @@ +/* + * 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.qp.logical.sys; + +import org.apache.iotdb.db.metadata.PartialPath; + +public class ShowLockInfoOperator extends ShowOperator { + + private final PartialPath path; + + public ShowLockInfoOperator(int tokenIntType, PartialPath path) { + super(tokenIntType); + this.path = path; + } + + public PartialPath getPath() { + return path; + } +} diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ShowLockInfoPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ShowLockInfoPlan.java new file mode 100644 index 0000000..e69bbd2 --- /dev/null +++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ShowLockInfoPlan.java @@ -0,0 +1,36 @@ +/* + * 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.qp.physical.sys; + +import org.apache.iotdb.db.metadata.PartialPath; + +public class ShowLockInfoPlan extends ShowPlan { + + private final PartialPath path; + + public ShowLockInfoPlan(ShowContentType showContentType, PartialPath path) { + super(showContentType); + this.path = path; + } + + @Override + public PartialPath getPath() { + return this.path; + } +} diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ShowPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ShowPlan.java index a77917a..94d74b5 100644 --- a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ShowPlan.java +++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ShowPlan.java @@ -117,6 +117,7 @@ public class ShowPlan extends PhysicalPlan { COUNT_DEVICES, COUNT_STORAGE_GROUP, QUERY_PROCESSLIST, - TRIGGERS + TRIGGERS, + LOCK_INFO } } diff --git a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java index ad681e9..4684111 100644 --- a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java +++ b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java @@ -68,6 +68,7 @@ import org.apache.iotdb.db.qp.logical.sys.ShowChildNodesOperator; import org.apache.iotdb.db.qp.logical.sys.ShowChildPathsOperator; import org.apache.iotdb.db.qp.logical.sys.ShowDevicesOperator; import org.apache.iotdb.db.qp.logical.sys.ShowFunctionsOperator; +import org.apache.iotdb.db.qp.logical.sys.ShowLockInfoOperator; import org.apache.iotdb.db.qp.logical.sys.ShowMergeStatusOperator; import org.apache.iotdb.db.qp.logical.sys.ShowOperator; import org.apache.iotdb.db.qp.logical.sys.ShowStorageGroupOperator; @@ -183,6 +184,7 @@ import org.apache.iotdb.db.qp.sql.SqlBaseParser.ShowChildPathsContext; import org.apache.iotdb.db.qp.sql.SqlBaseParser.ShowDevicesContext; import org.apache.iotdb.db.qp.sql.SqlBaseParser.ShowFlushTaskInfoContext; import org.apache.iotdb.db.qp.sql.SqlBaseParser.ShowFunctionsContext; +import org.apache.iotdb.db.qp.sql.SqlBaseParser.ShowLockInfoContext; import org.apache.iotdb.db.qp.sql.SqlBaseParser.ShowMergeStatusContext; import org.apache.iotdb.db.qp.sql.SqlBaseParser.ShowQueryProcesslistContext; import org.apache.iotdb.db.qp.sql.SqlBaseParser.ShowStorageGroupContext; @@ -844,6 +846,16 @@ public class IoTDBSqlVisitor extends SqlBaseBaseVisitor<Operator> { } @Override + public Operator visitShowLockInfo(ShowLockInfoContext ctx) { + if (ctx.prefixPath() != null) { + return new ShowLockInfoOperator(SQLConstant.TOK_LOCK_INFO, parsePrefixPath(ctx.prefixPath())); + } else { + return new ShowLockInfoOperator( + SQLConstant.TOK_LOCK_INFO, new PartialPath(SQLConstant.getSingleRootArray())); + } + } + + @Override public Operator visitShowChildPaths(ShowChildPathsContext ctx) { if (ctx.prefixPath() != null) { return new ShowChildPathsOperator( diff --git a/server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java b/server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java index ef3ca16..eddfa2b 100644 --- a/server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java +++ b/server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java @@ -61,6 +61,7 @@ import org.apache.iotdb.db.qp.logical.sys.ShowChildNodesOperator; import org.apache.iotdb.db.qp.logical.sys.ShowChildPathsOperator; import org.apache.iotdb.db.qp.logical.sys.ShowDevicesOperator; import org.apache.iotdb.db.qp.logical.sys.ShowFunctionsOperator; +import org.apache.iotdb.db.qp.logical.sys.ShowLockInfoOperator; import org.apache.iotdb.db.qp.logical.sys.ShowStorageGroupOperator; import org.apache.iotdb.db.qp.logical.sys.ShowTTLOperator; import org.apache.iotdb.db.qp.logical.sys.ShowTimeSeriesOperator; @@ -111,6 +112,7 @@ import org.apache.iotdb.db.qp.physical.sys.ShowChildNodesPlan; import org.apache.iotdb.db.qp.physical.sys.ShowChildPathsPlan; import org.apache.iotdb.db.qp.physical.sys.ShowDevicesPlan; import org.apache.iotdb.db.qp.physical.sys.ShowFunctionsPlan; +import org.apache.iotdb.db.qp.physical.sys.ShowLockInfoPlan; import org.apache.iotdb.db.qp.physical.sys.ShowMergeStatusPlan; import org.apache.iotdb.db.qp.physical.sys.ShowPlan; import org.apache.iotdb.db.qp.physical.sys.ShowPlan.ShowContentType; @@ -299,6 +301,9 @@ public class PhysicalGenerator { case SQLConstant.TOK_STORAGE_GROUP: return new ShowStorageGroupPlan( ShowContentType.STORAGE_GROUP, ((ShowStorageGroupOperator) operator).getPath()); + case SQLConstant.TOK_LOCK_INFO: + return new ShowLockInfoPlan( + ShowContentType.LOCK_INFO, ((ShowLockInfoOperator) operator).getPath()); case SQLConstant.TOK_DEVICES: ShowDevicesOperator showDevicesOperator = (ShowDevicesOperator) operator; return new ShowDevicesPlan( @@ -435,6 +440,7 @@ public class PhysicalGenerator { } interface Transfrom { + QueryPlan transform(QueryOperator queryOperator, int fetchSize) throws QueryProcessException; }
