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

Subgraph Composition: Fix Entity Ordering with different Idtype #5760

Open
wants to merge 1 commit into
base: zoran/subgraph-composition-rework-vid-wrap2
Choose a base branch
from

Conversation

incrypto32
Copy link
Member

No description provided.

let other_str = String::from_utf8(other.id.clone()).map_err(IdCompareError::InvalidUtf8)?;
Ok(self_str.cmp(&other_str))
}
IdType::Bytes => Ok(self.id.cmp(&other.id)),
Copy link
Contributor

Choose a reason for hiding this comment

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

The same check could be used for the string too. We don't care what is the content of the ID, only if it's equal to the other one. And I would go so far to say that it holds for Int8 case too as we don't mind if the order is ascending or descending, we only need the cmp() to be able to detect equality and have a consistent ordering otherwise which is achieved with byte comparison. So I would keep the Ord a it is and only change the type of the id field in EntityDataExt.

@@ -406,3 +420,71 @@ fn read_immutable_only_range_test() {
assert_eq!(e.len(), 4);
})
}

#[test]
fn read_range_pool_created_test() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Very nice to add a test case!

@incrypto32 incrypto32 force-pushed the krishna/sgc-multiple-sg-sources-fix branch from 0d72898 to ad34735 Compare January 9, 2025 11:56
@incrypto32 incrypto32 marked this pull request as ready for review January 9, 2025 12:13
@incrypto32 incrypto32 added this to the Subgraph Composition milestone Jan 9, 2025
fn compare_entity_data_ext(a: &EntityDataExt, b: &EntityDataExt) -> std::cmp::Ordering {
a.block_number
.cmp(&b.block_number)
.then_with(|| a.entity.cmp(&b.entity))
Copy link
Contributor

Choose a reason for hiding this comment

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

elegant!

@incrypto32 incrypto32 force-pushed the krishna/sgc-multiple-sg-sources-fix branch from ad34735 to 748ff48 Compare January 9, 2025 12:22
@incrypto32 incrypto32 changed the base branch from krishna/sgc-multiple-sg-sources to zoran/subgraph-composition-rework-vid-wrap2 January 9, 2025 12:22
@zorancv zorancv force-pushed the zoran/subgraph-composition-rework-vid-wrap2 branch 13 times, most recently from 14671db to 640e7d1 Compare January 21, 2025 15:24
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