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

add functionality to clone graphs (important for unit test performance) #162

Closed
wants to merge 3 commits into from

Conversation

bbrehm
Copy link
Contributor

@bbrehm bbrehm commented Mar 22, 2024

I think you needed that for unit test performance in joern + codescience.

@bbrehm bbrehm requested a review from mpollmeier March 22, 2024 14:52
@bbrehm
Copy link
Contributor Author

bbrehm commented Mar 22, 2024

@mpollmeier if you want to do changes to this yourself, feel free to push on the branch and merge.

If you want me to do the changes, then add a note here and I will do (e.g. make storagepath val again, or factor out the code into a helper object).

You can also hit the merge button and change this later.

Please let me now whether this solves the unit-test performance problem!

@mpollmeier
Copy link
Contributor

my changes are rather large so I'll create a follow-up PR.

@mpollmeier
Copy link
Contributor

This is actually incomplete - I added a test that fails. The root cause is that cloneThing does not really clone anything besides Array[GNode] - for everything else it just returns the identity. For all primitive arrays and known things like Array[String] that's straightforward to implement, but what if we have property types like java.util.Map, or a random object?

@bbrehm
Copy link
Contributor Author

bbrehm commented Mar 23, 2024

👍 Good find!

I made setEdgeProperty also cow.

, but what if we have property types like java.util.Map, or a random object?

Not supported by flatgraph.

@mpollmeier
Copy link
Contributor

👍🏻 thank you

@mpollmeier
Copy link
Contributor

wouldn't it be better to just add this case to cloneThing?
i.e.

        case a: Array[_] =>
          a.clone()

@mpollmeier
Copy link
Contributor

I'd prefer #163
But if you prefer this variant, we can go with this as well.

@mpollmeier
Copy link
Contributor

switching to #163

@mpollmeier mpollmeier closed this Mar 24, 2024
mpollmeier added a commit that referenced this pull request Mar 25, 2024
…e) (#163)

Alternative proposal to #162
I moved a few things around and refactored for readability. Main difference in API is that rather than
`graph.copyDataFrom(other: Graph)` 
this does
`graph.copy(): Graph`
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