Skip to content

Commit

Permalink
refactor(AbstractFastTracking): rename field dico into dictionnary
Browse files Browse the repository at this point in the history
  • Loading branch information
nharrand committed Mar 1, 2019
1 parent 7a3fe2f commit 1007b8e
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 23 deletions.
14 changes: 7 additions & 7 deletions src/main/java/fr/inria/yajta/api/AbstractFastTracking.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
public abstract class AbstractFastTracking implements FastTracking {
private int elementCount = 1;

protected BiMap<String, Integer> dico = HashBiMap.create();
public BiMap<String, Integer> getDico() {
return dico;
protected BiMap<String, Integer> dictionary = HashBiMap.create();
public BiMap<String, Integer> getDictionary() {
return dictionary;
}

public File log;
Expand All @@ -24,9 +24,9 @@ public void setLogFile(File log) {
public int register(String clazz, String method, String branch) {
String id = clazz + "." + method + "#" + branch;
int r;
if(dico.containsKey(id)) r = dico.get(id);
if(dictionary.containsKey(id)) r = dictionary.get(id);
else {
dico.put(id,elementCount);
dictionary.put(id,elementCount);
r = elementCount;
elementCount++;
}
Expand All @@ -37,9 +37,9 @@ public int register(String clazz, String method, String branch) {
public int register(String clazz, String method) {
String id = clazz + "." + method;
int r;
if(dico.containsKey(id)) r = dico.get(id);
if(dictionary.containsKey(id)) r = dictionary.get(id);
else {
dico.put(id,elementCount);
dictionary.put(id,elementCount);
r = elementCount;
elementCount++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ public void setLogFile(File log) {
public void load(MyMap<Long, IdTreeNode> threadLogs, MyMap<Long, Boolean> threadOfftrack, BiMap<String,Integer> dico) {
this.threadLogs = threadLogs;
this.threadOfftrack = threadOfftrack;
this.dico = dico;
this.dictionary = dico;
}

public void offTrack(long thread, int method, int cur) {
BiMap<Integer, String> d = dico.inverse();
BiMap<Integer, String> d = dictionary.inverse();
System.err.println("[OFF TRACK] <" + d.get(method) + "> instead of <" + d.get(cur) + ">");
threadOfftrack.put(thread,true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void flush() {
else log = new File("log" + i);
}
try {
BiMap<Integer, String> rdico = dico.inverse();
BiMap<Integer, String> rdico = dictionary.inverse();
IdTreeNode.dico = i -> rdico.get(i);

if(log.exists()) log.delete();
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/fr/inria/yajta/processor/loggers/FastTie.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.*;

public class FastTie extends AbstractFastTracking implements FastTracking {
//Set<Integer> visited = new HashSet<>();
Set<Integer> visited = new TreeSet<>();

static FastTie instance;
Expand All @@ -17,8 +16,8 @@ public static FastTie getInstance() {
return instance;
}

public void printDico() {
for(Map.Entry<String, Integer> e :dico.entrySet()) {
public void printDictionary() {
for(Map.Entry<String, Integer> e : dictionary.entrySet()) {
System.err.println("M: " + e.getKey() + " -> " + e.getValue());
}
}
Expand All @@ -28,7 +27,7 @@ public void stepIn(long thread, int id) {
//System.err.println("[FastTie] step in " + id);
if(visited.contains(id)) return;
visited.add(id);
System.out.println(dico.inverse().get(id) + " is new.");
System.out.println(dictionary.inverse().get(id) + " is new.");
/*ClassLoader cl = FastTie.class.getClassLoader();
try {
System.out.println("path: " + (String) cl.loadClass("spoon.test.main.MainTest").getField("curPath").get(null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void testProduceRemoteTraceThenReadTrace() throws MalformedTrackingClassE

//Check that the logs collected are consistent with what was expected
List<TestFastLogger.Log> logs = TestFastLogger.getInstance().logs;
BiMap<Integer, String> dico = TestFastLogger.getInstance().getDico().inverse();
BiMap<Integer, String> dico = TestFastLogger.getInstance().getDictionary().inverse();


//contract: Every method and each branch is indeed logged (in and out)
Expand Down Expand Up @@ -83,7 +83,7 @@ public void testReadTrace() throws InterruptedException {

//Check that the logs collected are consistent with what was expected
List<TestFastLogger.Log> logs = TestFastLogger.getInstance().logs;
BiMap<Integer, String> dico = TestFastLogger.getInstance().getDico().inverse();
BiMap<Integer, String> dico = TestFastLogger.getInstance().getDictionary().inverse();


//contract: Every method and each branch is indeed logged (in and out)
Expand Down
5 changes: 2 additions & 3 deletions src/test/java/fr/inria/yajta/api/FastTracerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import fr.inria.yajta.api.loggerimplem.TestFastLogger;
import org.junit.Test;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -32,7 +31,7 @@ public void testProbesInsertion() throws MalformedTrackingClassException {
logs.stream().filter(l -> l.type == TestFastLogger.LOGTYPE.OUT).count()
);

BiMap<Integer, String> dico = TestFastLogger.getInstance().getDico().inverse();
BiMap<Integer, String> dico = TestFastLogger.getInstance().getDictionary().inverse();

//First method logged is "main", "fr.inria.helloworld.App", "main(java.lang.String[])"
assertEquals("fr.inria.helloworldf.App.main(java.lang.String[])", logs.get(0).getElementName(dico));
Expand All @@ -52,7 +51,7 @@ public void testBranchProbesInsertion() throws MalformedTrackingClassException {
"main",
logs);

BiMap<Integer, String> dico = TestFastLogger.getInstance().getDico().inverse();
BiMap<Integer, String> dico = TestFastLogger.getInstance().getDictionary().inverse();


//contract: Every method and each branch is indeed logged (in and out)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void testReadTrace() throws InterruptedException {

//Feed traces to FastTie
MyMap<Long, IdTreeNode> oldLogs = FastLogger.getInstance().exportLogs();
BiMap<String, Integer> oldDico = FastLogger.getInstance().getDico();
BiMap<String, Integer> oldDico = FastLogger.getInstance().getDictionary();

FastFollower follower = new FastFollower();
MyMap<Long, Boolean> threadOfftrack = new MyMap<>();
Expand Down Expand Up @@ -56,7 +56,7 @@ public void testDivergentTrace() throws InterruptedException {

//Feed traces to FastTie
MyMap<Long, IdTreeNode> oldLogs = FastLogger.getInstance().exportLogs();
BiMap<String, Integer> oldDico = FastLogger.getInstance().getDico();
BiMap<String, Integer> oldDico = FastLogger.getInstance().getDictionary();

FastFollower follower = new FastFollower();
MyMap<Long, Boolean> threadOfftrack = new MyMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public void testReadTrace() throws InterruptedException {

//Feed traces to FastTie
Set<Integer> logs = FastTie.getInstance().visited;
BiMap<Integer, String> dico = FastTie.getInstance().getDico().inverse();
BiMap<Integer, String> dico = FastTie.getInstance().getDictionary().inverse();


//contract: Every method and each branch is indeed logged (in and out)
assertTrue(logs.size() == 47);

//contract: As we only log each distinct method once, dico should have the same size as log
//contract: As we only log each distinct method once, dictionary should have the same size as log
assertEquals(logs.size(), dico.size());

}
Expand Down

0 comments on commit 1007b8e

Please sign in to comment.