-
Notifications
You must be signed in to change notification settings - Fork 1k
Docs: Clarify that Array::value does not check for nulls #8065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6ee4c63
140cd5b
618a255
f89c8e0
18fce22
1c463b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,13 +178,20 @@ impl BooleanArray { | |
|
||
/// Returns the boolean value at index `i`. | ||
/// | ||
/// Note: This method does not check for nulls and the value is arbitrary | ||
/// if [`is_null`](Self::is_null) returns true for the index. | ||
/// | ||
/// # Safety | ||
/// This doesn't check bounds, the caller must ensure that index < self.len() | ||
pub unsafe fn value_unchecked(&self, i: usize) -> bool { | ||
self.values.value_unchecked(i) | ||
} | ||
|
||
/// Returns the boolean value at index `i`. | ||
/// | ||
/// Note: This method does not check for nulls and the value is arbitrary | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And actually I think all There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I agree, that is why i was trying to add the documentation. |
||
/// if [`is_null`](Self::is_null) returns true for the index. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this calls There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is an excellent call. I have done so |
||
/// | ||
/// # Panics | ||
/// Panics if index `i` is out of bounds | ||
pub fn value(&self, i: usize) -> bool { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -276,6 +276,10 @@ impl<T: ByteArrayType> GenericByteArray<T> { | |
} | ||
|
||
/// Returns the element at index `i` | ||
/// | ||
/// Note: This method does not check for nulls and the value is arbitrary | ||
/// if [`is_null`](Self::is_null) returns true for the index. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here and in other places, is it guaranteed not to panic and return a valid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, to the best of my knowledge
Yes I think this is possible -- the only one I can think of now is potentially date/time types where some valid integer is not a valid date/time/timestamp instance. |
||
/// | ||
/// # Safety | ||
/// Caller is responsible for ensuring that the index is within the bounds of the array | ||
pub unsafe fn value_unchecked(&self, i: usize) -> &T::Native { | ||
|
@@ -304,6 +308,10 @@ impl<T: ByteArrayType> GenericByteArray<T> { | |
} | ||
|
||
/// Returns the element at index `i` | ||
/// | ||
/// Note: This method does not check for nulls and the value is arbitrary | ||
/// (but still well-defined) if [`is_null`](Self::is_null) returns true for the index. | ||
/// | ||
/// # Panics | ||
/// Panics if index `i` is out of bounds. | ||
pub fn value(&self, i: usize) -> &T::Native { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -243,6 +243,12 @@ impl FixedSizeListArray { | |
} | ||
|
||
/// Returns ith value of this list array. | ||
/// | ||
/// Note: This method does not check for nulls and the value is arbitrary | ||
/// (but still well-defined) if [`is_null`](Self::is_null) returns true for the index. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
should this be construed as meaning the returned value is of size L, if self is a FixedSizeList(L)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
/// | ||
/// # Panics | ||
/// Panics if index `i` is out of bounds | ||
pub fn value(&self, i: usize) -> ArrayRef { | ||
self.values | ||
.slice(self.value_offset_at(i), self.value_length() as usize) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and in other places, is it guaranteed not to panic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it is guaranteed not to panic.