-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-17299: [C++][Python] Expose the Scanner kDefaultBatchReadahead and kDefaultFragmentReadahead parameters #13799
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0466f0d
implemented exposing flags
marsupialtail 0e63689
fix typo
marsupialtail 3103dc6
updated docs
marsupialtail 0277eaf
addressed suggestions
marsupialtail c2f2cf6
Update cpp/src/arrow/dataset/scanner.h
marsupialtail 6068071
Update cpp/src/arrow/dataset/scanner.h
marsupialtail 185f252
Update python/pyarrow/_dataset.pyx
marsupialtail 16ee6d7
Update python/pyarrow/_dataset.pyx
marsupialtail b266b95
Update python/pyarrow/_dataset.pyx
marsupialtail 6a1eeb1
Update python/pyarrow/_dataset.pyx
marsupialtail 7a8b85e
Update cpp/src/arrow/dataset/scanner.h
marsupialtail 5d05d63
added a very simple test
marsupialtail 66e3fe2
Update cpp/src/arrow/dataset/scanner.h
marsupialtail 724057d
Merge branch 'JIRA-17299' of https://github.com/marsupialtail/arrow i…
marsupialtail 4ce3473
try again
marsupialtail e85e9e3
now it works
marsupialtail File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -2168,11 +2168,14 @@ cdef class TaggedRecordBatchIterator(_Weakrefable): | |||
|
|
||||
|
|
||||
| _DEFAULT_BATCH_SIZE = 2**17 | ||||
|
|
||||
| _DEFAULT_BATCH_READAHEAD = 16 | ||||
| _DEFAULT_FRAGMENT_READAHEAD = 4 | ||||
|
|
||||
| cdef void _populate_builder(const shared_ptr[CScannerBuilder]& ptr, | ||||
| object columns=None, Expression filter=None, | ||||
| int batch_size=_DEFAULT_BATCH_SIZE, | ||||
| int batch_readahead=_DEFAULT_BATCH_READAHEAD, | ||||
| int fragment_readahead=_DEFAULT_FRAGMENT_READAHEAD, | ||||
| bint use_threads=True, MemoryPool memory_pool=None, | ||||
| FragmentScanOptions fragment_scan_options=None)\ | ||||
| except *: | ||||
|
|
@@ -2207,6 +2210,8 @@ cdef void _populate_builder(const shared_ptr[CScannerBuilder]& ptr, | |||
| ) | ||||
|
|
||||
| check_status(builder.BatchSize(batch_size)) | ||||
| check_status(builder.BatchReadahead(batch_readahead)) | ||||
| check_status(builder.FragmentReadahead(fragment_readahead)) | ||||
| check_status(builder.UseThreads(use_threads)) | ||||
| if memory_pool: | ||||
| check_status(builder.Pool(maybe_unbox_memory_pool(memory_pool))) | ||||
|
|
@@ -2254,6 +2259,12 @@ cdef class Scanner(_Weakrefable): | |||
| The maximum row count for scanned record batches. If scanned | ||||
| record batches are overflowing memory then this method can be | ||||
| called to reduce their size. | ||||
| batch_readahead : int, default 16 | ||||
| The number of batches to read ahead in a file. Increasing this number | ||||
| will increase RAM usage but could also improve IO utilization. | ||||
| fragment_readahead : int, default 4 | ||||
| The number of files to read ahead. Increasing this number will increase | ||||
| RAM usage but could also improve IO utilization. | ||||
marsupialtail marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
| use_threads : bool, default True | ||||
| If enabled, then maximum parallelism will be used determined by | ||||
| the number of available CPU cores. | ||||
|
|
@@ -2291,6 +2302,8 @@ cdef class Scanner(_Weakrefable): | |||
| MemoryPool memory_pool=None, | ||||
| object columns=None, Expression filter=None, | ||||
| int batch_size=_DEFAULT_BATCH_SIZE, | ||||
| int batch_readahead=_DEFAULT_BATCH_READAHEAD, | ||||
| int fragment_readahead=_DEFAULT_FRAGMENT_READAHEAD, | ||||
| FragmentScanOptions fragment_scan_options=None): | ||||
| """ | ||||
| Create Scanner from Dataset, | ||||
|
|
@@ -2328,6 +2341,13 @@ cdef class Scanner(_Weakrefable): | |||
| The maximum row count for scanned record batches. If scanned | ||||
| record batches are overflowing memory then this method can be | ||||
| called to reduce their size. | ||||
| batch_readahead : int, default 16 | ||||
| The number of batches to read ahead in a file. This might not work | ||||
| for all file formats. Increasing this number will increase | ||||
| RAM usage but could also improve IO utilization. | ||||
| fragment_readahead : int, default 4 | ||||
| The number of files to read ahead. Increasing this number will increase | ||||
| RAM usage but could also improve IO utilization. | ||||
| use_threads : bool, default True | ||||
| If enabled, then maximum parallelism will be used determined by | ||||
| the number of available CPU cores. | ||||
|
|
@@ -2354,7 +2374,8 @@ cdef class Scanner(_Weakrefable): | |||
|
|
||||
| builder = make_shared[CScannerBuilder](dataset.unwrap(), options) | ||||
| _populate_builder(builder, columns=columns, filter=filter, | ||||
| batch_size=batch_size, use_threads=use_threads, | ||||
| batch_size=batch_size, batch_readahead=batch_readahead, | ||||
| fragment_readahead=fragment_readahead, use_threads=use_threads, | ||||
| memory_pool=memory_pool, | ||||
| fragment_scan_options=fragment_scan_options) | ||||
|
|
||||
|
|
@@ -2367,6 +2388,7 @@ cdef class Scanner(_Weakrefable): | |||
| MemoryPool memory_pool=None, | ||||
| object columns=None, Expression filter=None, | ||||
| int batch_size=_DEFAULT_BATCH_SIZE, | ||||
| int batch_readahead=_DEFAULT_BATCH_READAHEAD, | ||||
| FragmentScanOptions fragment_scan_options=None): | ||||
| """ | ||||
| Create Scanner from Fragment, | ||||
|
|
@@ -2406,6 +2428,10 @@ cdef class Scanner(_Weakrefable): | |||
| The maximum row count for scanned record batches. If scanned | ||||
| record batches are overflowing memory then this method can be | ||||
| called to reduce their size. | ||||
| batch_readahead : int, default 16 | ||||
| The number of batches to read ahead in a file. This might not work | ||||
| for all file formats. Increasing this number will increase | ||||
| RAM usage but could also improve IO utilization. | ||||
| use_threads : bool, default True | ||||
| If enabled, then maximum parallelism will be used determined by | ||||
| the number of available CPU cores. | ||||
|
|
@@ -2435,7 +2461,9 @@ cdef class Scanner(_Weakrefable): | |||
| builder = make_shared[CScannerBuilder](pyarrow_unwrap_schema(schema), | ||||
| fragment.unwrap(), options) | ||||
| _populate_builder(builder, columns=columns, filter=filter, | ||||
| batch_size=batch_size, use_threads=use_threads, | ||||
| batch_size=batch_size, batch_readahead=batch_readahead, | ||||
| fragment_readahead=_DEFAULT_FRAGMENT_READAHEAD, | ||||
|
Member
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.
Suggested change
I don't think we need to specify this kwarg if we're just going to specify the default.
Contributor
Author
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. This is a Cython quirk. You have to specify all the arguments. |
||||
| use_threads=use_threads, | ||||
| memory_pool=memory_pool, | ||||
| fragment_scan_options=fragment_scan_options) | ||||
|
|
||||
|
|
@@ -2508,7 +2536,8 @@ cdef class Scanner(_Weakrefable): | |||
| FutureWarning) | ||||
|
|
||||
| _populate_builder(builder, columns=columns, filter=filter, | ||||
| batch_size=batch_size, use_threads=use_threads, | ||||
| batch_size=batch_size, batch_readahead=_DEFAULT_BATCH_READAHEAD, | ||||
| fragment_readahead=_DEFAULT_FRAGMENT_READAHEAD, use_threads=use_threads, | ||||
marsupialtail marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
| memory_pool=memory_pool, | ||||
| fragment_scan_options=fragment_scan_options) | ||||
| scanner = GetResultValue(builder.get().Finish()) | ||||
|
|
||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.