You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently, when a byte-array or string is encoded as fixed, it tries to match the fixed size by padding with 0s at the beginning (for ByteArray and ByteBuffer) or at the end (for String), which ends up to a modified content.
This should be done on the user side, depending on its needs.
Describe the solution you'd like
Totally remove the automatic-padding feature, and fail when the given string/ByteArray/ByteBuffer is not of the same size as the expected fixed schema.
To still be able to pad with 0s, the user has to provide its own AvroSerializer, providing explicitly the fixed schema and doing its padding logic inside serializeAvro and deserializeAvro. Here is an example:
publicobject ZeroPaddedByteArraySerializer: AvroSerializer<ByteArray>("zero-padded-byte-array") {
overridefungetSchema(context:SchemaSupplierContext): Schema {
return context.fixed?.createSchema() ?:throwSerializationException("ZeroPaddedByteArraySerializer requires @AvroFixed annotation")
}
overridefunserializeAvro(encoder:AvroEncoder, value:ByteArray) {
// pad with 0s to match 15 bytes
encoder.encodeFixed(value.zeroPadded(15, endPadded =true))
}
overridefundeserializeAvro(decoder:AvroDecoder): ByteArray {
TODO("Not yet implemented")
}
}
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Currently, when a byte-array or string is encoded as fixed, it tries to match the fixed size by padding with 0s at the beginning (for ByteArray and ByteBuffer) or at the end (for String), which ends up to a modified content.
This should be done on the user side, depending on its needs.
Describe the solution you'd like
Totally remove the automatic-padding feature, and fail when the given string/ByteArray/ByteBuffer is not of the same size as the expected fixed schema.
To still be able to pad with 0s, the user has to provide its own
AvroSerializer
, providing explicitly the fixed schema and doing its padding logic insideserializeAvro
anddeserializeAvro
. Here is an example:The text was updated successfully, but these errors were encountered: