Skip to content

Commit 4fb05e6

Browse files
committed
Don't keep all line graphs in memory during mining
1 parent 060310e commit 4fb05e6

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.variantsync.diffdetective.analysis.strategies;
2+
3+
import java.io.IOException;
4+
import java.io.OutputStream;
5+
import java.nio.file.Path;
6+
7+
import org.apache.commons.io.output.CloseShieldOutputStream;
8+
import org.tinylog.Logger;
9+
import org.variantsync.diffdetective.datasets.Repository;
10+
import org.variantsync.diffdetective.diff.CommitDiff;
11+
import org.variantsync.diffdetective.util.IO;
12+
13+
/**
14+
* Collects all linegraph representations generated by an analysis and exports them at the end.
15+
* @author Benjamin Moosherr
16+
*/
17+
public class AnalyzeAllAndExport extends AnalysisStrategy {
18+
private OutputStream lineGraphDestination;
19+
20+
@Override
21+
public void start(Repository repo, Path outputPath) {
22+
try {
23+
lineGraphDestination = IO.newBufferedOutputStream(outputPath);
24+
} catch (IOException e) {
25+
Logger.error(e);
26+
}
27+
}
28+
29+
@Override
30+
public OutputStream onCommit(CommitDiff commit) {
31+
try {
32+
lineGraphDestination.flush();
33+
} catch (IOException e) {
34+
Logger.error(e);
35+
}
36+
37+
return new CloseShieldOutputStream(lineGraphDestination);
38+
}
39+
40+
@Override
41+
public void end() {
42+
try {
43+
lineGraphDestination.close();
44+
} catch (IOException e) {
45+
Logger.error(e);
46+
}
47+
}
48+
}

src/main/java/org/variantsync/diffdetective/mining/DiffTreeMiner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.variantsync.diffdetective.analysis.CommitHistoryAnalysisTaskFactory;
77
import org.variantsync.diffdetective.analysis.HistoryAnalysis;
88
import org.variantsync.diffdetective.analysis.strategies.AnalysisStrategy;
9-
import org.variantsync.diffdetective.analysis.strategies.AnalyzeAllThenExport;
9+
import org.variantsync.diffdetective.analysis.strategies.AnalyzeAllAndExport;
1010
import org.variantsync.diffdetective.datasets.*;
1111
import org.variantsync.diffdetective.datasets.predefined.StanciulescuMarlin;
1212
import org.variantsync.diffdetective.diff.difftree.filter.DiffTreeFilter;
@@ -87,7 +87,7 @@ public static LineGraphExportOptions MiningExportOptions(final Repository reposi
8787
}
8888

8989
public static AnalysisStrategy MiningStrategy() {
90-
return new AnalyzeAllThenExport();
90+
return new AnalyzeAllAndExport();
9191
// new CompositeDiffTreeMiningStrategy(
9292
// new MineAndExportIncrementally(1000),
9393
// new MiningMonitor(10)

0 commit comments

Comments
 (0)