You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "DanielWang2035 (via GitHub)" <gi...@apache.org> on 2025/02/12 09:16:24 UTC

Re: [PR] Load: auto detect TsFile's model (tree/table) [iotdb]

DanielWang2035 commented on code in PR #14751:
URL: https://github.com/apache/iotdb/pull/14751#discussion_r1952262363


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/load/LoadTsFileAnalyzer.java:
##########
@@ -175,10 +252,154 @@ protected boolean doAnalyzeFileByFile(IAnalysis analysis) {
     return true;
   }
 
-  protected abstract void analyzeSingleTsFile(final File tsFile)
-      throws IOException, AuthException, LoadAnalyzeException;
+  private void analyzeSingleTsFile(final File tsFile, int i)
+      throws IOException, AuthException, LoadAnalyzeException {
+    try (final TsFileSequenceReader reader = new TsFileSequenceReader(tsFile.getAbsolutePath())) {
+      // can be reused when constructing tsfile resource
+      final TsFileSequenceReaderTimeseriesMetadataIterator timeseriesMetadataIterator =
+          new TsFileSequenceReaderTimeseriesMetadataIterator(reader, true, 1);
+
+      // check if the tsfile is empty
+      if (!timeseriesMetadataIterator.hasNext()) {
+        throw new LoadEmptyFileException(tsFile.getAbsolutePath());
+      }
+
+      // check whether the encrypt type of the tsfile is supported
+      final EncryptParameter param = reader.getEncryptParam();
+      if (!Objects.equals(param.getType(), EncryptUtils.encryptParam.getType())
+          || !Arrays.equals(param.getKey(), EncryptUtils.encryptParam.getKey())) {
+        throw new SemanticException("The encryption way of the TsFile is not supported.");
+      }
+
+      // check whether the tsfile is tree-model or not
+      final Map<String, TableSchema> tableSchemaMap = reader.getTableSchemaMap();
+      final boolean isTableModelFile = Objects.nonNull(tableSchemaMap) && !tableSchemaMap.isEmpty();

Review Comment:
   gettableschema v3?



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