-
Notifications
You must be signed in to change notification settings - Fork 4.3k
ARROW-206: Expose a C++ api to compare ranges of slots between two arrays #80
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
Changes from 1 commit
dadb244
318855d
dcbaad4
f5c6bd5
f963639
d5ae777
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,21 @@ bool ListArray::Equals(const std::shared_ptr<Array>& arr) const { | |
| return EqualsExact(*static_cast<const ListArray*>(arr.get())); | ||
| } | ||
|
|
||
| bool ListArray::RangeEquals( | ||
| int32_t start_idx, int32_t end_idx, const std::shared_ptr<Array>& arr) const { | ||
| if (this == arr.get()) { return true; } | ||
| if (this->type_enum() != arr->type_enum()) { return false; } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do as your've done the check |
||
| auto other = static_cast<ListArray*>(arr.get()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const |
||
| for (int i = start_idx; i < end_idx; ++i) { | ||
| const bool is_null = IsNull(i); | ||
| if ((is_null != arr->IsNull(i)) || | ||
| (!is_null && !values_->RangeEquals(offset(i), offset(i + 1), other->values()))) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| Status ListArray::Validate() const { | ||
| if (length_ < 0) { return Status::Invalid("Length was negative"); } | ||
| if (!offset_buf_) { return Status::Invalid("offset_buf_ was null"); } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -185,10 +185,25 @@ bool BooleanArray::EqualsExact(const BooleanArray& other) const { | |
| } | ||
| } | ||
|
|
||
| bool BooleanArray::Equals(const std::shared_ptr<Array>& arr) const { | ||
| bool BooleanArray::Equals(const ArrayPtr& arr) const { | ||
| if (this == arr.get()) return true; | ||
| if (Type::BOOL != arr->type_enum()) { return false; } | ||
| return EqualsExact(*static_cast<const BooleanArray*>(arr.get())); | ||
| } | ||
|
|
||
| bool BooleanArray::RangeEquals( | ||
| int32_t start_idx, int32_t end_idx, const ArrayPtr& arr) const { | ||
| if (this == arr.get()) { return true; } | ||
| if (!arr) { return false; } | ||
| if (this->type_enum() != arr->type_enum()) { return false; } | ||
| auto other = static_cast<BooleanArray*>(arr.get()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const |
||
| for (int i = start_idx; i < end_idx; ++i) { | ||
| bool is_null = IsNull(i); | ||
| if (is_null != arr->IsNull(i) || (!is_null && Value(i) != other->Value(i))) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| } // namespace arrow | ||
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.
Are you thinking of the case of start_idx == end_idx or something else?
All else being equal it seems that an empty set should equal an empty. Do you disagree?