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-12428: [Python] Expose pre_buffer in pyarrow.parquet#10074
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
Closed
Uh oh!
There was an error while loading. Please reload this page.
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -209,13 +209,18 @@ class ParquetFile: | ||
| buffer_size : int, default 0 | ||
| If positive, perform read buffering when deserializing individual | ||
| column chunks. Otherwise IO calls are unbuffered. | ||
| pre_buffer : bool, default False | ||
| Coalesce and issue file reads in parallel to improve performance on | ||
| high-latency filesystems (e.g. S3). If True, Arrow will use a | ||
| background I/O thread pool. | ||
| """ | ||
| def __init__(self, source, metadata=None, common_metadata=None, | ||
| read_dictionary=None, memory_map=False, buffer_size=0): | ||
| read_dictionary=None, memory_map=False, buffer_size=0, | ||
| pre_buffer=False): | ||
| self.reader = ParquetReader() | ||
| self.reader.open(source, use_memory_map=memory_map, | ||
| buffer_size=buffer_size, | ||
| buffer_size=buffer_size, pre_buffer=pre_buffer, | ||
| read_dictionary=read_dictionary, metadata=metadata) | ||
| self.common_metadata = common_metadata | ||
| self._nested_paths_by_prefix = self._build_nested_paths() | ||
| @@ -1212,13 +1217,20 @@ class ParquetDataset: | ||
| new Arrow Dataset API). Among other things, this allows to pass | ||
| `filters` for all columns and not only the partition keys, enables | ||
| different partitioning schemes, etc. | ||
| pre_buffer : bool, default True | ||
| Coalesce and issue file reads in parallel to improve performance on | ||
| high-latency filesystems (e.g. S3). If True, Arrow will use a | ||
| background I/O thread pool. This option is only supported for | ||
| use_legacy_dataset=False. If using a filesystem layer that itself | ||
| performs readahead (e.g. fsspec's S3FS), disable readahead for best | ||
| results. | ||
| """.format(_read_docstring_common, _DNF_filter_doc) | ||
| def __new__(cls, path_or_paths=None, filesystem=None, schema=None, | ||
| metadata=None, split_row_groups=False, validate_schema=True, | ||
| filters=None, metadata_nthreads=1, read_dictionary=None, | ||
| memory_map=False, buffer_size=0, partitioning="hive", | ||
| use_legacy_dataset=None): | ||
| use_legacy_dataset=None, pre_buffer=True): | ||
| if use_legacy_dataset is None: | ||
| # if a new filesystem is passed -> default to new implementation | ||
| if isinstance(filesystem, FileSystem): | ||
| @@ -1234,6 +1246,7 @@ def __new__(cls, path_or_paths=None, filesystem=None, schema=None, | ||
| read_dictionary=read_dictionary, | ||
| memory_map=memory_map, | ||
| buffer_size=buffer_size, | ||
| pre_buffer=pre_buffer, | ||
| # unsupported keywords | ||
| schema=schema, metadata=metadata, | ||
| split_row_groups=split_row_groups, | ||
| @@ -1246,7 +1259,7 @@ def __init__(self, path_or_paths, filesystem=None, schema=None, | ||
| metadata=None, split_row_groups=False, validate_schema=True, | ||
| filters=None, metadata_nthreads=1, read_dictionary=None, | ||
| memory_map=False, buffer_size=0, partitioning="hive", | ||
| use_legacy_dataset=True): | ||
| use_legacy_dataset=True, pre_buffer=True): | ||
| if partitioning != "hive": | ||
| raise ValueError( | ||
| 'Only "hive" for hive-like partitioning is supported when ' | ||
| @@ -1480,7 +1493,8 @@ class _ParquetDatasetV2: | ||
| def __init__(self, path_or_paths, filesystem=None, filters=None, | ||
| partitioning="hive", read_dictionary=None, buffer_size=None, | ||
| memory_map=False, ignore_prefixes=None, **kwargs): | ||
| memory_map=False, ignore_prefixes=None, pre_buffer=True, | ||
| **kwargs): | ||
| import pyarrow.dataset as ds | ||
| # Raise error for not supported keywords | ||
| @@ -1494,7 +1508,7 @@ def __init__(self, path_or_paths, filesystem=None, filters=None, | ||
| "Dataset API".format(keyword)) | ||
| # map format arguments | ||
| read_options = {} | ||
| read_options = {"pre_buffer": pre_buffer} | ||
| if buffer_size: | ||
| read_options.update(use_buffered_stream=True, | ||
| buffer_size=buffer_size) | ||
| @@ -1676,6 +1690,13 @@ def pieces(self): | ||
| keys and only a hive-style directory structure is supported. When | ||
| setting `use_legacy_dataset` to False, also within-file level filtering | ||
| and different partitioning schemes are supported. | ||
| pre_buffer : bool, default True | ||
| Coalesce and issue file reads in parallel to improve performance on | ||
jorisvandenbossche marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| high-latency filesystems (e.g. S3). If True, Arrow will use a | ||
| background I/O thread pool. This option is only supported for | ||
| use_legacy_dataset=False. If using a filesystem layer that itself | ||
| performs readahead (e.g. fsspec's S3FS), disable readahead for best | ||
| results. | ||
| {3} | ||
| @@ -1689,7 +1710,7 @@ def read_table(source, columns=None, use_threads=True, metadata=None, | ||
| use_pandas_metadata=False, memory_map=False, | ||
| read_dictionary=None, filesystem=None, filters=None, | ||
| buffer_size=0, partitioning="hive", use_legacy_dataset=False, | ||
| ignore_prefixes=None): | ||
| ignore_prefixes=None, pre_buffer=True): | ||
| if not use_legacy_dataset: | ||
| if metadata is not None: | ||
| raise ValueError( | ||
| @@ -1708,6 +1729,7 @@ def read_table(source, columns=None, use_threads=True, metadata=None, | ||
| buffer_size=buffer_size, | ||
| filters=filters, | ||
| ignore_prefixes=ignore_prefixes, | ||
| pre_buffer=pre_buffer, | ||
| ) | ||
| except ImportError: | ||
| # fall back on ParquetFile for simple cases when pyarrow.dataset | ||
| @@ -1728,7 +1750,8 @@ def read_table(source, columns=None, use_threads=True, metadata=None, | ||
| # TODO test that source is not a directory or a list | ||
| dataset = ParquetFile( | ||
| source, metadata=metadata, read_dictionary=read_dictionary, | ||
| memory_map=memory_map, buffer_size=buffer_size) | ||
| memory_map=memory_map, buffer_size=buffer_size, | ||
| pre_buffer=pre_buffer) | ||
| return dataset.read(columns=columns, use_threads=use_threads, | ||
| use_pandas_metadata=use_pandas_metadata) | ||
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
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.