-
Notifications
You must be signed in to change notification settings - Fork 245
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
readability improvement for metadata class #275
Conversation
} | ||
auto it = std::upper_bound(pb_.batch_offsets().begin(), pb_.batch_offsets().end(), row_index); | ||
if (it == pb_.batch_offsets().end()) { | ||
return ::arrow::Status::IndexError("Row index out of range {} of {}", row_index, len); | ||
} | ||
int32_t bound_idx = std::distance(pb_.batch_offsets().begin(), it); | ||
int32_t bound_idx = std::distance(pb_.batch_offsets().begin(), it) - 1; |
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.
what if the it == batch_offset().begin()
? in such case bound_idx = -1?
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.
The first value of offsets is always 0, row_index
is always not less than 0, so this case should not happen unless we change how offsets works.
https://github.com/eto-ai/lance/blob/861230d0d8186312e18f206fb8262eb919828549/cpp/src/lance/format/metadata.cc#L59
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.
ok, got it. It seems line #83 assert
is always true as well? lets remove it?
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.
updated
} | ||
auto it = std::upper_bound(pb_.batch_offsets().begin(), pb_.batch_offsets().end(), row_index); | ||
if (it == pb_.batch_offsets().end()) { | ||
return ::arrow::Status::IndexError("Row index out of range {} of {}", row_index, len); | ||
} | ||
int32_t bound_idx = std::distance(pb_.batch_offsets().begin(), it); | ||
int32_t bound_idx = std::distance(pb_.batch_offsets().begin(), it) - 1; |
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.
ok, got it. It seems line #83 assert
is always true as well? lets remove it?
cpp/src/lance/format/metadata.cc
Outdated
@@ -68,16 +68,19 @@ int32_t Metadata::GetBatchLength(int32_t batch_id) const { | |||
|
|||
::arrow::Result<std::tuple<int32_t, int32_t>> Metadata::LocateBatch(int32_t row_index) const { | |||
int64_t len = length(); | |||
if (len == 0) { | |||
return ::arrow::Status::IndexError(fmt::format("The offsets table is empty")); |
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.
don't need fmt::format
here
No description provided.