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

Commit

Permalink
Improved the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zhyass committed Sep 3, 2021
1 parent b4befc8 commit a7bc6a3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
6 changes: 1 addition & 5 deletions src/array/binary/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ impl<O: Offset> MutableBinaryArray<O> {
{
let (validity, offsets, values) = trusted_len_unzip(iterator);

// soundness: P is `str`
Self::from_data(Self::default_data_type(), offsets, values, validity)
}

Expand All @@ -207,14 +206,13 @@ impl<O: Offset> MutableBinaryArray<O> {
unsafe { Self::from_trusted_len_iter_unchecked(iterator) }
}

/// Creates a new [`BinaryArray`] from a [`TrustedLen`] of `&str`.
/// Creates a new [`BinaryArray`] from a [`TrustedLen`] of `&[u8]`.
#[inline]
pub fn from_trusted_len_values_iter<T: AsRef<[u8]>, I: TrustedLen<Item = T>>(
iterator: I,
) -> Self {
// soundness: I is `TrustedLen`
let (offsets, values) = unsafe { trusted_len_values_iter(iterator) };
// soundness: T is AsRef<[u8]>
Self::from_data(Self::default_data_type(), offsets, values, None)
}

Expand All @@ -235,7 +233,6 @@ impl<O: Offset> MutableBinaryArray<O> {
// soundness: assumed trusted len
let (validity, offsets, values) = try_trusted_len_unzip(iterator)?;

// soundness: P is `str`
Ok(Self::from_data(
Self::default_data_type(),
offsets,
Expand All @@ -258,7 +255,6 @@ impl<O: Offset> MutableBinaryArray<O> {
/// Creates a new [`MutableBinaryArray`] from a [`Iterator`] of `&[u8]`.
pub fn from_iter_values<T: AsRef<[u8]>, I: Iterator<Item = T>>(iterator: I) -> Self {
let (offsets, values) = values_iter(iterator);
// soundness: T: AsRef<[u8]>
Self::from_data(Self::default_data_type(), offsets, values, None)
}
}
Expand Down
28 changes: 14 additions & 14 deletions src/compute/comparison/utf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{array::*, bitmap::Bitmap};

use super::{super::utils::combine_validities, Operator};

/// Evaluate `op(lhs, rhs)` for [`PrimitiveArray`]s using a specified
/// Evaluate `op(lhs, rhs)` for [`Utf8Array`]s using a specified
/// comparison function.
fn compare_op<O, F>(lhs: &Utf8Array<O>, rhs: &Utf8Array<O>, op: F) -> Result<BooleanArray>
where
Expand All @@ -46,7 +46,7 @@ where
Ok(BooleanArray::from_data(DataType::Boolean, values, validity))
}

/// Evaluate `op(lhs, rhs)` for [`PrimitiveArray`] and scalar using
/// Evaluate `op(lhs, rhs)` for [`Utf8Array`] and scalar using
/// a specified comparison function.
fn compare_op_scalar<O, F>(lhs: &Utf8Array<O>, rhs: &str, op: F) -> BooleanArray
where
Expand All @@ -61,62 +61,62 @@ where
BooleanArray::from_data(DataType::Boolean, values, validity)
}

/// Perform `lhs == rhs` operation on [`StringArray`] / [`LargeStringArray`].
/// Perform `lhs == rhs` operation on [`Utf8Array`].
fn eq<O: Offset>(lhs: &Utf8Array<O>, rhs: &Utf8Array<O>) -> Result<BooleanArray> {
compare_op(lhs, rhs, |a, b| a == b)
}

/// Perform `lhs == rhs` operation on [`StringArray`] / [`LargeStringArray`] and a scalar.
/// Perform `lhs == rhs` operation on [`Utf8Array`] and a scalar.
fn eq_scalar<O: Offset>(lhs: &Utf8Array<O>, rhs: &str) -> BooleanArray {
compare_op_scalar(lhs, rhs, |a, b| a == b)
}

/// Perform `lhs != rhs` operation on [`StringArray`] / [`LargeStringArray`].
/// Perform `lhs != rhs` operation on [`Utf8Array`].
fn neq<O: Offset>(lhs: &Utf8Array<O>, rhs: &Utf8Array<O>) -> Result<BooleanArray> {
compare_op(lhs, rhs, |a, b| a != b)
}

/// Perform `lhs != rhs` operation on [`StringArray`] / [`LargeStringArray`] and a scalar.
/// Perform `lhs != rhs` operation on [`Utf8Array`] and a scalar.
fn neq_scalar<O: Offset>(lhs: &Utf8Array<O>, rhs: &str) -> BooleanArray {
compare_op_scalar(lhs, rhs, |a, b| a != b)
}

/// Perform `lhs < rhs` operation on [`StringArray`] / [`LargeStringArray`].
/// Perform `lhs < rhs` operation on [`Utf8Array`].
fn lt<O: Offset>(lhs: &Utf8Array<O>, rhs: &Utf8Array<O>) -> Result<BooleanArray> {
compare_op(lhs, rhs, |a, b| a < b)
}

/// Perform `lhs < rhs` operation on [`StringArray`] / [`LargeStringArray`] and a scalar.
/// Perform `lhs < rhs` operation on [`Utf8Array`] and a scalar.
fn lt_scalar<O: Offset>(lhs: &Utf8Array<O>, rhs: &str) -> BooleanArray {
compare_op_scalar(lhs, rhs, |a, b| a < b)
}

/// Perform `lhs <= rhs` operation on [`StringArray`] / [`LargeStringArray`].
/// Perform `lhs <= rhs` operation on [`Utf8Array`].
fn lt_eq<O: Offset>(lhs: &Utf8Array<O>, rhs: &Utf8Array<O>) -> Result<BooleanArray> {
compare_op(lhs, rhs, |a, b| a <= b)
}

/// Perform `lhs <= rhs` operation on [`StringArray`] / [`LargeStringArray`] and a scalar.
/// Perform `lhs <= rhs` operation on [`Utf8Array`] and a scalar.
fn lt_eq_scalar<O: Offset>(lhs: &Utf8Array<O>, rhs: &str) -> BooleanArray {
compare_op_scalar(lhs, rhs, |a, b| a <= b)
}

/// Perform `lhs > rhs` operation on [`StringArray`] / [`LargeStringArray`].
/// Perform `lhs > rhs` operation on [`Utf8Array`].
fn gt<O: Offset>(lhs: &Utf8Array<O>, rhs: &Utf8Array<O>) -> Result<BooleanArray> {
compare_op(lhs, rhs, |a, b| a > b)
}

/// Perform `lhs > rhs` operation on [`StringArray`] / [`LargeStringArray`] and a scalar.
/// Perform `lhs > rhs` operation on [`Utf8Array`] and a scalar.
fn gt_scalar<O: Offset>(lhs: &Utf8Array<O>, rhs: &str) -> BooleanArray {
compare_op_scalar(lhs, rhs, |a, b| a > b)
}

/// Perform `lhs >= rhs` operation on [`StringArray`] / [`LargeStringArray`].
/// Perform `lhs >= rhs` operation on [`Utf8Array`].
fn gt_eq<O: Offset>(lhs: &Utf8Array<O>, rhs: &Utf8Array<O>) -> Result<BooleanArray> {
compare_op(lhs, rhs, |a, b| a >= b)
}

/// Perform `lhs >= rhs` operation on [`StringArray`] / [`LargeStringArray`] and a scalar.
/// Perform `lhs >= rhs` operation on [`Utf8Array`] and a scalar.
fn gt_eq_scalar<O: Offset>(lhs: &Utf8Array<O>, rhs: &str) -> BooleanArray {
compare_op_scalar(lhs, rhs, |a, b| a >= b)
}
Expand Down
2 changes: 1 addition & 1 deletion src/compute/contains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ where
Ok(BooleanArray::from_data(DataType::Boolean, values, validity))
}

/// Checks if a [`GenericListArray`] contains a value in the [`BinaryArray`]
/// Checks if a [`ListArray`] contains a value in the [`BinaryArray`]
fn contains_binary<O, OO>(list: &ListArray<O>, values: &BinaryArray<OO>) -> Result<BooleanArray>
where
O: Offset,
Expand Down

0 comments on commit a7bc6a3

Please sign in to comment.