Hallo Mark,

here the SQL clause doing what dspam_merge does. Assuming you would like to 
merge the tokens from USER1, USER2 and USER3 into the data of USER2000.

Assuming:
 - USER2000 has uid 2000
 - USER1 has uid 1
 - USER2 has uid 2
 - USER3 has uid 3

Then the SQL clause for merging the tokens would be:
INSERT INTO dspam_token_data(uid,token,spam_hits,innocent_hits,last_hit) SELECT 
2000,token,SUM(spam_hits),SUM(innocent_hits),MAX(last_hit) FROM 
dspam_token_data WHERE uid IN(1,2,3) GROUP BY token ON DUPLICATE KEY UPDATE 
spam_hits=VALUES(spam_hits)+spam_hits,innocent_hits=VALUES(innocent_hits)+innocent_hits,last_hit=IF(VALUES(last_hit)>last_hit,VALUES(last_hit),last_hit);


And the SQL clause for cumulating the statistics would be:
INSERT INTO 
dspam_stats(uid,spam_learned,innocent_learned,spam_misclassified,innocent_misclassified,spam_corpusfed,innocent_corpusfed,spam_classified,innocent_classified)
 SELECT 
2000,SUM(spam_learned),SUM(innocent_learned),SUM(spam_misclassified),SUM(innocent_misclassified),SUM(spam_corpusfed),SUM(innocent_corpusfed),SUM(spam_classified),SUM(innocent_classified)
 FROM dspam_stats WHERE uid IN(1,2,3) GROUP BY uid ON DUPLICATE KEY UPDATE 
spam_learned=VALUES(spam_learned)+spam_learned,innocent_learned=VALUES(innocent_learned)+innocent_learned,spam_misclassified=VALUES(spam_misclassified)+spam_misclassified,innocent_misclassified=VALUES(innocent_misclassified)+innocent_misclassified,spam_corpusfed=VALUES(spam_corpusfed)+spam_corpusfed,innocent_corpusfed=VALUES(innocent_corpusfed)+innocent_corpusfed,spam_classified=VALUES(spam_classified)+spam_classified,innocent_classified=VALUES(innocent_classified)+innocent_classified;


I know, I know. It's a crazy long SQL clause. Anyway... it should be faster 
then doing it with dspam_merge.

Let me know how it went for you.


cheers,

Steve


-------- Original-Nachricht --------
> Datum: Fri, 03 Jul 2009 18:27:25 +0200
> Von: "Steve" <[email protected]>
> An: 
> CC: [email protected]
> Betreff: Re: [Dspam-user] dspam_merge and mysql errors

> Hallo Mark,
> 
> 
> > It does seem to be a somewhat unhappy tool :)  If you ask it for help,
> > it barfs in a nasty way.  I can send that output along too if you'd like
> > that as well.
> > 
> I am going to fix that. I must!
> 
> 
> > Absolutely acceptable.
> > 
> I am a bit in a rush right now so I am going to send you a SQL clause that
> does something like dspam_merge but not exactly what dspam_merge does.
> dspam_merge is able to merge the tokens from USER1 into the tokens of USER2.
> The SQL clause from here will merge tokens from USER1, USER2, USERx into a
> new user USERy.
> 
> Assuming:
>  - USERy has uid 2000
>  - USER1 has uid 1
>  - USER2 has uid 2
>  - USERx has uid 3
> 
> Then you should first drop all the tokens for USERy:
> DELETE FROM dspam_token_data WHERE uid=2000;
> 
> And then you can use one SQL clause to merge the tokens from USER1, USER2
> and USERx into USERy:
> 
> INSERT INTO dspam_token_data (uid,token,spam_hits,innocent_hits,last_hit)
> SELECT 2000,token,SUM(spam_hits),SUM(innocent_hits),MAX(last_hit) FROM
> dspam_token_data WHERE uid IN (1,2,3) GROUP BY token;
> 
> To be 100% like dspam_merge I would need to do "ON DUPLICATE" but right
> now I can't test that since I am on the run and I don't want to send you
> something non working. But I will quickly do the stuff over the weekend and
> send it here. I have to look if I can glue everything into SQL or if I need to
> make a quick script? Anyway... I will send the script here to the list.
> Just give me the weekend to look at it.
> 
> 
> > pace
> >
> Steve
> -- 
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Dspam-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/dspam-user

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

------------------------------------------------------------------------------
_______________________________________________
Dspam-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspam-user

Reply via email to