Skip to content

Commit cdd15b8

Browse files
authored
Expose ReadPlan and ReadPlanBuilder (#8399)
# Which issue does this PR close? We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. - Closes #8347 . # Rationale for this change Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. # What changes are included in this PR? Expose relevant structs and methods for `ReadPlan` and `ReadPlanBuilder` which can be used to build customized reader. # Are these changes tested? We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? # Are there any user-facing changes? Yes. Now `ReadPlanBuilder`, `ReadPlan` and relevant methods are exposed. Signed-off-by: Ben Ye <[email protected]>
1 parent 78ab9d7 commit cdd15b8

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

parquet/src/arrow/arrow_reader/read_plan.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,30 @@ use std::collections::VecDeque;
2929

3030
/// A builder for [`ReadPlan`]
3131
#[derive(Clone)]
32-
pub(crate) struct ReadPlanBuilder {
32+
pub struct ReadPlanBuilder {
3333
batch_size: usize,
3434
/// Current to apply, includes all filters
3535
selection: Option<RowSelection>,
3636
}
3737

3838
impl ReadPlanBuilder {
3939
/// Create a `ReadPlanBuilder` with the given batch size
40-
pub(crate) fn new(batch_size: usize) -> Self {
40+
pub fn new(batch_size: usize) -> Self {
4141
Self {
4242
batch_size,
4343
selection: None,
4444
}
4545
}
4646

4747
/// Set the current selection to the given value
48-
pub(crate) fn with_selection(mut self, selection: Option<RowSelection>) -> Self {
48+
pub fn with_selection(mut self, selection: Option<RowSelection>) -> Self {
4949
self.selection = selection;
5050
self
5151
}
5252

5353
/// Returns the current selection, if any
5454
#[cfg(feature = "async")]
55-
pub(crate) fn selection(&self) -> Option<&RowSelection> {
55+
pub fn selection(&self) -> Option<&RowSelection> {
5656
self.selection.as_ref()
5757
}
5858

@@ -68,7 +68,7 @@ impl ReadPlanBuilder {
6868
}
6969

7070
/// Returns true if the current plan selects any rows
71-
pub(crate) fn selects_any(&self) -> bool {
71+
pub fn selects_any(&self) -> bool {
7272
self.selection
7373
.as_ref()
7474
.map(|s| s.selects_any())
@@ -77,7 +77,7 @@ impl ReadPlanBuilder {
7777

7878
/// Returns the number of rows selected, or `None` if all rows are selected.
7979
#[cfg(feature = "async")]
80-
pub(crate) fn num_rows_selected(&self) -> Option<usize> {
80+
pub fn num_rows_selected(&self) -> Option<usize> {
8181
self.selection.as_ref().map(|s| s.row_count())
8282
}
8383

@@ -90,7 +90,7 @@ impl ReadPlanBuilder {
9090
/// Note: pre-existing selections may come from evaluating a previous predicate
9191
/// or if the [`ParquetRecordBatchReader`] specified an explicit
9292
/// [`RowSelection`] in addition to one or more predicates.
93-
pub(crate) fn with_predicate(
93+
pub fn with_predicate(
9494
mut self,
9595
array_reader: Box<dyn ArrayReader>,
9696
predicate: &mut dyn ArrowPredicate,
@@ -123,7 +123,7 @@ impl ReadPlanBuilder {
123123
}
124124

125125
/// Create a final `ReadPlan` the read plan for the scan
126-
pub(crate) fn build(mut self) -> ReadPlan {
126+
pub fn build(mut self) -> ReadPlan {
127127
// If selection is empty, truncate
128128
if !self.selects_any() {
129129
self.selection = Some(RowSelection::from(vec![]));
@@ -230,7 +230,7 @@ impl LimitedReadPlanBuilder {
230230
/// A plan reading specific rows from a Parquet Row Group.
231231
///
232232
/// See [`ReadPlanBuilder`] to create `ReadPlan`s
233-
pub(crate) struct ReadPlan {
233+
pub struct ReadPlan {
234234
/// The number of rows to read in each batch
235235
batch_size: usize,
236236
/// Row ranges to be selected from the data source
@@ -239,7 +239,7 @@ pub(crate) struct ReadPlan {
239239

240240
impl ReadPlan {
241241
/// Returns a mutable reference to the selection, if any
242-
pub(crate) fn selection_mut(&mut self) -> Option<&mut VecDeque<RowSelector>> {
242+
pub fn selection_mut(&mut self) -> Option<&mut VecDeque<RowSelector>> {
243243
self.selection.as_mut()
244244
}
245245

0 commit comments

Comments
 (0)