pub fn shift_str<T: Integer>(
arr: StringAVT<'_, T>,
shift_offset: isize,
) -> Result<StringArray<T>, KernelError>Expand description
Shifts string array elements with UTF-8 integrity and bidirectional offset support.
String shifting function supporting both LAG and LEAD operations through signed offset parameter. Maintains UTF-8 encoding integrity while providing flexible positional access for textual sequence analysis.
§Parameters
arr- String array view containing textual data for shiftingshift_offset- Signed offset: positive for LEAD (forward), negative for LAG (backward), zero for identity
§Returns
Returns Result<StringArray<T>, KernelError> containing:
- Success: Shifted string values maintaining UTF-8 integrity
- Error: KernelError if string processing encounters issues
- Empty strings for positions beyond data boundaries
- Null mask reflecting validity of shifted string positions
§Shift Semantics
- Positive offset: LEAD operation accessing future string values
- Negative offset: LAG operation accessing historical string values
- Zero offset: Identity operation (returns cloned array slice)
- Boundary conditions: Out-of-range positions produce empty strings
§Examples
ⓘ
use minarrow::StringArray;
use simd_kernels::kernels::window::shift_str;
let arr = StringArray::<u32>::from_slice(&["one", "two", "three"]);
let back = shift_str((&arr, 0, arr.len()), -1).unwrap(); // LAG
let forward = shift_str((&arr, 0, arr.len()), 1).unwrap(); // LEAD
// back: ["", "one", "two"]
// forward: ["two", "three", ""]