pub fn values_as_dictionary(&self, row_ids: &[u32]) -> Values<'_> {
        //
        // Example:
        //
        // Suppose you have column encoded like this:
        //
        // values: NULL, "alpha", "beta", "gamma"
        // encoded: 1, 1, 2, 0, 3 (alpha, alpha, beta, NULL, gamma)
        //
        // And only the rows: {0, 1, 3, 4} are required.
        //
        // The column encoding will return the following encoded values
        //
        // encoded: 1, 1, 0, 3 (alpha, alpha, NULL, gamma)
        //
        // Because the dictionary has likely changed, the encoded values need
        // to be transformed into a new domain `[0, encoded.len())` so that they
        // become:
        //
        // keys: [1, 1, 0, 2]
        // values: [None, Some("alpha"), Some("gamma")]
        let mut keys = self.encoded_values(row_ids, vec![]);

        // build a mapping from encoded value to new ordinal position.
        let mut ordinal_mapping = hashbrown::HashMap::new();
        for key in &keys {
            ordinal_mapping.insert(*key, u32::default()); // don't know final ordinal position yet
        }

        // create new ordinal offsets - the encoded values need to be shifted
        // into a new domain `[0, ordinal_mapping.len())` which is the length
        // of the new dictionary.
        let mut ordinal_mapping_keys = ordinal_mapping
            .keys()
            .into_iter()
            .cloned()
            .collect::<Vec<_>>();
        ordinal_mapping_keys.sort_unstable();

        for (i, key) in ordinal_mapping_keys.iter().enumerate() {
            // now we can insert the new ordinal position of the encoded in key
            // in the final values vector.
            ordinal_mapping.insert(*key, i as u32);
        }

        // Rewrite all the encoded values into the new domain.
        for key in keys.iter_mut() {
            *key = *ordinal_mapping.get(key).unwrap();
        }

        // now generate the values vector, which will contain the sorted set of
        // string values
        let mut values = match &self {
            Self::RleDictionary(c) => ordinal_mapping_keys
                .iter()
                .map(|id| c.decode_id(*id))
                .collect::<Vec<_>>(),
            Self::Dictionary(c) => ordinal_mapping_keys
                .iter()
                .map(|id| c.decode_id(*id))
                .collect::<Vec<_>>(),
        };
        values.sort_unstable();

        Values::Dictionary(keys, values)
    }
/// Returns all values present at the provided logical row IDs as a
/// dictionary encoded `Values` format.
Returns all values present at the provided logical row IDs as a
dictionary encoded `Values` format.
Returns all values present at the provided logical row IDs as a dictionary encoded ` Values ` format .
pub fn values_as_dictionary(&self, row_ids: &[u32]) -> Values<'_> {
        //
        // Example:
        //
        // Suppose you have column encoded like this:
        //
        // values: NULL, "alpha", "beta", "gamma"
        // encoded: 1, 1, 2, 0, 3 (alpha, alpha, beta, NULL, gamma)
        //
        // And only the rows: {0, 1, 3, 4} are required.
        //
        // The column encoding will return the following encoded values
        //
        // encoded: 1, 1, 0, 3 (alpha, alpha, NULL, gamma)
        //
        // Because the dictionary has likely changed, the encoded values need
        // to be transformed into a new domain `[0, encoded.len())` so that they
        // become:
        //
        // keys: [1, 1, 0, 2]
        // values: [None, Some("alpha"), Some("gamma")]
        let mut keys = self.encoded_values(row_ids, vec![]);
        // build a mapping from encoded value to new ordinal position.
        let mut ordinal_mapping = hashbrown::HashMap::new();
        for key in &keys {
            ordinal_mapping.insert(*key, u32::default()); // don't know final ordinal position yet
        }
        // create new ordinal offsets - the encoded values need to be shifted
        // into a new domain `[0, ordinal_mapping.len())` which is the length
        // of the new dictionary.
        let mut ordinal_mapping_keys = ordinal_mapping
            .keys()
            .into_iter()
            .cloned()
            .collect::<Vec<_>>();
        ordinal_mapping_keys.sort_unstable();
        for (i, key) in ordinal_mapping_keys.iter().enumerate() {
            // now we can insert the new ordinal position of the encoded in key
            // in the final values vector.
            ordinal_mapping.insert(*key, i as u32);
        }
        // Rewrite all the encoded values into the new domain.
        for key in keys.iter_mut() {
            *key = *ordinal_mapping.get(key).unwrap();
        }
        // now generate the values vector, which will contain the sorted set of
        // string values
        let mut values = match &self {
            Self::RleDictionary(c) => ordinal_mapping_keys
                .iter()
                .map(|id| c.decode_id(*id))
                .collect::<Vec<_>>(),
            Self::Dictionary(c) => ordinal_mapping_keys
                .iter()
                .map(|id| c.decode_id(*id))
                .collect::<Vec<_>>(),
        };
        values.sort_unstable();
        Values::Dictionary(keys, values)
    }
pub fn values_as_dictionary ( & self , row_ids : & [ u32 ] ) -> Values < ' _ > { // // Example: // // Suppose you have column encoded like this: // // values: NULL, "alpha", "beta", "gamma" // encoded: 1, 1, 2, 0, 3 (alpha, alpha, beta, NULL, gamma) // // And only the rows: {0, 1, 3, 4} are required. // // The column encoding will return the following encoded values // // encoded: 1, 1, 0, 3 (alpha, alpha, NULL, gamma) // // Because the dictionary has likely changed, the encoded values need // to be transformed into a new domain `[0, encoded.len())` so that they // become: // // keys: [1, 1, 0, 2] // values: [None, Some("alpha"), Some("gamma")] let mut keys = self . encoded_values ( row_ids , vec ! [ ] ) ; // build a mapping from encoded value to new ordinal position. let mut ordinal_mapping = hashbrown :: HashMap :: new ( ) ; for key in & keys { ordinal_mapping . insert ( * key , u32 :: default ( ) ) ; // don't know final ordinal position yet } // create new ordinal offsets - the encoded values need to be shifted // into a new domain `[0, ordinal_mapping.len())` which is the length // of the new dictionary. let mut ordinal_mapping_keys = ordinal_mapping . keys ( ) . into_iter ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) ; ordinal_mapping_keys . sort_unstable ( ) ; for ( i , key ) in ordinal_mapping_keys . iter ( ) . enumerate ( ) { // now we can insert the new ordinal position of the encoded in key // in the final values vector. ordinal_mapping . insert ( * key , i as u32 ) ; } // Rewrite all the encoded values into the new domain. for key in keys . iter_mut ( ) { * key = * ordinal_mapping . get ( key ) . unwrap ( ) ; } // now generate the values vector, which will contain the sorted set of // string values let mut values = match & self { Self :: RleDictionary ( c ) => ordinal_mapping_keys . iter ( ) . map ( | id | c . decode_id ( * id ) ) . collect :: < Vec < _ > > ( ) , Self :: Dictionary ( c ) => ordinal_mapping_keys . iter ( ) . map ( | id | c . decode_id ( * id ) ) . collect :: < Vec < _ > > ( ) , } ; values . sort_unstable ( ) ; Values :: Dictionary ( keys , values ) }
Returns all values present at the provided logical row IDs as a
dictionary encoded `Values` format.
Returns all values present at the provided logical row IDs as a dictionary encoded ` Values ` format .
&self
row_ids
&[u32]
&self
row_ids
&[u32]