Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
feat: expose (utf8|binary)_substring
Browse files Browse the repository at this point in the history
  • Loading branch information
orlp committed Aug 14, 2023
1 parent 36e905d commit 0096b9e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/compute/substring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ use crate::{
offset::{Offset, Offsets},
};

fn utf8_substring<O: Offset>(array: &Utf8Array<O>, start: O, length: &Option<O>) -> Utf8Array<O> {
/// Returns a Utf8Array<O> with a substring starting from `start` and with optional length `length` of each of the elements in `array`.
/// `start` can be negative, in which case the start counts from the end of the string.
pub fn utf8_substring<O: Offset>(array: &Utf8Array<O>, start: O, length: &Option<O>) -> Utf8Array<O> {
let length = length.map(|v| v.to_usize());

let iter = array.values_iter().map(|str_val| {
Expand Down Expand Up @@ -68,7 +70,9 @@ fn utf8_substring<O: Offset>(array: &Utf8Array<O>, start: O, length: &Option<O>)
new.with_validity(array.validity().cloned())
}

fn binary_substring<O: Offset>(
/// Returns a BinaryArray<O> with a substring starting from `start` and with optional length `length` of each of the elements in `array`.
/// `start` can be negative, in which case the start counts from the end of the string.
pub fn binary_substring<O: Offset>(
array: &BinaryArray<O>,
start: O,
length: &Option<O>,
Expand Down

0 comments on commit 0096b9e

Please sign in to comment.