gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-schemafuzz] branch master updated: Tweaking done.not


From: gnunet
Subject: [GNUnet-SVN] [taler-schemafuzz] branch master updated: Tweaking done.not tested.Need to hash stacktrace
Date: Fri, 20 Jul 2018 17:05:27 +0200

This is an automated email from the git hooks/post-receive script.

erwan-ulrich pushed a commit to branch master
in repository schemafuzz.

The following commit(s) were added to refs/heads/master by this push:
     new b90aa4e  Tweaking done.not tested.Need to hash stacktrace
b90aa4e is described below

commit b90aa4e328a557311e26837f0633848254f827b0
Author: Feideus <address@hidden>
AuthorDate: Fri Jul 20 17:05:18 2018 +0200

    Tweaking done.not tested.Need to hash stacktrace
---
 src/main/java/org/schemaspy/DBFuzzer.java          | 13 ++++----
 .../java/org/schemaspy/model/GenericTreeNode.java  | 18 +++++-----
 src/main/java/org/schemaspy/model/Scorer.java      | 39 ++++++++++++++++++----
 3 files changed, 49 insertions(+), 21 deletions(-)

diff --git a/src/main/java/org/schemaspy/DBFuzzer.java 
b/src/main/java/org/schemaspy/DBFuzzer.java
index 6b9e1db..fb898da 100644
--- a/src/main/java/org/schemaspy/DBFuzzer.java
+++ b/src/main/java/org/schemaspy/DBFuzzer.java
@@ -59,9 +59,9 @@ public class DBFuzzer
         //Evaluation
         try
         {
-            int mark;
+            double mark;
             Process evaluatorProcess = new ProcessBuilder("/bin/bash", 
"./aLittleBitLessDumbEvaluator.sh").start();
-            mark = Integer.parseInt(getEvaluatorResponse(evaluatorProcess));
+            mark = Double.parseDouble(getEvaluatorResponse(evaluatorProcess));
             rootMutation.setInterest_mark(mark);
             rootMutation.setWeight(mark);
             rootMutation.propagateWeight();
@@ -82,7 +82,7 @@ public class DBFuzzer
         boolean returnStatus = true;
         int TreeDepth = 0;
         int maxDepth = 
Integer.parseInt(analyzer.getCommandLineArguments().getMaxDepth());
-        int mark = 0;
+        double mark = 0.0;
         //adding CASCADE to all foreign key tableColumns.
         settingTemporaryCascade(false); // need to drop and recreate database
 
@@ -185,7 +185,7 @@ public class DBFuzzer
             {
                 // the evaluator sets a mark for representing how interesting 
the mutation was
                     Process tmpProcess = new ProcessBuilder("/bin/bash", 
"./emulated_program.sh").start(); // this should go soon now.
-                    mark = Integer.parseInt(getEvaluatorResponse(tmpProcess));
+                    mark = 
Double.parseDouble(getEvaluatorResponse(tmpProcess));
                 currentMutation.setInterest_mark(mark);
                 currentMutation.setWeight(mark);
                 currentMutation.propagateWeight(); //update parents weight 
according to this node new weight
@@ -198,6 +198,7 @@ public class DBFuzzer
                 ReportVector mutationReport = new 
ReportVector(currentMutation);
                 
mutationReport.parseFile("errorReports/parsedStackTrace_"+currentMutation.getId());
                 currentMutation.setReportVector(mutationReport);
+                currentMutation.setInterest_mark(new 
Scorer().score(currentMutation,mutationTree));
                 LOGGER.info(mutationReport.toString());
             }
             catch(Exception e)
@@ -358,7 +359,7 @@ public class DBFuzzer
     public GenericTreeNode chooseNextMutation()
     {
         GenericTreeNode previousMutation = mutationTree.getLastMutation();
-        int markingDiff = previousMutation.getInterest_mark();
+        double markingDiff = previousMutation.getInterest_mark();
         Random rand = new Random();
 
         if (mutationTree.getNumberOfNodes() > 1) // first mutation doesnt have 
a predecessor
@@ -368,7 +369,7 @@ public class DBFuzzer
 
         if (mutationTree.getRoot() != null)
         {
-            if (markingDiff > 0 ) //
+            if (markingDiff > 0.0 ) //
             {
                 System.out.println("creation1");
                 int randNumber = 
rand.nextInt(previousMutation.getPotential_changes().size());
diff --git a/src/main/java/org/schemaspy/model/GenericTreeNode.java 
b/src/main/java/org/schemaspy/model/GenericTreeNode.java
index 5bcc794..2d1a81c 100644
--- a/src/main/java/org/schemaspy/model/GenericTreeNode.java
+++ b/src/main/java/org/schemaspy/model/GenericTreeNode.java
@@ -12,8 +12,8 @@ public class GenericTreeNode {
 
 
     private final Integer id;
-    private Integer interest_mark;
-    private Integer weight;
+    private double interest_mark;
+    private double weight;
     private Integer subTreeWeight;
     private int depth;
     private Row initial_state_row;
@@ -33,7 +33,7 @@ public class GenericTreeNode {
         //this.cascadingFK = false;
         this.subTreeWeight = 0;
         this.parent = null;
-        this.weight = 1;
+        this.weight = 1.0;
         this.depth = 0;
         this.id = id;
         this.isFirstApperance = true;
@@ -46,7 +46,7 @@ public class GenericTreeNode {
         //this.cascadingFK = false;
         this.parent = parentMutation;
         this.subTreeWeight = 0;
-        this.weight = 1;
+        this.weight = 1.0;
         this.id = id;
         initDepth();
         this.isFirstApperance = isFirstApperance;
@@ -80,7 +80,7 @@ public class GenericTreeNode {
         this.potential_changes = potCh;
     }
 
-    public Integer getWeight() {
+    public double getWeight() {
         return this.weight;
     }
 
@@ -118,7 +118,7 @@ public class GenericTreeNode {
         this.subTreeWeight = tmp;
     }
 
-    public void setWeight(int weight) {
+    public void setWeight(double weight) {
         this.weight = weight;
     }
 
@@ -141,7 +141,7 @@ public class GenericTreeNode {
         rnd -= potential_changes.size(); // removing the potential changes 
"weight" of the current node to match subtree Weight
         for (GenericTreeNode n : children) // launching on every child if 
current node wasnt picked.
         {
-            int w = n.getWeight();
+            double w = n.getWeight();
             if (rnd < w) {
                 return n.singleChangeBasedOnWeight();
             }
@@ -172,11 +172,11 @@ public class GenericTreeNode {
         return initial_state_row;
     }
 
-    public int getInterest_mark() {
+    public double getInterest_mark() {
         return this.interest_mark;
     }
 
-    public void setInterest_mark(int mark) {
+    public void setInterest_mark(double mark) {
         this.interest_mark = mark;
     }
 
diff --git a/src/main/java/org/schemaspy/model/Scorer.java 
b/src/main/java/org/schemaspy/model/Scorer.java
index 317c62a..de7a5fb 100644
--- a/src/main/java/org/schemaspy/model/Scorer.java
+++ b/src/main/java/org/schemaspy/model/Scorer.java
@@ -52,8 +52,10 @@ public class Scorer {
         return hash;
     }
 
-    public int score () {
-
+    public double score (GenericTreeNode gtn,GenericTree mutationTree)
+    {
+        flushContext();
+        initContext(gtn,mutationTree);
         Scorer sc = new Scorer();
         //Lets create the centroids or 'average' locations of center for our 
points
         double[][] centroids;
@@ -68,9 +70,9 @@ public class Scorer {
         sc.solve();
 
         //Now lets predict our test array
-        sc.closestClusterIndex(euclideanDistances);
-
+        //sc.closestClusterIndex(euclideanDistances); // not used right now 
cause we need ALL the distances.
 
+        return computeScore();
     }
 
 
@@ -251,10 +253,35 @@ public class Scorer {
         return euclideanDistances;//Return cluster index of shortest distance
     }
 
-    public int computeScore()
+    private double computeScore()
+    {
+        double res = 0;
+        for(Double distance : euclideanDistances.keySet())
+        {
+            res = res + distance;
+        }
+        return res;
+    }
+
+    private void initContext(GenericTreeNode gtn,GenericTree mutationTree)
     {
+        int i = 0;
+        ReportVector rpv = gtn.getReportVector();
+        rpv.setStackTraceHash(rpv.hashStackTrace());
+        predict = rpv.getStackTraceHash();
+        for(GenericTreeNode gtnLoop : mutationTree.toArray())
+        {
+            double[] data = gtnLoop.getReportVector().getStackTraceHash();
+            input[i] = data;
+            i++;
+        }
+    }
 
-        return 0;
+    private void flushContext()
+    {
+        predict = null;
+        input = null;
+        clusters = new HashMap();
     }
 
 }

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]