You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/08/08 04:49:29 UTC
[GitHub] [arrow-rs] Ted-Jiang opened a new pull request, #2359: Combine multiple selections into the same batch size in skip_records
Ted-Jiang opened a new pull request, #2359:
URL: https://github.com/apache/arrow-rs/pull/2359
# Which issue does this PR close?
Closes #2358 .
# 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?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!---
If there are any breaking changes to public APIs, please add the `breaking change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2359: Combine multiple selections into the same batch size in skip_records
Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2359:
URL: https://github.com/apache/arrow-rs/pull/2359#discussion_r939986090
##########
parquet/src/arrow/arrow_reader.rs:
##########
@@ -287,43 +287,59 @@ impl Iterator for ParquetRecordBatchReader {
type Item = ArrowResult<RecordBatch>;
fn next(&mut self) -> Option<Self::Item> {
- let to_read = match self.selection.as_mut() {
- Some(selection) => loop {
- let front = selection.pop_front()?;
- if front.skip {
- let skipped = match self.array_reader.skip_records(front.row_count) {
- Ok(skipped) => skipped,
- Err(e) => return Some(Err(e.into())),
- };
-
- if skipped != front.row_count {
- return Some(Err(general_err!(
- "failed to skip rows, expected {}, got {}",
- front.row_count,
- skipped
- )
- .into()));
+ let mut read_records = 0;
+ match self.selection.as_mut() {
+ Some(selection) => {
+ while read_records < self.batch_size && !selection.is_empty() {
+ let front = selection.pop_front()?;
Review Comment:
```suggestion
let front = selection.pop_front().unwrap();
```
##########
parquet/src/arrow/arrow_reader.rs:
##########
@@ -287,43 +287,59 @@ impl Iterator for ParquetRecordBatchReader {
type Item = ArrowResult<RecordBatch>;
fn next(&mut self) -> Option<Self::Item> {
- let to_read = match self.selection.as_mut() {
- Some(selection) => loop {
- let front = selection.pop_front()?;
- if front.skip {
- let skipped = match self.array_reader.skip_records(front.row_count) {
- Ok(skipped) => skipped,
- Err(e) => return Some(Err(e.into())),
- };
-
- if skipped != front.row_count {
- return Some(Err(general_err!(
- "failed to skip rows, expected {}, got {}",
- front.row_count,
- skipped
- )
- .into()));
+ let mut read_records = 0;
+ match self.selection.as_mut() {
+ Some(selection) => {
+ while read_records < self.batch_size && !selection.is_empty() {
+ let front = selection.pop_front()?;
+ if front.skip {
+ let skipped =
+ match self.array_reader.skip_records(front.row_count) {
+ Ok(skipped) => skipped,
+ Err(e) => return Some(Err(e.into())),
+ };
+
+ if skipped != front.row_count {
+ return Some(Err(general_err!(
+ "failed to skip rows, expected {}, got {}",
+ front.row_count,
+ skipped
+ )
+ .into()));
+ }
+ continue;
}
- continue;
- }
- // try to read record
- let to_read = match front.row_count.checked_sub(self.batch_size) {
- Some(remaining) if remaining != 0 => {
- // if page row count less than batch_size we must set batch size to page row count.
- // add check avoid dead loop
- selection.push_front(RowSelection::select(remaining));
- self.batch_size
+ // try to read record
+ let need_read = self.batch_size - read_records;
+ let to_read = match front.row_count.checked_sub(need_read) {
+ Some(remaining) if remaining != 0 => {
+ // if page row count less than batch_size we must set batch size to page row count.
+ // add check avoid dead loop
+ selection.push_front(RowSelection::select(remaining));
+ need_read
+ }
+ _ => front.row_count,
+ };
+ match self.array_reader.read_records(to_read) {
+ Ok(rec) if rec == 0 =>
+ // no more data in file, the last batch in this reader
+ {
+ break
+ }
Review Comment:
```suggestion
Ok(0) => break,
```
##########
parquet/src/arrow/record_reader/mod.rs:
##########
@@ -198,12 +198,6 @@ where
self.num_records += buffered_records;
self.num_values += buffered_values;
- self.consume_def_levels();
Review Comment:
This makes sense to me
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] Ted-Jiang commented on a diff in pull request #2359: Combine multiple selections into the same batch size in skip_records
Posted by GitBox <gi...@apache.org>.
Ted-Jiang commented on code in PR #2359:
URL: https://github.com/apache/arrow-rs/pull/2359#discussion_r939821838
##########
parquet/src/arrow/record_reader/mod.rs:
##########
@@ -198,12 +198,6 @@ where
self.num_records += buffered_records;
self.num_values += buffered_values;
- self.consume_def_levels();
Review Comment:
@tustvold FYI,
Sometimes like `batch_size` is = 20, when read 15 records without consume.
Then skip 50 records, finally read 5 records for one batch.
If we call these consume api during skip, we will lose the 15 records.
Do you think remove these is reasonable 🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] ursabot commented on pull request #2359: Combine multiple selections into the same batch size in skip_records
Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #2359:
URL: https://github.com/apache/arrow-rs/pull/2359#issuecomment-1207897724
Benchmark runs are scheduled for baseline = f3baeaab8340d5cbbb1334fa3c179b08151a9a91 and contender = ce2bd1efe61b0ac755e64021d99f6169203c8e54. ce2bd1efe61b0ac755e64021d99f6169203c8e54 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/4b6cbfcccaa1491d8be6bdb04dbe3380...f13b49826e5a4ceea5874d2b0c0471ec/)
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/6642c072f0b84e63a77ba4ea8a0002ac...89dd367f5df84146b96c3c610a7e67c6/)
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/728f3f0367e54d15b7d8f90ac3a8f88c...b75e6c51eade45c5b01a7f2c3347bbc9/)
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/b5ff845b9119479aa41df25edafded2f...62f91292d0264eb7b6d3b25b409bc9fc/)
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold merged pull request #2359: Combine multiple selections into the same batch size in skip_records
Posted by GitBox <gi...@apache.org>.
tustvold merged PR #2359:
URL: https://github.com/apache/arrow-rs/pull/2359
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org