in spark/spark-tensorflow-connector/src/main/scala/org/tensorflow/spark/datasources/tfrecords/serde/DefaultTfRecordRowDecoder.scala [60:72]
def decodeExample(example: Example, schema: StructType): Row = {
val row = Array.fill[Any](schema.length)(null)
val featureMap = example.getFeatures.getFeatureMap.asScala
schema.fields.zipWithIndex.foreach {
case (field, index) =>
val feature = featureMap.get(field.name)
feature match {
case Some(f) => row(index) = decodeFeature(f, schema, index)
case None => if (!field.nullable) throw new NullPointerException(s"Field ${field.name} does not allow null values")
}
}
Row.fromSeq(row)
}