From ff357e3200d754ecb17bbb2a9d8ce9781b2fbd62 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Wed, 11 Sep 2024 14:00:53 +0200 Subject: [PATCH] Post rebase changes --- .../arrow/extension/tensor_extension_array_test.cc | 5 +++-- cpp/src/arrow/extension/uuid_test.cc | 2 ++ cpp/src/arrow/extension_type_test.cc | 2 ++ cpp/src/arrow/testing/gtest_util.cc | 14 -------------- cpp/src/arrow/testing/gtest_util.h | 3 --- 5 files changed, 7 insertions(+), 19 deletions(-) diff --git a/cpp/src/arrow/extension/tensor_extension_array_test.cc b/cpp/src/arrow/extension/tensor_extension_array_test.cc index f4044b88f6a8e..6cafa14cb84a9 100644 --- a/cpp/src/arrow/extension/tensor_extension_array_test.cc +++ b/cpp/src/arrow/extension/tensor_extension_array_test.cc @@ -34,6 +34,7 @@ namespace arrow { using FixedShapeTensorType = extension::FixedShapeTensorType; +using arrow::ipc::test::RoundtripBatch; using extension::fixed_shape_tensor; using extension::FixedShapeTensorArray; @@ -781,7 +782,7 @@ TEST_F(TestVariableShapeTensorType, RoudtripBatch) { std::shared_ptr read_batch; auto ext_field = field(/*name=*/"f0", /*type=*/ext_type_); auto batch = RecordBatch::Make(schema({ext_field}), ext_arr_->length(), {ext_arr_}); - RoundtripBatch(batch, &read_batch); + ASSERT_OK(RoundtripBatch(batch, &read_batch)); CompareBatch(*batch, *read_batch, /*compare_metadata=*/true); // Pass extension metadata and storage array, expect getting back extension array @@ -792,7 +793,7 @@ TEST_F(TestVariableShapeTensorType, RoudtripBatch) { ext_field = field(/*name=*/"f0", /*type=*/ext_type_->storage_type(), /*nullable=*/true, /*metadata=*/ext_metadata); auto batch2 = RecordBatch::Make(schema({ext_field}), ext_arr_->length(), {ext_arr_}); - RoundtripBatch(batch2, &read_batch2); + ASSERT_OK(RoundtripBatch(batch2, &read_batch2)); CompareBatch(*batch, *read_batch2, /*compare_metadata=*/true); } diff --git a/cpp/src/arrow/extension/uuid_test.cc b/cpp/src/arrow/extension/uuid_test.cc index e3fff0d49b976..1c1ffb6eb8e15 100644 --- a/cpp/src/arrow/extension/uuid_test.cc +++ b/cpp/src/arrow/extension/uuid_test.cc @@ -29,6 +29,8 @@ namespace arrow { +using arrow::ipc::test::RoundtripBatch; + TEST(TestUuuidExtensionType, ExtensionTypeTest) { auto type = uuid(); ASSERT_EQ(type->id(), Type::EXTENSION); diff --git a/cpp/src/arrow/extension_type_test.cc b/cpp/src/arrow/extension_type_test.cc index e812541f159c0..1f9be21780f2e 100644 --- a/cpp/src/arrow/extension_type_test.cc +++ b/cpp/src/arrow/extension_type_test.cc @@ -40,6 +40,8 @@ #include "arrow/util/key_value_metadata.h" #include "arrow/util/logging.h" +using arrow::ipc::test::RoundtripBatch; + namespace arrow { class Parametric1Array : public ExtensionArray { diff --git a/cpp/src/arrow/testing/gtest_util.cc b/cpp/src/arrow/testing/gtest_util.cc index 97ef2931507c7..07d15826f2c8f 100644 --- a/cpp/src/arrow/testing/gtest_util.cc +++ b/cpp/src/arrow/testing/gtest_util.cc @@ -591,20 +591,6 @@ void ApproxCompareBatch(const RecordBatch& left, const RecordBatch& right, }); } -void RoundtripBatch(const std::shared_ptr& batch, - std::shared_ptr* out) { - ASSERT_OK_AND_ASSIGN(auto out_stream, io::BufferOutputStream::Create()); - ASSERT_OK(ipc::WriteRecordBatchStream({batch}, ipc::IpcWriteOptions::Defaults(), - out_stream.get())); - - ASSERT_OK_AND_ASSIGN(auto complete_ipc_stream, out_stream->Finish()); - - io::BufferReader reader(complete_ipc_stream); - std::shared_ptr batch_reader; - ASSERT_OK_AND_ASSIGN(batch_reader, ipc::RecordBatchStreamReader::Open(&reader)); - ASSERT_OK(batch_reader->ReadNext(out)); -} - std::shared_ptr TweakValidityBit(const std::shared_ptr& array, int64_t index, bool validity) { auto data = array->data()->Copy(); diff --git a/cpp/src/arrow/testing/gtest_util.h b/cpp/src/arrow/testing/gtest_util.h index f482f8bfc2245..90311464c283b 100644 --- a/cpp/src/arrow/testing/gtest_util.h +++ b/cpp/src/arrow/testing/gtest_util.h @@ -309,9 +309,6 @@ ARROW_TESTING_EXPORT void ApproxCompareBatch( const RecordBatch& left, const RecordBatch& right, bool compare_metadata = true, const EqualOptions& options = TestingEqualOptions()); -ARROW_TESTING_EXPORT void RoundtripBatch(const std::shared_ptr& batch, - std::shared_ptr* out); - // Check if the padding of the buffers of the array is zero. // Also cause valgrind warnings if the padding bytes are uninitialized. ARROW_TESTING_EXPORT void AssertZeroPadded(const Array& array);