jt2594838 commented on a change in pull request #258: [IOTDB-143]Development of merge URL: https://github.com/apache/incubator-iotdb/pull/258#discussion_r314577395
########## File path: server/src/main/java/org/apache/iotdb/db/utils/TimeValuePairUtils.java ########## @@ -64,17 +74,93 @@ public static TimeValuePair getCurrentTimeValuePair(AggreResultData data) { case INT32: return new TimeValuePair(data.getTimestamp(), new TsPrimitiveType.TsInt(data.getIntRet())); case INT64: - return new TimeValuePair(data.getTimestamp(), new TsPrimitiveType.TsLong(data.getLongRet())); + return new TimeValuePair(data.getTimestamp(), + new TsPrimitiveType.TsLong(data.getLongRet())); case FLOAT: - return new TimeValuePair(data.getTimestamp(), new TsPrimitiveType.TsFloat(data.getFloatRet())); + return new TimeValuePair(data.getTimestamp(), + new TsPrimitiveType.TsFloat(data.getFloatRet())); case DOUBLE: - return new TimeValuePair(data.getTimestamp(), new TsPrimitiveType.TsDouble(data.getDoubleRet())); + return new TimeValuePair(data.getTimestamp(), + new TsPrimitiveType.TsDouble(data.getDoubleRet())); case TEXT: - return new TimeValuePair(data.getTimestamp(), new TsPrimitiveType.TsBinary(data.getBinaryRet())); + return new TimeValuePair(data.getTimestamp(), + new TsPrimitiveType.TsBinary(data.getBinaryRet())); case BOOLEAN: - return new TimeValuePair(data.getTimestamp(), new TsPrimitiveType.TsBoolean(data.isBooleanRet())); + return new TimeValuePair(data.getTimestamp(), + new TsPrimitiveType.TsBoolean(data.isBooleanRet())); default: throw new UnSupportedDataTypeException(String.valueOf(data.getDataType())); } } -} + + public static void setCurrentTimeValuePair(BatchData data, TimeValuePair current) { + current.setTimestamp(data.currentTime()); + switch (data.getDataType()) { + case INT32: + current.getValue().setInt(data.getInt()); + break; + case INT64: + current.getValue().setLong(data.getLong()); + break; + case FLOAT: + current.getValue().setFloat(data.getFloat()); + break; + case DOUBLE: + current.getValue().setDouble(data.getDouble()); + break; + case TEXT: + current.getValue().setBinary(data.getBinary()); + break; + case BOOLEAN: + current.getValue().setBoolean(data.getBoolean()); + break; + default: + throw new UnSupportedDataTypeException(String.valueOf(data.getDataType())); + } + } + + public static void setTimeValuePair(TimeValuePair from, TimeValuePair to) { + to.setTimestamp(from.getTimestamp()); + switch (from.getValue().getDataType()) { + case INT32: + to.getValue().setInt(from.getValue().getInt()); + break; + case INT64: + to.getValue().setLong(from.getValue().getLong()); + break; + case FLOAT: + to.getValue().setFloat(from.getValue().getFloat()); + break; + case DOUBLE: + to.getValue().setDouble(from.getValue().getDouble()); + break; + case TEXT: + to.getValue().setBinary(from.getValue().getBinary()); + break; + case BOOLEAN: + to.getValue().setBoolean(from.getValue().getBoolean()); + break; + default: + throw new UnSupportedDataTypeException(String.valueOf(from.getValue().getDataType())); + } + } + + public static TimeValuePair getEmptyTimeValuePair(TSDataType dataType) { + switch (dataType) { + case FLOAT: + return new TimeValuePair(0, new TsFloat(0.0f)); Review comment: Where? This is not a method like Collections.emptyMap() at all. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services