You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/10/29 02:05:34 UTC

[GitHub] [iotdb] jt2594838 commented on a change in pull request #4244: [IOTDB-1745] Metagroup snapshots support template

jt2594838 commented on a change in pull request #4244:
URL: https://github.com/apache/iotdb/pull/4244#discussion_r738880741



##########
File path: cluster/src/main/java/org/apache/iotdb/cluster/log/snapshot/MetaSimpleSnapshot.java
##########
@@ -115,6 +125,13 @@ public ByteBuffer serialize() {
         dataOutputStream.write(entry.getValue().serialize().array());
       }
 
+      dataOutputStream.writeInt(templateMap.size());
+      for (Map.Entry<String, Template> entry : templateMap.entrySet()) {
+        SerializeUtils.serialize(entry.getKey(), dataOutputStream);
+        logger.info("A template into snapshot: {}", entry.getValue());

Review comment:
       I suggest it be reduced to debug level.

##########
File path: cluster/src/test/java/org/apache/iotdb/cluster/server/member/MetaGroupMemberTest.java
##########
@@ -767,14 +772,61 @@ public void testSendSnapshot() throws IllegalPathException {
       Assert.fail(e.getMessage());
     }
 
-    // 4. prepare the partition table
+    // 4. prepare the template info
+    Map<String, Template> templateMap = new HashMap<>();
+    // create createTemplatePlan for template
+    List<List<String>> measurementList = new ArrayList<>();
+    measurementList.add(Collections.singletonList("template_sensor"));
+    List<String> measurements = new ArrayList<>();
+    for (int j = 0; j < 10; j++) {
+      measurements.add("s" + j);
+    }
+    measurementList.add(measurements);
+
+    List<List<TSDataType>> dataTypeList = new ArrayList<>();
+    dataTypeList.add(Collections.singletonList(TSDataType.INT64));
+    List<TSDataType> dataTypes = new ArrayList<>();
+    for (int j = 0; j < 10; j++) {
+      dataTypes.add(TSDataType.INT64);
+    }
+    dataTypeList.add(dataTypes);
+
+    List<List<TSEncoding>> encodingList = new ArrayList<>();
+    encodingList.add(Collections.singletonList(TSEncoding.RLE));
+    List<TSEncoding> encodings = new ArrayList<>();
+    for (int j = 0; j < 10; j++) {
+      encodings.add(TSEncoding.RLE);
+    }
+    encodingList.add(encodings);
+
+    List<CompressionType> compressionTypes = new ArrayList<>();
+    for (int j = 0; j < 11; j++) {
+      compressionTypes.add(CompressionType.SNAPPY);
+    }
+
+    List<String> schemaNames = new ArrayList<>();
+    schemaNames.add("template_sensor");
+    schemaNames.add("vector");
+
+    CreateTemplatePlan createTemplatePlan =
+        new CreateTemplatePlan(
+            "template", schemaNames, measurementList, dataTypeList, encodingList, compressionTypes);
+    for (int i = 0; i < 10; i++) {
+      String templateName = "template_" + i;
+      createTemplatePlan.setName(templateName);
+      Template template = new Template(createTemplatePlan);
+      templateMap.put(templateName, template);
+    }

Review comment:
       This block seem to duplicate that in the previous test, maybe you can put it into a util class.

##########
File path: cluster/src/test/java/org/apache/iotdb/cluster/log/snapshot/MetaSimpleSnapshotTest.java
##########
@@ -183,9 +211,58 @@ public void testInstall()
       assertEquals(roleMap.get(roleName), role);
     }
 
+    for (int i = 0; i < 10; i++) {
+      String templateName = "template_" + i;
+      try {
+        Template template = TemplateManager.getInstance().getTemplate(templateName);
+        assertEquals(templateMap.get(templateName), template);
+      } catch (UndefinedTemplateException e) {
+        assertTrue(false);

Review comment:
       Use `fail` when an unexpected exception occurs.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org