Skip to content

Implemention of variation trees#59

Merged
pmbittner merged 11 commits into
developfrom
benjamin/variation-trees
Nov 24, 2022
Merged

Implemention of variation trees#59
pmbittner merged 11 commits into
developfrom
benjamin/variation-trees

Conversation

@ibbem
Copy link
Copy Markdown
Collaborator

@ibbem ibbem commented Nov 6, 2022

Implements variation trees and generalizes some algorithms by using projections of variation diffs.

There is some more refactoring potential here (for example DiffTreeSource could use two VariationTreeSources) and there are very few convenience methods in VariationTree in comparison to DiffTree but this can be fixed later, when needed.

Currently this adds FilterMappedList to DiffDetective. If VariantSync/Functjonal#5 is merged before this one, I will instead update the Functjonal dependency in this pull request. Otherwise I will create a second one.

@ibbem ibbem added the bm_thesis ibbem is working on this as part of his bachelor's thesis label Nov 6, 2022
@ibbem ibbem self-assigned this Nov 6, 2022
@ibbem ibbem requested a review from pmbittner November 6, 2022 13:54
@ibbem ibbem mentioned this pull request Nov 6, 2022
@pmbittner pmbittner added the enhancement New feature or request label Nov 7, 2022
@pmbittner
Copy link
Copy Markdown
Member

Ok, we should merge the PR in Functjonal first.

Copy link
Copy Markdown
Member

@pmbittner pmbittner left a comment

Choose a reason for hiding this comment

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

The changes look awesome! Thank you. I still have to review VariationTree and VariationTreeNode which I will do asap.

Comment thread src/main/java/org/variantsync/diffdetective/diff/difftree/DiffNode.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/diff/difftree/DiffNode.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/variationtree/VariationNode.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/variationtree/VariationNode.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/variationtree/VariationNode.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/variationtree/VariationNode.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/variationtree/VariationNode.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/variationtree/VariationTreeNode.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/variationtree/VariationTreeNode.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/variationtree/VariationTreeNode.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/variationtree/VariationTreeNode.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/variationtree/VariationTreeNode.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/variationtree/VariationTreeNode.java Outdated
NodeType.values()[nodeTypeOrdinal],
from,
DiffLineNumber.InvalidLineNumber,
null,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use true if we have an annotation node? Maybe its best to keep null here though as a "reminder" that this node is still incomplete.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤦 This is the exact same bug as I fixed in #50 (it caused the test failures). This needs to be fixed otherwise assertConsistency will detect that and we would have an unexpected inconsistent behavior between DiffTreen.assertConsistency and VariationNode.assertConsistency.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we should document in the method's javadoc which information is lost and only recovered by heuristics (i.e., line numbers and formula of annotations)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't think it's a good idea to give definite answers to what exactly can be recovered from this ID because this would encourage using it for serialization. Misusing getID for serializing some fields of DiffNode was a mistake in my opinion. It's only real use case should be identifying a node uniquely in a tree.
It's probably a good idea to completely eliminate fromID in the future as it's not really stable across versions (I already changed the IDs multiple times) and implicitly looses information.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see your point. So the misuse would be any use of fromID but toID should be fine. I implemented these methods because of a use case were we had to export DiffTrees for another tool that reads linegraph files which in turn require natural number identifiers for nodes. I agree that upon serialisation we should either use a proper format that stores node data separately (e.g., in a json or in a text label in the linegraph file).

@pmbittner
Copy link
Copy Markdown
Member

I am done with the first review now.

@ibbem ibbem force-pushed the benjamin/variation-trees branch 3 times, most recently from eb21341 to df8c0a6 Compare November 9, 2022 15:19
@ibbem ibbem requested a review from pmbittner November 9, 2022 15:24
Comment thread src/main/java/org/variantsync/diffdetective/diff/DiffLineNumber.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/diff/DiffLineNumber.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/variationtree/VariationTreeNode.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/variationtree/VariationTreeNode.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/variationtree/VariationTreeNode.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/variationtree/VariationNode.java Outdated
Comment thread src/main/java/org/variantsync/diffdetective/variationtree/VariationNode.java Outdated
This also avoids duplicating `ID_OFFSET` in both `DiffNode` and
`VariationTreeNode`.
This check will only be `true` if the root is not an `IF` node, but this
is an invariant so it should never occur. It's better to get the
resulting `NullPointerException` than a `null` return value.
@ibbem ibbem force-pushed the benjamin/variation-trees branch from df8c0a6 to a3a2a51 Compare November 13, 2022 16:39
@ibbem ibbem requested a review from pmbittner November 13, 2022 16:41
@pmbittner
Copy link
Copy Markdown
Member

Thank you for all the fixes and adaptations. We can merge now. 🥳

@pmbittner pmbittner merged commit 2b3adaf into develop Nov 24, 2022
@pmbittner pmbittner deleted the benjamin/variation-trees branch March 14, 2023 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bm_thesis ibbem is working on this as part of his bachelor's thesis enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants