[Pkg-mozext-commits] [nostalgy] 204/252: Improve performance of statistical prediction. (Patch contributed by Wolfgang Mayer.)

David Prévot taffit at moszumanska.debian.org
Tue Jun 14 15:24:59 UTC 2016


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

taffit pushed a commit to branch master
in repository nostalgy.

commit 8e2a53ced1e69986ea0acedcff5e80ee648fd152
Author: frisch <frisch at 56b81dcf-5a2f-0410-9db0-014be2e416ff>
Date:   Tue Sep 7 16:50:41 2010 +0000

    Improve performance of statistical prediction. (Patch contributed by Wolfgang Mayer.)
---
 CHANGES                |  3 +++
 content/edit_prefs.js  |  6 ++++++
 content/edit_prefs.xul |  4 ++++
 content/nfpredict.js   | 17 ++++++++++++++++-
 files                  | 22 +++++++++++-----------
 5 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/CHANGES b/CHANGES
index 1b7909f..2f9db9a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+Since 0.2.25
+  - Improve performance of statistical prediction. (Patch contributed by Wolfgang Mayer.)
+
 0.2.25
   - Use a prefix for all public identifiers in order to comply with amo
     packaging policy.
diff --git a/content/edit_prefs.js b/content/edit_prefs.js
index bf1de18..a1d6335 100644
--- a/content/edit_prefs.js
+++ b/content/edit_prefs.js
@@ -208,6 +208,11 @@ function onNostalgyAcceptChanges() {
   } catch (exn) {
       NostalgyDebug(exn);
   }
+  try {
+      prefs.setIntPref("extensions.nostalgy.predict_max_addresses_to_update", 0 + NostalgyEBI("predict_max_addresses_to_update").value);
+  } catch (exn) {
+      NostalgyDebug(exn);
+  }
 
   for (var n in nostalgy_completion_options)
     prefs.setBoolPref("extensions.nostalgy."+n,	NostalgyEBI(n).checked);
@@ -320,6 +325,7 @@ function onNostalgyLoad() {
    NostalgyEBI(n).checked = NostalgyGetBoolPref(prefs, n);
 
  NostalgyEBI("number_of_recent_folders").value = NostalgyGetIntPref(prefs, "number_of_recent_folders", 5);
+ NostalgyEBI("predict_max_addresses_to_update").value = NostalgyGetIntPref(prefs, "predict_max_addresses_to_update", 100);
 
  nostalgy_key_rows = NostalgyEBI("nostalgy_key_rows");
  for (var i = 0; i < nostalgy_keys.length; i++) {
diff --git a/content/edit_prefs.xul b/content/edit_prefs.xul
index 531cd2f..3fe2369 100644
--- a/content/edit_prefs.xul
+++ b/content/edit_prefs.xul
@@ -88,6 +88,10 @@ shortcuts to move/copy the message to this folder.</label>
      <label>Number of recent folders to remember:</label>
      <textbox type="number" min="0" max="50" id="number_of_recent_folders"/>
    </hbox>
+   <hbox align="center">
+     <label>Number of addresses to consider for statistical prediction:</label>
+     <textbox type="number" min="0" max="99999" id="predict_max_addresses_to_update"/>
+   </hbox>
  </groupbox>
  </tabpanel>
 
diff --git a/content/nfpredict.js b/content/nfpredict.js
index 9c1f154..d279f1d 100644
--- a/content/nfpredict.js
+++ b/content/nfpredict.js
@@ -5,6 +5,9 @@ var nostalgy_DBFile = 'nfpredict.sqlite';
 var nostalgy_CreateTablesQuery1 = 'CREATE TABLE IF NOT EXISTS addresses (id INTEGER PRIMARY KEY AUTOINCREMENT, address TEXT, count INTEGER)';
 var nostalgy_CreateTablesQuery2 = 'CREATE TABLE IF NOT EXISTS folders (id INTEGER PRIMARY KEY AUTOINCREMENT, folder TEXT)';
 var nostalgy_CreateTablesQuery3 = 'CREATE TABLE IF NOT EXISTS probabilities (id INTEGER PRIMARY KEY AUTOINCREMENT, address_id INTEGER, folder_id INTEGER, probability REAL, count INTEGER)';
+var nostalgy_CreateIndexesQuery1 = 'CREATE INDEX IF NOT EXISTS address_index on addresses(address)';
+var nostalgy_CreateIndexesQuery2 = 'CREATE INDEX IF NOT EXISTS folder_index on folders(folder)';
+var nostalgy_CreateIndexesQuery3 = 'CREATE INDEX IF NOT EXISTS probabilities_index on probabilities(address_id,folder_id)';
 
 var nostalgy_PredictQueryA = 'SELECT avg(probabilities.count*100/addresses.count) as prob,folder FROM addresses,folders,probabilities '+
     'WHERE probabilities.address_id=addresses.id AND  probabilities.folder_id=folders.id AND addresses.address in (';
@@ -60,6 +63,9 @@ var NostalgyPredict =
         nostalgy_sqlite.cmd(this.getDBFile(),nostalgy_CreateTablesQuery1);
         nostalgy_sqlite.cmd(this.getDBFile(),nostalgy_CreateTablesQuery2);
         nostalgy_sqlite.cmd(this.getDBFile(),nostalgy_CreateTablesQuery3);
+        nostalgy_sqlite.cmd(this.getDBFile(),nostalgy_CreateIndexesQuery1);
+        nostalgy_sqlite.cmd(this.getDBFile(),nostalgy_CreateIndexesQuery2);
+        nostalgy_sqlite.cmd(this.getDBFile(),nostalgy_CreateIndexesQuery3);
     },
 
     dbExists: function() {
@@ -170,6 +176,9 @@ var NostalgyPredict =
     },
 
     update_folder: function (nsiFolder) {
+        if (nostalgy_completion_options.use_statistical_prediction==false)
+            return;
+
         if ( this.inited==false )
             this.init();
 
@@ -186,9 +195,15 @@ var NostalgyPredict =
 
         email_re = /(([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+)/;
         var aAdresses = addresses.split(email_re);
+        //  limit number of addresses to be updated (avoids excessive processing time for large address lists)
+        var maxAddresses = 100;
+        try {
+            maxAddresses = NostalgyGetIntPref("predict_max_addresses_to_update",maxAdresses);
+        } catch (ex) { }
         for (var i=0; i < aAdresses.length; i++) {
             //NostalgyDebug(aAdresses[i]);
-            if (aAdresses[i].match(email_re) && this.keep_email(aAdresses[i]) ) {
+            if (aAdresses[i].match(email_re) && this.keep_email(aAdresses[i]) && maxAddresses>0 ) {
+                maxAddresses--;
                 //NostalgyDebug(nostalgy_CountsQuery+" "+folder_id+" "+aAdresses[i]);
                 var nostalgy_Array1 = nostalgy_sqlite.select(this.getDBFile(),nostalgy_CountsQuery,folder_id,aAdresses[i]);
                 if (nostalgy_Array1.length==0) {
diff --git a/files b/files
index 7737634..ec7d0f2 100644
--- a/files
+++ b/files
@@ -1,23 +1,23 @@
-content/header_parser.js
+content/about.xhtml
 content/about.xul
-content/edit_rule.js
+content/composer.js
+content/composerOverlay.xul
 content/dummy_window.xul
-content/messageOverlay.xul
 content/edit_prefs.js
-content/nostalgy_keys.js
-content/composer.js
 content/edit_prefs.xul
-content/composerOverlay.xul
+content/edit_rule.js
+content/edit_rule.xul
 content/folders.js
-content/nfpredict.js
+content/header_parser.js
+content/messageOverlay.xul
 content/misc.js
+content/nfpredict.js
 content/nostalgy.js
-content/thunderbirdOverlay.xul
-content/edit_rule.xul
+content/nostalgy_keys.js
 content/sqlite.js
-content/about.xhtml
-locale/en-US/nostalgy.properties
+content/thunderbirdOverlay.xul
 locale/en-US/nostalgy.dtd
+locale/en-US/nostalgy.properties
 defaults/preferences/nostalgy.js
 install.rdf
 chrome.manifest

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/nostalgy.git



More information about the Pkg-mozext-commits mailing list