| 298 | |
| 299 | template <typename DType, typename RowGroupReader, typename RowGroupMetadata> |
| 300 | void ReadAndVerifyColumn(RowGroupReader* rg_reader, RowGroupMetadata* rg_md, |
| 301 | int column_index, int rows) { |
| 302 | ColumnData<DType> expected_column_data = GenerateSampleData<DType>(rows); |
| 303 | std::shared_ptr<parquet::ColumnReader> column_reader = rg_reader->Column(column_index); |
| 304 | TypedColumnReader<DType>* reader = |
| 305 | static_cast<TypedColumnReader<DType>*>(column_reader.get()); |
| 306 | |
| 307 | std::unique_ptr<ColumnChunkMetaData> col_md = rg_md->ColumnChunk(column_index); |
| 308 | |
| 309 | int64_t rows_should_read = expected_column_data.values.size(); |
| 310 | |
| 311 | // Read all the rows in the column |
| 312 | ColumnData<DType> read_col_data; |
| 313 | read_col_data.values.resize(rows_should_read); |
| 314 | int64_t values_read; |
| 315 | int64_t rows_read; |
| 316 | if (expected_column_data.definition_levels.size() > 0 && |
| 317 | expected_column_data.repetition_levels.size() > 0) { |
| 318 | std::vector<int16_t> definition_levels(rows_should_read); |
| 319 | std::vector<int16_t> repetition_levels(rows_should_read); |
| 320 | rows_read = reader->ReadBatch(rows_should_read, definition_levels.data(), |
| 321 | repetition_levels.data(), read_col_data.values.data(), |
| 322 | &values_read); |
| 323 | ASSERT_EQ(definition_levels, expected_column_data.definition_levels); |
| 324 | ASSERT_EQ(repetition_levels, expected_column_data.repetition_levels); |
| 325 | } else { |
| 326 | rows_read = reader->ReadBatch(rows_should_read, nullptr, nullptr, |
| 327 | read_col_data.values.data(), &values_read); |
| 328 | } |
| 329 | ASSERT_EQ(rows_read, rows_should_read); |
| 330 | ASSERT_EQ(values_read, rows_should_read); |
| 331 | // make sure we got the same number of values the metadata says |
| 332 | ASSERT_EQ(col_md->num_values(), rows_read); |
| 333 | // GH-35571: need to use approximate floating-point comparison because of |
| 334 | // precision issues on MinGW32 (the values generated in the C++ test code |
| 335 | // may not exactly match those from the parquet-testing data files). |
| 336 | if constexpr (std::is_floating_point_v<typename DType::c_type>) { |
| 337 | ASSERT_EQ(read_col_data.rows(), expected_column_data.rows()); |
| 338 | for (int i = 0; i < read_col_data.rows(); ++i) { |
| 339 | if constexpr (std::is_same_v<float, typename DType::c_type>) { |
| 340 | EXPECT_FLOAT_EQ(expected_column_data.values[i], read_col_data.values[i]); |
| 341 | } else { |
| 342 | EXPECT_DOUBLE_EQ(expected_column_data.values[i], read_col_data.values[i]); |
| 343 | } |
| 344 | } |
| 345 | } else { |
| 346 | ASSERT_EQ(expected_column_data.values, read_col_data.values); |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | void FileDecryptor::DecryptFile( |
| 351 | const std::string& file, |
nothing calls this directly
no test coverage detected