This is an automated email from the ASF dual-hosted git repository. qiaojialin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit 023d9a7c851dd80dec593d34ef4cfd5ae2172631 Author: Wei Zhong <[email protected]> AuthorDate: Wed Apr 29 20:29:25 2020 +0800 address comments --- flink-tsfile-connector/README.md | 8 ++--- .../iotdb/flink/tsfile/RowTSRecordConverter.java | 36 +++++++++++++--------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/flink-tsfile-connector/README.md b/flink-tsfile-connector/README.md index 9e576ba..b7a1e74 100644 --- a/flink-tsfile-connector/README.md +++ b/flink-tsfile-connector/README.md @@ -108,11 +108,11 @@ String[] filedNames = { TypeInformation[] typeInformations = new TypeInformation[] { Types.LONG, Types.FLOAT, - Types.INT, - Types.INT, + Types.LONG, + Types.LONG, Types.FLOAT, - Types.INT, - Types.INT + Types.LONG, + Types.LONG }; RowTypeInfo rowTypeInfo = new RowTypeInfo(typeInformations, filedNames); Schema schema = new Schema(); diff --git a/flink-tsfile-connector/src/main/java/org/apache/iotdb/flink/tsfile/RowTSRecordConverter.java b/flink-tsfile-connector/src/main/java/org/apache/iotdb/flink/tsfile/RowTSRecordConverter.java index 640b9c6..cf698af 100644 --- a/flink-tsfile-connector/src/main/java/org/apache/iotdb/flink/tsfile/RowTSRecordConverter.java +++ b/flink-tsfile-connector/src/main/java/org/apache/iotdb/flink/tsfile/RowTSRecordConverter.java @@ -120,21 +120,27 @@ public class RowTSRecordConverter implements TSRecordConverter<Row> { DataPoint templateDataPoint = templateRecord.dataPointList.get(dataPointIndexMapping[i]); Object o = input.getField(i); if (o != null) { - Class typeClass = o.getClass(); - if (typeClass == Boolean.class || typeClass == boolean.class) { - templateDataPoint.setBoolean((Boolean) o); - } else if (typeClass == Integer.class || typeClass == int.class) { - templateDataPoint.setInteger((Integer) o); - } else if (typeClass == Long.class || typeClass == long.class) { - templateDataPoint.setLong((Long) o); - } else if (typeClass == Float.class || typeClass == float.class) { - templateDataPoint.setFloat((Float) o); - } else if (typeClass == Double.class || typeClass == double.class) { - templateDataPoint.setDouble((Double) o); - } else if (typeClass == String.class) { - templateDataPoint.setString(Binary.valueOf((String) o)); - } else { - throw new UnSupportedDataTypeException(typeClass.toString()); + switch (templateDataPoint.getType()) { + case BOOLEAN: + templateDataPoint.setBoolean((Boolean) o); + break; + case INT32: + templateDataPoint.setInteger((Integer) o); + break; + case INT64: + templateDataPoint.setLong((Long) o); + break; + case FLOAT: + templateDataPoint.setFloat((Float) o); + break; + case DOUBLE: + templateDataPoint.setDouble((Double) o); + break; + case TEXT: + templateDataPoint.setString(Binary.valueOf((String) o)); + break; + default: + templateDataPoint.setString(Binary.valueOf(o.toString())); } reuse[tsRecordIndexMapping[i]].addTuple(templateDataPoint); }
