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

Support Limit / Offset #45

Merged
merged 11 commits into from
Jul 24, 2022
Merged

Support Limit / Offset #45

merged 11 commits into from
Jul 24, 2022

Conversation

eddyxu
Copy link
Contributor

@eddyxu eddyxu commented Jul 22, 2022

No description provided.

@eddyxu
Copy link
Contributor Author

eddyxu commented Jul 22, 2022

This implement has a few caveats:

  1. Once the LIMIT clause is presented, the Scanner disables parallel scan (and prefetch) because the current implementation of Limit / Offset requires serialized counting of the rows.
  2. Apache Arrow's ScanOptions do not have limit/offset. Thus this function can not be used directly by the arrow integration. We can enable it via a Py(Lance) API for now and look for some opportunity to integrate with other systems later.

For 1, we can probably improve it with some literal studies. The questions that need to answer is whether it should be a file format feature.

@eddyxu eddyxu requested a review from changhiskhan July 22, 2022 04:35
@eddyxu
Copy link
Contributor Author

eddyxu commented Jul 22, 2022

Mac build failure was due to #35 . Expect homebrew upgrading protobuf (already happened on the Apple Silicon version) will resolve the build issue automatically. See comment in #35

Copy link
Contributor

@changhiskhan changhiskhan left a comment

Choose a reason for hiding this comment

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

A few nits

cpp/src/lance/io/limit.h Outdated Show resolved Hide resolved
cpp/src/lance/io/project.cc Show resolved Hide resolved
cpp/src/lance/io/scanner.h Show resolved Hide resolved
q_(std::move(other.q_)) {}

::arrow::Status Scanner::Open() {
schema_ = std::make_shared<lance::format::Schema>(reader_->schema());
ARROW_ASSIGN_OR_RAISE(project_, Project::Make(schema_, options_));
ARROW_ASSIGN_OR_RAISE(project_, Project::Make(schema_, options_, limit_, offset_));
if (!project_->CanParallelScan()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to implement some data structure that tracks some mapping of chunk no -> offset/length? So there will be some "over reading" that gets discarded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you elaborate a bit? I am confused. In what case will over-reading occur?

Copy link
Contributor

Choose a reason for hiding this comment

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

Parallel

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. Did you mean hedged read? Yes, we can do hedged read later, we can discuss the design choices in #48.

@eddyxu eddyxu merged commit 7303b0d into main Jul 24, 2022
@eddyxu eddyxu deleted the lei/limit_offset branch July 24, 2022 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants