You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2008/06/12 15:21:01 UTC

svn commit: r667073 [3/13] - in /spamassassin/site/full/3.2.x: ./ doc/

Added: spamassassin/site/full/3.2.x/doc/Mail_SpamAssassin_BayesStore_SQL.html
URL: http://svn.apache.org/viewvc/spamassassin/site/full/3.2.x/doc/Mail_SpamAssassin_BayesStore_SQL.html?rev=667073&view=auto
==============================================================================
--- spamassassin/site/full/3.2.x/doc/Mail_SpamAssassin_BayesStore_SQL.html (added)
+++ spamassassin/site/full/3.2.x/doc/Mail_SpamAssassin_BayesStore_SQL.html Thu Jun 12 06:20:58 2008
@@ -0,0 +1,434 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>Mail::SpamAssassin::BayesStore::SQL - SQL Bayesian Storage Module Implementation</title>
+<link rev="made" href="mailto:jm@minotaur.apache.org" />
+</head>
+
+<body style="background-color: white">
+
+<p><a name="__index__"></a></p>
+<!-- INDEX BEGIN -->
+
+<ul>
+
+	<li><a href="#name">NAME</a></li>
+	<li><a href="#synopsis">SYNOPSIS</a></li>
+	<li><a href="#description">DESCRIPTION</a></li>
+	<li><a href="#methods">METHODS</a></li>
+	<ul>
+
+		<li><a href="#new">new</a></li>
+		<li><a href="#tie_db_readonly">tie_db_readonly</a></li>
+		<li><a href="#tie_db_writable">tie_db_writable</a></li>
+		<li><a href="#untie_db">untie_db</a></li>
+		<li><a href="#calculate_expire_delta">calculate_expire_delta</a></li>
+		<li><a href="#token_expiration">token_expiration</a></li>
+		<li><a href="#sync_due">sync_due</a></li>
+		<li><a href="#seen_get">seen_get</a></li>
+		<li><a href="#seen_put">seen_put</a></li>
+		<li><a href="#seen_delete">seen_delete</a></li>
+		<li><a href="#get_storage_variables">get_storage_variables</a></li>
+		<li><a href="#dump_db_toks">dump_db_toks</a></li>
+		<li><a href="#set_last_expire">set_last_expire</a></li>
+		<li><a href="#get_running_expire_tok">get_running_expire_tok</a></li>
+		<li><a href="#set_running_expire_tok">set_running_expire_tok</a></li>
+		<li><a href="#remove_running_expire_tok">remove_running_expire_tok</a></li>
+		<li><a href="#tok_get">tok_get</a></li>
+		<li><a href="#tok_get_all">tok_get_all</a></li>
+		<li><a href="#tok_count_change">tok_count_change</a></li>
+		<li><a href="#multi_tok_count_change">multi_tok_count_change</a></li>
+		<li><a href="#nspam_nham_get">nspam_nham_get</a></li>
+		<li><a href="#nspam_nham_change">nspam_nham_change</a></li>
+		<li><a href="#tok_touch">tok_touch</a></li>
+		<li><a href="#tok_touch_all">tok_touch_all</a></li>
+		<li><a href="#cleanup">cleanup</a></li>
+		<li><a href="#get_magic_re">get_magic_re</a></li>
+		<li><a href="#sync">sync</a></li>
+		<li><a href="#perform_upgrade">perform_upgrade</a></li>
+		<li><a href="#clear_database">clear_database</a></li>
+		<li><a href="#backup_database">backup_database</a></li>
+		<li><a href="#restore_database">restore_database</a></li>
+		<li><a href="#db_readable">db_readable</a></li>
+		<li><a href="#db_writable">db_writable</a></li>
+	</ul>
+
+	<li><a href="#private_methods">Private Methods</a></li>
+	<ul>
+
+		<li><a href="#_connect_db">_connect_db</a></li>
+		<li><a href="#_get_db_version">_get_db_version</a></li>
+		<li><a href="#_initialize_db">_initialize_db</a></li>
+		<li><a href="#_put_token">_put_token</a></li>
+		<li><a href="#_put_tokens">_put_tokens</a></li>
+		<li><a href="#_get_oldest_token_age">_get_oldest_token_age</a></li>
+		<li><a href="#_get_num_hapaxes">_get_num_hapaxes</a></li>
+		<li><a href="#_get_num_lowfreq">_get_num_lowfreq</a></li>
+		<li><a href="#_token_select_string">_token_select_string</a></li>
+	</ul>
+
+</ul>
+<!-- INDEX END -->
+
+<hr />
+<p>
+</p>
+<h1><a name="name">NAME</a></h1>
+<p>Mail::SpamAssassin::BayesStore::SQL - SQL Bayesian Storage Module Implementation</p>
+<p>
+</p>
+<hr />
+<h1><a name="synopsis">SYNOPSIS</a></h1>
+<p>
+</p>
+<hr />
+<h1><a name="description">DESCRIPTION</a></h1>
+<p>This module implementes a SQL based bayesian storage module.</p>
+<p>
+</p>
+<hr />
+<h1><a name="methods">METHODS</a></h1>
+<p>
+</p>
+<h2><a name="new">new</a></h2>
+<p>public class (Mail::SpamAssassin::BayesStore::SQL) new (Mail::Spamassassin::Bayes $bayes)</p>
+<p>Description:
+This methods creates a new instance of the Mail::SpamAssassin::BayesStore::SQL
+object.  It expects to be passed an instance of the Mail::SpamAssassin:Bayes
+object which is passed into the Mail::SpamAssassin::BayesStore parent object.</p>
+<p>This method sets up the database connection and determines the username to
+use in queries.</p>
+<p>
+</p>
+<h2><a name="tie_db_readonly">tie_db_readonly</a></h2>
+<p>public instance (Boolean) tie_db_readonly ();</p>
+<p>Description:
+This method ensures that the database connection is properly setup
+and working.  If necessary it will initialize a user's bayes variables
+so that they can begin using the database immediately.</p>
+<p>
+</p>
+<h2><a name="tie_db_writable">tie_db_writable</a></h2>
+<p>public instance (Boolean) tie_db_writable ()</p>
+<p>Description:
+This method ensures that the database connetion is properly setup
+and working. If necessary it will initialize a users bayes variables
+so that they can begin using the database immediately.</p>
+<p>
+</p>
+<h2><a name="untie_db">untie_db</a></h2>
+<p>public instance () untie_db ()</p>
+<p>Description:
+This method is unused for the SQL based implementation.</p>
+<p>
+</p>
+<h2><a name="calculate_expire_delta">calculate_expire_delta</a></h2>
+<p>public instance (%) calculate_expire_delta (Integer $newest_atime,
+                                             Integer $start,
+                                             Integer $max_expire_mult)</p>
+<p>Description:
+This method performs a calculation on the data to determine the optimum
+atime for token expiration.</p>
+<p>
+</p>
+<h2><a name="token_expiration">token_expiration</a></h2>
+<p>public instance (Integer, Integer,
+                 Integer, Integer) token_expiration(\% $opts,
+                                                    Integer $newdelta,
+                                                    @ @vars)</p>
+<p>Description:
+This method performs the database specific expiration of tokens based on
+the passed in <code>$newdelta</code> and <code>@vars</code>.</p>
+<p>
+</p>
+<h2><a name="sync_due">sync_due</a></h2>
+<p>public instance (Boolean) sync_due ()</p>
+<p>Description:
+This method determines if a database sync is currently required.</p>
+<p>Unused for SQL based implementation.</p>
+<p>
+</p>
+<h2><a name="seen_get">seen_get</a></h2>
+<p>public instance (String) seen_get (string $msgid)</p>
+<p>Description:
+This method retrieves the stored value, if any, for <code>$msgid</code>.  The return value
+is the stored string ('s' for spam and 'h' for ham) or undef if <code>$msgid</code> is not
+found.</p>
+<p>
+</p>
+<h2><a name="seen_put">seen_put</a></h2>
+<p>public (Boolean) seen_put (string $msgid, char $flag)</p>
+<p>Description:
+This method records <code>$msgid</code> as the type given by <code>$flag</code>.  <code>$flag</code> is one of
+two values 's' for spam and 'h' for ham.</p>
+<p>
+</p>
+<h2><a name="seen_delete">seen_delete</a></h2>
+<p>public instance (Boolean) seen_delete (string $msgid)</p>
+<p>Description:
+This method removes <code>$msgid</code> from the database.</p>
+<p>
+</p>
+<h2><a name="get_storage_variables">get_storage_variables</a></h2>
+<p>public instance (@) get_storage_variables ()</p>
+<p>Description:
+This method retrieves the various administrative variables used by
+the Bayes process and database.</p>
+<p>The values returned in the array are in the following order:</p>
+<p>0: scan count base</p>
+<p>1: number of spam</p>
+<p>2: number of ham</p>
+<p>3: number of tokens in db</p>
+<p>4: last expire atime</p>
+<p>5: oldest token in db atime</p>
+<p>6: db version value</p>
+<p>7: last journal sync</p>
+<p>8: last atime delta</p>
+<p>9: last expire reduction count</p>
+<p>10: newest token in db atime</p>
+<p>
+</p>
+<h2><a name="dump_db_toks">dump_db_toks</a></h2>
+<p>public instance () dump_db_toks (String $template, String $regex, Array @vars)</p>
+<p>Description:
+This method loops over all tokens, computing the probability for the token and then
+printing it out according to the passed in token.</p>
+<p>
+</p>
+<h2><a name="set_last_expire">set_last_expire</a></h2>
+<p>public instance (Boolean) set_last_expire (Integer $time)</p>
+<p>Description:
+This method sets the last expire time.</p>
+<p>
+</p>
+<h2><a name="get_running_expire_tok">get_running_expire_tok</a></h2>
+<p>public instance (String $time) get_running_expire_tok ()</p>
+<p>Description:
+This method determines if an expire is currently running and returns
+the last time set.</p>
+<p>There can be multiple times, so we just pull the greatest (most recent)
+value.</p>
+<p>
+</p>
+<h2><a name="set_running_expire_tok">set_running_expire_tok</a></h2>
+<p>public instance (String $time) set_running_expire_tok ()</p>
+<p>Description:
+This method sets the time that an expire starts running.</p>
+<p>
+</p>
+<h2><a name="remove_running_expire_tok">remove_running_expire_tok</a></h2>
+<p>public instance (Boolean) remove_running_expire_tok ()</p>
+<p>Description:
+This method removes the row in the database that indicates that
+and expire is currently running.</p>
+<p>
+</p>
+<h2><a name="tok_get">tok_get</a></h2>
+<p>public instance (Integer, Integer, Integer) tok_get (String $token)</p>
+<p>Description:
+This method retrieves a specificed token (<code>$token</code>) from the database
+and returns it's spam_count, ham_count and last access time.</p>
+<p>
+</p>
+<h2><a name="tok_get_all">tok_get_all</a></h2>
+<p>public instance (\@) tok_get (@ $tokens)</p>
+<p>Description:
+This method retrieves the specified tokens (<code>$tokens</code>) from storage and returns
+an array ref of arrays spam count, ham acount and last access time.</p>
+<p>
+</p>
+<h2><a name="tok_count_change">tok_count_change</a></h2>
+<p><table cellspacing="0" cellpadding="0"><tr><td>public instance (Boolean) tok_count_change (Integer $spam_count,
+<tr><td><td>    Integer $ham_count,
+<tr><td><td>    String $token,
+<tr><td><td>    String $atime)</table></p>
+<p>Description:
+This method takes a <code>$spam_count</code> and <code>$ham_count</code> and adds it to
+<code>$tok</code> along with updating <code>$tok</code>s atime with <code>$atime</code>.</p>
+<p>
+</p>
+<h2><a name="multi_tok_count_change">multi_tok_count_change</a></h2>
+<p><table cellspacing="0" cellpadding="0"><tr><td>public instance (Boolean) multi_tok_count_change (Integer $spam_count,
+<tr><td> <td>          Integer $ham_count,
+<tr><td><td> <td>          \% $tokens,
+<tr><td><td>          String $atime)</table></p>
+<p>Description:
+This method takes a <code>$spam_count</code> and <code>$ham_count</code> and adds it to all
+of the tokens in the <code>$tokens</code> hash ref along with updating each tokens
+atime with <code>$atime</code>.</p>
+<p>
+</p>
+<h2><a name="nspam_nham_get">nspam_nham_get</a></h2>
+<p>public instance ($spam_count, $ham_count) nspam_nham_get ()</p>
+<p>Description:
+This method retrieves the total number of spam and the total number of
+ham learned.</p>
+<p>
+</p>
+<h2><a name="nspam_nham_change">nspam_nham_change</a></h2>
+<p>public instance (Boolean) nspam_nham_change (Integer $num_spam,
+                                             Integer $num_ham)</p>
+<p>Description:
+This method updates the number of spam and the number of ham in the database.</p>
+<p>
+</p>
+<h2><a name="tok_touch">tok_touch</a></h2>
+<p>public instance (Boolean) tok_touch (String $token,
+                                     String $atime)</p>
+<p>Description:
+This method updates the given tokens (<code>$token</code>) atime.</p>
+<p>The assumption is that the token already exists in the database.</p>
+<p>
+</p>
+<h2><a name="tok_touch_all">tok_touch_all</a></h2>
+<p>public instance (Boolean) tok_touch (\@ $tokens
+                                     String $atime)</p>
+<p>Description:
+This method does a mass update of the given list of tokens <code>$tokens</code>, if the existing token
+atime is &lt; <code>$atime</code>.</p>
+<p>The assumption is that the tokens already exist in the database.</p>
+<p>We should never be touching more than N_SIGNIFICANT_TOKENS, so we can make
+some assumptions about how to handle the data (ie no need to batch like we
+do in tok_get_all)</p>
+<p>
+</p>
+<h2><a name="cleanup">cleanup</a></h2>
+<p>public instance (Boolean) cleanup ()</p>
+<p>Description:
+This method peroms any cleanup necessary before moving onto the next
+operation.</p>
+<p>
+</p>
+<h2><a name="get_magic_re">get_magic_re</a></h2>
+<p>public instance get_magic_re (String)</p>
+<p>Description:
+This method returns a regexp which indicates a magic token.</p>
+<p>Unused in SQL implementation.</p>
+<p>
+</p>
+<h2><a name="sync">sync</a></h2>
+<p>public instance (Boolean) sync (\% $opts)</p>
+<p>Description:
+This method performs a sync of the database</p>
+<p>
+</p>
+<h2><a name="perform_upgrade">perform_upgrade</a></h2>
+<p>public instance (Boolean) perform_upgrade (\% $opts);</p>
+<p>Description:
+Performs an upgrade of the database from one version to another, not
+currently used in this implementation.</p>
+<p>
+</p>
+<h2><a name="clear_database">clear_database</a></h2>
+<p>public instance (Boolean) clear_database ()</p>
+<p>Description:
+This method deletes all records for a particular user.</p>
+<p>Callers should be aware that any errors returned by this method
+could causes the database to be inconsistent for the given user.</p>
+<p>
+</p>
+<h2><a name="backup_database">backup_database</a></h2>
+<p>public instance (Boolean) backup_database ()</p>
+<p>Description:
+This method will dump the users database in a marchine readable format.</p>
+<p>
+</p>
+<h2><a name="restore_database">restore_database</a></h2>
+<p>public instance (Boolean) restore_database (String $filename, Boolean $showdots)</p>
+<p>Description:
+This method restores a database from the given filename, <code>$filename</code>.</p>
+<p>Callers should be aware that any errors returned by this method
+could causes the database to be inconsistent for the given user.</p>
+<p>
+</p>
+<h2><a name="db_readable">db_readable</a></h2>
+<p>public instance (Boolean) <code>db_readable()</code></p>
+<p>Description:
+This method returns a boolean value indicating if the database is in a
+readable state.</p>
+<p>
+</p>
+<h2><a name="db_writable">db_writable</a></h2>
+<p>public instance (Boolean) <code>db_writeable()</code></p>
+<p>Description:
+This method returns a boolean value indicating if the database is in a
+writable state.</p>
+<p>
+</p>
+<hr />
+<h1><a name="private_methods">Private Methods</a></h1>
+<p>
+</p>
+<h2><a name="_connect_db">_connect_db</a></h2>
+<p>private instance (Boolean) _connect_db ()</p>
+<p>Description:
+This method connects to the SQL database.</p>
+<p>
+</p>
+<h2><a name="_get_db_version">_get_db_version</a></h2>
+<p>private instance (Integer) _get_db_version ()</p>
+<p>Description:
+Gets the current version of the database from the special global vars
+tables.</p>
+<p>
+</p>
+<h2><a name="_initialize_db">_initialize_db</a></h2>
+<p>private instance (Boolean) _initialize_db ()</p>
+<p>Description:
+This method will check to see if a user has had their bayes variables
+initialized. If not then it will perform this initialization.</p>
+<p>
+</p>
+<h2><a name="_put_token">_put_token</a></h2>
+<p>private instance (Boolean) _put_token (string $token,
+                                       integer $spam_count,
+                                       integer $ham_count,
+				       string $atime)</p>
+<p>Description:
+This method performs the work of either inserting or updating a token in
+the database.</p>
+<p>
+</p>
+<h2><a name="_put_tokens">_put_tokens</a></h2>
+<p>private instance (Boolean) _put_tokens (\% $tokens,
+                                        integer $spam_count,
+                                        integer $ham_count,
+	 			        string $atime)</p>
+<p>Description:
+This method performs the work of either inserting or updating tokens in
+the database.</p>
+<p>
+</p>
+<h2><a name="_get_oldest_token_age">_get_oldest_token_age</a></h2>
+<p>private instance (Integer) _get_oldest_token_age ()</p>
+<p>Description:
+This method finds the atime of the oldest token in the database.</p>
+<p>The use of <code>min(atime)</code> in the SQL is ugly and but really the most efficient
+way of getting the oldest_token_age after we've done a mass expire.  It should
+only be called at expire time.</p>
+<p>
+</p>
+<h2><a name="_get_num_hapaxes">_get_num_hapaxes</a></h2>
+<p>private instance (Integer) _get_num_hapaxes ()</p>
+<p>Description:
+This method gets the total number of hapaxes (spam_count + ham_count == 1) in
+the token database for a user.</p>
+<p>
+</p>
+<h2><a name="_get_num_lowfreq">_get_num_lowfreq</a></h2>
+<p>private instance (Integer) _get_num_lowfreq ()</p>
+<p>Description:
+This method gets the total number of lowfreq tokens (spam_count &lt; 8 and
+ham_count &lt; 8) in the token database for a user</p>
+<p>
+</p>
+<h2><a name="_token_select_string">_token_select_string</a></h2>
+<p>private instance (String) _token_select_string</p>
+<p>Description:
+This method returns the string to be used in SELECT statements to represent
+the token column.</p>
+<p>The default is to use the RPAD function to pad the token out to 5 characters.</p>
+
+</body>
+
+</html>

Added: spamassassin/site/full/3.2.x/doc/Mail_SpamAssassin_BayesStore_SQL.txt
URL: http://svn.apache.org/viewvc/spamassassin/site/full/3.2.x/doc/Mail_SpamAssassin_BayesStore_SQL.txt?rev=667073&view=auto
==============================================================================
--- spamassassin/site/full/3.2.x/doc/Mail_SpamAssassin_BayesStore_SQL.txt (added)
+++ spamassassin/site/full/3.2.x/doc/Mail_SpamAssassin_BayesStore_SQL.txt Thu Jun 12 06:20:58 2008
@@ -0,0 +1,326 @@
+NAME
+    Mail::SpamAssassin::BayesStore::SQL - SQL Bayesian Storage Module
+    Implementation
+
+SYNOPSIS
+DESCRIPTION
+    This module implementes a SQL based bayesian storage module.
+
+METHODS
+  new
+    public class (Mail::SpamAssassin::BayesStore::SQL) new
+    (Mail::Spamassassin::Bayes $bayes)
+
+    Description: This methods creates a new instance of the
+    Mail::SpamAssassin::BayesStore::SQL object. It expects to be passed an
+    instance of the Mail::SpamAssassin:Bayes object which is passed into the
+    Mail::SpamAssassin::BayesStore parent object.
+
+    This method sets up the database connection and determines the username
+    to use in queries.
+
+  tie_db_readonly
+    public instance (Boolean) tie_db_readonly ();
+
+    Description: This method ensures that the database connection is
+    properly setup and working. If necessary it will initialize a user's
+    bayes variables so that they can begin using the database immediately.
+
+  tie_db_writable
+    public instance (Boolean) tie_db_writable ()
+
+    Description: This method ensures that the database connetion is properly
+    setup and working. If necessary it will initialize a users bayes
+    variables so that they can begin using the database immediately.
+
+  untie_db
+    public instance () untie_db ()
+
+    Description: This method is unused for the SQL based implementation.
+
+  calculate_expire_delta
+    public instance (%) calculate_expire_delta (Integer $newest_atime,
+    Integer $start, Integer $max_expire_mult)
+
+    Description: This method performs a calculation on the data to determine
+    the optimum atime for token expiration.
+
+  token_expiration
+    public instance (Integer, Integer, Integer, Integer) token_expiration(\%
+    $opts, Integer $newdelta, @ @vars)
+
+    Description: This method performs the database specific expiration of
+    tokens based on the passed in $newdelta and @vars.
+
+  sync_due
+    public instance (Boolean) sync_due ()
+
+    Description: This method determines if a database sync is currently
+    required.
+
+    Unused for SQL based implementation.
+
+  seen_get
+    public instance (String) seen_get (string $msgid)
+
+    Description: This method retrieves the stored value, if any, for $msgid.
+    The return value is the stored string ('s' for spam and 'h' for ham) or
+    undef if $msgid is not found.
+
+  seen_put
+    public (Boolean) seen_put (string $msgid, char $flag)
+
+    Description: This method records $msgid as the type given by $flag.
+    $flag is one of two values 's' for spam and 'h' for ham.
+
+  seen_delete
+    public instance (Boolean) seen_delete (string $msgid)
+
+    Description: This method removes $msgid from the database.
+
+  get_storage_variables
+    public instance (@) get_storage_variables ()
+
+    Description: This method retrieves the various administrative variables
+    used by the Bayes process and database.
+
+    The values returned in the array are in the following order:
+
+    0: scan count base
+
+    1: number of spam
+
+    2: number of ham
+
+    3: number of tokens in db
+
+    4: last expire atime
+
+    5: oldest token in db atime
+
+    6: db version value
+
+    7: last journal sync
+
+    8: last atime delta
+
+    9: last expire reduction count
+
+    10: newest token in db atime
+
+  dump_db_toks
+    public instance () dump_db_toks (String $template, String $regex, Array
+    @vars)
+
+    Description: This method loops over all tokens, computing the
+    probability for the token and then printing it out according to the
+    passed in token.
+
+  set_last_expire
+    public instance (Boolean) set_last_expire (Integer $time)
+
+    Description: This method sets the last expire time.
+
+  get_running_expire_tok
+    public instance (String $time) get_running_expire_tok ()
+
+    Description: This method determines if an expire is currently running
+    and returns the last time set.
+
+    There can be multiple times, so we just pull the greatest (most recent)
+    value.
+
+  set_running_expire_tok
+    public instance (String $time) set_running_expire_tok ()
+
+    Description: This method sets the time that an expire starts running.
+
+  remove_running_expire_tok
+    public instance (Boolean) remove_running_expire_tok ()
+
+    Description: This method removes the row in the database that indicates
+    that and expire is currently running.
+
+  tok_get
+    public instance (Integer, Integer, Integer) tok_get (String $token)
+
+    Description: This method retrieves a specificed token ($token) from the
+    database and returns it's spam_count, ham_count and last access time.
+
+  tok_get_all
+    public instance (\@) tok_get (@ $tokens)
+
+    Description: This method retrieves the specified tokens ($tokens) from
+    storage and returns an array ref of arrays spam count, ham acount and
+    last access time.
+
+  tok_count_change
+    public instance (Boolean) tok_count_change (Integer $spam_count, Integer
+    $ham_count, String $token, String $atime)
+
+    Description: This method takes a $spam_count and $ham_count and adds it
+    to $tok along with updating $toks atime with $atime.
+
+  multi_tok_count_change
+    public instance (Boolean) multi_tok_count_change (Integer $spam_count,
+    Integer $ham_count, \% $tokens, String $atime)
+
+    Description: This method takes a $spam_count and $ham_count and adds it
+    to all of the tokens in the $tokens hash ref along with updating each
+    tokens atime with $atime.
+
+  nspam_nham_get
+    public instance ($spam_count, $ham_count) nspam_nham_get ()
+
+    Description: This method retrieves the total number of spam and the
+    total number of ham learned.
+
+  nspam_nham_change
+    public instance (Boolean) nspam_nham_change (Integer $num_spam, Integer
+    $num_ham)
+
+    Description: This method updates the number of spam and the number of
+    ham in the database.
+
+  tok_touch
+    public instance (Boolean) tok_touch (String $token, String $atime)
+
+    Description: This method updates the given tokens ($token) atime.
+
+    The assumption is that the token already exists in the database.
+
+  tok_touch_all
+    public instance (Boolean) tok_touch (\@ $tokens String $atime)
+
+    Description: This method does a mass update of the given list of tokens
+    $tokens, if the existing token atime is < $atime.
+
+    The assumption is that the tokens already exist in the database.
+
+    We should never be touching more than N_SIGNIFICANT_TOKENS, so we can
+    make some assumptions about how to handle the data (ie no need to batch
+    like we do in tok_get_all)
+
+  cleanup
+    public instance (Boolean) cleanup ()
+
+    Description: This method peroms any cleanup necessary before moving onto
+    the next operation.
+
+  get_magic_re
+    public instance get_magic_re (String)
+
+    Description: This method returns a regexp which indicates a magic token.
+
+    Unused in SQL implementation.
+
+  sync
+    public instance (Boolean) sync (\% $opts)
+
+    Description: This method performs a sync of the database
+
+  perform_upgrade
+    public instance (Boolean) perform_upgrade (\% $opts);
+
+    Description: Performs an upgrade of the database from one version to
+    another, not currently used in this implementation.
+
+  clear_database
+    public instance (Boolean) clear_database ()
+
+    Description: This method deletes all records for a particular user.
+
+    Callers should be aware that any errors returned by this method could
+    causes the database to be inconsistent for the given user.
+
+  backup_database
+    public instance (Boolean) backup_database ()
+
+    Description: This method will dump the users database in a marchine
+    readable format.
+
+  restore_database
+    public instance (Boolean) restore_database (String $filename, Boolean
+    $showdots)
+
+    Description: This method restores a database from the given filename,
+    $filename.
+
+    Callers should be aware that any errors returned by this method could
+    causes the database to be inconsistent for the given user.
+
+  db_readable
+    public instance (Boolean) db_readable()
+
+    Description: This method returns a boolean value indicating if the
+    database is in a readable state.
+
+  db_writable
+    public instance (Boolean) db_writeable()
+
+    Description: This method returns a boolean value indicating if the
+    database is in a writable state.
+
+Private Methods
+  _connect_db
+    private instance (Boolean) _connect_db ()
+
+    Description: This method connects to the SQL database.
+
+  _get_db_version
+    private instance (Integer) _get_db_version ()
+
+    Description: Gets the current version of the database from the special
+    global vars tables.
+
+  _initialize_db
+    private instance (Boolean) _initialize_db ()
+
+    Description: This method will check to see if a user has had their bayes
+    variables initialized. If not then it will perform this initialization.
+
+  _put_token
+    private instance (Boolean) _put_token (string $token, integer
+    $spam_count, integer $ham_count, string $atime)
+
+    Description: This method performs the work of either inserting or
+    updating a token in the database.
+
+  _put_tokens
+    private instance (Boolean) _put_tokens (\% $tokens, integer $spam_count,
+    integer $ham_count, string $atime)
+
+    Description: This method performs the work of either inserting or
+    updating tokens in the database.
+
+  _get_oldest_token_age
+    private instance (Integer) _get_oldest_token_age ()
+
+    Description: This method finds the atime of the oldest token in the
+    database.
+
+    The use of min(atime) in the SQL is ugly and but really the most
+    efficient way of getting the oldest_token_age after we've done a mass
+    expire. It should only be called at expire time.
+
+  _get_num_hapaxes
+    private instance (Integer) _get_num_hapaxes ()
+
+    Description: This method gets the total number of hapaxes (spam_count +
+    ham_count == 1) in the token database for a user.
+
+  _get_num_lowfreq
+    private instance (Integer) _get_num_lowfreq ()
+
+    Description: This method gets the total number of lowfreq tokens
+    (spam_count < 8 and ham_count < 8) in the token database for a user
+
+  _token_select_string
+    private instance (String) _token_select_string
+
+    Description: This method returns the string to be used in SELECT
+    statements to represent the token column.
+
+    The default is to use the RPAD function to pad the token out to 5
+    characters.
+

Added: spamassassin/site/full/3.2.x/doc/Mail_SpamAssassin_Client.html
URL: http://svn.apache.org/viewvc/spamassassin/site/full/3.2.x/doc/Mail_SpamAssassin_Client.html?rev=667073&view=auto
==============================================================================
--- spamassassin/site/full/3.2.x/doc/Mail_SpamAssassin_Client.html (added)
+++ spamassassin/site/full/3.2.x/doc/Mail_SpamAssassin_Client.html Thu Jun 12 06:20:58 2008
@@ -0,0 +1,165 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>Mail::SpamAssassin::Client - Client for spamd Protocol</title>
+<link rev="made" href="mailto:jm@minotaur.apache.org" />
+</head>
+
+<body style="background-color: white">
+
+<p><a name="__index__"></a></p>
+<!-- INDEX BEGIN -->
+
+<ul>
+
+	<li><a href="#name">NAME</a></li>
+	<li><a href="#synopsis">SYNOPSIS</a></li>
+	<li><a href="#description">DESCRIPTION</a></li>
+	<li><a href="#public_methods">PUBLIC METHODS</a></li>
+	<ul>
+
+		<li><a href="#new">new</a></li>
+		<li><a href="#process">process</a></li>
+		<li><a href="#check">check</a></li>
+		<li><a href="#learn">learn</a></li>
+		<li><a href="#report">report</a></li>
+		<li><a href="#revoke">revoke</a></li>
+		<li><a href="#ping">ping</a></li>
+	</ul>
+
+	<li><a href="#private_methods">PRIVATE METHODS</a></li>
+	<ul>
+
+		<li><a href="#_create_connection">_create_connection</a></li>
+		<li><a href="#_parse_response_line">_parse_response_line</a></li>
+		<li><a href="#_clear_errors">_clear_errors</a></li>
+	</ul>
+
+</ul>
+<!-- INDEX END -->
+
+<hr />
+<p>
+</p>
+<h1><a name="name">NAME</a></h1>
+<p>Mail::SpamAssassin::Client - Client for spamd Protocol</p>
+<p>NOTE: This interface is alpha at best, and almost guaranteed to change</p>
+<p>
+</p>
+<hr />
+<h1><a name="synopsis">SYNOPSIS</a></h1>
+<pre>
+  my $client = new Mail::SpamAssassin::Client({port =&gt; 783,
+                                               host =&gt; 'localhost',
+                                               username =&gt; 'someuser'});</pre>
+<pre>
+  if ($client-&gt;ping()) {
+    print &quot;Ping is ok\n&quot;;
+  }</pre>
+<pre>
+  my $result = $client-&gt;process($testmsg);</pre>
+<pre>
+  if ($result-&gt;{isspam} eq 'True') {
+    do something with spam message here
+  }</pre>
+<p>
+</p>
+<hr />
+<h1><a name="description">DESCRIPTION</a></h1>
+<p>Mail::SpamAssassin::Client is a module that provides a perl implementation for
+the spamd protocol.</p>
+<p>
+</p>
+<hr />
+<h1><a name="public_methods">PUBLIC METHODS</a></h1>
+<p>
+</p>
+<h2><a name="new">new</a></h2>
+<p>public class (Mail::SpamAssassin::Client) new (\% $args)</p>
+<p>Description:
+This method creates a new Mail::SpamAssassin::Client object.</p>
+<p>
+</p>
+<h2><a name="process">process</a></h2>
+<p>public instance (\%) process (String $msg, Boolean $is_check_p)</p>
+<p>Description:
+This method makes a call to the spamd server and depending on the value of
+<code>$is_check_p</code> either calls PROCESS or CHECK.</p>
+<p>The return value is a hash reference containing several pieces of information,
+if available:</p>
+<p>content_length</p>
+<p>isspam</p>
+<p>score</p>
+<p>threshold</p>
+<p>message</p>
+<p>
+</p>
+<h2><a name="check">check</a></h2>
+<p>public instance (\%) check (String $msg)</p>
+<p>Description:
+The method implements the check call.</p>
+<p>Since check and process are so similar, we simply pass this
+call along to the process method with a flag to indicate
+to actually make the CHECK call.</p>
+<p>See the process method for the return value.</p>
+<p>
+</p>
+<h2><a name="learn">learn</a></h2>
+<p>public instance (Boolean) learn (String $msg, Integer $learntype)</p>
+<p>Description:
+This method implements the learn call.  <code>$learntype</code> should be
+an integer, 0 for spam, 1 for ham and 2 for forget.  The return
+value is a boolean indicating if the message was learned or not.</p>
+<p>An undef return value indicates that there was an error and you
+should check the resp_code/resp_msg values to determine what
+the error was.</p>
+<p>
+</p>
+<h2><a name="report">report</a></h2>
+<p>public instance (Boolean) report (String $msg)</p>
+<p>Description:
+This method provides the report interface to spamd.</p>
+<p>
+</p>
+<h2><a name="revoke">revoke</a></h2>
+<p>public instance (Boolean) revoke (String $msg)</p>
+<p>Description:
+This method provides the revoke interface to spamd.</p>
+<p>
+</p>
+<h2><a name="ping">ping</a></h2>
+<p>public instance (Boolean) ping ()</p>
+<p>Description:
+This method performs a server ping and returns 0 or 1 depending on
+if the server responded correctly.</p>
+<p>
+</p>
+<hr />
+<h1><a name="private_methods">PRIVATE METHODS</a></h1>
+<p>
+</p>
+<h2><a name="_create_connection">_create_connection</a></h2>
+<p>private instance (IO::Socket) _create_connection ()</p>
+<p>Description:
+This method sets up a proper IO::Socket connection based on the arguments
+used when greating the client object.</p>
+<p>On failure, it sets an internal error code and returns undef.</p>
+<p>
+</p>
+<h2><a name="_parse_response_line">_parse_response_line</a></h2>
+<p>private instance (@) _parse_response_line (String $line)</p>
+<p>Description:
+This method parses the initial response line/header from the server
+and returns its parts.</p>
+<p>We have this as a seperate method in case we ever decide to get fancy
+with the response line.</p>
+<p>
+</p>
+<h2><a name="_clear_errors">_clear_errors</a></h2>
+<p>private instance () _clear_errors ()</p>
+<p>Description:
+This method clears out any current errors.</p>
+
+</body>
+
+</html>

Added: spamassassin/site/full/3.2.x/doc/Mail_SpamAssassin_Client.txt
URL: http://svn.apache.org/viewvc/spamassassin/site/full/3.2.x/doc/Mail_SpamAssassin_Client.txt?rev=667073&view=auto
==============================================================================
--- spamassassin/site/full/3.2.x/doc/Mail_SpamAssassin_Client.txt (added)
+++ spamassassin/site/full/3.2.x/doc/Mail_SpamAssassin_Client.txt Thu Jun 12 06:20:58 2008
@@ -0,0 +1,110 @@
+NAME
+    Mail::SpamAssassin::Client - Client for spamd Protocol
+
+    NOTE: This interface is alpha at best, and almost guaranteed to change
+
+SYNOPSIS
+      my $client = new Mail::SpamAssassin::Client({port => 783,
+                                                   host => 'localhost',
+                                                   username => 'someuser'});
+
+      if ($client->ping()) {
+        print "Ping is ok\n";
+      }
+
+      my $result = $client->process($testmsg);
+
+      if ($result->{isspam} eq 'True') {
+        do something with spam message here
+      }
+
+DESCRIPTION
+    Mail::SpamAssassin::Client is a module that provides a perl
+    implementation for the spamd protocol.
+
+PUBLIC METHODS
+  new
+    public class (Mail::SpamAssassin::Client) new (\% $args)
+
+    Description: This method creates a new Mail::SpamAssassin::Client
+    object.
+
+  process
+    public instance (\%) process (String $msg, Boolean $is_check_p)
+
+    Description: This method makes a call to the spamd server and depending
+    on the value of $is_check_p either calls PROCESS or CHECK.
+
+    The return value is a hash reference containing several pieces of
+    information, if available:
+
+    content_length
+
+    isspam
+
+    score
+
+    threshold
+
+    message
+
+  check
+    public instance (\%) check (String $msg)
+
+    Description: The method implements the check call.
+
+    Since check and process are so similar, we simply pass this call along
+    to the process method with a flag to indicate to actually make the CHECK
+    call.
+
+    See the process method for the return value.
+
+  learn
+    public instance (Boolean) learn (String $msg, Integer $learntype)
+
+    Description: This method implements the learn call. $learntype should be
+    an integer, 0 for spam, 1 for ham and 2 for forget. The return value is
+    a boolean indicating if the message was learned or not.
+
+    An undef return value indicates that there was an error and you should
+    check the resp_code/resp_msg values to determine what the error was.
+
+  report
+    public instance (Boolean) report (String $msg)
+
+    Description: This method provides the report interface to spamd.
+
+  revoke
+    public instance (Boolean) revoke (String $msg)
+
+    Description: This method provides the revoke interface to spamd.
+
+  ping
+    public instance (Boolean) ping ()
+
+    Description: This method performs a server ping and returns 0 or 1
+    depending on if the server responded correctly.
+
+PRIVATE METHODS
+  _create_connection
+    private instance (IO::Socket) _create_connection ()
+
+    Description: This method sets up a proper IO::Socket connection based on
+    the arguments used when greating the client object.
+
+    On failure, it sets an internal error code and returns undef.
+
+  _parse_response_line
+    private instance (@) _parse_response_line (String $line)
+
+    Description: This method parses the initial response line/header from
+    the server and returns its parts.
+
+    We have this as a seperate method in case we ever decide to get fancy
+    with the response line.
+
+  _clear_errors
+    private instance () _clear_errors ()
+
+    Description: This method clears out any current errors.
+