tjmac1200 commented on PR #3650: URL: https://github.com/apache/avro/pull/3650#issuecomment-3923958366
@jjatria -- Here's my use case. I generate a Perl data structure, then encode it with Avro::BinaryEncoder (which uses encode_map) to generate its binary equivalent. The top level of my data structure is a Perl hash. I'm attempting to write a unit test that ensures a given input data structure generates an expected binary representation (via md5sum comparison of the binary data). The non-deterministic nature of Perl's keys function prevents me from consistently getting an md5sum match. So, I monkey-patched encode_map in my unit test to sort the map keys. Now my test passes consistently. This pull request was an attempt to roll that change back into the core Avro::BinaryEncoder module on CPAN, so I could then undo my monkey-patch. I suppose I could pivot my approach in the unit test. I can still keep the expected binary result as binary, but instead of using md5sum to compare the expected binary to the binary generated by my test, I could instead decode both the expected result and the generated result, then compare those Perl structures to ensure they match. Other suggestions are welcomed. I completely agree with you that map key sorting is not required by the spec, nor does it say it's illegal. Since sorting the map keys will be slower, I think we can deny this pull request. Not all is lost, though. This entire process was a worthwhile exploration for me. I'll work on undoing my monkey-patch using my proposed test alterations above instead. Thanks of all of your help - @jjatria and @martin-g! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
