-
Notifications
You must be signed in to change notification settings - Fork 33
Add cleaning to the PropertyStore #323
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
Open
fwnter
wants to merge
23
commits into
opalj:develop
Choose a base branch
from
fwnter:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
079ec9e
Add cleaning to the PropertyStore
fwnter e19a5b7
Fix Nullpointer, streamline code
fwnter 7de135a
incooperate feedback, revert some changes
fwnter 8d9148c
Merge branch 'opalj:develop' into develop
fwnter 0c6a47a
Merge branch 'opalj:develop' into develop
fwnter e1c4510
fixes, no longer expect ids in parameters
fwnter 08c12af
Merge remote-tracking branch 'origin/develop' into develop
fwnter 180be94
add cleanup to PKESequentialPropertyStore
fwnter 885d23f
formatting
fwnter ef9b83f
add programmatical way to setup cleanup
fwnter a7d16c4
move config
fwnter d984043
add scaladoc, rename variables
fwnter 4af591c
add to cleanup-docu
fwnter df3018f
add to cleanup-docu
fwnter 5dd519e
add license-header
fwnter 3b0737b
Merge branch 'develop' into develop
fwnter ea4c15a
move params
fwnter 645bb56
Merge remote-tracking branch 'origin/develop' into develop
fwnter 5dbdb46
add new step
fwnter da6dcbf
add new step in docu, fix logical flaw in calculation, enable cleanup…
fwnter 7f671d1
Merge branch 'opalj:develop' into develop
fwnter 91b3a6a
remove unneccessary toDelete-calculation for final phase
fwnter 8220f87
change key for deletion-logging, fix order for steps
fwnter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
OPAL/si/src/main/scala/org/opalj/fpcf/scheduling/Cleanup.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /* BSD 2-Clause License - see OPAL/LICENSE for details. */ | ||
| package org.opalj | ||
| package fpcf | ||
| package scheduling | ||
|
|
||
| /** | ||
| * Class that allows to configure the cleanup of the PropertyStore inbetween phases programmatically | ||
| * @param keep IDs of the PropertyKeys to be kept at the end | ||
| * @param clear IDs of the PropertyKeys to be definitely removed | ||
| * @param disable Allows the cleanup to be disabled since it is on by default | ||
| */ | ||
| final case class CleanupSpec( | ||
| keep: Set[Int] = Set.empty, | ||
| clear: Set[Int] = Set.empty, | ||
| disable: Boolean = false | ||
| ) | ||
|
|
||
| /** | ||
| * Factory for creating [[CleanupSpec]]-objects, also handles calculation of per-phase cleanup | ||
| */ | ||
| object Cleanup { | ||
|
|
||
| /** | ||
| * Creates a [[CleanupSpec]] from given [[PropertyKey]]-names to keep and/or to clear. Also allows disabling the cleanup by setting 'disable' to 'true'. | ||
| * @param keep Names of PropertyKeys to be kept after the analyses | ||
| * @param clear Names of PropertyKeys to be removed after the analyses | ||
| * @param disable Setting this to 'true' disables the cleanup inbetween the phases | ||
| * @return A new [[CleanupSpec]] | ||
| */ | ||
| def fromArgs(keep: Set[String], clear: Set[String], disable: Boolean): CleanupSpec = { | ||
| val toKeep = keep.map(PropertyKey.idByName) | ||
| val toClear = clear.map(PropertyKey.idByName) | ||
| CleanupSpec(toKeep, toClear, disable) | ||
| } | ||
|
|
||
| /** | ||
| * Calculates the properties to be safely removed inbetween phases. Returns an unmodified schedule if cleanup is disabled | ||
| */ | ||
| def withPerPhaseCleanup[A]( | ||
| schedule: List[PhaseConfiguration[A]], | ||
| ps: PropertyStore, | ||
| spec: CleanupSpec | ||
| ): List[PhaseConfiguration[A]] = { | ||
| if (spec.disable) return schedule | ||
|
|
||
| val producedInAnyPhase: Set[Int] = | ||
| schedule.iterator.flatMap(_.propertyKinds.propertyKindsComputedInThisPhase.map(_.id)).toSet | ||
| val neededLater = Array.fill[Set[Int]](schedule.size + 1)(Set.empty) | ||
| var index = schedule.size - 1 | ||
| var usedInAnyPhase: Set[Int] = Set.empty | ||
| while (index >= 0) { | ||
| val usedInThisPhase: Set[Int] = | ||
| schedule(index).scheduled.iterator.flatMap(_.uses(ps).iterator).map(_.pk.id).toSet | ||
| neededLater(index) = usedInAnyPhase | ||
| usedInAnyPhase = usedInAnyPhase union usedInThisPhase | ||
| index -= 1 | ||
| } | ||
|
|
||
| schedule.indices.iterator.map { index => | ||
| val producedHere = schedule(index) | ||
| val toDelete = ((producedInAnyPhase -- neededLater(index)) -- spec.keep) union spec.clear | ||
| producedHere.copy(toDelete = toDelete) | ||
| }.toList | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.