andrewthauer opened a new pull request #1102:
URL: https://github.com/apache/avro/pull/1102


   ### Jira
   
   - [ ] My PR addresses the following [Avro 
Jira](https://issues.apache.org/jira/browse/AVRO-3054) issues and references 
them in the PR title. For example, "AVRO-1234: My Avro PR"
     - https://issues.apache.org/jira/browse/AVRO-3054
     - In case you are adding a dependency, check if the license complies with 
the [ASF 3rd Party License 
Policy](https://www.apache.org/legal/resolved.html#category-x).
   
   ### Tests
   
   - [  ] My PR adds the following unit tests __OR__ does not need testing for 
this extremely good reason:
   
   ### Commits
   
   - [  ] My commits all reference Jira issues in their subject lines. In 
addition, my commits follow the guidelines from "[How to write a good git 
commit message](https://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Documentation
   
   - [  ] In case of new functionality, my PR adds documentation that describes 
how to use it.
     - All the public functions and the classes in the PR contain Javadoc that 
explain what it does
   
   ### Credit
   
   This upstream PR was originally created by @ziggythehamster & @johvet as 
part of #918.
   
   ### Supercedes PRs (from $918)
   
   The following PRs are currently open and implement an incorrect version of 
this feature, and should be closed:
   
   - #829
   - #840
   
   Both PRs shove a string like "1.234" into the bytes, rather than encoding 
them according to the specification. Both PRs do not validate inputs nor 
introduce infrastructure to do that.
   
   ### Notes from #918
   
   > The Avro specification is imprecise about how decimals are to be 
implemented, which required us to dig into the source code of Avro for Java as 
well as dig into Java's BigDecimal and BigInteger to make sure we were doing 
the same thing. Perhaps the specification could include a Java one-liner that 
implements the encoder/decoder? Here's a Scala one-liner that we used to test 
our implementation:
   
   ```java
   val encoded = new 
java.math.BigDecimal("3.4562").setScale(6).unscaledValue().toByteArray()
   val decoded = new java.math.BigDecimal(new java.math.BigInteger(encoded), 6)
   
   encoded.map("%02x".format(_)).mkString(" ") // 34 bc c8: String
   decoded // 3.456200: java.math.BigDecimal
   ```
   
   > - We tested this in Ruby 2.3, 2.4, 2.5, 2.6, and 2.7. This is the reason 
for the <= check for retained objects, as some Ruby versions retain objects 
where others don't. We think this is either a bug in memory_profiler or a bug 
in Ruby itself.
   > - Your build system depends on the echoe gem, but echoe is not compatible 
with RubyGems > 2.7. RubyGems 3.x has been out since 2018, and RubyGems 2.7 
barely works in newer versions of Ruby. Consider upgrading this.
   > - This PR is against master, but 1.9 is the current stable version. This 
branch is a version based on 1.9 with #761 incorporated (#761 was the PR that 
incompletely implemented AVRO-2677).
   > - There's a gem published to GitHub packages as well, if you're like us 
and need a version with decimal support before this hits an official channel.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to