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