| 444 | |
| 445 | template <typename ArrowType> |
| 446 | inline Status NumPyConverter::PrepareInputData(std::shared_ptr<Buffer>* data) { |
| 447 | if (PyArray_ISBYTESWAPPED(arr_)) { |
| 448 | // TODO |
| 449 | return Status::NotImplemented("Byte-swapped arrays not supported"); |
| 450 | } |
| 451 | |
| 452 | if (dtype_->type_num == NPY_BOOL) { |
| 453 | int64_t nbytes = bit_util::BytesForBits(length_); |
| 454 | ARROW_ASSIGN_OR_RAISE(auto buffer, AllocateBuffer(nbytes, pool_)); |
| 455 | |
| 456 | Ndarray1DIndexer<uint8_t> values(arr_); |
| 457 | int64_t i = 0; |
| 458 | const auto generate = [&values, &i]() -> bool { return values[i++] > 0; }; |
| 459 | GenerateBitsUnrolled(buffer->mutable_data(), 0, length_, generate); |
| 460 | |
| 461 | *data = std::move(buffer); |
| 462 | } else if (is_strided()) { |
| 463 | RETURN_NOT_OK(NumPyStridedConverter::Convert(arr_, length_, pool_, data)); |
| 464 | } else { |
| 465 | // Can zero-copy |
| 466 | *data = std::make_shared<NumPyBuffer>(reinterpret_cast<PyObject*>(arr_)); |
| 467 | } |
| 468 | |
| 469 | return Status::OK(); |
| 470 | } |
| 471 | |
| 472 | template <typename ArrowType> |
| 473 | inline Status NumPyConverter::ConvertData(std::shared_ptr<Buffer>* data) { |
nothing calls this directly
no test coverage detected