in connectors/spark-tsfile/src/main/scala/org/apache/iotdb/spark/tsfile/NarrowConverter.scala [569:595]
def toTsRecord(row: InternalRow, dataSchema: StructType): TSRecord = {
val time = row.getLong(0)
val res = new TSRecord(row.getString(1), time)
var i = 2
dataSchema.fields.filter(f => {
(!QueryConstant.RESERVED_TIME.equals(f.name)).&&(!DEVICE_NAME.equals(f.name))
}).foreach(f => {
val dataType = getTsDataType(f.dataType)
if (!row.isNullAt(i)) {
val value = f.dataType match {
case BooleanType => row.getBoolean(i)
case IntegerType => row.getInt(i)
case LongType => row.getLong(i)
case FloatType => row.getFloat(i)
case DoubleType => row.getDouble(i)
case StringType => row.getString(i)
case other => throw new UnsupportedOperationException(s"Unsupported type $other")
}
val dataPoint = DataPoint.getDataPoint(dataType, f.name, value.toString)
res.addTuple(dataPoint)
}
i += 1
})
res
}