Skip to content

Hash ode map json deduplication#11

Open
John-Wiens wants to merge 5 commits into
developfrom
hash-odeMapJson-deduplication
Open

Hash ode map json deduplication#11
John-Wiens wants to merge 5 commits into
developfrom
hash-odeMapJson-deduplication

Conversation

@John-Wiens

Copy link
Copy Markdown

This PR updates the logic in the OdeMapJson deduplication topology so that it will forward a new MAP message if the new map message is different from the previous message. Previously, a new OdeMapJson message would only be forwarded if it happens more than 1 hour after the preceeding message. After this update, a new OdeMapJson message will also be forwarded if it has different contents than the previous MAP message. For example, if the new message has different lane ID's or geometries it will be forwarded regardless of how long after the previous message the new message occurred. This update changes the OdeMapJson topology logic to be more in line with how the ProcessedMap and other topologies operate. As with the ProcessedMap topology, this update ignores changes to the ASN.1, odeReceivedAt, and MOY fields since these fields are expected to change frequently and do not necessarily correspond to a change in the intersection geometry.

@drewjj drewjj left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just a few questions. Looks good, though.

@drewjj drewjj left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good! Thanks for the changes.

@Michael7371 Michael7371 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, just noticed an outdated comment.

List<KeyValue<String, OdeMessageFrameData>> mapDeduplicationResults = outputOdeMapData
.readKeyValuesToList();

// validate that only 3 messages make it through

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

chore: stale comment, update to 4 messages.

int oldHash = Objects.hash(lastMessage.toString());
int newHash = Objects.hash(newMessage.toString());

if(oldHash != newHash){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue: the hash can have collisions.

suggestion: test object equality instead. Either using 'toString' if there is some reason to do that (not sure if there is):

lastMessage.toString().equals(newMessage.toString())

or use the 'equals' method defined on OdeMessageFrameData (by the @EqualsAndHashCode annotation on OdeData):

lastMessage.equals(newMessage)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The two objects being compared are different objects, with different nested elements. ToString is used as a quick way to ensure I am comparing the content of the object as opposed to the memory pointers.

Using the message hash's instead of the messages themselves was selected for performance reasons. From my testing it takes about 1 ms to compare the message hashes from the strings compared to about 3ms to perform string comparison on the strings. While a collision is possible it is quite unlikely given that MAP messages change very infrequently.

In the event that a collision did happen, the impact is fairly minimal. The original MAP would be retained for at most 1 additional hour, before the new MAP message takes over anyway.

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.

4 participants