(&mut self)
| 117 | } |
| 118 | |
| 119 | fn consume_batch(&mut self) -> Result<ArrayRef> { |
| 120 | let buffer = self.record_reader.consume_record_data(); |
| 121 | let null_buffer = self.record_reader.consume_bitmap_buffer(); |
| 122 | self.def_levels_buffer = self.record_reader.consume_def_levels(); |
| 123 | self.rep_levels_buffer = self.record_reader.consume_rep_levels(); |
| 124 | self.record_reader.reset(); |
| 125 | |
| 126 | let array: ArrayRef = match self.data_type { |
| 127 | // Apply conversion to all elements regardless of null slots as the conversions |
| 128 | // are infallible. This improves performance by avoiding a branch in the inner |
| 129 | // loop (see docs for `PrimitiveArray::from_unary`). |
| 130 | ArrowType::Decimal128(p, s) => { |
| 131 | let array = buffer.into_array(null_buffer, ArrowType::Binary); |
| 132 | let binary = array.as_any().downcast_ref::<BinaryArray>().unwrap(); |
| 133 | // Null slots will have 0 length, so we need to check for that in the lambda |
| 134 | // or sign_extend_be will panic. |
| 135 | let decimal = Decimal128Array::from_unary(binary, |x| match x.len() { |
| 136 | 0 => i128::default(), |
| 137 | _ => i128::from_be_bytes(sign_extend_be(x)), |
| 138 | }) |
| 139 | .with_precision_and_scale(p, s)?; |
| 140 | Arc::new(decimal) |
| 141 | } |
| 142 | ArrowType::Decimal256(p, s) => { |
| 143 | let array = buffer.into_array(null_buffer, ArrowType::Binary); |
| 144 | let binary = array.as_any().downcast_ref::<BinaryArray>().unwrap(); |
| 145 | // Null slots will have 0 length, so we need to check for that in the lambda |
| 146 | // or sign_extend_be will panic. |
| 147 | let decimal = Decimal256Array::from_unary(binary, |x| match x.len() { |
| 148 | 0 => i256::default(), |
| 149 | _ => i256::from_be_bytes(sign_extend_be(x)), |
| 150 | }) |
| 151 | .with_precision_and_scale(p, s)?; |
| 152 | Arc::new(decimal) |
| 153 | } |
| 154 | _ => buffer.into_array(null_buffer, self.data_type.clone()), |
| 155 | }; |
| 156 | |
| 157 | Ok(array) |
| 158 | } |
| 159 | |
| 160 | fn skip_records(&mut self, num_records: usize) -> Result<usize> { |
| 161 | skip_records(&mut self.record_reader, self.pages.as_mut(), num_records) |
nothing calls this directly
no test coverage detected