| 141 | } |
| 142 | |
| 143 | static std::shared_ptr<Array> MaskArrayWithNullsAt(std::shared_ptr<Array> input, |
| 144 | std::vector<int> indices_to_mask) { |
| 145 | auto masked = input->data()->Copy(); |
| 146 | masked->buffers[0] = *AllocateEmptyBitmap(input->length()); |
| 147 | masked->null_count = kUnknownNullCount; |
| 148 | |
| 149 | using arrow::internal::Bitmap; |
| 150 | Bitmap is_valid(masked->buffers[0], 0, input->length()); |
| 151 | if (auto original = input->null_bitmap()) { |
| 152 | is_valid.CopyFrom(Bitmap(original, input->offset(), input->length())); |
| 153 | } else { |
| 154 | is_valid.SetBitsTo(true); |
| 155 | } |
| 156 | |
| 157 | for (int i : indices_to_mask) { |
| 158 | is_valid.SetBitTo(i, false); |
| 159 | } |
| 160 | return MakeArray(masked); |
| 161 | } |
| 162 | |
| 163 | TEST(Cast, CanCast) { |
| 164 | auto ExpectCanCast = [](std::shared_ptr<DataType> from, |