kou commented on code in PR #43882:
URL: https://github.com/apache/arrow/pull/43882#discussion_r1735706476


##########
ruby/red-arrow/lib/arrow/decimal128-array.rb:
##########
@@ -18,7 +18,9 @@
 module Arrow
   class Decimal128Array
     def get_value(i)
-      BigDecimal(format_value(i))
+      string = format_value(i)
+      string.sub!(".E", ".0E") if string.include?(".E")

Review Comment:
   Hmm. Could you provide a code for your suggested approach?
   
   FYI: Here is a benchmark script:
   
   ```ruby
   #!/usr/bin/env ruby
   
   require "benchmark"
   
   n = 100000
   Benchmark.bmbm do |x|
     x.report("0.0E - nothing") do
       n.times do
         string = "0.0E"
         string
       end
     end
   
     x.report("0.E - nothing") do
       n.times do
         string = "0.E"
         string
       end
     end
   
     x.report("0.0E - include?") do
       n.times do
         string = "0.0E"
         string.sub!(".E", ".0E") if string.include?(".E")
         string
       end
     end
   
     x.report("0.E - include?") do
       n.times do
         string = "0.E"
         string.sub!(".E", ".0E") if string.include?(".E")
         string
       end
     end
   end
   ```
   
   ```text
   Rehearsal ---------------------------------------------------
   0.0E - nothing    0.007074   0.000452   0.007526 (  0.007524)
   0.E - nothing     0.006988   0.000000   0.006988 (  0.006988)
   0.0E - include?   0.015868   0.000000   0.015868 (  0.015869)
   0.E - include?    0.066138   0.000000   0.066138 (  0.066140)
   ------------------------------------------ total: 0.096520sec
   
                         user     system      total        real
   0.0E - nothing    0.006819   0.000000   0.006819 (  0.006819)
   0.E - nothing     0.006878   0.000000   0.006878 (  0.006878)
   0.0E - include?   0.015696   0.000000   0.015696 (  0.015697)
   0.E - include?    0.066329   0.000000   0.066329 (  0.066330)
   ```



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

Reply via email to