예제 #1
0
 public void process(String projectId, Date from, Date to) {
   reset();
   Collection<VcsCommitInfo> allCommits = getCommitsForProject(projectId, from, to);
   generateTestAndTrainSets(allCommits);
   System.out.println("Processing commits...");
   int total = allCommits.size();
   int counter = 0;
   long startTime = System.currentTimeMillis();
   for (VcsCommitInfo commitInfo : allCommits) {
     counter++;
     if (counter % 100 == 0) {
       System.out.println(
           counter
               + " / "
               + total
               + " | last 100 processed in "
               + (System.currentTimeMillis() - startTime)
               + " ms");
       startTime = System.currentTimeMillis();
     }
     for (String filename : commitInfo.getAffectedFiles()) {
       if (!commitAffections.containsKey(filename)) {
         commitAffections.put(filename, new ArrayList<VcsCommitInfo>());
       }
       commitAffections.get(filename).add(commitInfo);
     }
     if (VcsCommitInfoUtils.isRelatedToBugIssue(commitInfo)) {
       for (String filename : commitInfo.getAffectedFiles()) {
         if (!bugFixCommitAffections.containsKey(filename)) {
           bugFixCommitAffections.put(filename, new ArrayList<VcsCommitInfo>());
         }
         bugFixCommitAffections.get(filename).add(commitInfo);
       }
     }
     for (PredictionModel model : myModels) {
       if (trainSet.contains(commitInfo.getCommitId())) {
         // train the model
         model.update(commitInfo, true);
       }
       if (testSet.contains(commitInfo.getCommitId())) {
         // update the model without training and get prediction data
         Map<String, List<VcsCommitInfo>> topAppearanceMapForCurrentModel =
             appearancesInTop.get(model);
         for (String fileInTop : model.getPredictionData().keySet()) {
           if (!topAppearanceMapForCurrentModel.containsKey(fileInTop)) {
             topAppearanceMapForCurrentModel.put(fileInTop, new ArrayList<VcsCommitInfo>());
           }
           topAppearanceMapForCurrentModel.get(fileInTop).add(commitInfo);
         }
       }
     }
   }
 }
예제 #2
0
 public void dumpData(String projectId, Date from, Date to, int part) {
   String postfix = "_" + part;
   dump(projectId, "time_allFiles" + postfix + ".dat", getAllAffectionToBugFixIntervals());
   dump(projectId, "commits_allFiles" + postfix + ".dat", getAllAffectionToBugFixCommitNumbers());
   dump(projectId, "bugfixDensity" + postfix + ".dat", getBugFixTimes(projectId, from, to));
   int n = 0;
   for (PredictionModel model : myModels) {
     dump(
         projectId,
         model.getParameters().getAbbreviation() + postfix + ".dat",
         getAllTopToBugFixIntervals(model));
     dump(
         projectId,
         "commits_" + model.getParameters().getAbbreviation() + postfix + ".dat",
         getAllTopToBugFixCommitNumbers(model));
   }
 }