From ae02d47b9b3ee099a42fffa1675c6e178956e974 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 16 May 2005 21:08:45 +0000 Subject: [PATCH] * Began writing all the "glue" for the indexer. --- citadel/serv_extensions.h | 1 + citadel/serv_fulltext.c | 77 ++++++++++++++++++++++++++++++++++++++ citadel/serv_fulltext.d | 2 +- citadel/serv_fulltext.h | 1 - citadel/serv_fulltext.o | Bin 1397 -> 2694 bytes 5 files changed, 79 insertions(+), 2 deletions(-) diff --git a/citadel/serv_extensions.h b/citadel/serv_extensions.h index 1a2ed6028..6f6543ab9 100644 --- a/citadel/serv_extensions.h +++ b/citadel/serv_extensions.h @@ -32,6 +32,7 @@ char *serv_test_init(void); char *serv_upgrade_init(void); char *serv_vandelay_init(void); char *serv_vcard_init(void); +char *serv_fulltext_init(void); /* */ diff --git a/citadel/serv_fulltext.c b/citadel/serv_fulltext.c index 0cbcd2e24..6597988b6 100644 --- a/citadel/serv_fulltext.c +++ b/citadel/serv_fulltext.c @@ -40,12 +40,60 @@ #include "database.h" #include "msgbase.h" #include "control.h" +#include "room_ops.h" #include "tools.h" #include "serv_fulltext.h" #include "ft_wordbreaker.h" +long ft_newhighest = 0L; +long *ft_newmsgs = NULL; +int ft_num_msgs = 0; +int ft_num_alloc = 0; + + +void ft_index_msg(long msgnum, void *userdata) { + + if ((msgnum > CitControl.MMfulltext) && (msgnum <= ft_newhighest)) { + ++ft_num_msgs; + if (ft_num_msgs > ft_num_alloc) { + ft_num_alloc += 1024; + ft_newmsgs = realloc(ft_newmsgs, (ft_num_alloc * sizeof(long))); + } + ft_newmsgs[ft_num_msgs - 1] = msgnum; + } + +} + +/* + * Scan a room for messages to index. + */ +void ft_index_room(struct ctdlroom *qrbuf, void *data) +{ + getroom(&CC->room, qrbuf->QRname); + CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, ft_index_msg, NULL); +} + + +/* + * Compare function + */ +int longcmp(const void *rec1, const void *rec2) { + long i1, i2; + + i1 = *(const long *)rec1; + i2 = *(const long *)rec2; + + if (i1 > i2) return(1); + if (i1 < i2) return(-1); + return(0); +} + + + void do_fulltext_indexing(void) { + int i; + lprintf(CTDL_DEBUG, "do_fulltext_indexing() started\n"); /* @@ -58,12 +106,41 @@ void do_fulltext_indexing(void) { lprintf(CTDL_DEBUG, "Nothing to do!\n"); return; } + + /* + * Make sure we don't run the indexer too frequently. + * FIXME write this... + */ /* * If we've switched wordbreaker modules, burn the index and start * over. FIXME write this... */ + /* + * Now go through each room and find messages to index. + */ + ft_newhighest = CitControl.MMhighest; + ForEachRoom(ft_index_room, NULL); /* merge ptrs */ + + if (ft_num_msgs > 0) { + qsort(ft_newmsgs, ft_num_msgs, sizeof(long), longcmp); /* sort */ + if (i>1) for (i=0; i<(ft_num_msgs-1); ++i) { /* purge dups */ + if (ft_newmsgs[i] == ft_newmsgs[i+1]) { + memmove(&ft_newmsgs[i], &ft_newmsgs[i+1], ((ft_num_msgs - i)*sizeof(long))); + --ft_num_msgs; + } + } + + /* Here it is ... do each message! */ + for (i=0; i7|K@(bR-sV(g_C_29)s1rHhydmyggH}f9*Cz|-k%=f4eCHjsW$7q#0&G{V9#10z?t5DC;JoMv0}Oxi?^zRu68PyDWJ7SRh!T z0IMo*H(|nnMRV7WF@@wv6C`P>B#s2Nqz%|E)XLeS^!XZj&^Eus>+KBpW{vu{7qJ+> z6Mj!BW$ouTzFFa`NDbfLgmMcbZkVOAY~N6+;TW8RmD3E0>_`3V ze(Z8zIK2RuO4|bGZwouo+HyAijxl^?#_nCO@h)E6t2!?Wy?%dm=k9$1+pYT|NqcsF zDVz1IE8c7-pR}%I@~O@)!}a2hXC+%?Fyjr{dC#%4v9YmqCY82a&oIs#C$sfR9Y!n1 zZ7+>rhG!c|`{@=L9-SF8jnVNTb0+ZquiW#Qe8x>PImU_6B#!ol!NHe|&I{wyUB=m1 zU#!>Y?e6aD>F#;n=$y2Y#z@=?dOM@lIn-`)a!*G*Cm^b%Qg$4#RjqY9pYwdqLT0)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