What happened?
reset is documented as "Clear the encoder state to make it ready for a new round of decoding", but the implementations do not clear it properly.
BytesDictBuilder::reset keeps lookup and null_code
PrimitiveDictBuilder::reset keeps lookup, null_code and values
Steps to reproduce
BytesDictBuilder:
let session = vortex_array::array_session();
let mut ctx = session.create_execution_ctx();
let first = VarBinViewArray::from_iter_str(["one", "two"]).into_array();
let mut encoder = dict_encoder(&first, &UNCONSTRAINED);
encoder.encode(&first, &mut ctx).unwrap();
encoder.reset();
let second = VarBinViewArray::from_iter_str(["one", "three"]).into_array();
encoder.encode(&second, &mut ctx).unwrap(); // index out of bounds: the len is 0 but the index is 0
PrimitiveDictBuilder
let session = vortex_array::array_session();
let mut ctx = session.create_execution_ctx();
let first = PrimitiveArray::from_option_iter([Some(1i32), None, Some(3)]).into_array();
let mut encoder = dict_encoder(&first, &UNCONSTRAINED);
encoder.encode(&first, &mut ctx).unwrap();
encoder.reset();
let second = PrimitiveArray::from_option_iter([Some(4i32), Some(5)]).into_array();
let codes = encoder.encode(&second, &mut ctx).unwrap();
assert_eq!(codes.as_slice::<u32>(), &[0, 1]); // assertion `left == right` failed
// left: [3, 4]
// right: [0, 1]
Environment
- Vortex develop
- Rust 1.98.0
Additional context
No response
What happened?
resetis documented as "Clear the encoder state to make it ready for a new round of decoding", but the implementations do not clear it properly.BytesDictBuilder::resetkeepslookupandnull_codePrimitiveDictBuilder::resetkeepslookup,null_codeandvaluesSteps to reproduce
BytesDictBuilder:PrimitiveDictBuilderEnvironment
Additional context
No response