1Mail::SpamAssassin::BayUesseSrtoCroen:t:rBiDbBu(t3e)d PeMralilD:o:cSupmaemnAtsastaisosnin::BayesStore::BDB(3)
2
3
4
6 Mail::SpamAssassin::BayesStore::BDB - BerkeleyDB Bayesian Storage
7 Module Implementation
8
11 This module implementes a BDB based bayesian storage module.
12
14 new
15 public class (Mail::SpamAssassin::BayesStore::SQL) new
16 (Mail::Spamassassin::Plugin::Bayes $bayes)
17
18 Description: This methods creates a new instance of the
19 Mail::SpamAssassin::BayesStore::BDB object. It expects to be passed an
20 instance of the Mail::SpamAssassin:Bayes object which is passed into
21 the Mail::SpamAssassin::BayesStore parent object.
22
23 tie_db_readonly
24 public instance (Boolean) tie_db_readonly ();
25
26 Description: This method ensures that the database connection is
27 properly setup and working.
28
29 tie_db_writable
30 public instance (Boolean) tie_db_writable ()
31
32 Description: This method ensures that the database connection is
33 properly setup and working. If necessary it will initialize the
34 database so that they can begin using the database immediately.
35
36 _open_db
37 private instance (Boolean) _open_db (Boolean $writable)
38
39 Description: This method ensures that the database connection is
40 properly setup and working. It will initialize a users bayes variables
41 so that they can begin using the database immediately.
42
43 untie_db
44 public instance () untie_db ()
45
46 Description: Closes any open db handles. You can safely call this at
47 any time.
48
49 calculate_expire_delta
50 public instance (%) calculate_expire_delta (
51 Integer $newest_atime, Integer $start, Integer $max_expire_mult)
52
53 Description: This method performs a calculation on the data to
54 determine the optimum atime for token expiration.
55
56 token_expiration
57 public instance (Integer, Integer,
58 Integer, Integer) token_expiration (\% $opts,
59 Integer $newdelta,
60 @ @vars)
61
62 Description: This method performs the database specific expiration of
63 tokens based on the passed in $newdelta and @vars.
64
65 sync_due
66 public instance (Boolean) sync_due ()
67
68 Description: This method determines if a database sync is currently
69 required.
70
71 Unused for BDB implementation.
72
73 seen_get
74 public instance (String) seen_get (string $msgid)
75
76 Description: This method retrieves the stored value, if any, for
77 $msgid. The return value is the stored string ('s' for spam and 'h'
78 for ham) or undef if $msgid is not found.
79
80 seen_put
81 public (Boolean) seen_put (string $msgid, char $flag)
82
83 Description: This method records $msgid as the type given by $flag.
84 $flag is one of two values 's' for spam and 'h' for ham.
85
86 seen_delete
87 public instance (Boolean) seen_delete (string $msgid)
88
89 Description: This method removes $msgid from the database.
90
91 get_storage_variables
92 public instance (@) get_storage_variables ()
93
94 Description: This method retrieves the various administrative variables
95 used by the Bayes process and database.
96
97 The values returned in the array are in the following order:
98
99 0: scan count base
100
101 1: number of spam
102
103 2: number of ham
104
105 3: number of tokens in db
106
107 4: last expire atime
108
109 5: oldest token in db atime
110
111 6: db version value
112
113 7: last journal sync
114
115 8: last atime delta
116
117 9: last expire reduction count
118
119 10: newest token in db atime
120
121 dump_tokens
122 public instance () dump_tokens (String $template, String $regex, Array
123 @vars)
124
125 Description: This method loops over all tokens, computing the
126 probability for the token and then printing it out according to the
127 passed in token.
128
129 set_last_expire
130 public instance (Boolean) set_last_expire (Integer $time)
131
132 Description: This method sets the last expire time.
133
134 get_running_expire_tok
135 public instance (String $time) get_running_expire_tok ()
136
137 Description: This method determines if an expire is currently running
138 and returns the last time set.
139
140 There can be multiple times, so we just pull the greatest (most recent)
141 value.
142
143 set_running_expire_tok
144 public instance (String $time) set_running_expire_tok ()
145
146 Description: This method sets the time that an expire starts running.
147
148 remove_running_expire_tok
149 public instance (Boolean) remove_running_expire_tok ()
150
151 Description: This method removes the row in the database that indicates
152 that and expire is currently running.
153
154 tok_get
155 public instance (Integer, Integer, Integer) tok_get (String $token)
156
157 Description: This method retrieves a specificed token ($token) from the
158 database and returns its spam_count, ham_count and last access time.
159
160 tok_get_all
161 public instance (\@) tok_get (@ $tokens)
162
163 Description: This method retrieves the specified tokens ($tokens) from
164 storage and returns an array ref of arrays spam count, ham acount and
165 last access time.
166
167 tok_count_change
168 public instance (Boolean) tok_count_change (
169 Integer $dspam, Integer $dham, String $token, String $newatime)
170
171 Description: This method takes a $spam_count and $ham_count and adds it
172 to $tok along with updating $toks atime with $atime.
173
174 multi_tok_count_change
175 public instance (Boolean) multi_tok_count_change (
176 Integer $dspam, Integer $dham, \% $tokens, String $newatime)
177
178 Description: This method takes a $dspam and $dham and adds it to all of
179 the tokens in the $tokens hash ref along with updating each tokens
180 atime with $atime.
181
182 nspam_nham_get
183 public instance ($spam_count, $ham_count) nspam_nham_get ()
184
185 Description: This method retrieves the total number of spam and the
186 total number of ham learned.
187
188 nspam_nham_change
189 public instance (Boolean) nspam_nham_change (Integer $num_spam,
190 Integer $num_ham)
191
192 Description: This method updates the number of spam and the number of
193 ham in the database.
194
195 tok_touch
196 public instance (Boolean) tok_touch (String $token,
197 String $atime)
198
199 Description: This method updates the given tokens ($token) atime.
200
201 The assumption is that the token already exists in the database.
202
203 We will never update to an older atime
204
205 tok_touch_all
206 public instance (Boolean) tok_touch (\@ $tokens
207 String $atime)
208
209 Description: This method does a mass update of the given list of tokens
210 $tokens, if the existing token atime is < $atime.
211
212 The assumption is that the tokens already exist in the database.
213
214 We should never be touching more than N_SIGNIFICANT_TOKENS, so we can
215 make some assumptions about how to handle the data (ie no need to batch
216 like we do in tok_get_all)
217
218 cleanup
219 public instance (Boolean) cleanup ()
220
221 Description: This method peroms any cleanup necessary before moving
222 onto the next operation.
223
224 get_magic_re
225 public instance (String) get_magic_re ()
226
227 Description: This method returns a regexp which indicates a magic
228 token.
229
230 Unused in BDB implementation.
231
232 sync
233 public instance (Boolean) sync (\% $opts)
234
235 Description: This method performs a sync of the database
236
237 perform_upgrade
238 public instance (Boolean) perform_upgrade (\% $opts);
239
240 Description: Performs an upgrade of the database from one version to
241 another, not currently used in this implementation.
242
243 clear_database
244 public instance (Boolean) clear_database ()
245
246 Description: This method deletes all records for a particular user.
247
248 Callers should be aware that any errors returned by this method could
249 causes the database to be inconsistent for the given user.
250
251 backup_database
252 public instance (Boolean) backup_database ()
253
254 Description: This method will dump the users database in a machine
255 readable format.
256
257 restore_database
258 public instance (Boolean) restore_database (String $filename, Boolean
259 $showdots)
260
261 Description: This method restores a database from the given filename,
262 $filename.
263
264 Callers should be aware that any errors returned by this method could
265 causes the database to be inconsistent for the given user.
266
267 db_readable
268 public instance (Boolean) db_readable()
269
270 Description: This method returns a boolean value indicating if the
271 database is in a readable state.
272
273 db_writable
274 public instance (Boolean) db_writable()
275
276 Description: This method returns a boolean value indicating if the
277 database is in a writable state.
278
279 _extract_atime
280 private instance () _extract_atime (String $token,
281 String $value,
282 String $index)
283
284 Description: This method ensures that the database connection is
285 properly setup and working. If appropriate it will initialize a users
286 bayes variables so that they can begin using the database immediately.
287
288 _put_token
289 FIXME: This is rarely a good interface, because of the churn that will
290 often happen in the "magic" tokens. Open-code this stuff in the
291 presence of loops.
292
293
294
295perl v5.12.4 2011-06M-a0i6l::SpamAssassin::BayesStore::BDB(3)