Uh oh!
There was an error while loading. Please reload this page.
ARROW-12231: [C++][Python][Dataset] Isolate one-shot data to scanner - #10070
ARROW-12231: [C++][Python][Dataset] Isolate one-shot data to scanner#10070lidavidm wants to merge 4 commits into
Conversation
lidavidm
commented
Apr 16, 2021
CC @westonpace |
westonpace
commented
Apr 16, 2021
It's a pity, if we were not crossing languages I think we could require as input an iterable (something that can be invoked to generate a (potentially one-shot) iterator) instead of an iterator and then wouldn't have to have this distinction. This looks good but do we want to open a second JIRA for the post-12289 follow-up or just wait and do that work in this JIRA later? |
lidavidm
commented
Apr 16, 2021
If the other side is something like a Flight stream, then I think we'd still have the distinction, unfortunately. I am happy to wait until we have AsyncScanner merged and then I can update this. |
westonpace
commented
Apr 16, 2021
How would a flight stream even work with the datasets API? What would fragments be? How would it know when the file is ended? I think I need to fit this into my mental model. |
lidavidm
commented
Apr 16, 2021
Sorry, so this was originally added to support writing data from a generator - which could be something like a Flight stream (=record batch reader). But writing data in Datasets consumes a scanner, so you end up having to support one-shot datasets. I agree supporting reading data from Flight is an entirely different manner and would be modeled differently (presumably, as an iterable, as you suggest, corresponding to an RPC with a fixed set of parameters). |
westonpace
commented
Apr 16, 2021
Ah, that's right. And for the writing from memory case we want to free up the memory after we write it so an iterable would be out of the question. |
westonpace
commented
Apr 16, 2021
Hmm...maybe streaming isn't the most intuitive name then. Technically all the file-based datasets are "streaming". If a user was copying a dataset for example we would stream the data a few batches at a time. Should we just use SingleShotDataset? |
lidavidm
commented
Apr 16, 2021
Sounds good to me. |
lidavidm
commented
Apr 21, 2021
Rebased to pick up ARROW-12289; now OneShotDataset uses its own Fragment implementation so that ScanBatchesAsync uses a background thread, to avoid blocking in the async scanner. |
lidavidm
commented
Apr 27, 2021
@westonpace do you want to look over the ScanBatchesAsync implementation here? |
b0a97ec to
f1106c2Comparebkietz
commented
May 4, 2021
To me, this seems less like a subclass of dataset and more like a subclass of Scanner: IMHO it's not intuitive that a dataset would ever be single-shot. Instead, I think it'd make more sense to add |
westonpace
commented
May 4, 2021
I'm not sure I agree. I agree with "it's not intuitive that a dataset would ever be single-shot". I don't agree that it makes any more sense for Scanner to be single-shot. I think the core non-intuitive piece is the concept of a "one-shot iterable". In my mental model: So Scanner is just a "map" function which is generally (Python being the exception) reusable. Perhaps I will revisit my original suggestion of having the input to dataset be an iterable ( Although that takes us back pretty close to where we started 😬 |
lidavidm
commented
May 5, 2021
I think you could argue that Fragment is just Or put another way, if we limit the one-shotness to the Scanner, then we can hide the odd nonconforming Dataset/Fragment from the public API. |
westonpace
commented
May 5, 2021
So this would be a scanner that doesn't use fragments or datasets at all? Then would the python API change? Right now they pass batches/tables to the So this change would be creating a scanner directly from a table/batches and bypassing the creation of a "dataset" entirely? I think that makes a lot of sense. |
lidavidm
commented
May 5, 2021
Right (though the implementation would just be a SyncScanner wrapping a OneShotFragment). In fact, Joris already refactored the Python side to have |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| DCHECK_OK(Filter(scan_options_->filter)); | ||
| } | ||
| class ARROW_DS_EXPORT OneShotScanTask : public ScanTask { |
There was a problem hiding this comment.
Instead of exporting these, I think we can keep them in an anonymous namespace
westonpace
left a comment
There was a problem hiding this comment.
Ok, I like this latest approach. Right now there is a fallback in AsyncScanner::Finish to always use the sync scanner if creating a scanner from a fragment because I wasn't sure if wanted to keep the API. This uses that API so I created ARROW-12664 which I'll add soon.
jorisvandenbossche
commented
May 6, 2021
LGTM, the |
This isolates the one-shot portion of InMemoryDataset to Scanner, so that it more clearly is used only for writing data from a source that cannot be re-read.