Path: blob/main/crates/polars-arrow/src/array/dictionary/fmt.rs
6939 views
use std::fmt::{Debug, Formatter, Result, Write};12use super::super::fmt::{get_display, write_vec};3use super::{DictionaryArray, DictionaryKey};4use crate::array::Array;56pub fn write_value<K: DictionaryKey, W: Write>(7array: &DictionaryArray<K>,8index: usize,9null: &'static str,10f: &mut W,11) -> Result {12let keys = array.keys();13let values = array.values();1415if keys.is_valid(index) {16let key = array.key_value(index);17get_display(values.as_ref(), null)(f, key)18} else {19write!(f, "{null}")20}21}2223impl<K: DictionaryKey> Debug for DictionaryArray<K> {24fn fmt(&self, f: &mut Formatter<'_>) -> Result {25let writer = |f: &mut Formatter, index| write_value(self, index, "None", f);2627write!(f, "DictionaryArray")?;28write_vec(f, writer, self.validity(), self.len(), "None", false)29}30}313233