Skip to content

Commit 85092b2

Browse files
committed
test-fix
1 parent 4891c67 commit 85092b2

File tree

2 files changed

+88
-1
lines changed

2 files changed

+88
-1
lines changed

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/source/schemaregion/PipeTreeStatementToPlanVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ public BatchActivateTemplateNode visitBatchActivateTemplate(
5555
// The value pair will not be used at the receiver
5656
return new BatchActivateTemplateNode(
5757
new PlanNodeId(""),
58-
node.getPaths().stream().collect(Collectors.toMap(k -> k, k -> new Pair<>(0, 0))));
58+
node.getDevicePathList().stream().collect(Collectors.toMap(k -> k, k -> new Pair<>(0, 0))));
5959
}
6060
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.iotdb.db.pipe.source;
21+
22+
import org.apache.iotdb.commons.exception.IllegalPathException;
23+
import org.apache.iotdb.commons.path.PartialPath;
24+
import org.apache.iotdb.db.pipe.source.schemaregion.PipeTreeStatementToPlanVisitor;
25+
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.MeasurementGroup;
26+
import org.apache.iotdb.db.queryengine.plan.statement.internal.InternalCreateMultiTimeSeriesStatement;
27+
import org.apache.iotdb.db.queryengine.plan.statement.metadata.template.BatchActivateTemplateStatement;
28+
29+
import org.apache.tsfile.enums.TSDataType;
30+
import org.apache.tsfile.file.metadata.enums.CompressionType;
31+
import org.apache.tsfile.file.metadata.enums.TSEncoding;
32+
import org.apache.tsfile.utils.Pair;
33+
import org.junit.Assert;
34+
import org.junit.Test;
35+
36+
import java.util.Arrays;
37+
import java.util.Collections;
38+
import java.util.HashMap;
39+
import java.util.HashSet;
40+
import java.util.List;
41+
import java.util.Map;
42+
43+
public class PipeTreeStatementToPlanVisitorTest {
44+
@Test
45+
public void testInternalCreateMultiTimeSeries() throws IllegalPathException {
46+
final MeasurementGroup originalMeasurementGroup = new MeasurementGroup();
47+
originalMeasurementGroup.addMeasurement(
48+
"s1", TSDataType.FLOAT, TSEncoding.RLE, CompressionType.SNAPPY);
49+
originalMeasurementGroup.addProps(Collections.emptyMap());
50+
originalMeasurementGroup.addAlias("a1");
51+
originalMeasurementGroup.addTags(Collections.emptyMap());
52+
originalMeasurementGroup.addAttributes(Collections.emptyMap());
53+
originalMeasurementGroup.addMeasurement(
54+
"s2", TSDataType.BOOLEAN, TSEncoding.PLAIN, CompressionType.SNAPPY);
55+
originalMeasurementGroup.addProps(Collections.emptyMap());
56+
originalMeasurementGroup.addAlias("a2");
57+
originalMeasurementGroup.addTags(Collections.emptyMap());
58+
originalMeasurementGroup.addAttributes(Collections.emptyMap());
59+
60+
final Map<PartialPath, Pair<Boolean, MeasurementGroup>> testMap =
61+
new HashMap<PartialPath, Pair<Boolean, MeasurementGroup>>() {
62+
{
63+
put(new PartialPath("root.db.device"), new Pair<>(false, originalMeasurementGroup));
64+
put(new PartialPath("root.db1.device"), new Pair<>(false, originalMeasurementGroup));
65+
}
66+
};
67+
68+
Assert.assertEquals(
69+
testMap,
70+
new PipeTreeStatementToPlanVisitor()
71+
.visitInternalCreateMultiTimeSeries(
72+
new InternalCreateMultiTimeSeriesStatement(testMap), null)
73+
.getDeviceMap());
74+
}
75+
76+
@Test
77+
public void testBatchActivateTemplate() throws IllegalPathException {
78+
final List<PartialPath> templatePaths =
79+
Arrays.asList(new PartialPath("root.db.device"), new PartialPath("root.db.device2"));
80+
Assert.assertEquals(
81+
new HashSet<>(templatePaths),
82+
new PipeTreeStatementToPlanVisitor()
83+
.visitBatchActivateTemplate(new BatchActivateTemplateStatement(templatePaths), null)
84+
.getTemplateActivationMap()
85+
.keySet());
86+
}
87+
}

0 commit comments

Comments
 (0)