Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
0466f0d0e636893103dc60277eafc2f2cf66068071185f25216ee6d7b266b956a1eeb17a8b85e5d05d6366e3fe2724057d4ce3473e85e9e3File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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.
Uh oh!There was an error while loading. Please reload this page. | ||||
| 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. ContributorAuthor 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.
Uh oh!There was an error while loading. Please reload this page. | ||||
| memory_pool=memory_pool, | ||||
| fragment_scan_options=fragment_scan_options) | ||||
| scanner = GetResultValue(builder.get().Finish()) | ||||
Uh oh!
There was an error while loading. Please reload this page.