Skip to content
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

Add to support byte input stream back by file #10717

Closed
wants to merge 1 commit into from

Conversation

xiaoxmeng
Copy link
Contributor

@xiaoxmeng xiaoxmeng commented Aug 12, 2024

Current spill leverage SpillInputStream to handle the byte stream read from spilled file. SpillInputStream is a
derived class from ByteInputStream and its implementation a bit hack as most of operations of ByteInputStream
doesn't apply for SpillInputStream as we don't support backward seek on a file for now. It just works for now.
It is better to split them and make a generic file based input stream which can be used in other cases as well.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 12, 2024
Copy link

netlify bot commented Aug 12, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 2449d86
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/66bd2a24b80bfd0008820d64

@facebook-github-bot
Copy link
Contributor

@xiaoxmeng has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@xiaoxmeng xiaoxmeng force-pushed the refactor branch 2 times, most recently from 964c912 to 66881bd Compare August 13, 2024 03:48
@facebook-github-bot
Copy link
Contributor

@xiaoxmeng has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@xiaoxmeng xiaoxmeng force-pushed the refactor branch 3 times, most recently from 70226dc to 4b9a815 Compare August 13, 2024 05:51
@facebook-github-bot
Copy link
Contributor

@xiaoxmeng has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@xiaoxmeng has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@xiaoxmeng xiaoxmeng force-pushed the refactor branch 2 times, most recently from 16c5812 to d94f51f Compare August 13, 2024 23:33
@facebook-github-bot
Copy link
Contributor

@xiaoxmeng has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@xiaoxmeng xiaoxmeng marked this pull request as ready for review August 13, 2024 23:37
@xiaoxmeng xiaoxmeng changed the title Add to support file back up byte input stream Add to support byte input stream back by file Aug 13, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D61148216

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Aug 14, 2024
Summary: Pull Request resolved: facebookincubator#10717

Differential Revision: D61148216

Pulled By: xiaoxmeng
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D61148216

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Aug 14, 2024
Summary: Pull Request resolved: facebookincubator#10717

Differential Revision: D61148216

Pulled By: xiaoxmeng
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D61148216

@@ -91,64 +94,29 @@ class OStreamOutputStream : public OutputStream {
std::ostream* out_;
};

/// Read-only stream over one or more byte buffers.
/// Read-only byte input stream interface.
class ByteInputStream {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move this base class to the base folder as it has both memory stream subclass BufferInputStream and file stream subclass FileInputStream?

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D61148216

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Aug 14, 2024
Summary:
Current spill leverage SpillInputStream to handle the byte stream read from spilled file. SpillInputStream is a
derived class from ByteInputStream and its implementation a bit hack as most of operations of ByteInputStream
doesn't apply for SpillInputStream as we don't support backward seek on a file for now. It just works for now.
It is better to split them and make a generic file based input stream which can be used in other cases as well.

Pull Request resolved: facebookincubator#10717

Reviewed By: tanjialiang

Differential Revision: D61148216

Pulled By: xiaoxmeng
xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Aug 14, 2024
Summary:
Current spill leverage SpillInputStream to handle the byte stream read from spilled file. SpillInputStream is a
derived class from ByteInputStream and its implementation a bit hack as most of operations of ByteInputStream
doesn't apply for SpillInputStream as we don't support backward seek on a file for now. It just works for now.
It is better to split them and make a generic file based input stream which can be used in other cases as well.

Pull Request resolved: facebookincubator#10717

Reviewed By: tanjialiang

Differential Revision: D61148216

Pulled By: xiaoxmeng
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D61148216

Copy link
Collaborator

@duanmeng duanmeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % one nit will resolve it in the follow-up per discuss.

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Aug 14, 2024
Summary:
Current spill leverage SpillInputStream to handle the byte stream read from spilled file. SpillInputStream is a
derived class from ByteInputStream and its implementation a bit hack as most of operations of ByteInputStream
doesn't apply for SpillInputStream as we don't support backward seek on a file for now. It just works for now.
It is better to split them and make a generic file based input stream which can be used in other cases as well.

Pull Request resolved: facebookincubator#10717

Reviewed By: tanjialiang

Differential Revision: D61148216

Pulled By: xiaoxmeng
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D61148216

Copy link
Contributor

@Yuhta Yuhta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except one optimization idea. Also can you have a line in the description to state the new roles of the classes (ByteInputStream becomes interface, BufferInputStream is the old ByteInputStream etc.)?

velox/common/memory/ByteStream.h Outdated Show resolved Hide resolved
if (skipBytes == 0) {
return;
}
readNextRange();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to actually do the IO? Can we just manipulate fileOffset_ instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I think we could. Let me see how to skip io in followup. Thanks!

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Aug 14, 2024
Summary:
Current spill leverage SpillInputStream to handle the byte stream read from spilled file. SpillInputStream is a
derived class from ByteInputStream and its implementation a bit hack as most of operations of ByteInputStream
doesn't apply for SpillInputStream as we don't support backward seek on a file for now. It just works for now.
It is better to split them and make a generic file based input stream which can be used in other cases as well.

Pull Request resolved: facebookincubator#10717

Reviewed By: Yuhta, tanjialiang

Differential Revision: D61148216

Pulled By: xiaoxmeng
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D61148216

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Aug 14, 2024
Summary:
Current spill leverage SpillInputStream to handle the byte stream read from spilled file. SpillInputStream is a
derived class from ByteInputStream and its implementation a bit hack as most of operations of ByteInputStream
doesn't apply for SpillInputStream as we don't support backward seek on a file for now. It just works for now.
It is better to split them and make a generic file based input stream which can be used in other cases as well.

With this change, ByteInputStream has two derived implementations:

(1) BufferInputStream which support byte stream API back by a set of buffers;
(2) FileInputStream which support byte stream API back by a sequential read file and doesn't support
for backward seek.
FileInputStream can be used by spill, tracing and file-based broadcast join etc.

Pull Request resolved: facebookincubator#10717

Reviewed By: Yuhta, tanjialiang, ktsiam

Differential Revision: D61148216

Pulled By: xiaoxmeng
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D61148216

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D61148216

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Aug 14, 2024
Summary:
Current spill leverage SpillInputStream to handle the byte stream read from spilled file. SpillInputStream is a
derived class from ByteInputStream and its implementation a bit hack as most of operations of ByteInputStream
doesn't apply for SpillInputStream as we don't support backward seek on a file for now. It just works for now.
It is better to split them and make a generic file based input stream which can be used in other cases as well.

With this change, ByteInputStream has two derived implementations:

(1) BufferInputStream which support byte stream API back by a set of buffers;
(2) FileInputStream which support byte stream API back by a sequential read file and doesn't support
for backward seek.
FileInputStream can be used by spill, tracing and file-based broadcast join etc.

Pull Request resolved: facebookincubator#10717

Reviewed By: Yuhta, tanjialiang, ktsiam

Differential Revision: D61148216

Pulled By: xiaoxmeng
Summary:
Current spill leverage SpillInputStream to handle the byte stream read from spilled file. SpillInputStream is a
derived class from ByteInputStream and its implementation a bit hack as most of operations of ByteInputStream
doesn't apply for SpillInputStream as we don't support backward seek on a file for now. It just works for now.
It is better to split them and make a generic file based input stream which can be used in other cases as well.

With this change, ByteInputStream has two derived implementations:

(1) BufferInputStream which support byte stream API back by a set of buffers;
(2) FileInputStream which support byte stream API back by a sequential read file and doesn't support
for backward seek.
FileInputStream can be used by spill, tracing and file-based broadcast join etc.

Pull Request resolved: facebookincubator#10717

Reviewed By: Yuhta, tanjialiang, ktsiam

Differential Revision: D61148216

Pulled By: xiaoxmeng
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D61148216

@facebook-github-bot
Copy link
Contributor

@xiaoxmeng merged this pull request in 9523840.

Copy link

Conbench analyzed the 1 benchmark run on commit 9523840a.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants