| 492 | } |
| 493 | |
| 494 | void GenerateInputData(const std::shared_ptr<::arrow::DataType>& dense_type, |
| 495 | double null_probability, bool create_dict) { |
| 496 | constexpr int num_unique = 100; |
| 497 | constexpr int repeat = 100; |
| 498 | constexpr int64_t min_length = 2; |
| 499 | constexpr int64_t max_length = 10; |
| 500 | ::arrow::random::RandomArrayGenerator rag(0); |
| 501 | binary_dense_ = rag.BinaryWithRepeats(repeat * num_unique, num_unique, min_length, |
| 502 | max_length, null_probability); |
| 503 | dense_type_ = dense_type; |
| 504 | ASSERT_OK_AND_ASSIGN(expected_dense_, |
| 505 | ::arrow::compute::Cast(*binary_dense_, dense_type_)); |
| 506 | |
| 507 | num_values_ = static_cast<int>(binary_dense_->length()); |
| 508 | null_count_ = static_cast<int>(binary_dense_->null_count()); |
| 509 | valid_bits_ = binary_dense_->null_bitmap_data(); |
| 510 | |
| 511 | if (create_dict) { |
| 512 | auto builder = CreateDictBuilder(); |
| 513 | ASSERT_OK(builder->AppendArray(*binary_dense_)); |
| 514 | ASSERT_OK(builder->Finish(&expected_dict_)); |
| 515 | } |
| 516 | |
| 517 | // Initialize input_data_ for the encoder from the expected_array_ values |
| 518 | const auto& binary_array = checked_cast<const ::arrow::BinaryArray&>(*binary_dense_); |
| 519 | input_data_.resize(binary_array.length()); |
| 520 | for (int64_t i = 0; i < binary_array.length(); ++i) { |
| 521 | input_data_[i] = binary_array.GetView(i); |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | std::unique_ptr<DictBuilder> CreateDictBuilder() { |
| 526 | EXPECT_EQ(dense_type_->id(), ::arrow::Type::BINARY) |
nothing calls this directly
no test coverage detected