Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-39575

ByteBuffer forget to rewind after get in AvroDeserializer

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.3.0
    • 3.2.2, 3.3.1, 3.4.0
    • Spark Core
    • None

    Description

      case (BYTES, BinaryType) => (updater, ordinal, value) =>
        val bytes = value match {
          case b: ByteBuffer =>
            val bytes = new Array[Byte](b.remaining)
            b.get(bytes)
            // Do not forget to reset the position
            b.rewind()
            bytes
          case b: Array[Byte] => b
          case other => throw new RuntimeException(s"$other is not a valid avro binary.")
        }
        updater.set(ordinal, bytes) 

      After Avro data is converted to InternalRow, there will be redundant position in ByteBuffer type caused by ByteBuffer#get

      Attachments

        Activity

          People

            wzx Frank Wong
            wzx Frank Wong
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: