fanhualta commented on a change in pull request #430: [IOTDB-193]Create schema automatically URL: https://github.com/apache/incubator-iotdb/pull/430#discussion_r332930175
########## File path: server/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java ########## @@ -661,4 +717,111 @@ private AuthDataSet executeListUserPrivileges(IAuthorizer authorizer, String use } return dataSet; } + + /** + * Set storage group when creating schema automatically is enable + */ + private void setStorageGroupToMTreeByAutoLevel(String deviceId) throws ProcessorException, PathErrorException { + IoTDBConfig conf = IoTDBDescriptor.getInstance().getConfig(); + MetadataPlan metadataPlan = new MetadataPlan( + MetadataOperator.NamespaceType.SET_STORAGE_GROUP, + new Path(mManager.getStorageGroupNameByAutoLevel(deviceId, conf.getAutoStorageGroupLevel()))); + operateMetadata(metadataPlan); + } + + private void addPathListToMTree(String deviceId, String[] measurementList, Object[] values) + throws ProcessorException { + for (int i = 0; i < measurementList.length; i++) { + addPathToMTree(deviceId, measurementList[i], values[i]); + } + } + + private void addPathToMTree(String deviceId, String measurementId, Object value) + throws ProcessorException { + TSDataType predictedDataType = getPredictedDataType(value); + TSEncoding defaultEncoding = getDefaultEncoding(predictedDataType); + MetadataPlan metadataPlan = new MetadataPlan( + MetadataOperator.NamespaceType.ADD_PATH, + new Path(deviceId + "." + measurementId), + predictedDataType, defaultEncoding, + CompressionType.valueOf(TSFileDescriptor.getInstance().getConfig().getCompressor())); + operateMetadata(metadataPlan); Review comment: You can use interfaces in `MManager` rather than creating a `MetadataPlan`. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services