Fokko commented on code in PR #5747:
URL: https://github.com/apache/iceberg/pull/5747#discussion_r969814395
##########
python/pyiceberg/io/pyarrow.py:
##########
@@ -164,7 +163,27 @@ def to_input_file(self) -> "PyArrowFile":
return self
+
class PyArrowFileIO(FileIO):
+
+ def __init__(self, properties: Properties = {}):
+ self.get_fs_and_path: Callable = lru_cache(self._get_fs_and_path)
+ super().__init__(properties=properties)
+
+ def _get_fs_and_path(self, location: str) -> (FileSystem, str):
+ uri = urlparse(location) # Create a ParseResult from the URI
+ if not uri.scheme: # If no scheme, assume the path is to a local file
+ return FileSystem.from_uri(os.path.abspath(location))
+ elif uri.scheme in ['s3', 's3a', 's3n']:
Review Comment:
You're right on the performance:
```python
➜ iceberg git:(fd-add-docs) ✗ python3
Python 3.10.6 (main, Aug 30 2022, 04:58:14) [Clang 13.1.6
(clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> f_set = f"""
... 's3a' in {'s3', 's3a', 's3n'}
... """
>>>
>>> f_list = f"""
... 's3a' in ['s3', 's3a', 's3n']
... """
>>>
>>> iters = 100000000
>>>
>>> import timeit
>>>
>>> print(f"Set: {timeit.timeit(stmt=f_set, number=iters)}")
print(f"List: {timeit.timeit(stmt=f_list, number=iters)}")
Set: 1.4491868750010326
>>> print(f"List: {timeit.timeit(stmt=f_list, number=iters)}")
List: 1.4320723749988247
```
For me it makes sense to convert it into a set because they elements are
unique and there is no explicit sorting and therefore it makes more sense (to
me) to convert it into a set.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]