| 124 | } |
| 125 | |
| 126 | static std::shared_ptr<Array> MaskArrayWithNullsAt(std::shared_ptr<Array> input, |
| 127 | std::vector<int> indices_to_mask) { |
| 128 | auto masked = input->data()->Copy(); |
| 129 | masked->buffers[0] = *AllocateEmptyBitmap(input->length()); |
| 130 | masked->null_count = kUnknownNullCount; |
| 131 | |
| 132 | using arrow::internal::Bitmap; |
| 133 | Bitmap is_valid(masked->buffers[0], 0, input->length()); |
| 134 | if (auto original = input->null_bitmap()) { |
| 135 | is_valid.CopyFrom(Bitmap(original, input->offset(), input->length())); |
| 136 | } else { |
| 137 | is_valid.SetBitsTo(true); |
| 138 | } |
| 139 | |
| 140 | for (int i : indices_to_mask) { |
| 141 | is_valid.SetBitTo(i, false); |
| 142 | } |
| 143 | return MakeArray(masked); |
| 144 | } |
| 145 | |
| 146 | TEST(Cast, CanCast) { |
| 147 | auto ExpectCanCast = [](std::shared_ptr<DataType> from, |