Skip to content

Commit c790cfb

Browse files
authored
Support reading SparseArray with non zero offset (#7150)
Motivated by #7094 I tried simplifying offset handling in Patches. Unfortunately because of how chunk_offsets and indices interact with each other you need to store two offsets in order to support zero-copy slicing. Since we want to support zero copy slicing there's nothing fundamentally better we can do here than supporting non zero offsets. Signed-off-by: Robert Kruszewski <github@robertk.io> Signed-off-by: Robert Kruszewski <github@robertk.io>
1 parent 6cef60b commit c790cfb

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

encodings/sparse/src/lib.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,6 @@ impl VTable for Sparse {
200200
"SparseArray expects 2 children for sparse encoding, found {}",
201201
children.len()
202202
);
203-
vortex_ensure_eq!(
204-
metadata.patches.offset()?,
205-
0,
206-
"Patches must start at offset 0"
207-
);
208203

209204
let patch_indices = children.get(
210205
0,
@@ -213,10 +208,14 @@ impl VTable for Sparse {
213208
)?;
214209
let patch_values = children.get(1, dtype, metadata.patches.len()?)?;
215210

216-
SparseArray::try_new(
217-
patch_indices,
218-
patch_values,
219-
len,
211+
SparseArray::try_new_from_patches(
212+
Patches::new(
213+
len,
214+
metadata.patches.offset()?,
215+
patch_indices,
216+
patch_values,
217+
None,
218+
)?,
220219
metadata.fill_value.clone(),
221220
)
222221
}

0 commit comments

Comments
 (0)