def encodeSequenceExample()

in spark/spark-tensorflow-connector/src/main/scala/org/tensorflow/spark/datasources/tfrecords/serde/DefaultTfRecordRowEncoder.scala [84:108]


  def encodeSequenceExample(row: Row): SequenceExample = {
    val features = Features.newBuilder()
    val featureLists = FeatureLists.newBuilder()
    val sequenceExample = SequenceExample.newBuilder()

    row.schema.zipWithIndex.foreach {
      case (structField, index) if row.get(index) == null => {
        if (!structField.nullable) {
          throw new NullPointerException(s"${structField.name}  does not allow null values")
        }
      }
      case (structField, index) => structField.dataType match {
        case ArrayType(ArrayType(_, _), _) =>
          val featureList = encodeFeatureList(row, structField, index)
          featureLists.putFeatureList(structField.name, featureList)
        case _ =>
          val feature = encodeFeature(row, structField, index)
          features.putFeature(structField.name, feature)
      }
    }

    sequenceExample.setContext(features.build())
    sequenceExample.setFeatureLists(featureLists.build())
    sequenceExample.build()
  }