未验证 提交 d33dbed0 编写于 作者: B Boris 提交者: GitHub

update client. (#1076)

上级 9e8fe564
......@@ -25,6 +25,7 @@ import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.iotdb.exception.ArgsErrorException;
import org.apache.iotdb.jdbc.IoTDBConnection;
import org.apache.iotdb.jdbc.IoTDBNonAlignQueryResultSet;
import org.apache.iotdb.jdbc.IoTDBQueryResultSet;
import org.apache.iotdb.service.rpc.thrift.ServerProperties;
import org.apache.iotdb.tool.ImportCsv;
......@@ -70,7 +71,7 @@ public abstract class AbstractClient {
static final String MAX_PRINT_ROW_COUNT_ARGS = "maxPRC";
private static final String MAX_PRINT_ROW_COUNT_NAME = "maxPrintRowCount";
static final String RPC_COMPRESS_ARGS = "c";
static final String RPC_COMPRESS_NAME = "rpcCompressed";
private static final String RPC_COMPRESS_NAME = "rpcCompressed";
static final String SET_MAX_DISPLAY_NUM = "set max_display_num";
static final String SET_TIMESTAMP_DISPLAY = "set time_display_type";
static final String SHOW_TIMESTAMP_DISPLAY = "show time_display_type";
......@@ -582,40 +583,74 @@ public abstract class AbstractClient {
*/
private static List<List<String>> cacheResult(ResultSet resultSet, List<Integer> maxSizeList,
int columnCount, ResultSetMetaData resultSetMetaData, ZoneId zoneId) throws SQLException {
boolean printTimestamp = !((IoTDBQueryResultSet) resultSet).isIgnoreTimeStamp();
List<List<String>> lists = new ArrayList<>(columnCount);
for (int i = 1; i <= columnCount; i++) {
List<String> list = new ArrayList<>(maxPrintRowCount + 1);
list.add(resultSetMetaData.getColumnLabel(i));
lists.add(list);
maxSizeList.add(resultSetMetaData.getColumnLabel(i).length());
if( resultSet instanceof IoTDBQueryResultSet) {
for (int i = 1; i <= columnCount; i++) {
List<String> list = new ArrayList<>(maxPrintRowCount + 1);
list.add(resultSetMetaData.getColumnLabel(i));
lists.add(list);
maxSizeList.add(resultSetMetaData.getColumnLabel(i).length());
}
} else {
for (int i = 1; i <= columnCount; i+=2) {
List<String> timeList = new ArrayList<>(maxPrintRowCount + 1);
timeList.add(resultSetMetaData.getColumnLabel(i).substring(0, TIMESTAMP_STR.length()));
lists.add(timeList);
List<String> valueList = new ArrayList<>(maxPrintRowCount + 1);
valueList.add(resultSetMetaData.getColumnLabel(i+1));
lists.add(valueList);
maxSizeList.add(TIMESTAMP_STR.length());
maxSizeList.add(resultSetMetaData.getColumnLabel(i+1).length());
}
}
int j = 0;
if (cursorBeforeFirst) {
isReachEnd = !resultSet.next();
cursorBeforeFirst = false;
}
while (j < maxPrintRowCount && !isReachEnd) {
for (int i = 1; i <= columnCount; i++) {
String tmp;
if (printTimestamp && i == 1) {
tmp = formatDatetime(resultSet.getLong(TIMESTAMP_STR), zoneId);
} else {
tmp = resultSet.getString(i);
}
if (tmp == null) {
tmp = NULL;
if(resultSet instanceof IoTDBQueryResultSet) {
boolean printTimestamp = !((IoTDBQueryResultSet) resultSet).isIgnoreTimeStamp();
while (j < maxPrintRowCount && !isReachEnd) {
for (int i = 1; i <= columnCount; i++) {
String tmp;
if (printTimestamp && i == 1) {
tmp = formatDatetime(resultSet.getLong(TIMESTAMP_STR), zoneId);
} else {
tmp = resultSet.getString(i);
}
if (tmp == null) {
tmp = NULL;
}
lists.get(i - 1).add(tmp);
if (maxSizeList.get(i - 1) < tmp.length()) {
maxSizeList.set(i - 1, tmp.length());
}
}
lists.get(i - 1).add(tmp);
if (maxSizeList.get(i - 1) < tmp.length()) {
maxSizeList.set(i - 1, tmp.length());
j++;
isReachEnd = !resultSet.next();
}
return lists;
} else {
while (j < maxPrintRowCount && !isReachEnd) {
for (int i = 1; i <= columnCount; i++) {
String tmp;
tmp = resultSet.getString(i);
if (tmp == null) {
tmp = NULL;
}
if (i % 2 != 0 && !tmp.equals(NULL)) {
tmp = formatDatetime(Long.parseLong(tmp), zoneId);
}
lists.get(i - 1).add(tmp);
if (maxSizeList.get(i - 1) < tmp.length()) {
maxSizeList.set(i - 1, tmp.length());
}
}
j++;
isReachEnd = !resultSet.next();
}
j++;
isReachEnd = !resultSet.next();
return lists;
}
return lists;
}
private static void output(List<List<String>> lists, List<Integer> maxSizeList) {
......
......@@ -556,7 +556,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
// create and cache dataset
QueryDataSet newDataSet = createQueryDataSet(queryId, plan);
if (plan instanceof QueryPlan && !((QueryPlan) plan).isAlignByTime()) {
if (plan instanceof QueryPlan && !((QueryPlan) plan).isAlignByTime() && newDataSet instanceof NonAlignEngineDataSet) {
TSQueryNonAlignDataSet result = fillRpcNonAlignReturnData(fetchSize, newDataSet, username);
resp.setNonAlignQueryDataSet(result);
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册