| 575 | |
| 576 | template <typename T> |
| 577 | Status NumPyConverter::VisitBinary(T* builder) { |
| 578 | auto data = reinterpret_cast<const uint8_t*>(PyArray_DATA(arr_)); |
| 579 | |
| 580 | auto AppendNotNull = [builder, this](const uint8_t* data) { |
| 581 | // This is annoying. NumPy allows strings to have nul-terminators, so |
| 582 | // we must check for them here |
| 583 | const size_t item_size = |
| 584 | strnlen(reinterpret_cast<const char*>(data), static_cast<size_t>(itemsize_)); |
| 585 | return builder->Append(data, static_cast<int32_t>(item_size)); |
| 586 | }; |
| 587 | |
| 588 | if (mask_ != nullptr) { |
| 589 | Ndarray1DIndexer<uint8_t> mask_values(mask_); |
| 590 | for (int64_t i = 0; i < length_; ++i) { |
| 591 | if (mask_values[i]) { |
| 592 | RETURN_NOT_OK(builder->AppendNull()); |
| 593 | } else { |
| 594 | RETURN_NOT_OK(AppendNotNull(data)); |
| 595 | } |
| 596 | data += stride_; |
| 597 | } |
| 598 | } else { |
| 599 | for (int64_t i = 0; i < length_; ++i) { |
| 600 | RETURN_NOT_OK(AppendNotNull(data)); |
| 601 | data += stride_; |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | return Status::OK(); |
| 606 | } |
| 607 | |
| 608 | Status NumPyConverter::Visit(const BinaryType& type) { |
| 609 | ::arrow::internal::ChunkedBinaryBuilder builder(kBinaryChunksize, pool_); |
nothing calls this directly
no test coverage detected