Lei Rui created IOTDB-263:
-----------------------------
Summary: Refactor IoTDBQueryResultSet of JDBC
Key: IOTDB-263
URL: https://issues.apache.org/jira/browse/IOTDB-263
Project: Apache IoTDB
Issue Type: Improvement
Reporter: Lei Rui
Proposed by Tian Jiang, there are at least two points that can be improved of
IoTDBQueryResultSet.
The first point: Batch structure may be preferable to List<RowRecord> (as shown
in the following code). The data structure of List<RowRecord> looks bloated
(chinese: 臃肿的).
{code:java}
// as in nextWithoutConstraints method
TSQueryDataSet tsQueryDataSet = resp.getQueryDataSet();
List<RowRecord> records = Utils.convertRowRecords(tsQueryDataSet);
recordItr = records.iterator();
{code}
The batch structure may incur compact memory layout and possible beneficial
batch processing strategy. So I think this point is worth trying, especially
when we have already developed a new TSQueryDataSet with batch-like structure
(pr#455).
The second point: Some inefficient interface realizations. For example, as
shown in the following code, the getDouble method first calls the getString
method and then parses the string to get the double value. However, the double
value in the field could otherwise be directly got (if the data type of this
field is double).
{code:java}
public double getDouble(String columnName) throws SQLException {
return Double.parseDouble(getValueByName(columnName));
}
private String getValueByName(String columnName) throws SQLException {
checkRecord();
if (columnName.equals(TIMESTAMP_STR)) {
return String.valueOf(record.getTimestamp());
}
int tmp = columnInfoMap.get(columnName);
int i = 0;
for (Field field : record.getFields()) {
i++;
if (i == tmp - 1) {
return field.isNull() ? null : field.getStringValue();
}
}
return null;
}
{code}
This point is indeed a true problem. Although right now only the getString
method is actually in use, we do need to improve the other getXXX methods
(e.g., getDouble, getInt, getFloat) and inform our users of these interfaces.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)