Skip to content

Commit a501514

Browse files
committed
Merge branch 'show-fix' of https://github.com/Caideyipi/iotdb into show-fix
2 parents ac7870f + 55e26db commit a501514

14 files changed

Lines changed: 311 additions & 56 deletions

File tree

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ public TCheckTimeSeriesExistenceResp checkTimeSeriesExistence(
11531153
for (final PartialPath pattern : filteredPatternTree.getAllPathPatterns()) {
11541154
ISchemaSource<ITimeSeriesSchemaInfo> schemaSource =
11551155
SchemaSourceFactory.getTimeSeriesSchemaCountSource(
1156-
pattern, false, null, null, SchemaConstant.ALL_MATCH_SCOPE);
1156+
pattern, false, null, null, SchemaConstant.ALL_MATCH_SCOPE, true, true);
11571157
try (final ISchemaReader<ITimeSeriesSchemaInfo> schemaReader =
11581158
schemaSource.getSchemaReader(schemaRegion)) {
11591159
if (schemaReader.hasNext()) {
@@ -1996,7 +1996,9 @@ public TDeviceViewResp detectTreeDeviceViewFieldType(final TDeviceViewReq req) {
19961996
// Does not support logical view currently
19971997
SchemaFilterFactory.createViewTypeFilter(ViewType.BASE),
19981998
null,
1999-
SchemaConstant.ALL_MATCH_SCOPE);
1999+
SchemaConstant.ALL_MATCH_SCOPE,
2000+
true,
2001+
true);
20002002
try (final ISchemaReader<ITimeSeriesSchemaInfo> schemaReader =
20012003
schemaSource.getSchemaReader(schemaRegion)) {
20022004
final Map<String, Byte> updateMap = resp.getDeviewViewFieldTypeMap();

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/schema/source/SchemaSourceFactory.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,21 @@ public static ISchemaSource<ITimeSeriesSchemaInfo> getTimeSeriesSchemaCountSourc
4646
boolean isPrefixMatch,
4747
SchemaFilter schemaFilter,
4848
Map<Integer, Template> templateMap,
49-
PathPatternTree scope) {
49+
PathPatternTree scope,
50+
boolean includeSystemDatabase,
51+
boolean includeAuditDatabase) {
5052
return new TimeSeriesSchemaSource(
51-
pathPattern, isPrefixMatch, 0, 0, schemaFilter, templateMap, false, true, scope, null);
53+
pathPattern,
54+
isPrefixMatch,
55+
0,
56+
0,
57+
schemaFilter,
58+
templateMap,
59+
false,
60+
includeSystemDatabase,
61+
includeAuditDatabase,
62+
scope,
63+
null);
5264
}
5365

5466
// show time series
@@ -69,7 +81,8 @@ public static ISchemaSource<ITimeSeriesSchemaInfo> getTimeSeriesSchemaScanSource
6981
schemaFilter,
7082
templateMap,
7183
true,
72-
false,
84+
true,
85+
true,
7386
scope,
7487
timeseriesOrdering);
7588
}

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/schema/source/TimeSeriesSchemaSource.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public class TimeSeriesSchemaSource implements ISchemaSource<ITimeSeriesSchemaIn
5656
private final SchemaFilter schemaFilter;
5757
private final Map<Integer, Template> templateMap;
5858
private final boolean needViewDetail;
59-
private final boolean excludeInternalDatabase;
59+
private final boolean includeSystemDatabase;
60+
private final boolean includeAuditDatabase;
6061
private final Ordering timeseriesOrdering;
6162

6263
TimeSeriesSchemaSource(
@@ -67,7 +68,8 @@ public class TimeSeriesSchemaSource implements ISchemaSource<ITimeSeriesSchemaIn
6768
SchemaFilter schemaFilter,
6869
Map<Integer, Template> templateMap,
6970
boolean needViewDetail,
70-
boolean excludeInternalDatabase,
71+
boolean includeSystemDatabase,
72+
boolean includeAuditDatabase,
7173
PathPatternTree scope,
7274
Ordering timeseriesOrdering) {
7375
this.pathPattern = pathPattern;
@@ -77,7 +79,8 @@ public class TimeSeriesSchemaSource implements ISchemaSource<ITimeSeriesSchemaIn
7779
this.schemaFilter = schemaFilter;
7880
this.templateMap = templateMap;
7981
this.needViewDetail = needViewDetail;
80-
this.excludeInternalDatabase = excludeInternalDatabase;
82+
this.includeSystemDatabase = includeSystemDatabase;
83+
this.includeAuditDatabase = includeAuditDatabase;
8184
this.scope = scope;
8285
this.timeseriesOrdering = timeseriesOrdering;
8386
}
@@ -147,21 +150,15 @@ public long getSchemaStatistic(ISchemaRegion schemaRegion) {
147150

148151
@Override
149152
public boolean shouldSkipSchemaRegion(final ISchemaRegion schemaRegion) {
150-
if (!excludeInternalDatabase) {
151-
return false;
152-
}
153-
154153
final String database = schemaRegion.getDatabaseFullPath();
155-
if (!SchemaConstant.SYSTEM_DATABASE.equals(database)
156-
&& !SchemaConstant.AUDIT_DATABASE.equals(database)
157-
&& !Audit.TABLE_MODEL_AUDIT_DATABASE.equals(database)) {
158-
return false;
154+
if (SchemaConstant.SYSTEM_DATABASE.equals(database)) {
155+
return !includeSystemDatabase;
159156
}
160-
161-
final String[] nodes = pathPattern.getNodes();
162-
return nodes.length < 2
163-
|| !SchemaConstant.ROOT.equals(nodes[0])
164-
|| !database.endsWith("." + nodes[1]);
157+
if (SchemaConstant.AUDIT_DATABASE.equals(database)
158+
|| Audit.TABLE_MODEL_AUDIT_DATABASE.equals(database)) {
159+
return !includeAuditDatabase;
160+
}
161+
return false;
165162
}
166163

167164
public static String mapToString(Map<String, String> map) {

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeVisitor.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@
3636
import org.apache.iotdb.commons.path.PartialPath;
3737
import org.apache.iotdb.commons.path.PathPatternTree;
3838
import org.apache.iotdb.commons.queryengine.common.NodeRef;
39+
import org.apache.iotdb.commons.schema.SchemaConstant;
3940
import org.apache.iotdb.commons.schema.column.ColumnHeader;
4041
import org.apache.iotdb.commons.schema.column.ColumnHeaderConstant;
42+
import org.apache.iotdb.commons.schema.table.Audit;
4143
import org.apache.iotdb.commons.schema.template.Template;
4244
import org.apache.iotdb.commons.schema.view.LogicalViewSchema;
4345
import org.apache.iotdb.commons.schema.view.viewExpression.ViewExpression;
@@ -2935,6 +2937,7 @@ private boolean analyzeTimeseriesRegionScan(
29352937
MPPQueryContext context,
29362938
PathPatternTree authorityScope,
29372939
boolean canSeeAuditDB,
2940+
boolean canSeeSystemDB,
29382941
boolean includeLogicalView)
29392942
throws IllegalPathException {
29402943
analyzeGlobalTimeConditionInShowMetaData(timeCondition, analysis);
@@ -2968,6 +2971,10 @@ private boolean analyzeTimeseriesRegionScan(
29682971
for (DeviceSchemaInfo deviceSchemaInfo : deviceSchemaInfoList) {
29692972
boolean isAligned = deviceSchemaInfo.isAligned();
29702973
PartialPath devicePath = deviceSchemaInfo.getDevicePath();
2974+
if (shouldSkipInternalDatabaseForActiveCount(
2975+
devicePath, schemaTree, canSeeAuditDB, canSeeSystemDB)) {
2976+
continue;
2977+
}
29712978
if (isAligned) {
29722979
List<String> measurementList = new ArrayList<>();
29732980
List<IMeasurementSchema> schemaList = new ArrayList<>();
@@ -3025,6 +3032,22 @@ private boolean analyzeTimeseriesRegionScan(
30253032
return true;
30263033
}
30273034

3035+
private boolean shouldSkipInternalDatabaseForActiveCount(
3036+
PartialPath devicePath,
3037+
ISchemaTree schemaTree,
3038+
boolean canSeeAuditDB,
3039+
boolean canSeeSystemDB) {
3040+
String database = schemaTree.getBelongedDatabase(devicePath);
3041+
if (SchemaConstant.SYSTEM_DATABASE.equals(database)) {
3042+
return !canSeeSystemDB;
3043+
}
3044+
if (SchemaConstant.AUDIT_DATABASE.equals(database)
3045+
|| Audit.TABLE_MODEL_AUDIT_DATABASE.equals(database)) {
3046+
return !canSeeAuditDB;
3047+
}
3048+
return false;
3049+
}
3050+
30283051
private void addLogicalViewSourcesForActiveCount(
30293052
PartialPath viewDevicePath,
30303053
IMeasurementSchemaInfo viewSchemaInfo,
@@ -3145,6 +3168,7 @@ public Analysis visitShowTimeSeries(
31453168
context,
31463169
showTimeSeriesStatement.getAuthorityScope(),
31473170
showTimeSeriesStatement.isCanSeeAuditDB(),
3171+
true,
31483172
true);
31493173
if (!hasSchema) {
31503174
analysis.setRespDatasetHeader(DatasetHeaderFactory.getShowTimeSeriesHeader());
@@ -3397,6 +3421,7 @@ public Analysis visitCountTimeSeries(
33973421
context,
33983422
countTimeSeriesStatement.getAuthorityScope(),
33993423
countTimeSeriesStatement.isCanSeeAuditDB(),
3424+
countTimeSeriesStatement.isCanSeeSystemDB(),
34003425
true);
34013426
if (!hasSchema) {
34023427
analysis.setRespDatasetHeader(DatasetHeaderFactory.getCountTimeSeriesHeader());

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/LogicalPlanBuilder.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,15 +1176,19 @@ public LogicalPlanBuilder planTimeSeriesCountSource(
11761176
boolean prefixPath,
11771177
SchemaFilter schemaFilter,
11781178
Map<Integer, Template> templateMap,
1179-
PathPatternTree scope) {
1179+
PathPatternTree scope,
1180+
boolean includeSystemDatabase,
1181+
boolean includeAuditDatabase) {
11801182
this.root =
11811183
new TimeSeriesCountNode(
11821184
context.getQueryId().genPlanNodeId(),
11831185
partialPath,
11841186
prefixPath,
11851187
schemaFilter,
11861188
templateMap,
1187-
scope);
1189+
scope,
1190+
includeSystemDatabase,
1191+
includeAuditDatabase);
11881192
return this;
11891193
}
11901194

@@ -1194,7 +1198,9 @@ public LogicalPlanBuilder planLevelTimeSeriesCountSource(
11941198
int level,
11951199
SchemaFilter schemaFilter,
11961200
Map<Integer, Template> templateMap,
1197-
PathPatternTree scope) {
1201+
PathPatternTree scope,
1202+
boolean includeSystemDatabase,
1203+
boolean includeAuditDatabase) {
11981204
this.root =
11991205
new LevelTimeSeriesCountNode(
12001206
context.getQueryId().genPlanNodeId(),
@@ -1203,7 +1209,9 @@ public LogicalPlanBuilder planLevelTimeSeriesCountSource(
12031209
level,
12041210
schemaFilter,
12051211
templateMap,
1206-
scope);
1212+
scope,
1213+
includeSystemDatabase,
1214+
includeAuditDatabase);
12071215
return this;
12081216
}
12091217

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/LogicalPlanVisitor.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,9 @@ public PlanNode visitCountTimeSeries(
733733
countTimeSeriesStatement.isPrefixPath(),
734734
countTimeSeriesStatement.getSchemaFilter(),
735735
analysis.getRelatedTemplateInfo(),
736-
countTimeSeriesStatement.getAuthorityScope())
736+
countTimeSeriesStatement.getAuthorityScope(),
737+
countTimeSeriesStatement.isCanSeeSystemDB(),
738+
countTimeSeriesStatement.isCanSeeAuditDB())
737739
.planCountMerge()
738740
.getRoot();
739741
}
@@ -749,7 +751,9 @@ public PlanNode visitCountLevelTimeSeries(
749751
countLevelTimeSeriesStatement.getLevel(),
750752
countLevelTimeSeriesStatement.getSchemaFilter(),
751753
analysis.getRelatedTemplateInfo(),
752-
countLevelTimeSeriesStatement.getAuthorityScope())
754+
countLevelTimeSeriesStatement.getAuthorityScope(),
755+
countLevelTimeSeriesStatement.isCanSeeSystemDB(),
756+
countLevelTimeSeriesStatement.isCanSeeAuditDB())
753757
.planCountMerge()
754758
.getRoot();
755759
}

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/OperatorTreeGenerator.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,9 @@ public Operator visitTimeSeriesCount(
984984
node.isPrefixPath(),
985985
node.getSchemaFilter(),
986986
node.getTemplateMap(),
987-
node.getScope()));
987+
node.getScope(),
988+
node.isIncludeSystemDatabase(),
989+
node.isIncludeAuditDatabase()));
988990
}
989991

990992
@Override
@@ -1006,7 +1008,9 @@ public Operator visitLevelTimeSeriesCount(
10061008
node.isPrefixPath(),
10071009
node.getSchemaFilter(),
10081010
node.getTemplateMap(),
1009-
node.getScope()));
1011+
node.getScope(),
1012+
node.isIncludeSystemDatabase(),
1013+
node.isIncludeAuditDatabase()));
10101014
}
10111015

10121016
@Override

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/metadata/read/LevelTimeSeriesCountNode.java

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public class LevelTimeSeriesCountNode extends SchemaQueryScanNode {
4848
private final int level;
4949
private final SchemaFilter schemaFilter;
5050
private final Map<Integer, Template> templateMap;
51+
private final boolean includeSystemDatabase;
52+
private final boolean includeAuditDatabase;
5153

5254
public LevelTimeSeriesCountNode(
5355
PlanNodeId id,
@@ -56,11 +58,15 @@ public LevelTimeSeriesCountNode(
5658
int level,
5759
SchemaFilter schemaFilter,
5860
@NotNull Map<Integer, Template> templateMap,
59-
@NotNull PathPatternTree scope) {
61+
@NotNull PathPatternTree scope,
62+
boolean includeSystemDatabase,
63+
boolean includeAuditDatabase) {
6064
super(id, partialPath, isPrefixPath, scope);
6165
this.level = level;
6266
this.schemaFilter = schemaFilter;
6367
this.templateMap = templateMap;
68+
this.includeSystemDatabase = includeSystemDatabase;
69+
this.includeAuditDatabase = includeAuditDatabase;
6470
}
6571

6672
public SchemaFilter getSchemaFilter() {
@@ -75,6 +81,14 @@ public Map<Integer, Template> getTemplateMap() {
7581
return templateMap;
7682
}
7783

84+
public boolean isIncludeSystemDatabase() {
85+
return includeSystemDatabase;
86+
}
87+
88+
public boolean isIncludeAuditDatabase() {
89+
return includeAuditDatabase;
90+
}
91+
7892
@Override
7993
public PlanNodeType getType() {
8094
return PlanNodeType.LEVEL_TIME_SERIES_COUNT;
@@ -83,7 +97,15 @@ public PlanNodeType getType() {
8397
@Override
8498
public PlanNode clone() {
8599
return new LevelTimeSeriesCountNode(
86-
getPlanNodeId(), path, isPrefixPath, level, schemaFilter, templateMap, scope);
100+
getPlanNodeId(),
101+
path,
102+
isPrefixPath,
103+
level,
104+
schemaFilter,
105+
templateMap,
106+
scope,
107+
includeSystemDatabase,
108+
includeAuditDatabase);
87109
}
88110

89111
@Override
@@ -101,6 +123,8 @@ protected void serializeAttributes(ByteBuffer byteBuffer) {
101123
ReadWriteIOUtils.write(isPrefixPath, byteBuffer);
102124
ReadWriteIOUtils.write(level, byteBuffer);
103125
SchemaFilter.serialize(schemaFilter, byteBuffer);
126+
ReadWriteIOUtils.write(includeSystemDatabase, byteBuffer);
127+
ReadWriteIOUtils.write(includeAuditDatabase, byteBuffer);
104128
ReadWriteIOUtils.write(templateMap.size(), byteBuffer);
105129
for (Template template : templateMap.values()) {
106130
template.serialize(byteBuffer);
@@ -115,6 +139,8 @@ protected void serializeAttributes(DataOutputStream stream) throws IOException {
115139
ReadWriteIOUtils.write(isPrefixPath, stream);
116140
ReadWriteIOUtils.write(level, stream);
117141
SchemaFilter.serialize(schemaFilter, stream);
142+
ReadWriteIOUtils.write(includeSystemDatabase, stream);
143+
ReadWriteIOUtils.write(includeAuditDatabase, stream);
118144
ReadWriteIOUtils.write(templateMap.size(), stream);
119145
for (Template template : templateMap.values()) {
120146
template.serialize(stream);
@@ -134,6 +160,8 @@ public static PlanNode deserialize(ByteBuffer buffer) {
134160
boolean isPrefixPath = ReadWriteIOUtils.readBool(buffer);
135161
int level = ReadWriteIOUtils.readInt(buffer);
136162
SchemaFilter schemaFilter = SchemaFilter.deserialize(buffer);
163+
boolean includeSystemDatabase = ReadWriteIOUtils.readBool(buffer);
164+
boolean includeAuditDatabase = ReadWriteIOUtils.readBool(buffer);
137165
int templateNum = ReadWriteIOUtils.readInt(buffer);
138166
Map<Integer, Template> templateMap = new HashMap<>();
139167
Template template;
@@ -144,7 +172,15 @@ public static PlanNode deserialize(ByteBuffer buffer) {
144172
}
145173
PlanNodeId planNodeId = PlanNodeId.deserialize(buffer);
146174
return new LevelTimeSeriesCountNode(
147-
planNodeId, path, isPrefixPath, level, schemaFilter, templateMap, scope);
175+
planNodeId,
176+
path,
177+
isPrefixPath,
178+
level,
179+
schemaFilter,
180+
templateMap,
181+
scope,
182+
includeSystemDatabase,
183+
includeAuditDatabase);
148184
}
149185

150186
@Override
@@ -159,12 +195,14 @@ public boolean equals(Object o) {
159195
return false;
160196
}
161197
LevelTimeSeriesCountNode that = (LevelTimeSeriesCountNode) o;
162-
return level == that.level;
198+
return level == that.level
199+
&& includeSystemDatabase == that.includeSystemDatabase
200+
&& includeAuditDatabase == that.includeAuditDatabase;
163201
}
164202

165203
@Override
166204
public int hashCode() {
167-
return Objects.hash(super.hashCode(), level);
205+
return Objects.hash(super.hashCode(), level, includeSystemDatabase, includeAuditDatabase);
168206
}
169207

170208
@Override

0 commit comments

Comments
 (0)