Skip to content

Commit 1f8cf14

Browse files
refactor: reorganize new packages
1 parent 38a601c commit 1f8cf14

6 files changed

Lines changed: 48 additions & 46 deletions

File tree

pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0"
2-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xmlns="http://maven.apache.org/POM/4.0.0"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
44
http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7-
<!-- Adjust group id for anonymous projects -->
7+
<!-- Adjust group id for anonymous projects -->
88
<groupId>org.variantsync.vevos.extraction</groupId>
9-
<!-- Adjust the project name -->
9+
<!-- Adjust the project name -->
1010
<artifactId>Extraction</artifactId>
1111
<version>1.1.0</version>
1212

1313
<properties>
1414
<!-- Adjust your java version here -->
1515
<java.version>19</java.version>
16-
<!-- Adjust the path to the class that contains the main-method, that is to be executed, here -->
17-
<path.to.fast>${project.groupId}.FastExtraction</path.to.fast>
18-
<path.to.full>${project.groupId}.FullExtraction</path.to.full>
16+
<!-- Adjust the path to the class that contains the main-method, that is to be executed, here -->
17+
<path.to.fast>${project.groupId}.FastGroundTruthExtraction</path.to.fast>
18+
<path.to.full>${project.groupId}.FullGroundTruthExtraction</path.to.full>
1919
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2020
<maven.compiler.source>${java.version}</maven.compiler.source>
2121
<maven.compiler.target>${java.version}</maven.compiler.target>

src/main/java/org/variantsync/vevos/extraction/fast/FastExtraction.java renamed to src/main/java/org/variantsync/vevos/extraction/FastGroundTruthExtraction.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.variantsync.vevos.extraction.fast;
1+
package org.variantsync.vevos.extraction;
22

33
import org.tinylog.Logger;
44
import org.variantsync.diffdetective.AnalysisRunner;
@@ -7,6 +7,7 @@
77
import org.variantsync.diffdetective.datasets.Repository;
88
import org.variantsync.diffdetective.diff.git.DiffFilter;
99
import org.variantsync.diffdetective.variation.diff.parse.VariationDiffParseOptions;
10+
import org.variantsync.vevos.extraction.analysis.fast.FastVariabilityAnalysis;
1011

1112
import java.io.File;
1213
import java.io.FileInputStream;
@@ -17,7 +18,7 @@
1718
import java.util.function.BiConsumer;
1819
import java.util.function.BiFunction;
1920

20-
public class FastExtraction {
21+
public class FastGroundTruthExtraction {
2122
public static final String PRINT_ENABLED
2223
= "extraction.print-enabled";
2324
public static final String GT_SAVE_DIR
@@ -38,7 +39,7 @@ public class FastExtraction {
3839
= "extraction.extract-code-matching";
3940
private final Properties properties;
4041

41-
public FastExtraction(Properties properties) {
42+
public FastGroundTruthExtraction(Properties properties) {
4243
this.properties = properties;
4344
}
4445

@@ -54,7 +55,7 @@ public static void main(String[] args) throws IOException {
5455

5556
// Load the configuration
5657
Properties properties = getProperties(getPropertiesFile(args));
57-
var extraction = new FastExtraction(properties);
58+
var extraction = new FastGroundTruthExtraction(properties);
5859

5960
var options = diffdetectiveOptions(properties);
6061
Logger.info("Starting SPL history analysis.");
@@ -160,7 +161,7 @@ private BiConsumer<Repository, Path> buildRunner() {
160161
Path resultsRoot = extractionDir.resolve(repo.getRepositoryName());
161162
boolean printEnabled = Boolean.parseBoolean(this.properties.getProperty(PRINT_ENABLED));
162163

163-
FastGTExtraction analysis = new FastGTExtraction(printEnabled, resultsRoot,
164+
FastVariabilityAnalysis analysis = new FastVariabilityAnalysis(printEnabled, resultsRoot,
164165
Boolean.parseBoolean(properties.getProperty(IGNORE_PC_CHANGES)),
165166
Boolean.parseBoolean(properties.getProperty(EXTRACT_CODE_MATCHING)));
166167
final BiFunction<Repository, Path, Analysis> AnalysisFactory = (r, out) -> new Analysis(
@@ -188,7 +189,7 @@ private BiConsumer<Repository, Path> buildRunner() {
188189

189190
Analysis.forEachCommit(() -> AnalysisFactory.apply(repo, repoOutputDir), batchSize, availableProcessors);
190191

191-
FastGTExtraction.numProcessed = 0;
192+
FastVariabilityAnalysis.numProcessed = 0;
192193
};
193194
}
194195

src/main/java/org/variantsync/vevos/extraction/full/FullExtraction.java renamed to src/main/java/org/variantsync/vevos/extraction/FullGroundTruthExtraction.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.variantsync.vevos.extraction.full;
1+
package org.variantsync.vevos.extraction;
22

33
import org.eclipse.jgit.api.Git;
44
import org.eclipse.jgit.api.errors.GitAPIException;
@@ -10,6 +10,7 @@
1010
import org.variantsync.diffdetective.datasets.Repository;
1111
import org.variantsync.diffdetective.diff.git.DiffFilter;
1212
import org.variantsync.diffdetective.variation.diff.parse.VariationDiffParseOptions;
13+
import org.variantsync.vevos.extraction.analysis.full.FullVariabilityAnalysis;
1314
import org.variantsync.vevos.extraction.common.GroundTruth;
1415
import org.variantsync.vevos.extraction.io.Serde;
1516

@@ -26,7 +27,7 @@
2627
import java.util.function.BiFunction;
2728

2829

29-
public class FullExtraction {
30+
public class FullGroundTruthExtraction {
3031
public static final String PRINT_ENABLED
3132
= "extraction.print-enabled";
3233
public static final String IGNORE_PC_CHANGES
@@ -48,7 +49,7 @@ public class FullExtraction {
4849
private static final String CODE_VARIABILITY_CSV = "code-variability.spl.csv";
4950
private final Properties properties;
5051

51-
public FullExtraction(Properties properties) {
52+
public FullGroundTruthExtraction(Properties properties) {
5253
this.properties = properties;
5354
}
5455

@@ -64,7 +65,7 @@ public static void main(String[] args) throws IOException {
6465

6566
// Load the configuration
6667
Properties properties = getProperties(getPropertiesFile(args));
67-
var extraction = new FullExtraction(properties);
68+
var extraction = new FullGroundTruthExtraction(properties);
6869

6970
var options = diffdetectiveOptions(properties);
7071
Logger.info("Starting SPL history analysis.");
@@ -181,7 +182,7 @@ public static void quitOnError() {
181182

182183
private BiConsumer<Repository, Path> buildRunner(String diffDetectiveCache) {
183184
return (repo, repoOutputDir) -> {
184-
FullPCAnalysis analysis = new FullPCAnalysis(Path.of(diffDetectiveCache), Boolean.parseBoolean(properties.getProperty(IGNORE_PC_CHANGES)), Boolean.parseBoolean(properties.getProperty(EXTRACT_CODE_MATCHING)));
185+
FullVariabilityAnalysis analysis = new FullVariabilityAnalysis(Path.of(diffDetectiveCache), Boolean.parseBoolean(properties.getProperty(IGNORE_PC_CHANGES)), Boolean.parseBoolean(properties.getProperty(EXTRACT_CODE_MATCHING)));
185186
final BiFunction<Repository, Path, Analysis> AnalysisFactory = (r, out) -> new Analysis(
186187
"PCAnalysis",
187188
List.of(
@@ -214,7 +215,7 @@ private BiConsumer<Repository, Path> buildRunner(String diffDetectiveCache) {
214215
threadPool.shutdown();
215216
}
216217
}
217-
FullPCAnalysis.numProcessed = 0;
218+
FullVariabilityAnalysis.numProcessed = 0;
218219
};
219220
}
220221

src/main/java/org/variantsync/vevos/extraction/GTExtraction.java renamed to src/main/java/org/variantsync/vevos/extraction/analysis/VariabilityAnalysis.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.variantsync.vevos.extraction;
1+
package org.variantsync.vevos.extraction.analysis;
22

33
import org.prop4j.Node;
44
import org.variantsync.diffdetective.util.LineRange;
@@ -11,7 +11,7 @@
1111

1212
import java.util.Map;
1313

14-
public interface GTExtraction {
14+
public interface VariabilityAnalysis {
1515

1616
/**
1717
* Analyzes the given node and applies its annotation to the file's ground truth

src/main/java/org/variantsync/vevos/extraction/fast/FastGTExtraction.java renamed to src/main/java/org/variantsync/vevos/extraction/analysis/fast/FastVariabilityAnalysis.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.variantsync.vevos.extraction.fast;
1+
package org.variantsync.vevos.extraction.analysis.fast;
22

33
import org.eclipse.jgit.diff.DiffEntry;
44
import org.eclipse.jgit.revwalk.RevCommit;
@@ -7,7 +7,7 @@
77
import org.variantsync.diffdetective.editclass.proposed.ProposedEditClasses;
88
import org.variantsync.diffdetective.metadata.EditClassCount;
99
import org.variantsync.diffdetective.variation.diff.Time;
10-
import org.variantsync.vevos.extraction.GTExtraction;
10+
import org.variantsync.vevos.extraction.analysis.VariabilityAnalysis;
1111
import org.variantsync.vevos.extraction.common.FileGT;
1212
import org.variantsync.vevos.extraction.common.GroundTruth;
1313
import org.variantsync.vevos.extraction.error.MatchingException;
@@ -24,7 +24,7 @@
2424
* Extracts ground truths for all repositories in a dataset. The ground truth consists of presence
2525
* conditions for each file, a list of all variables, and commit metadata.
2626
*/
27-
public class FastGTExtraction implements Analysis.Hooks, GTExtraction {
27+
public class FastVariabilityAnalysis implements Analysis.Hooks, VariabilityAnalysis {
2828
private final static String SUCCESS_COMMIT_FILE = "SUCCESS_COMMITS.txt";
2929
private final static String ERROR_COMMIT_FILE = "ERROR_COMMITS.txt";
3030
private final static String EMPTY_COMMIT_FILE = "EMPTY_COMMITS.txt";
@@ -44,7 +44,7 @@ public class FastGTExtraction implements Analysis.Hooks, GTExtraction {
4444
private final Path resultsRoot;
4545
private final boolean extractCodeMatching;
4646

47-
public FastGTExtraction(boolean printEnabled, Path resultsRoot, boolean ignorePCChanges, boolean extractCodeMatching) {
47+
public FastVariabilityAnalysis(boolean printEnabled, Path resultsRoot, boolean ignorePCChanges, boolean extractCodeMatching) {
4848
this.printEnabled = printEnabled;
4949
this.resultsRoot = resultsRoot;
5050
this.threadBatches = new ConcurrentHashMap<>();
@@ -82,7 +82,7 @@ public void onFailedParse(Analysis analysis) {
8282
}
8383

8484
private void extractionFailed(RevCommit commit) {
85-
synchronized (FastGTExtraction.class) {
85+
synchronized (FastVariabilityAnalysis.class) {
8686
Logger.warn("Was not able to extract ground truth for commit " + commit.getName());
8787
Serde.appendText(resultsRoot.resolve(ERROR_COMMIT_FILE), commit.getName() + "\n");
8888
failedCommits.add(commit.getName());
@@ -93,10 +93,10 @@ private void extractionFailed(RevCommit commit) {
9393
public void endCommit(Analysis analysis) {
9494
RevCommit commit = analysis.getCurrentCommit();
9595

96-
synchronized (FastGTExtraction.class) {
97-
FastGTExtraction.numProcessed++;
98-
if (FastGTExtraction.numProcessed % 1_000 == 0) {
99-
Logger.info("End Processing of Commit ({}): {}", FastGTExtraction.numProcessed,
96+
synchronized (FastVariabilityAnalysis.class) {
97+
FastVariabilityAnalysis.numProcessed++;
98+
if (FastVariabilityAnalysis.numProcessed % 1_000 == 0) {
99+
Logger.info("End Processing of Commit ({}): {}", FastVariabilityAnalysis.numProcessed,
100100
commit.name());
101101
}
102102
}
@@ -121,16 +121,16 @@ public void endCommit(Analysis analysis) {
121121
// Return early and do not save any data, if the ground truths are both empty.
122122
// In this case, no changes have been analyzed, and we are not interested in the commit's
123123
// data.
124-
synchronized (FastGTExtraction.class) {
124+
synchronized (FastVariabilityAnalysis.class) {
125125
Logger.debug("No code changes for " + commit.getName());
126126
Serde.appendText(resultsRoot.resolve(EMPTY_COMMIT_FILE), commit.getName() + "\n");
127127
failedCommits.add(commit.getName());
128128
}
129129
return;
130130
}
131131

132-
GTExtraction.makeComplete(groundTruthBefore);
133-
GTExtraction.makeComplete(groundTruthAfter);
132+
VariabilityAnalysis.makeComplete(groundTruthBefore);
133+
VariabilityAnalysis.makeComplete(groundTruthAfter);
134134

135135
if (printEnabled) {
136136
print(groundTruthBefore, commit.getName());
@@ -174,7 +174,7 @@ public void endCommit(Analysis analysis) {
174174
s -> Serde.writeToFile(commitSaveDir.resolve(COMMIT_PARENTS_FILE), s),
175175
() -> Serde.writeToFile(commitSaveDir.resolve(COMMIT_PARENTS_FILE), ""));
176176

177-
synchronized (FastGTExtraction.class) {
177+
synchronized (FastVariabilityAnalysis.class) {
178178
Serde.appendText(resultsRoot.resolve(SUCCESS_COMMIT_FILE), commit.getName() + "\n");
179179
}
180180

@@ -244,11 +244,11 @@ public boolean analyzeVariationDiff(Analysis analysis) {
244244
// Logger.debug("Node: {}", node);
245245
// If the file is not completely new, we consider the before case
246246
if (!(changeType == DiffEntry.ChangeType.ADD)) {
247-
GTExtraction.analyzeNode(fileGTBefore, node, Time.BEFORE, ignorePCChanges);
247+
VariabilityAnalysis.analyzeNode(fileGTBefore, node, Time.BEFORE, ignorePCChanges);
248248
}
249249
if (!(changeType == DiffEntry.ChangeType.DELETE)) {
250250
// If the file has not been deleted, we consider the after case
251-
GTExtraction.analyzeNode(fileGTAfter, node, Time.AFTER, ignorePCChanges);
251+
VariabilityAnalysis.analyzeNode(fileGTAfter, node, Time.AFTER, ignorePCChanges);
252252
}
253253
} catch (MatchingException e) {
254254
Logger.error("unhandled exception while analyzing {} -> {} for commit {}.",

src/main/java/org/variantsync/vevos/extraction/full/FullPCAnalysis.java renamed to src/main/java/org/variantsync/vevos/extraction/analysis/full/FullVariabilityAnalysis.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.variantsync.vevos.extraction.full;
1+
package org.variantsync.vevos.extraction.analysis.full;
22

33
import org.eclipse.jgit.diff.DiffEntry;
44
import org.eclipse.jgit.revwalk.RevCommit;
@@ -7,7 +7,7 @@
77
import org.variantsync.diffdetective.editclass.proposed.ProposedEditClasses;
88
import org.variantsync.diffdetective.metadata.EditClassCount;
99
import org.variantsync.diffdetective.variation.diff.Time;
10-
import org.variantsync.vevos.extraction.GTExtraction;
10+
import org.variantsync.vevos.extraction.analysis.VariabilityAnalysis;
1111
import org.variantsync.vevos.extraction.common.FileGT;
1212
import org.variantsync.vevos.extraction.common.GroundTruth;
1313
import org.variantsync.vevos.extraction.error.MatchingException;
@@ -23,15 +23,15 @@
2323
* Extracts ground truths for all repositories in a dataset. The ground truth consists of presence conditions for each file,
2424
* a list of all variables, and commit metadata.
2525
*/
26-
public class FullPCAnalysis implements Analysis.Hooks, GTExtraction {
26+
public class FullVariabilityAnalysis implements Analysis.Hooks, VariabilityAnalysis {
2727
public static int numProcessed = 0;
2828
private final Hashtable<String, GroundTruth> groundTruthMap;
2929
private final Path diffDetectiveCache;
3030
private final boolean ignorePCChanges;
3131
// TODO: extract code matching during full analysis
3232
private final boolean extractCodeMatching;
3333

34-
public FullPCAnalysis(Path diffDetectiveCache, boolean ignorePCChanges, boolean extractCodeMatching) {
34+
public FullVariabilityAnalysis(Path diffDetectiveCache, boolean ignorePCChanges, boolean extractCodeMatching) {
3535
this.groundTruthMap = new Hashtable<>();
3636
this.diffDetectiveCache = diffDetectiveCache;
3737
this.ignorePCChanges = ignorePCChanges;
@@ -47,13 +47,13 @@ public void endCommit(Analysis analysis) throws Exception {
4747

4848
GroundTruth groundTruth = this.groundTruthMap.getOrDefault(commit.getName(), new GroundTruth(new HashMap<>(), new HashSet<>()));
4949
// Complete all new or updated file ground truths
50-
GTExtraction.makeComplete(groundTruth);
50+
VariabilityAnalysis.makeComplete(groundTruth);
5151
Serde.serialize(resultFile.toFile(), groundTruth);
5252
this.groundTruthMap.remove(commit.getName());
53-
synchronized (FullPCAnalysis.class) {
54-
FullPCAnalysis.numProcessed++;
55-
if (FullPCAnalysis.numProcessed % 1_000 == 0) {
56-
Logger.info("Finished Commit ({}): {}", FullPCAnalysis.numProcessed, commit.name());
53+
synchronized (FullVariabilityAnalysis.class) {
54+
FullVariabilityAnalysis.numProcessed++;
55+
if (FullVariabilityAnalysis.numProcessed % 1_000 == 0) {
56+
Logger.info("Finished Commit ({}): {}", FullVariabilityAnalysis.numProcessed, commit.name());
5757
}
5858
}
5959
}
@@ -88,7 +88,7 @@ public boolean analyzeVariationDiff(Analysis analysis) throws Exception {
8888
analysis.getCurrentVariationDiff().forAll(node -> {
8989
// Logger.debug("Node: {}", node);
9090
try {
91-
GTExtraction.analyzeNode(fileGT, node, Time.AFTER, ignorePCChanges);
91+
VariabilityAnalysis.analyzeNode(fileGT, node, Time.AFTER, ignorePCChanges);
9292
} catch (MatchingException e) {
9393
Logger.error("unhandled exception while analyzing {} -> {} for commit {}.",
9494
fileNameBefore,

0 commit comments

Comments
 (0)