AVRO-2907: Fix Ruby single object encoding fingerprint and header (#937)
The bit masking + shifting operation should already result in grabbing
the least significant bytes first for the little endian CRC-64
fingerprint in the header - so traversing the array in reverse order is
unnecessary.
diff --git a/lang/ruby/lib/avro/schema.rb b/lang/ruby/lib/avro/schema.rb
index ed90323..634562f 100644
--- a/lang/ruby/lib/avro/schema.rb
+++ b/lang/ruby/lib/avro/schema.rb
@@ -181,7 +181,7 @@
working = crc_64_avro_fingerprint
bytes = Array.new(8)
8.times do |i|
- bytes[7 - i] = (working & 0xff)
+ bytes[i] = (working & 0xff)
working = working >> 8
end
bytes
diff --git a/lang/ruby/test/test_fingerprints.rb b/lang/ruby/test/test_fingerprints.rb
index 516a9a0..aa0c763 100644
--- a/lang/ruby/test/test_fingerprints.rb
+++ b/lang/ruby/test/test_fingerprints.rb
@@ -50,7 +50,7 @@
{ "type": "int" }
SCHEMA
- assert_equal ["c3", "01", "72", "75", "d5", "1a", "3f", "39", "5c", "8f"].map{|e| e.to_i(16) },
+ assert_equal ["c3", "01", "8f", "5c", "39", "3f", "1a", "D5", "75", "72"].map{|e| e.to_i(16) },
schema.single_object_encoding_header
end
end