Copilot commented on code in PR #17031:
URL: https://github.com/apache/iotdb/pull/17031#discussion_r2696768766
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/tools/TsFileSketchTool.java:
##########
@@ -266,6 +273,29 @@ private void printIndexOfTimerseriesIndex(long pos,
MetadataIndexNode metadataIn
String.format("%20s", "") + "|\t\t<endOffset, " +
metadataIndexNode.getEndOffset() + ">");
}
+ private void printTableSchemaMap(Map<String, TableSchema> tableSchemaMap) {
+ if (tableSchemaMap == null || tableSchemaMap.isEmpty()) {
+ return;
+ }
+ printlnBoth(pw, String.format("%20s", "") + "|\t[TableSchemaMap]");
+ for (Entry<String, TableSchema> entry : tableSchemaMap.entrySet()) {
+ String tableName = entry.getKey();
+ TableSchema tableSchema = entry.getValue();
+ printlnBoth(pw, String.format("%20s", "") +
String.format("|\t\t[TableSchema] " + tableName));
+ List<ColumnCategory> columnTypes = tableSchema.getColumnTypes();
+ List<IMeasurementSchema> columnSchemas = tableSchema.getColumnSchemas();
+ for (int i = 0; i < columnTypes.size(); i++) {
Review Comment:
The loop iterates based on columnTypes.size() but accesses
columnSchemas.get(i) without verifying that both lists have the same size. This
could cause an IndexOutOfBoundsException if columnSchemas.size() is less than
columnTypes.size(). Consider adding a size check or using the minimum of both
sizes for the loop condition.
```suggestion
int size = Math.min(columnTypes.size(), columnSchemas.size());
for (int i = 0; i < size; i++) {
```
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/tools/TsFileSketchTool.java:
##########
@@ -266,6 +273,29 @@ private void printIndexOfTimerseriesIndex(long pos,
MetadataIndexNode metadataIn
String.format("%20s", "") + "|\t\t<endOffset, " +
metadataIndexNode.getEndOffset() + ">");
}
+ private void printTableSchemaMap(Map<String, TableSchema> tableSchemaMap) {
+ if (tableSchemaMap == null || tableSchemaMap.isEmpty()) {
+ return;
+ }
+ printlnBoth(pw, String.format("%20s", "") + "|\t[TableSchemaMap]");
+ for (Entry<String, TableSchema> entry : tableSchemaMap.entrySet()) {
+ String tableName = entry.getKey();
+ TableSchema tableSchema = entry.getValue();
+ printlnBoth(pw, String.format("%20s", "") +
String.format("|\t\t[TableSchema] " + tableName));
+ List<ColumnCategory> columnTypes = tableSchema.getColumnTypes();
+ List<IMeasurementSchema> columnSchemas = tableSchema.getColumnSchemas();
+ for (int i = 0; i < columnTypes.size(); i++) {
+ IMeasurementSchema columnSchema = columnSchemas.get(i);
+ printlnBoth(
+ pw,
+ String.format("%20s", "")
+ + String.format(
+ "|\t\t\t[%s, %s, %s]",
+ columnSchema.getMeasurementName(), columnSchema.getType(),
columnTypes.get(i)));
+ }
+ }
+ }
Review Comment:
The new printTableSchemaMap method lacks test coverage. Consider adding a
test case that creates a table model TsFile with TableSchema data to verify
that the method correctly prints the table schema information.
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/tools/TsFileSketchTool.java:
##########
@@ -266,6 +273,29 @@ private void printIndexOfTimerseriesIndex(long pos,
MetadataIndexNode metadataIn
String.format("%20s", "") + "|\t\t<endOffset, " +
metadataIndexNode.getEndOffset() + ">");
}
+ private void printTableSchemaMap(Map<String, TableSchema> tableSchemaMap) {
+ if (tableSchemaMap == null || tableSchemaMap.isEmpty()) {
+ return;
+ }
+ printlnBoth(pw, String.format("%20s", "") + "|\t[TableSchemaMap]");
+ for (Entry<String, TableSchema> entry : tableSchemaMap.entrySet()) {
+ String tableName = entry.getKey();
+ TableSchema tableSchema = entry.getValue();
+ printlnBoth(pw, String.format("%20s", "") +
String.format("|\t\t[TableSchema] " + tableName));
Review Comment:
The string concatenation pattern is inconsistent. The code uses
String.format with a concatenation operator (+) when it could be simpler.
Consider using either a single String.format call with proper format
specifiers, or simplify to: String.format("%20s|\t\t[TableSchema] %s", "",
tableName)
```suggestion
printlnBoth(pw, String.format("%20s|\t\t[TableSchema] %s", "",
tableName));
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]