Skip to content

Commit fb762dd

Browse files
committed
SPLCommit::clearCaches
1 parent 0ca475b commit fb762dd

5 files changed

Lines changed: 24 additions & 10 deletions

File tree

src/main/java/de/variantsync/evolution/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ public static void main(final String[] args) throws IOException, Resources.Resou
107107
final VariabilityDatasetLoader datasetLoader = new VariabilityDatasetLoader();
108108
assert datasetLoader.canLoad(variabilityDatasetDir);
109109
variabilityDataset = datasetLoader.load(variabilityDatasetDir).getSuccess();
110-
final Set<CommitPair<SPLCommit>> commitPairs = variabilityDataset.getCommitPairsForEvolutionStudy();
110+
final Set<SPLCommitPair> commitPairs = variabilityDataset.getCommitPairsForEvolutionStudy();
111111
Logger.info("The dataset contains " + variabilityDataset.getSuccessCommits().size() + " commits for which the variability extraction succeeded.");
112112
Logger.info("The dataset contains " + variabilityDataset.getErrorCommits().size() + " commits for which the variability extraction failed.");
113113
Logger.info("The dataset contains " + variabilityDataset.getPartialSuccessCommits().size() + " commits that for which the file presence conditions are missing.");
114114
Logger.info("The dataset contains " + commitPairs.size() + " usable pairs.");
115-
for (final CommitPair<SPLCommit> pair : commitPairs) {
115+
for (final SPLCommitPair pair : commitPairs) {
116116
Logger.debug("<<CHILD> " + pair.child().id() + "> -- <<PARENT> " + pair.parent().id() + ">");
117117
Logger.debug("<<CHILD> " + pair.child().id() + "> -- <<SPL_COMMIT> " + pair.child().id() + ">");
118118
Logger.debug("<<PARENT> " + pair.parent().id() + "> -- <<SPL_COMMIT> " + pair.parent().id() + ">");

src/main/java/de/variantsync/evolution/variability/CommitPair.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/main/java/de/variantsync/evolution/variability/SPLCommit.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ private static Path tryUnzip(final Path path) throws ZipException {
115115
return path;
116116
}
117117

118+
/**
119+
* Clears all cached values by calling {@link Lazy#forget()} on all fields.
120+
*/
121+
public void clearCaches() {
122+
kernelHavenLog.forget();
123+
featureModel.forget();
124+
presenceConditions.forget();
125+
message.forget();
126+
filterCounts.forget();
127+
}
128+
118129
/**
119130
* Return the parents of this commit. As the dataset only contains the data about non-error commits,
120131
* not all <code>SPLCommit</code> objects are associated with their parents. Therefore, an <code>Optional</code> is returned.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package de.variantsync.evolution.variability;
2+
3+
public record SPLCommitPair(SPLCommit parent, SPLCommit child) {
4+
void clearCaches() {
5+
parent.clearCaches();
6+
child.clearCaches();
7+
}
8+
}

src/main/java/de/variantsync/evolution/variability/VariabilityDataset.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ public VariabilityHistory getVariabilityHistory(final Function<Collection<SPLCom
9696
*
9797
* @return Set of commit pairs that can be used in a variability evolution study
9898
*/
99-
public Set<CommitPair<SPLCommit>> getCommitPairsForEvolutionStudy() {
99+
public Set<SPLCommitPair> getCommitPairsForEvolutionStudy() {
100100
Logger.info("Retrieving commit pairs for study...");
101-
var set = successCommits.stream()
101+
final var set = successCommits.stream()
102102
.map(c -> {
103103
if (c.parents().isPresent()) {
104104
final SPLCommit[] parents = c.parents().get();
@@ -108,7 +108,7 @@ public Set<CommitPair<SPLCommit>> getCommitPairsForEvolutionStudy() {
108108
// We only consider commits that processed an SPL commit whose parent was also processed
109109
final boolean parentSuccess = successCommits.contains(p);
110110
if (notAMerge && parentSuccess) {
111-
return new CommitPair<>(p, c);
111+
return new SPLCommitPair(p, c);
112112
}
113113
}
114114
return null;

0 commit comments

Comments
 (0)