| 260 | } |
| 261 | |
| 262 | void AssertBatchWriteReadEqual( |
| 263 | const std::vector<std::shared_ptr<RecordBatch>>& input_batches, |
| 264 | const std::shared_ptr<Table>& expected_output_table, |
| 265 | const int64_t max_size = kDefaultSmallMemStreamSize) { |
| 266 | EXPECT_OK_AND_ASSIGN(auto buffer_output_stream, |
| 267 | io::BufferOutputStream::Create(max_size)); |
| 268 | auto write_options = adapters::orc::WriteOptions(); |
| 269 | #ifdef ARROW_WITH_SNAPPY |
| 270 | write_options.compression = Compression::SNAPPY; |
| 271 | #else |
| 272 | write_options.compression = Compression::UNCOMPRESSED; |
| 273 | #endif |
| 274 | write_options.file_version = adapters::orc::FileVersion(0, 11); |
| 275 | write_options.compression_block_size = 64 * 1024; |
| 276 | write_options.row_index_stride = 5000; |
| 277 | EXPECT_OK_AND_ASSIGN(auto writer, adapters::orc::ORCFileWriter::Open( |
| 278 | buffer_output_stream.get(), write_options)); |
| 279 | for (auto& input_batch : input_batches) { |
| 280 | ARROW_EXPECT_OK(writer->Write(*input_batch)); |
| 281 | } |
| 282 | ARROW_EXPECT_OK(writer->Close()); |
| 283 | EXPECT_OK_AND_ASSIGN(auto buffer, buffer_output_stream->Finish()); |
| 284 | std::shared_ptr<io::RandomAccessFile> in_stream(new io::BufferReader(buffer)); |
| 285 | EXPECT_OK_AND_ASSIGN( |
| 286 | auto reader, adapters::orc::ORCFileReader::Open(in_stream, default_memory_pool())); |
| 287 | ASSERT_EQ(reader->GetFileVersion(), write_options.file_version); |
| 288 | ASSERT_EQ(reader->GetCompression(), write_options.compression); |
| 289 | ASSERT_EQ(reader->GetCompressionSize(), write_options.compression_block_size); |
| 290 | ASSERT_EQ(reader->GetRowIndexStride(), write_options.row_index_stride); |
| 291 | EXPECT_OK_AND_ASSIGN(auto actual_output_table, reader->Read()); |
| 292 | AssertTablesEqual(*expected_output_table, *actual_output_table, false, false); |
| 293 | } |
| 294 | |
| 295 | void AssertTableWriteReadEqual(const std::shared_ptr<Table>& input_table, |
| 296 | const std::shared_ptr<Table>& expected_output_table, |
no test coverage detected