Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
df250c3d
I
Iotdb
项目概览
apache
/
Iotdb
11 个月 前同步成功
通知
25
Star
3344
Fork
916
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iotdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
df250c3d
编写于
9月 07, 2020
作者:
Y
yhwang-hbl
提交者:
GitHub
9月 07, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[IOTDB-813] Show storage group under given path prefix (#1694)
上级
1aa0c506
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
153 addition
and
9 deletion
+153
-9
antlr/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4
...rc/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4
+1
-1
server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
.../src/main/java/org/apache/iotdb/db/metadata/MManager.java
+16
-0
server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
+44
-0
server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
...in/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
+8
-6
server/src/main/java/org/apache/iotdb/db/qp/logical/sys/ShowStorageGroupOperator.java
...che/iotdb/db/qp/logical/sys/ShowStorageGroupOperator.java
+36
-0
server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ShowStorageGroupPlan.java
...apache/iotdb/db/qp/physical/sys/ShowStorageGroupPlan.java
+36
-0
server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
...ava/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
+8
-1
server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
...va/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
+4
-1
未找到文件。
antlr/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4
浏览文件 @
df250c3d
...
...
@@ -72,7 +72,7 @@ statement
| SHOW DYNAMIC PARAMETER #showDynamicParameter
| SHOW VERSION #showVersion
| {hasSingleQuoteString = false;} SHOW LATEST? TIMESERIES prefixPath? showWhereClause? limitClause? #showTimeseries
|
SHOW STORAGE GROUP
#showStorageGroup
|
{hasSingleQuoteString = false;} SHOW STORAGE GROUP prefixPath?
#showStorageGroup
| {hasSingleQuoteString = false;} SHOW CHILD PATHS prefixPath? #showChildPaths
| {hasSingleQuoteString = false;} SHOW DEVICES prefixPath? #showDevices
| SHOW MERGE #showMergeStatus
...
...
server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
浏览文件 @
df250c3d
...
...
@@ -771,6 +771,22 @@ public class MManager {
}
}
/**
* Get all storage group under given prefixPath.
*
* @param prefixPath a prefix of a full path. if the wildcard is not at the tail, then each
* wildcard can only match one level, otherwise it can match to the tail.
* @return A ArrayList instance which stores storage group paths with given prefixPath.
*/
public
List
<
PartialPath
>
getStorageGroupPaths
(
PartialPath
prefixPath
)
throws
MetadataException
{
lock
.
readLock
().
lock
();
try
{
return
mtree
.
getStorageGroupPaths
(
prefixPath
);
}
finally
{
lock
.
readLock
().
unlock
();
}
}
/**
* Get all storage group MNodes
*/
...
...
server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
浏览文件 @
df250c3d
...
...
@@ -502,6 +502,50 @@ public class MTree implements Serializable {
return
res
;
}
/**
* Get all storage group under give path
*
* @return a list contains all storage group names under give path
*/
List
<
PartialPath
>
getStorageGroupPaths
(
PartialPath
prefixPath
)
throws
MetadataException
{
String
[]
nodes
=
prefixPath
.
getNodes
();
if
(
nodes
.
length
==
0
||
!
nodes
[
0
].
equals
(
root
.
getName
()))
{
throw
new
IllegalPathException
(
prefixPath
.
getFullPath
());
}
List
<
PartialPath
>
storageGroupPaths
=
new
ArrayList
<>();
findStorageGroupPaths
(
root
,
nodes
,
1
,
""
,
storageGroupPaths
);
return
storageGroupPaths
;
}
/**
* Traverse the MTree to match all storage group with prefix path.
*
* @param node the current traversing node
* @param nodes split the prefix path with '.'
* @param idx the current index of array nodes
* @param parent current parent path
* @param storageGroupPaths store all matched storage group names
*/
private
void
findStorageGroupPaths
(
MNode
node
,
String
[]
nodes
,
int
idx
,
String
parent
,
List
<
PartialPath
>
storageGroupPaths
)
{
if
(
node
instanceof
StorageGroupMNode
)
{
storageGroupPaths
.
add
(
node
.
getPartialPath
());
return
;
}
String
nodeReg
=
MetaUtils
.
getNodeRegByIdx
(
idx
,
nodes
);
if
(!(
PATH_WILDCARD
).
equals
(
nodeReg
))
{
if
(
node
.
hasChild
(
nodeReg
))
{
findStorageGroupPaths
(
node
.
getChild
(
nodeReg
),
nodes
,
idx
+
1
,
parent
+
node
.
getName
()
+
PATH_SEPARATOR
,
storageGroupPaths
);
}
}
else
{
for
(
MNode
child
:
node
.
getChildren
().
values
())
{
findStorageGroupPaths
(
child
,
nodes
,
idx
+
1
,
parent
+
node
.
getName
()
+
PATH_SEPARATOR
,
storageGroupPaths
);
}
}
}
/**
* Get all storage group MNodes
*/
...
...
server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
浏览文件 @
df250c3d
...
...
@@ -113,6 +113,7 @@ import org.apache.iotdb.db.qp.physical.sys.SetTTLPlan;
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.ShowPlan
;
import
org.apache.iotdb.db.qp.physical.sys.ShowStorageGroupPlan
;
import
org.apache.iotdb.db.qp.physical.sys.ShowTTLPlan
;
import
org.apache.iotdb.db.qp.physical.sys.ShowTimeSeriesPlan
;
import
org.apache.iotdb.db.qp.physical.sys.TracingPlan
;
...
...
@@ -362,7 +363,7 @@ public class PlanExecutor implements IPlanExecutor {
case
TIMESERIES:
return
processShowTimeseries
((
ShowTimeSeriesPlan
)
showPlan
,
context
);
case
STORAGE_GROUP:
return
processShowStorageGroup
();
return
processShowStorageGroup
(
(
ShowStorageGroupPlan
)
showPlan
);
case
DEVICES:
return
processShowDevices
((
ShowDevicesPlan
)
showPlan
);
case
CHILD_PATH:
...
...
@@ -487,16 +488,17 @@ public class PlanExecutor implements IPlanExecutor {
return
IoTDB
.
metaManager
.
getChildNodePathInNextLevel
(
path
);
}
protected
List
<
PartialPath
>
get
AllStorageGroupNames
()
{
return
IoTDB
.
metaManager
.
get
AllStorageGroupPaths
(
);
protected
List
<
PartialPath
>
get
StorageGroupNames
(
PartialPath
path
)
throws
MetadataException
{
return
IoTDB
.
metaManager
.
get
StorageGroupPaths
(
path
);
}
private
QueryDataSet
processShowStorageGroup
()
{
private
QueryDataSet
processShowStorageGroup
(
ShowStorageGroupPlan
showStorageGroupPlan
)
throws
MetadataException
{
ListDataSet
listDataSet
=
new
ListDataSet
(
Collections
.
singletonList
(
new
PartialPath
(
COLUMN_STORAGE_GROUP
,
false
)),
Collections
.
singletonList
(
TSDataType
.
TEXT
));
List
<
PartialPath
>
storageGroupList
=
get
AllStorageGroupNames
(
);
List
<
PartialPath
>
storageGroupList
=
get
StorageGroupNames
(
showStorageGroupPlan
.
getPath
()
);
for
(
PartialPath
s
:
storageGroupList
)
{
RowRecord
record
=
new
RowRecord
(
0
);
Field
field
=
new
Field
(
TSDataType
.
TEXT
);
...
...
@@ -1057,7 +1059,7 @@ public class PlanExecutor implements IPlanExecutor {
}
return
true
;
}
protected
QueryDataSet
processAuthorQuery
(
AuthorPlan
plan
)
throws
QueryProcessException
{
AuthorType
authorType
=
plan
.
getAuthorType
();
...
...
server/src/main/java/org/apache/iotdb/db/qp/logical/sys/ShowStorageGroupOperator.java
0 → 100644
浏览文件 @
df250c3d
/*
* 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
ShowStorageGroupOperator
extends
ShowOperator
{
private
PartialPath
path
;
public
ShowStorageGroupOperator
(
int
tokenIntType
,
PartialPath
path
)
{
super
(
tokenIntType
);
this
.
path
=
path
;
}
public
PartialPath
getPath
()
{
return
path
;
}
}
server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ShowStorageGroupPlan.java
0 → 100644
浏览文件 @
df250c3d
/*
* 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
ShowStorageGroupPlan
extends
ShowPlan
{
private
PartialPath
path
;
public
ShowStorageGroupPlan
(
ShowContentType
showContentType
,
PartialPath
path
)
{
super
(
showContentType
);
this
.
path
=
path
;
}
public
PartialPath
getPath
()
{
return
this
.
path
;
}
}
server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
浏览文件 @
df250c3d
...
...
@@ -71,6 +71,7 @@ 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.ShowMergeStatusOperator
;
import
org.apache.iotdb.db.qp.logical.sys.ShowOperator
;
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
;
import
org.apache.iotdb.db.qp.logical.sys.TracingOperator
;
...
...
@@ -301,7 +302,13 @@ public class LogicalGenerator extends SqlBaseBaseListener {
@Override
public
void
enterShowStorageGroup
(
ShowStorageGroupContext
ctx
)
{
super
.
enterShowStorageGroup
(
ctx
);
initializedOperator
=
new
ShowOperator
(
SQLConstant
.
TOK_STORAGE_GROUP
);
if
(
ctx
.
prefixPath
()
!=
null
)
{
initializedOperator
=
new
ShowStorageGroupOperator
(
SQLConstant
.
TOK_STORAGE_GROUP
,
parsePrefixPath
(
ctx
.
prefixPath
()));
}
else
{
initializedOperator
=
new
ShowStorageGroupOperator
(
SQLConstant
.
TOK_STORAGE_GROUP
,
new
PartialPath
(
SQLConstant
.
getSingleRootArray
()));
}
}
@Override
...
...
server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
浏览文件 @
df250c3d
...
...
@@ -60,6 +60,7 @@ import org.apache.iotdb.db.qp.logical.sys.SetStorageGroupOperator;
import
org.apache.iotdb.db.qp.logical.sys.SetTTLOperator
;
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.ShowStorageGroupOperator
;
import
org.apache.iotdb.db.qp.logical.sys.ShowTTLOperator
;
import
org.apache.iotdb.db.qp.logical.sys.ShowTimeSeriesOperator
;
import
org.apache.iotdb.db.qp.logical.sys.TracingOperator
;
...
...
@@ -98,6 +99,7 @@ import org.apache.iotdb.db.qp.physical.sys.ShowDevicesPlan;
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
;
import
org.apache.iotdb.db.qp.physical.sys.ShowStorageGroupPlan
;
import
org.apache.iotdb.db.qp.physical.sys.ShowTTLPlan
;
import
org.apache.iotdb.db.qp.physical.sys.ShowTimeSeriesPlan
;
import
org.apache.iotdb.db.qp.physical.sys.TracingPlan
;
...
...
@@ -232,7 +234,8 @@ public class PhysicalGenerator {
showTimeSeriesOperator
.
getValue
(),
showTimeSeriesOperator
.
getLimit
(),
showTimeSeriesOperator
.
getOffset
(),
showTimeSeriesOperator
.
isOrderByHeat
());
case
SQLConstant
.
TOK_STORAGE_GROUP
:
return
new
ShowPlan
(
ShowContentType
.
STORAGE_GROUP
);
return
new
ShowStorageGroupPlan
(
ShowContentType
.
STORAGE_GROUP
,
((
ShowStorageGroupOperator
)
operator
).
getPath
());
case
SQLConstant
.
TOK_DEVICES
:
return
new
ShowDevicesPlan
(
ShowContentType
.
DEVICES
,
((
ShowDevicesOperator
)
operator
).
getPath
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录