Skip to content

Commit 2cec1aa

Browse files
committed
fix
1 parent 399a445 commit 2cec1aa

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

src/array_decoder/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use crate::error::{
4040
use crate::proto::stream::Kind;
4141
use crate::schema::DataType;
4242
use crate::stripe::Stripe;
43+
use crate::RowSelection;
4344

4445
use self::decimal::new_decimal_decoder;
4546
use self::list::ListArrayDecoder;
@@ -238,7 +239,7 @@ pub struct NaiveStripeDecoder {
238239
index: usize,
239240
batch_size: usize,
240241
number_of_rows: usize,
241-
row_selection: Option<crate::row_selection::RowSelection>,
242+
row_selection: Option<RowSelection>,
242243
selection_index: usize,
243244
}
244245

@@ -251,18 +252,16 @@ impl Iterator for NaiveStripeDecoder {
251252
if self.row_selection.is_some() {
252253
// Process selectors until we find rows to select or exhaust the selection
253254
loop {
254-
let selector_info = {
255-
let selection = self.row_selection.as_ref().unwrap();
256-
let selectors = selection.selectors();
255+
let (is_skip, row_count) = {
256+
// Safety: this has been checked above
257+
let selectors = self.row_selection.as_ref().unwrap().selectors();
257258
if self.selection_index >= selectors.len() {
258259
return None;
259260
}
260261
let selector = selectors[self.selection_index];
261262
(selector.skip, selector.row_count)
262263
};
263264

264-
let (is_skip, row_count) = selector_info;
265-
266265
if is_skip {
267266
// Skip these rows by advancing the index
268267
self.index += row_count;
@@ -492,7 +491,7 @@ impl NaiveStripeDecoder {
492491
stripe: Stripe,
493492
schema_ref: SchemaRef,
494493
batch_size: usize,
495-
row_selection: Option<crate::row_selection::RowSelection>,
494+
row_selection: Option<RowSelection>,
496495
) -> Result<Self> {
497496
let number_of_rows = stripe.number_of_rows();
498497
let decoders = stripe

tests/row_selection/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//
99
// http://www.apache.org/licenses/LICENSE-2.0
1010
//
11-
// Unless required by applicable law or agreed to in writing,
11+
// Unless required by applicable law or agreed to in writing,
1212
// software distributed under the License is distributed on an
1313
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1414
// KIND, either express or implied. See the License for the

0 commit comments

Comments
 (0)