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