Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make dictionary preservation optional in row encoding #3831

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion arrow-row/src/dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

use crate::fixed::{FixedLengthEncoding, FromSlice};
use crate::interner::{Interned, OrderPreservingInterner};
use crate::{null_sentinel, Rows};
use crate::{null_sentinel, Row, Rows};
use arrow_array::builder::*;
use arrow_array::cast::*;
use arrow_array::types::*;
Expand Down Expand Up @@ -56,6 +56,24 @@ pub fn compute_dictionary_mapping(
}
}

/// Encode dictionary values not preserving the dictionary encoding
pub fn encode_dictionary_values<K: ArrowDictionaryKeyType>(
out: &mut Rows,
column: &DictionaryArray<K>,
values: &Rows,
null: &Row<'_>,
) {
for (offset, k) in out.offsets.iter_mut().skip(1).zip(column.keys()) {
let row = match k {
Some(k) => values.row(k.as_usize()).data,
None => null.data,
};
let end_offset = *offset + row.len();
out.buffer[*offset..end_offset].copy_from_slice(row);
*offset = end_offset;
}
}

/// Dictionary types are encoded as
///
/// - single `0_u8` if null
Expand Down
Loading