| 206 | |
| 207 | template <typename T> |
| 208 | static inline Status GetBitmapFromVector(const std::vector<T>& is_valid, |
| 209 | std::shared_ptr<Buffer>* result) { |
| 210 | size_t length = is_valid.size(); |
| 211 | |
| 212 | ARROW_ASSIGN_OR_RAISE(auto buffer, AllocateEmptyBitmap(length)); |
| 213 | |
| 214 | uint8_t* bitmap = buffer->mutable_data(); |
| 215 | for (size_t i = 0; i < static_cast<size_t>(length); ++i) { |
| 216 | if (is_valid[i]) { |
| 217 | bit_util::SetBit(bitmap, i); |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | *result = buffer; |
| 222 | return Status::OK(); |
| 223 | } |
| 224 | |
| 225 | template <typename T> |
| 226 | inline void BitmapFromVector(const std::vector<T>& is_valid, |