Skip to content

Commit

Permalink
Apply thread to AnnotationGraphBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
yoon committed Mar 22, 2020
1 parent f69fc39 commit ba7f229
Show file tree
Hide file tree
Showing 3 changed files with 247 additions and 199 deletions.
15 changes: 1 addition & 14 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,7 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/main/resources">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/test" path="src/test/resources">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-13/"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-12/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
42 changes: 20 additions & 22 deletions src/main/java/hgu/csee/isel/alinew/szz/AGSZZ.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.apache.commons.io.FileUtils;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;

import hgu.csee.isel.alinew.szz.exception.EmptyHunkTypeException;
import hgu.csee.isel.alinew.szz.graph.AnnotationGraphBuilder;
import hgu.csee.isel.alinew.szz.graph.AnnotationGraphModel;
import hgu.csee.isel.alinew.szz.model.Line;
Expand All @@ -27,6 +24,7 @@ public class AGSZZ {
private List<String> BFCList = new ArrayList<>();
private boolean debug;
private File localPath;
public static AnnotationGraphModel agm = new AnnotationGraphModel();

public AGSZZ(String gIT_URL, List<String> bFCList, boolean debug) {
this.GIT_URL = gIT_URL;
Expand All @@ -38,55 +36,55 @@ public void run() throws IOException {
try {
// Clone
final String REMOTE_URI = GIT_URL + ".git";

// prepare a new folder for the cloned repository
localPath = File.createTempFile("TestGitRepository", "");
if (!localPath.delete()) {
throw new IOException("Could not delete temporary file " + localPath);
}

System.out.println("\nCloning from " + REMOTE_URI + " to " + localPath);

Git git = Git.cloneRepository()
.setURI(REMOTE_URI)
.setDirectory(localPath)
.call();
Git git = Git.cloneRepository().setURI(REMOTE_URI).setDirectory(localPath).call();

System.out.println("Having repository: " + git.getRepository().getDirectory());

Repository repo = git.getRepository();

List<RevCommit> revs = GitUtils.getRevs(git);

List<RevCommit> bfcList = GitUtils.getBFCList(BFCList, revs);

List<String> targetPaths = GitUtils.getTargetPaths(repo, bfcList);

RevsWithPath revsWithPath = GitUtils.collectRevsWithSpecificPath(GitUtils.configurePathRevisionList(repo, revs), targetPaths);


RevsWithPath revsWithPath = GitUtils
.collectRevsWithSpecificPath(GitUtils.configurePathRevisionList(repo, revs), targetPaths);

// Phase 1 : Build the annotation graph
final long startBuildingTime = System.currentTimeMillis();

AnnotationGraphBuilder agb = new AnnotationGraphBuilder();
AnnotationGraphModel agm = agb.buildAnnotationGraph(repo, revsWithPath, debug);
agb.buildAnnotationGraph(repo, revsWithPath, debug);

final long endBuildingTime = System.currentTimeMillis();
System.out.println("\nBuilding Annotation Graph takes " + (endBuildingTime - startBuildingTime) / 1000.0 + "s\n");

// Phase 2 : Trace and collect BIC candidates and filter out format changes, comments, etc among candidates
// Phase 2 : Trace and collect BIC candidates and filter out format changes,
// comments, etc among candidates
final long startTracingTime = System.currentTimeMillis();

Tracer tracer = new Tracer();
//List<Line> BILines = tracer.collectBILines(repo, revs, agm, revsWithPath, BFCList, debug);
// List<Line> BILines = tracer.collectBILines(repo, revs, agm, revsWithPath,
// BFCList, debug);
List<Line> BILines = tracer.collectBILines(repo, bfcList, agm, revsWithPath, debug);

final long endTracingTime = System.currentTimeMillis();
System.out.println("\nCollecting BICs takes " + (endTracingTime - startTracingTime) / 1000.0 + "s\n");

// Phase 3 : store outputs
Utils.storeOutputFile(GIT_URL, BILines);

} catch (IOException | GitAPIException | EmptyHunkTypeException e) {
} catch (IOException | GitAPIException e) {
e.printStackTrace();
} finally {
// clean up here to not keep using more and more disk-space for these samples
Expand Down
Loading

0 comments on commit ba7f229

Please sign in to comment.