Yuan Tian created IOTDB-194:
-------------------------------

             Summary: Redundant field 'measurementSchemaList' in Schema.java
                 Key: IOTDB-194
                 URL: https://issues.apache.org/jira/browse/IOTDB-194
             Project: Apache IoTDB
          Issue Type: Improvement
            Reporter: Yuan Tian


There are two fields in Schema.java, 'measurementSchemaMap' and 
'measurementSchemaList'. I don't understand the meaning of the existence of the 
'measurementSchemaList' in Schema.java. If we use the following constructor and 
there are repetitive measurement_id in the list, this will cause the 
inconsistency of the above two fields.
{code:java}
private Map<String, MeasurementSchema> measurementSchemaMap;
private List<MeasurementSchema> measurementSchemaList;
public Schema(List<MeasurementSchema> measurements) {
    this();
    this.registerMeasurements(measurements);
}
public void registerMeasurements(List<MeasurementSchema> measurements) {
    measurements.forEach((md) -> registerMeasurement(md));
}
public void registerMeasurement(MeasurementSchema descriptor) {
    this.measurementSchemaMap.put(descriptor.getMeasurementId(), descriptor);
    this.measurementSchemaList.add(descriptor);
}
{code}

If the purpose of 'measurementSchemaList' is to maintain the insertion order of 
the measurements, why not use LinkedHashMap, then the order of map.values() is 
certain.

 

 



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to