Skip to content

Commit 97953be

Browse files
authored
fix(dict): cap max_dict_bytes at the u32 range BinaryView addresses (#9690)
- Tracking Issue: #9687 Limit `max_dict_bytes` to `u32::MAX` so the builder can never be asked for a bound it cannot address --------- Signed-off-by: Antoine Dupuis <[email protected]>
1 parent 8edd88f commit 97953be

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎vortex-array/src/builders/dict/bytes.rs‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<Code: UnsignedPType> BytesDictBuilder<Code> {
7171
values_nulls: BitBufferMut::empty(),
7272
hasher: DefaultHashBuilder::default(),
7373
dtype,
74-
max_dict_bytes: constraints.max_bytes,
74+
max_dict_bytes: constraints.max_bytes.min(u32::MAX as usize),
7575
max_dict_len: constraints.max_len,
7676
}
7777
}
@@ -322,6 +322,7 @@ mod test {
322322
use vortex_error::VortexResult;
323323
use vortex_session::VortexSession;
324324

325+
use super::BytesDictBuilder;
325326
use crate::IntoArray;
326327
use crate::VortexSessionExecute;
327328
use crate::arrays::PrimitiveArray;
@@ -461,4 +462,11 @@ mod test {
461462

462463
Ok(())
463464
}
465+
466+
#[test]
467+
fn max_dict_bytes_cannot_exceed_the_view_offset_range() {
468+
let builder =
469+
BytesDictBuilder::<u32>::new(DType::Utf8(Nullability::NonNullable), &UNCONSTRAINED);
470+
assert_eq!(builder.max_dict_bytes, u32::MAX as usize);
471+
}
464472
}

0 commit comments

Comments
 (0)