amoeba commented on code in PR #40392: URL: https://github.com/apache/arrow/pull/40392#discussion_r1602387512
########## cpp/src/arrow/ipc/CMakeLists.txt: ########## @@ -41,6 +41,7 @@ add_arrow_test(feather_test) add_arrow_ipc_test(json_simple_test) add_arrow_ipc_test(read_write_test EXTRA_LINK_LIBS arrow::flatbuffers) add_arrow_ipc_test(tensor_test) +add_arrow_ipc_test(message_internal_test EXTRA_LINK_LIBS arrow::flatbuffers) Review Comment: Good catch. Done in 1afe6bba4f16d10018720816c0d6bb4b6aebbce5. ########## cpp/src/arrow/ipc/message_internal_test.cc: ########## @@ -0,0 +1,80 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include <flatbuffers/flatbuffers.h> +#include <gtest/gtest.h> +#include <memory> + +#include "arrow/buffer.h" +#include "arrow/ipc/dictionary.h" +#include "arrow/ipc/metadata_internal.h" +#include "arrow/ipc/options.h" +#include "arrow/testing/gtest_util.h" +#include "arrow/util/key_value_metadata.h" + +namespace arrow::ipc::internal { + +using FBB = flatbuffers::FlatBufferBuilder; + +// GH-40361: Test that Flatbuffer serialization matches a known output +// byte-for-byte. +// +// Our Flatbuffers code should not depend on argument evaluation order as it's +// undefined (https://en.cppreference.com/w/cpp/language/eval_order) and may +// lead to unnecessary platform- or toolchain-specific differences in +// serialization. +TEST(TestMessageInternal, TestByteIdentical) { + FBB fbb; + flatbuffers::Offset<org::apache::arrow::flatbuf::Schema> fb_schema; + DictionaryFieldMapper mapper; + + // Create a simple Schema with just one metadata KVP + auto f0 = field("f0", int64()); + auto f1 = field("f1", int64()); + std::vector<std::shared_ptr<Field>> fields = {f0, f1}; + std::shared_ptr<KeyValueMetadata> metadata = + KeyValueMetadata::Make({"key_1", "key_2"}, {"key_1_value", "key_2_value"}); + auto schema = ::arrow::schema({f0}, metadata); + + // Serialize the Schema to a Buffer + std::shared_ptr<Buffer> outBuffer; Review Comment: Thanks, fixed in 91ae07a743c0614f8b7a8fbe8187cc372c29eb7c. -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org