diff --git a/src/main/java/org/codetracker/AttributeTrackerImpl.java b/src/main/java/org/codetracker/AttributeTrackerImpl.java index 3f10681eed1..a3422863a08 100644 --- a/src/main/java/org/codetracker/AttributeTrackerImpl.java +++ b/src/main/java/org/codetracker/AttributeTrackerImpl.java @@ -42,18 +42,23 @@ public History track() throws Exception { ArrayDeque attributes = new ArrayDeque<>(); attributes.addFirst(start); + Map> map = new LinkedHashMap<>(); HashSet analysedCommits = new HashSet<>(); List commits = null; String lastFileName = null; while (!attributes.isEmpty()) { Attribute currentAttribute = attributes.poll(); - if (currentAttribute.isAdded()) { + if (currentAttribute.isAdded() || currentAttribute.getVersion().getId().equals("0")) { commits = null; continue; } if (commits == null || !currentAttribute.getFilePath().equals(lastFileName)) { lastFileName = currentAttribute.getFilePath(); commits = getCommits(repository, currentAttribute.getVersion().getId(), lastFileName, git); + if (map.containsKey(currentAttribute.getVersion().getId()) && map.get(currentAttribute.getVersion().getId()).equals(commits)) { + break; + } + map.put(currentAttribute.getVersion().getId(), commits); historyReport.gitLogCommandCallsPlusPlus(); analysedCommits.clear(); } diff --git a/src/main/java/org/codetracker/AttributeTrackerWithLocalFiles.java b/src/main/java/org/codetracker/AttributeTrackerWithLocalFiles.java index 46b0a699e90..47c5390e336 100644 --- a/src/main/java/org/codetracker/AttributeTrackerWithLocalFiles.java +++ b/src/main/java/org/codetracker/AttributeTrackerWithLocalFiles.java @@ -59,6 +59,7 @@ public History track() throws Exception { ArrayDeque attributes = new ArrayDeque<>(); attributes.addFirst(start); + Map> map = new LinkedHashMap<>(); HashSet analysedCommits = new HashSet<>(); List commits = null; String lastFileName = null; @@ -77,6 +78,10 @@ public History track() throws Exception { String jsonPath = System.getProperty("user.dir") + "/src/test/resources/attribute/" + repoName + "-" + className + "-" + changeHistory.getAttributeName() + ".json"; File jsonFile = new File(jsonPath); commits = getCommits(currentAttribute.getVersion().getId(), jsonFile); + if (map.containsKey(currentAttribute.getVersion().getId()) && map.get(currentAttribute.getVersion().getId()).equals(commits)) { + break; + } + map.put(currentAttribute.getVersion().getId(), commits); historyReport.gitLogCommandCallsPlusPlus(); analysedCommits.clear(); } diff --git a/src/main/resources/oracle/attribute/test/hadoop-SchedulerApplicationAttempt-liveContainers.json b/src/main/resources/oracle/attribute/test/hadoop-SchedulerApplicationAttempt-liveContainers.json index b0c23ba891b..1a396b8605c 100644 --- a/src/main/resources/oracle/attribute/test/hadoop-SchedulerApplicationAttempt-liveContainers.json +++ b/src/main/resources/oracle/attribute/test/hadoop-SchedulerApplicationAttempt-liveContainers.json @@ -138,39 +138,6 @@ "elementFileAfter": "hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSSchedulerApp.java", "elementNameAfter": "hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSSchedulerApp@(private)liveContainers:Map(80)", "comment": "new attribute" - }, - { - "parentCommitId": "30099efb3525265f8b9fccd2709d45327f5b6724", - "commitId": "7f2b1eadc1b0807ec1302a0c3488bf6e7a59bc76", - "commitTime": 1342489383, - "changeType": "container change", - "elementFileBefore": "hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApp.java", - "elementNameBefore": "hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApp@(private)liveContainers:Map(81)", - "elementFileAfter": "hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java", - "elementNameAfter": "hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp@(private)liveContainers:Map(89)", - "comment": "Move And Rename Class org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApp moved and renamed to org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp" - }, - { - "parentCommitId": "bb0005cfec5fd2861600ff5babd259b48ba18b63", - "commitId": "cd7157784e5e5ddc4e77144d042e54dd0d04bac1", - "commitTime": 1314231264, - "changeType": "container change", - "elementFileBefore": "hadoop-mapreduce/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApp.java", - "elementNameBefore": "hadoop-mapreduce/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApp@(private)liveContainers:Map(50)", - "elementFileAfter": "hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApp.java", - "elementNameAfter": "hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApp@(private)liveContainers:Map(50)", - "comment": "Move Source Folder hadoop-mapreduce to hadoop-mapreduce-project" - }, - { - "parentCommitId": "dd86860633d2ed64705b669a75bf318442ed6225", - "commitId": "dbecbe5dfe50f834fc3b8401709079e9470cc517", - "commitTime": 1313665630, - "changeType": "introduced", - "elementFileBefore": "hadoop-mapreduce/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApp.java", - "elementNameBefore": "hadoop-mapreduce/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApp@(private)liveContainers:Map(50)", - "elementFileAfter": "hadoop-mapreduce/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApp.java", - "elementNameAfter": "hadoop-mapreduce/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApp@(private)liveContainers:Map(50)", - "comment": "added with new class" } ] } \ No newline at end of file diff --git a/src/test/resources/attribute/test-expected.txt b/src/test/resources/attribute/test-expected.txt index ac13a043cd0..2e671705cbe 100644 --- a/src/test/resources/attribute/test-expected.txt +++ b/src/test/resources/attribute/test-expected.txt @@ -24,7 +24,7 @@ hadoop-SchedulerApplicationAttempt-MEM_AGGREGATE_ALLOCATION_CACHE_MSECS.json, 1, hadoop-SchedulerApplicationAttempt-lastMemoryAggregateAllocationUpdateTime.json, 1, 0, 0 hadoop-SchedulerApplicationAttempt-lastResourceSecondsMap.json, 1, 0, 0 hadoop-SchedulerApplicationAttempt-lastScheduledContainer.json, 7, 0, 0 -hadoop-SchedulerApplicationAttempt-liveContainers.json, 11, 0, 0 +hadoop-SchedulerApplicationAttempt-liveContainers.json, 8, 0, 0 hadoop-SchedulerApplicationAttempt-schedulingOpportunities.json, 7, 0, 0 hibernate-search-ClassLoaderHelper-log.json, 1, 0, 0 hibernate-search-DefaultBatchBackend-progressMonitor.json, 2, 0, 0