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/06/21 02:38:04 UTC

[GitHub] [iotdb] bigreybear commented on a change in pull request #3407: Complete syntax sugar for createSchemaTemplate

bigreybear commented on a change in pull request #3407:
URL: https://github.com/apache/iotdb/pull/3407#discussion_r655038591



##########
File path: session/src/main/java/org/apache/iotdb/session/Session.java
##########
@@ -1790,6 +1790,81 @@ public void createSchemaTemplate(
     defaultSessionConnection.createSchemaTemplate(request);
   }
 
+  public void createSchemaTemplate(String templateName, List<IMeasurementSchema> measurementSchemas)
+      throws IoTDBConnectionException, StatementExecutionException {
+    List<String> schemaNames = new ArrayList<>();
+    List<List<String>> measurements = new ArrayList<>();
+    List<List<TSDataType>> dataTypes = new ArrayList<>();
+    List<List<TSEncoding>> encodings = new ArrayList<>();
+
+    List<CompressionType> compressors = new ArrayList<>();
+    for (IMeasurementSchema measurementSchema : measurementSchemas) {
+      schemaNames.add(measurementSchema.getMeasurementId());
+      measurements.add(Collections.singletonList(measurementSchema.getMeasurementId()));
+      dataTypes.add(Collections.singletonList(measurementSchema.getType()));
+      encodings.add(Collections.singletonList(measurementSchema.getEncodingType()));
+
+      compressors.add(measurementSchema.getCompressor());
+    }
+
+    TSCreateSchemaTemplateReq request =
+        getTSCreateSchemaTemplateReq(
+            templateName, schemaNames, measurements, dataTypes, encodings, compressors);
+    defaultSessionConnection.createSchemaTemplate(request);
+  }
+
+  public void createMeasurementSchemaTemplate(
+      String name,
+      String path,
+      TSDataType dataType,
+      TSEncoding encoding,
+      CompressionType compressor)
+      throws IoTDBConnectionException, StatementExecutionException {
+    List<String> schemaNames = new ArrayList<>();
+    List<List<String>> measurements = new ArrayList<>();
+    List<List<TSDataType>> dataTypes = new ArrayList<>();
+    List<List<TSEncoding>> encodings = new ArrayList<>();
+    List<CompressionType> compressors = new ArrayList<>();
+
+    schemaNames.add(path);
+    measurements.add(Collections.singletonList(path));
+    dataTypes.add(Collections.singletonList(dataType));
+    encodings.add(Collections.singletonList(encoding));
+    compressors.add(compressor);
+
+    TSCreateSchemaTemplateReq request =
+        getTSCreateSchemaTemplateReq(
+            name, schemaNames, measurements, dataTypes, encodings, compressors);
+    defaultSessionConnection.createSchemaTemplate(request);
+  }
+
+  public void createVectorSchemaTemplate(

Review comment:
       deleted




-- 
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.

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