2525import org .apache .iotdb .commons .schema .table .column .AttributeColumnSchema ;
2626import org .apache .iotdb .commons .schema .table .column .FieldColumnSchema ;
2727import org .apache .iotdb .commons .schema .table .column .TagColumnSchema ;
28+ import org .apache .iotdb .commons .schema .table .column .TimeColumnSchema ;
2829import org .apache .iotdb .commons .schema .table .column .TsTableColumnCategory ;
2930import org .apache .iotdb .commons .schema .table .column .TsTableColumnSchema ;
3031import org .apache .iotdb .commons .schema .table .column .TsTableColumnSchemaUtil ;
@@ -93,6 +94,9 @@ public class TsTable {
9394 private transient int tagNums = 0 ;
9495 private transient int fieldNum = 0 ;
9596
97+ // Initiated during creation and never changed the reference
98+ private transient TsTableColumnSchema timeColumnSchema ;
99+
96100 public TsTable (final String tableName ) {
97101 this .tableName = tableName ;
98102 }
@@ -101,7 +105,12 @@ public TsTable(final String tableName) {
101105 public TsTable (String tableName , ImmutableList <TsTableColumnSchema > columnSchemas ) {
102106 this .tableName = tableName ;
103107 columnSchemas .forEach (
104- columnSchema -> columnSchemaMap .put (columnSchema .getColumnName (), columnSchema ));
108+ columnSchema -> {
109+ columnSchemaMap .put (columnSchema .getColumnName (), columnSchema );
110+ if (columnSchema instanceof TimeColumnSchema ) {
111+ timeColumnSchema = columnSchema ;
112+ }
113+ });
105114 }
106115
107116 public TsTable (TsTable origin ) {
@@ -146,10 +155,10 @@ public TsTableColumnSchema getColumnSchema(final String columnName) {
146155 public TsTableColumnSchema getTimeColumnSchema () {
147156 if (Objects .isNull (timeColumnSchema )) {
148157 timeColumnSchema =
149- columnSchemaMap .values ().stream ()
150- .filter (column -> column instanceof TimeColumnSchema )
151- .findFirst ()
152- .orElse (null );
158+ columnSchemaMap .values ().stream ()
159+ .filter (column -> column instanceof TimeColumnSchema )
160+ .findFirst ()
161+ .orElse (null );
153162 }
154163 return timeColumnSchema ;
155164 }
0 commit comments