-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-5494: [Python] Create FileSystem bindings #5258
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
Closed
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
1a4e031
local file system
kszucs a6a6243
pathlib
kszucs cd21741
remove comment
kszucs fd0b4ca
flake8
kszucs 5de8881
mtime
kszucs cc25721
inlining
kszucs e812dca
docstrings
kszucs 74598eb
python2
kszucs b73300c
write bytes in the test case
kszucs 545a2c6
move to internal namespace
kszucs e24a036
raise on invalid path
kszucs cd8b387
ARROW_PYTHON_EXPORT
kszucs 8ba3c60
don't export
kszucs 299c702
use internal namespace
kszucs 76993d2
review comments
kszucs 43c12bc
review comments
kszucs 962c346
revert FindClangTools
kszucs 0baf5ee
convert string paths to posix too; don't accept bytes paths
kszucs 88409ed
remove comment
kszucs d898b06
io.pxi docstring
kszucs abc51ab
clang-format; use posix-style path as basepath for SubTreeFileSystem
kszucs 0939d97
int enum
kszucs de75cb5
remove pathlib dependency
kszucs 4c794a3
explain Selector.base_dir; a couple of additional tests
kszucs 4ae9951
remove default value from selector; test relative paths
kszucs fadf3a4
typo
kszucs 19a44ad
include symlinks and hidden files in the test glob
kszucs 787eaf4
use PurePosixPath
kszucs a391016
move out PyDateTime_IMPORT
kszucs 9c90de5
use slash delimited paths everywhere in the tests
kszucs ab803e3
windows
kszucs 58ce6d1
repr
kszucs cf066da
try to fix appveyor test
kszucs ea3a488
flake8
kszucs a7798f5
don't accept pathlib.Paths objects
kszucs 9b66277
flake8
kszucs 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| #ifndef ARROW_FILESYSTEM_API_H | ||
| #define ARROW_FILESYSTEM_API_H | ||
|
|
||
| #include "arrow/filesystem/filesystem.h" // IWYU pragma: export | ||
| #include "arrow/filesystem/localfs.h" // IWYU pragma: export | ||
| #include "arrow/filesystem/mockfs.h" // IWYU pragma: export | ||
| #include "arrow/filesystem/s3fs.h" // IWYU pragma: export | ||
|
|
||
| #endif // ARROW_FILESYSTEM_API_H |
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
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 |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| #ifndef PYARROW_UTIL_DATETIME_H | ||
| #define PYARROW_UTIL_DATETIME_H | ||
|
|
||
| #include <algorithm> | ||
| #include <chrono> | ||
|
|
||
| #include "arrow/python/platform.h" | ||
| #include "arrow/python/visibility.h" | ||
| #include "arrow/status.h" | ||
| #include "arrow/type.h" | ||
| #include "arrow/util/logging.h" | ||
|
|
||
| namespace arrow { | ||
| namespace py { | ||
| namespace internal { | ||
|
|
||
| ARROW_PYTHON_EXPORT | ||
| inline int64_t PyTime_to_us(PyObject* pytime) { | ||
| return (static_cast<int64_t>(PyDateTime_TIME_GET_HOUR(pytime)) * 3600000000LL + | ||
| static_cast<int64_t>(PyDateTime_TIME_GET_MINUTE(pytime)) * 60000000LL + | ||
| static_cast<int64_t>(PyDateTime_TIME_GET_SECOND(pytime)) * 1000000LL + | ||
| PyDateTime_TIME_GET_MICROSECOND(pytime)); | ||
| } | ||
|
|
||
| ARROW_PYTHON_EXPORT | ||
| inline int64_t PyTime_to_s(PyObject* pytime) { return PyTime_to_us(pytime) / 1000000; } | ||
kszucs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ARROW_PYTHON_EXPORT | ||
| inline int64_t PyTime_to_ms(PyObject* pytime) { return PyTime_to_us(pytime) / 1000; } | ||
|
|
||
| ARROW_PYTHON_EXPORT | ||
| inline int64_t PyTime_to_ns(PyObject* pytime) { return PyTime_to_us(pytime) * 1000; } | ||
|
|
||
| ARROW_PYTHON_EXPORT | ||
| Status PyTime_from_int(int64_t val, const TimeUnit::type unit, PyObject** out); | ||
|
|
||
| ARROW_PYTHON_EXPORT | ||
| Status PyDate_from_int(int64_t val, const DateUnit unit, PyObject** out); | ||
|
|
||
| ARROW_PYTHON_EXPORT | ||
| Status PyDateTime_from_int(int64_t val, const TimeUnit::type unit, PyObject** out); | ||
|
|
||
| using TimePoint = | ||
| std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>; | ||
|
|
||
| ARROW_PYTHON_EXPORT | ||
| Status PyDateTime_from_TimePoint(TimePoint val, PyObject** out); | ||
|
|
||
| ARROW_PYTHON_EXPORT | ||
| int64_t PyDate_to_days(PyDateTime_Date* pydate); | ||
|
|
||
| ARROW_PYTHON_EXPORT | ||
| inline int64_t PyDate_to_ms(PyDateTime_Date* pydate) { | ||
| return PyDate_to_days(pydate) * 24 * 3600 * 1000; | ||
| } | ||
|
|
||
| ARROW_PYTHON_EXPORT | ||
| inline int64_t PyDateTime_to_s(PyDateTime_DateTime* pydatetime) { | ||
| int64_t total_seconds = 0; | ||
| total_seconds += PyDateTime_DATE_GET_SECOND(pydatetime); | ||
| total_seconds += PyDateTime_DATE_GET_MINUTE(pydatetime) * 60; | ||
| total_seconds += PyDateTime_DATE_GET_HOUR(pydatetime) * 3600; | ||
|
|
||
| return total_seconds + | ||
| (PyDate_to_ms(reinterpret_cast<PyDateTime_Date*>(pydatetime)) / 1000LL); | ||
| } | ||
|
|
||
| ARROW_PYTHON_EXPORT | ||
| inline int64_t PyDateTime_to_ms(PyDateTime_DateTime* pydatetime) { | ||
| int64_t date_ms = PyDateTime_to_s(pydatetime) * 1000; | ||
| int ms = PyDateTime_DATE_GET_MICROSECOND(pydatetime) / 1000; | ||
| return date_ms + ms; | ||
| } | ||
|
|
||
| ARROW_PYTHON_EXPORT | ||
| inline int64_t PyDateTime_to_us(PyDateTime_DateTime* pydatetime) { | ||
| int64_t ms = PyDateTime_to_s(pydatetime) * 1000; | ||
| int us = PyDateTime_DATE_GET_MICROSECOND(pydatetime); | ||
| return ms * 1000 + us; | ||
| } | ||
|
|
||
| ARROW_PYTHON_EXPORT | ||
| inline int64_t PyDateTime_to_ns(PyDateTime_DateTime* pydatetime) { | ||
| return PyDateTime_to_us(pydatetime) * 1000; | ||
| } | ||
|
|
||
| } // namespace internal | ||
| } // namespace py | ||
| } // namespace arrow | ||
|
|
||
| #endif // PYARROW_UTIL_DATETIME_H | ||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pitrou this is the outermost I can move
PyDateTime_IMPORT, otherwise its call inFileStats.mtimesegfaults. Removed the import from the other functions, andPyDateTime_from_TimePointis only used from the_fs.pyx, so it should not be that expensive.