Converts this into an [`ArrayRef`] with the provided `data_type` and `null_buffer`
(self, null_buffer: Option<Buffer>, data_type: &ArrowType)
| 53 | |
| 54 | /// Converts this into an [`ArrayRef`] with the provided `data_type` and `null_buffer` |
| 55 | pub fn into_array(self, null_buffer: Option<Buffer>, data_type: &ArrowType) -> ArrayRef { |
| 56 | let len = self.views.len(); |
| 57 | let views = ScalarBuffer::from(self.views); |
| 58 | let nulls = null_buffer.and_then(|b| NullBuffer::from_unsliced_buffer(b, len)); |
| 59 | match data_type { |
| 60 | ArrowType::Utf8View => { |
| 61 | // Safety: views were created correctly, and checked that the data is utf8 when building the buffer |
| 62 | unsafe { Arc::new(StringViewArray::new_unchecked(views, self.buffers, nulls)) } |
| 63 | } |
| 64 | ArrowType::BinaryView => { |
| 65 | // Safety: views were created correctly |
| 66 | unsafe { Arc::new(BinaryViewArray::new_unchecked(views, self.buffers, nulls)) } |
| 67 | } |
| 68 | _ => panic!("Unsupported data type: {data_type}"), |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | impl ValuesBuffer for ViewBuffer { |