API, Core: Use Supplier for FileIO on Scan#15646
Conversation
| @Override | ||
| public FileIO io() { | ||
| return table.io(); | ||
| public Supplier<FileIO> io() { |
There was a problem hiding this comment.
e87053c to
a7e24f2
Compare
| return scanFileIO; | ||
| public Supplier<FileIO> fileIO() { | ||
| return () -> { | ||
| Preconditions.checkState( |
There was a problem hiding this comment.
@rdblue we could consider removing this check, wdyt?
There was a problem hiding this comment.
I do feel like there's an argument that we should still keep the check. The Supplier return type indicates to a caller that they need to think about when to invoke get but if the caller does invoke get prematurely, I think it's best to throw rather than return null.
amogh-jahagirdar
left a comment
There was a problem hiding this comment.
This looks good to me, thank you @nastra
| return scanFileIO; | ||
| public Supplier<FileIO> fileIO() { | ||
| return () -> { | ||
| Preconditions.checkState( |
There was a problem hiding this comment.
I do feel like there's an argument that we should still keep the check. The Supplier return type indicates to a caller that they need to think about when to invoke get but if the caller does invoke get prematurely, I think it's best to throw rather than return null.
This PR refactors the Scan API to return
Supplier<FileIO>instead of a directFileIOinstance, enabling lazy/deferred initialization of theFileIO. The motivation is to accommodate cases (e.g., REST scans) whereFileIOmay not be immediately available at scan construction time.