Skip to content

Commit 69e5e5f

Browse files
authored
Minor: improve filter documentation (#6317)
* Minor: improve filter documentation * less space
1 parent 1336973 commit 69e5e5f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

arrow-select/src/filter.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ pub fn prep_null_mask_filter(filter: &BooleanArray) -> BooleanArray {
153153
BooleanArray::new(mask, None)
154154
}
155155

156-
/// Filters an [Array], returning elements matching the filter (i.e. where the values are true).
156+
/// Returns a filtered `values` [Array] where the corresponding elements of
157+
/// `predicate` are `true`.
158+
///
159+
/// See also [`FilterBuilder`] for more control over the filtering process.
157160
///
158161
/// # Example
159162
/// ```rust
@@ -170,14 +173,18 @@ pub fn filter(values: &dyn Array, predicate: &BooleanArray) -> Result<ArrayRef,
170173
filter_array(values, &predicate)
171174
}
172175

173-
/// Returns a new [RecordBatch] with arrays containing only values matching the filter.
176+
/// Returns a filtered [RecordBatch] where the corresponding elements of
177+
/// `predicate` are true.
178+
///
179+
/// This is the equivalent of calling [filter] on each column of the [RecordBatch].
174180
pub fn filter_record_batch(
175181
record_batch: &RecordBatch,
176182
predicate: &BooleanArray,
177183
) -> Result<RecordBatch, ArrowError> {
178184
let mut filter_builder = FilterBuilder::new(predicate);
179185
if record_batch.num_columns() > 1 {
180186
// Only optimize if filtering more than one column
187+
// Otherwise, the overhead of optimization can be more than the benefit
181188
filter_builder = filter_builder.optimize();
182189
}
183190
let filter = filter_builder.build();

0 commit comments

Comments
 (0)