You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by zy...@apache.org on 2023/02/07 13:15:09 UTC
[iotdb] branch rel/1.0 updated: [To rel/1.0][IOTDB-5350] Fix bug about show devices (#9005)
This is an automated email from the ASF dual-hosted git repository.
zyk pushed a commit to branch rel/1.0
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/1.0 by this push:
new a6ad55c8e5 [To rel/1.0][IOTDB-5350] Fix bug about show devices (#9005)
a6ad55c8e5 is described below
commit a6ad55c8e543ae040de991bb0ddcc2c1c69fd914
Author: 橘子 <70...@users.noreply.github.com>
AuthorDate: Tue Feb 7 21:15:03 2023 +0800
[To rel/1.0][IOTDB-5350] Fix bug about show devices (#9005)
---
.../mtree/traverser/collector/EntityCollector.java | 2 +-
.../apache/iotdb/db/metadata/SchemaBasicTest.java | 72 ++++++++++++++++++++++
2 files changed, 73 insertions(+), 1 deletion(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/traverser/collector/EntityCollector.java b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/traverser/collector/EntityCollector.java
index 9b80facaac..22c670b47d 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/traverser/collector/EntityCollector.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/traverser/collector/EntityCollector.java
@@ -50,7 +50,7 @@ public abstract class EntityCollector<T> extends CollectorTraverser<T> {
if (hasLimit) {
curOffset += 1;
if (curOffset < offset) {
- return true;
+ return false;
}
}
collectEntity(node.getAsEntityMNode());
diff --git a/server/src/test/java/org/apache/iotdb/db/metadata/SchemaBasicTest.java b/server/src/test/java/org/apache/iotdb/db/metadata/SchemaBasicTest.java
index b1ef35b409..6022559d5e 100644
--- a/server/src/test/java/org/apache/iotdb/db/metadata/SchemaBasicTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/metadata/SchemaBasicTest.java
@@ -29,8 +29,10 @@ import org.apache.iotdb.db.metadata.utils.MetaUtils;
import org.apache.iotdb.db.qp.physical.sys.CreateAlignedTimeSeriesPlan;
import org.apache.iotdb.db.qp.physical.sys.CreateTemplatePlan;
import org.apache.iotdb.db.qp.physical.sys.CreateTimeSeriesPlan;
+import org.apache.iotdb.db.qp.physical.sys.ShowDevicesPlan;
import org.apache.iotdb.db.qp.physical.sys.ShowTimeSeriesPlan;
import org.apache.iotdb.db.query.context.QueryContext;
+import org.apache.iotdb.db.query.dataset.ShowDevicesResult;
import org.apache.iotdb.db.query.dataset.ShowResult;
import org.apache.iotdb.db.query.dataset.ShowTimeSeriesResult;
import org.apache.iotdb.db.service.IoTDB;
@@ -731,6 +733,76 @@ public abstract class SchemaBasicTest {
}
}
+ @Test
+ public void testGetMatchedDevicesWithPlan() {
+ LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
+
+ try {
+ schemaProcessor.createTimeseries(
+ new PartialPath("root.laptop.d1.s0"),
+ TSDataType.INT32,
+ TSEncoding.PLAIN,
+ CompressionType.GZIP,
+ Collections.emptyMap());
+ schemaProcessor.createTimeseries(
+ new PartialPath("root.laptop.d1.s2"),
+ TSDataType.valueOf("INT32"),
+ TSEncoding.PLAIN,
+ CompressionType.GZIP,
+ Collections.emptyMap());
+ schemaProcessor.createTimeseries(
+ new PartialPath("root.laptop.d2.s0"),
+ TSDataType.INT32,
+ TSEncoding.PLAIN,
+ CompressionType.GZIP,
+ Collections.emptyMap());
+ schemaProcessor.createTimeseries(
+ new PartialPath("root.laptop.d3.s0"),
+ TSDataType.INT32,
+ TSEncoding.PLAIN,
+ CompressionType.GZIP,
+ Collections.emptyMap());
+ schemaProcessor.createTimeseries(
+ new PartialPath("root.laptop.abc.d4.s0"),
+ TSDataType.INT32,
+ TSEncoding.PLAIN,
+ CompressionType.GZIP,
+ Collections.emptyMap());
+
+ // CASE 01. show devices
+ List<ShowDevicesResult> result =
+ schemaProcessor.getMatchedDevices(new ShowDevicesPlan(new PartialPath("root.**")));
+ assertEquals(4, result.size());
+
+ // CASE 02. show devices limit 100 offset 1
+ result =
+ schemaProcessor.getMatchedDevices(
+ new ShowDevicesPlan(new PartialPath("root.**"), 100, 1, false));
+ assertEquals(3, result.size());
+
+ // CASE 03. show devices limit 2 offset 1
+ result =
+ schemaProcessor.getMatchedDevices(
+ new ShowDevicesPlan(new PartialPath("root.**"), 2, 1, false));
+ assertEquals(2, result.size());
+
+ // CASE 04. show devices limit 2 offset 3
+ result =
+ schemaProcessor.getMatchedDevices(
+ new ShowDevicesPlan(new PartialPath("root.**"), 2, 3, false));
+ assertEquals(1, result.size());
+
+ // CASE 04. show devices limit 2 offset 5
+ result =
+ schemaProcessor.getMatchedDevices(
+ new ShowDevicesPlan(new PartialPath("root.**"), 2, 5, false));
+ assertEquals(0, result.size());
+ } catch (MetadataException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
@Test
public void testGetChildNodePathInNextLevel() {
LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;