MCPcopy Create free account
hub / github.com/apache/datafusion / decode_array

Function decode_array

datafusion/functions/src/encoding/inner.rs:287–314  ·  view source on GitHub ↗
(array: &ArrayRef, encoding: Encoding)

Source from the content-addressed store, hash-verified

285}
286
287fn decode_array(array: &ArrayRef, encoding: Encoding) -> Result<ColumnarValue> {
288 let array = match array.data_type() {
289 DataType::Binary => {
290 let array = array.as_binary::<i32>();
291 encoding.decode_array::<_, i32>(&array, estimate_byte_data_size(array))
292 }
293 DataType::BinaryView => {
294 let array = array.as_binary_view();
295 // Don't know if there is a more strict upper bound we can infer
296 // for view arrays byte data size.
297 encoding.decode_array::<_, i32>(&array, array.get_buffer_memory_size())
298 }
299 DataType::LargeBinary => {
300 let array = array.as_binary::<i64>();
301 encoding.decode_array::<_, i64>(&array, estimate_byte_data_size(array))
302 }
303 DataType::FixedSizeBinary(size) => {
304 let array = array.as_fixed_size_binary();
305 // TODO: could we be more conservative by accounting for nulls?
306 let estimate = array.len().saturating_mul(*size as usize);
307 encoding.decode_array::<_, i32>(&array, estimate)
308 }
309 dt => {
310 internal_err!("Unexpected data type for decode: {dt}")
311 }
312 };
313 array.map(ColumnarValue::Array)
314}
315
316#[derive(Debug, Copy, Clone)]
317enum Encoding {

Callers 1

invoke_with_argsMethod · 0.85

Calls 4

estimate_byte_data_sizeFunction · 0.85
data_typeMethod · 0.45
lenMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…