Skip to content

Commit c7bf00b

Browse files
committed
less
Signed-off-by: Robert Kruszewski <github@robertk.io>
1 parent e4ff8d1 commit c7bf00b

4 files changed

Lines changed: 13 additions & 11 deletions

File tree

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<Code: UnsignedPType> BytesDictBuilder<Code> {
135135
&mut self,
136136
var_bin: ArrayView<VarBin>,
137137
ctx: &mut ExecutionCtx,
138-
) -> VortexResult<ArrayRef> {
138+
) -> VortexResult<PrimitiveArray> {
139139
let mut local_lookup = self.lookup.take().vortex_expect("Must have a lookup dict");
140140
let mut codes: BufferMut<Code> = BufferMut::with_capacity(var_bin.len());
141141

@@ -205,14 +205,14 @@ impl<Code: UnsignedPType> BytesDictBuilder<Code> {
205205
// Restore lookup dictionary back into the struct
206206
self.lookup = Some(local_lookup);
207207

208-
Ok(PrimitiveArray::new(codes, Validity::NonNullable).into_array())
208+
Ok(PrimitiveArray::new(codes, Validity::NonNullable))
209209
}
210210

211211
fn encode_varbinview(
212212
&mut self,
213213
var_bin_view: ArrayView<VarBinView>,
214214
ctx: &mut ExecutionCtx,
215-
) -> VortexResult<ArrayRef> {
215+
) -> VortexResult<PrimitiveArray> {
216216
let mut local_lookup = self.lookup.take().vortex_expect("Must have a lookup dict");
217217
let mut codes: BufferMut<Code> = BufferMut::with_capacity(var_bin_view.len());
218218

@@ -286,12 +286,12 @@ impl<Code: UnsignedPType> BytesDictBuilder<Code> {
286286
// Restore lookup dictionary back into the struct
287287
self.lookup = Some(local_lookup);
288288

289-
Ok(PrimitiveArray::new(codes, Validity::NonNullable).into_array())
289+
Ok(PrimitiveArray::new(codes, Validity::NonNullable))
290290
}
291291
}
292292

293293
impl<Code: UnsignedPType> DictEncoder for BytesDictBuilder<Code> {
294-
fn encode(&mut self, array: &ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult<ArrayRef> {
294+
fn encode(&mut self, array: &ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult<PrimitiveArray> {
295295
debug_assert_eq!(
296296
&self.dtype,
297297
array.dtype(),

vortex-array/src/builders/dict/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub const UNCONSTRAINED: DictConstraints = DictConstraints {
3535

3636
pub trait DictEncoder: Send {
3737
/// Assign dictionary codes to the given input array.
38-
fn encode(&mut self, array: &ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult<ArrayRef>;
38+
fn encode(&mut self, array: &ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult<PrimitiveArray>;
3939

4040
/// Clear the encoder state to make it ready for a new round of decoding.
4141
fn reset(&mut self) -> ArrayRef;
@@ -68,8 +68,7 @@ pub fn dict_encode_with_constraints(
6868
ctx: &mut ExecutionCtx,
6969
) -> VortexResult<DictArray> {
7070
let mut encoder = dict_encoder(array, constraints);
71-
let encoded = encoder.encode(array, ctx)?;
72-
let codes = encoded.execute::<PrimitiveArray>(ctx)?.narrow()?;
71+
let codes = encoder.encode(array, ctx)?.narrow()?;
7372
// SAFETY: The encoding process will produce a value set of codes and values
7473
// All values in the dictionary are guaranteed to be referenced by at least one code
7574
// since we build the dictionary from the codes we observe during encoding

vortex-array/src/builders/dict/primitive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ where
118118
NativeValue<T>: Hash + Eq,
119119
Code: UnsignedPType,
120120
{
121-
fn encode(&mut self, array: &ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult<ArrayRef> {
121+
fn encode(&mut self, array: &ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult<PrimitiveArray> {
122122
let mut codes = BufferMut::<Code>::with_capacity(array.len());
123123

124124
let prim = array.clone().execute::<PrimitiveArray>(ctx)?;
@@ -167,7 +167,7 @@ where
167167
}
168168
}
169169

170-
Ok(PrimitiveArray::new(codes, Validity::NonNullable).into_array())
170+
Ok(PrimitiveArray::new(codes, Validity::NonNullable))
171171
}
172172

173173
fn reset(&mut self) -> ArrayRef {

vortex-layout/src/layouts/dict/writer.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use futures::stream::once;
2020
use futures::try_join;
2121
use vortex_array::ArrayContext;
2222
use vortex_array::ArrayRef;
23+
use vortex_array::IntoArray;
2324
use vortex_array::LEGACY_SESSION;
2425
use vortex_array::VortexSessionExecute;
2526
use vortex_array::arrays::Dict;
@@ -558,7 +559,9 @@ fn encode_chunk(
558559
mut encoder: Box<dyn DictEncoder>,
559560
chunk: &ArrayRef,
560561
) -> VortexResult<EncodingState> {
561-
let encoded = encoder.encode(chunk, &mut LEGACY_SESSION.create_execution_ctx())?;
562+
let encoded = encoder
563+
.encode(chunk, &mut LEGACY_SESSION.create_execution_ctx())?
564+
.into_array();
562565
match remainder(chunk, encoded.len())? {
563566
None => Ok(EncodingState::Continue((encoder, encoded))),
564567
Some(unencoded) => Ok(EncodingState::Done((encoder.reset(), encoded, unencoded))),

0 commit comments

Comments
 (0)