From b8a51b8a180fafa720d20e9b2dafe1afe44a59ef Mon Sep 17 00:00:00 2001 From: Kousuke Saruta Date: Thu, 24 Aug 2023 00:51:12 +0900 Subject: [PATCH] AVRO-3841: [Spec] Align the specification of the way to encode NaN to the actual implementations --- doc/content/en/docs/++version++/Specification/_index.md | 4 ++-- .../src/apache/main/IO/BinaryDecoder.netstandard2.0.cs | 4 ++-- .../src/apache/main/IO/BinaryDecoder.notnetstandard2.0.cs | 4 ++-- lang/csharp/src/apache/main/IO/BinaryEncoder.cs | 4 ++-- lang/py/avro/io.py | 8 ++++---- lang/ruby/lib/avro/io.rb | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/content/en/docs/++version++/Specification/_index.md b/doc/content/en/docs/++version++/Specification/_index.md index 30494e073f2..7a0c303e333 100755 --- a/doc/content/en/docs/++version++/Specification/_index.md +++ b/doc/content/en/docs/++version++/Specification/_index.md @@ -298,8 +298,8 @@ Primitive types are encoded in binary as follows: |64 | 80 01| |...|...| -* a _float_ is written as 4 bytes. The float is converted into a 32-bit integer using a method equivalent to Java's [floatToIntBits](https://docs.oracle.com/javase/8/docs/api/java/lang/Float.html#floatToIntBits-float-) and then encoded in little-endian format. -* a _double_ is written as 8 bytes. The double is converted into a 64-bit integer using a method equivalent to Java's [doubleToLongBits](https://docs.oracle.com/javase/8/docs/api/java/lang/Double.html#doubleToLongBits-double-) and then encoded in little-endian format. +* a _float_ is written as 4 bytes. The float is converted into a 32-bit integer using a method equivalent to Java's [floatToRawIntBits](https://docs.oracle.com/javase/8/docs/api/java/lang/Float.html#floatToRawIntBits-float-) and then encoded in little-endian format. +* a _double_ is written as 8 bytes. The double is converted into a 64-bit integer using a method equivalent to Java's [doubleToRawLongBits](https://docs.oracle.com/javase/8/docs/api/java/lang/Double.html#doubleToRawLongBits-double-) and then encoded in little-endian format. * _bytes_ are encoded as a long followed by that many bytes of data. * a _string_ is encoded as a long followed by that many bytes of UTF-8 encoded character data. For example, the three-character string "foo" would be encoded as the long value 3 (encoded as hex 06) followed by the UTF-8 encoding of 'f', 'o', and 'o' (the hex bytes 66 6f 6f): diff --git a/lang/csharp/src/apache/main/IO/BinaryDecoder.netstandard2.0.cs b/lang/csharp/src/apache/main/IO/BinaryDecoder.netstandard2.0.cs index 8c6cb7e5c09..a37d6fa6c84 100644 --- a/lang/csharp/src/apache/main/IO/BinaryDecoder.netstandard2.0.cs +++ b/lang/csharp/src/apache/main/IO/BinaryDecoder.netstandard2.0.cs @@ -34,7 +34,7 @@ public partial class BinaryDecoder /// /// A float is written as 4 bytes. /// The float is converted into a 32-bit integer using a method equivalent to - /// Java's floatToIntBits and then encoded in little-endian format. + /// Java's floatToRawIntBits and then encoded in little-endian format. /// /// public float ReadFloat() @@ -56,7 +56,7 @@ public float ReadFloat() /// /// A double is written as 8 bytes. /// The double is converted into a 64-bit integer using a method equivalent to - /// Java's doubleToLongBits and then encoded in little-endian format. + /// Java's doubleToRawLongBits and then encoded in little-endian format. /// /// A double value. public double ReadDouble() diff --git a/lang/csharp/src/apache/main/IO/BinaryDecoder.notnetstandard2.0.cs b/lang/csharp/src/apache/main/IO/BinaryDecoder.notnetstandard2.0.cs index a3bd2174e1d..c4a0dfaaf31 100644 --- a/lang/csharp/src/apache/main/IO/BinaryDecoder.notnetstandard2.0.cs +++ b/lang/csharp/src/apache/main/IO/BinaryDecoder.notnetstandard2.0.cs @@ -35,7 +35,7 @@ public partial class BinaryDecoder /// /// A float is written as 4 bytes. /// The float is converted into a 32-bit integer using a method equivalent to - /// Java's floatToIntBits and then encoded in little-endian format. + /// Java's floatToRawIntBits and then encoded in little-endian format. /// /// public float ReadFloat() @@ -49,7 +49,7 @@ public float ReadFloat() /// /// A double is written as 8 bytes. /// The double is converted into a 64-bit integer using a method equivalent to - /// Java's doubleToLongBits and then encoded in little-endian format. + /// Java's doubleToRawLongBits and then encoded in little-endian format. /// /// A double value. public double ReadDouble() diff --git a/lang/csharp/src/apache/main/IO/BinaryEncoder.cs b/lang/csharp/src/apache/main/IO/BinaryEncoder.cs index 30100bf31d6..469f209fbb1 100644 --- a/lang/csharp/src/apache/main/IO/BinaryEncoder.cs +++ b/lang/csharp/src/apache/main/IO/BinaryEncoder.cs @@ -87,7 +87,7 @@ public void WriteLong(long value) /// /// A float is written as 4 bytes. /// The float is converted into a 32-bit integer using a method equivalent to - /// Java's floatToIntBits and then encoded in little-endian format. + /// Java's floatToRawIntBits and then encoded in little-endian format. /// /// public void WriteFloat(float value) @@ -99,7 +99,7 @@ public void WriteFloat(float value) /// ///A double is written as 8 bytes. ///The double is converted into a 64-bit integer using a method equivalent to - ///Java's doubleToLongBits and then encoded in little-endian format. + ///Java's doubleToRawLongBits and then encoded in little-endian format. /// /// public void WriteDouble(double value) diff --git a/lang/py/avro/io.py b/lang/py/avro/io.py index 5e3ffa6c537..c43002a027e 100644 --- a/lang/py/avro/io.py +++ b/lang/py/avro/io.py @@ -256,7 +256,7 @@ def read_float(self) -> float: """ A float is written as 4 bytes. The float is converted into a 32-bit integer using a method equivalent to - Java's floatToIntBits and then encoded in little-endian format. + Java's floatToRawIntBits and then encoded in little-endian format. """ return float(STRUCT_FLOAT.unpack(self.read(4))[0]) @@ -264,7 +264,7 @@ def read_double(self) -> float: """ A double is written as 8 bytes. The double is converted into a 64-bit integer using a method equivalent to - Java's doubleToLongBits and then encoded in little-endian format. + Java's doubleToRawLongBits and then encoded in little-endian format. """ return float(STRUCT_DOUBLE.unpack(self.read(8))[0]) @@ -453,7 +453,7 @@ def write_float(self, datum: float) -> None: """ A float is written as 4 bytes. The float is converted into a 32-bit integer using a method equivalent to - Java's floatToIntBits and then encoded in little-endian format. + Java's floatToRawIntBits and then encoded in little-endian format. """ self.write(STRUCT_FLOAT.pack(datum)) @@ -461,7 +461,7 @@ def write_double(self, datum: float) -> None: """ A double is written as 8 bytes. The double is converted into a 64-bit integer using a method equivalent to - Java's doubleToLongBits and then encoded in little-endian format. + Java's doubleToRawLongBits and then encoded in little-endian format. """ self.write(STRUCT_DOUBLE.pack(datum)) diff --git a/lang/ruby/lib/avro/io.rb b/lang/ruby/lib/avro/io.rb index 0d2f3135850..091b3544672 100644 --- a/lang/ruby/lib/avro/io.rb +++ b/lang/ruby/lib/avro/io.rb @@ -75,7 +75,7 @@ def read_long def read_float # A float is written as 4 bytes. # The float is converted into a 32-bit integer using a method - # equivalent to Java's floatToIntBits and then encoded in + # equivalent to Java's floatToRawIntBits and then encoded in # little-endian format. read_and_unpack(4, 'e') end @@ -83,7 +83,7 @@ def read_float def read_double # A double is written as 8 bytes. # The double is converted into a 64-bit integer using a method - # equivalent to Java's doubleToLongBits and then encoded in + # equivalent to Java's doubleToRawLongBits and then encoded in # little-endian format. read_and_unpack(8, 'E') end @@ -203,7 +203,7 @@ def write_long(n) # A float is written as 4 bytes. # The float is converted into a 32-bit integer using a method - # equivalent to Java's floatToIntBits and then encoded in + # equivalent to Java's floatToRawIntBits and then encoded in # little-endian format. def write_float(datum) @writer.write([datum].pack('e')) @@ -211,7 +211,7 @@ def write_float(datum) # A double is written as 8 bytes. # The double is converted into a 64-bit integer using a method - # equivalent to Java's doubleToLongBits and then encoded in + # equivalent to Java's doubleToRawLongBits and then encoded in # little-endian format. def write_double(datum) @writer.write([datum].pack('E'))