zjw1111 commented on code in PR #255:
URL: https://github.com/apache/paimon-cpp/pull/255#discussion_r3878422770


##########
src/paimon/core/global_index/indexed_split_test.cpp:
##########
@@ -155,6 +157,25 @@ TEST(IndexedSplitTest, TestIndexedSplitWithScore) {
         << roundtrip_indexed_split->ToString();
 }
 
+TEST(IndexedSplitTest, TestSerializeCanonicalizesNaNScore) {
+    auto pool = GetDefaultPool();
+    DataSplitImpl::Builder builder(
+        /*partition=*/BinaryRow::EmptyRow(),
+        /*bucket=*/0, /*bucket_path=*/"bucket-0",
+        /*data_files=*/{});
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<Split> data_split, builder.Build());

Review Comment:
   Updated in 3c39a1ef to use `std::shared_ptr<DataSplitImpl>` directly, 
removing the unnecessary `dynamic_pointer_cast`.



##########
src/paimon/core/global_index/indexed_split_test.cpp:
##########
@@ -155,6 +157,25 @@ TEST(IndexedSplitTest, TestIndexedSplitWithScore) {
         << roundtrip_indexed_split->ToString();
 }
 
+TEST(IndexedSplitTest, TestSerializeCanonicalizesNaNScore) {
+    auto pool = GetDefaultPool();
+    DataSplitImpl::Builder builder(
+        /*partition=*/BinaryRow::EmptyRow(),
+        /*bucket=*/0, /*bucket_path=*/"bucket-0",
+        /*data_files=*/{});
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<Split> data_split, builder.Build());
+
+    const float payload_nan = FloatingPointFromBits<float>(0xffc12345U);
+    auto indexed_split = std::make_shared<IndexedSplitImpl>(
+        std::dynamic_pointer_cast<DataSplitImpl>(data_split), 
std::vector<Range>{Range(0, 0)},
+        std::vector<float>{payload_nan});
+
+    ASSERT_OK_AND_ASSIGN(std::string serialized, 
Split::Serialize(indexed_split, pool));
+    ASSERT_GE(serialized.size(), sizeof(float));
+    ASSERT_EQ(serialized.substr(serialized.size() - sizeof(float)),
+              std::string("\x7f\xc0\x00\x00", sizeof(float)));

Review Comment:
   Updated in 3c39a1ef. The test now compares the complete serialization of a 
payload NaN against the canonical NaN serialization, then deserializes the 
result and verifies the score. I applied the same full-result comparison to 
`GlobalIndexResultTest` as well.



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