* Began writing all the "glue" for the indexer.
authorArt Cancro <ajc@citadel.org>
Mon, 16 May 2005 21:08:45 +0000 (21:08 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 16 May 2005 21:08:45 +0000 (21:08 +0000)
citadel/serv_extensions.h
citadel/serv_fulltext.c
citadel/serv_fulltext.d
citadel/serv_fulltext.h
citadel/serv_fulltext.o

index 1a2ed6028606616d3618b8854b6713d53a52c1bc..6f6543ab93a9d1a7fc94d52acc6d04d3b44f678d 100644 (file)
@@ -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);
 /*
  */
 
index 0cbcd2e24bf838a717a5dd4358839f17aba7e6ae..6597988b649a8e8e81c22425d5f17ff241bcfb7f 100644 (file)
 #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; i<ft_num_msgs; ++i) {
+                       lprintf(CTDL_DEBUG, "FIXME INDEX %ld\n", ft_newmsgs[i]);
+               }
+
+               free(ft_newmsgs);
+               ft_num_msgs = 0;
+               ft_num_alloc = 0;
+       }
 
        lprintf(CTDL_DEBUG, "do_fulltext_indexing() finished\n");
        return;
index 3b7068466a9c3985bd8671cc10a6193a583accf1..c369d4091c16d11748f48d12502b7f91dbb60fa8 100644 (file)
@@ -56,4 +56,4 @@ serv_fulltext.o serv_fulltext/.o serv_fulltext.d: serv_fulltext.c sysdep.h /usr/
   /usr/include/openssl/ssl23.h sysdep_decls.h /usr/include/pthread.h \
   /usr/include/sched.h /usr/include/bits/initspin.h citserver.h \
   serv_extensions.h support.h config.h database.h msgbase.h control.h \
-  tools.h serv_fulltext.h ft_wordbreaker.h
+  room_ops.h tools.h serv_fulltext.h ft_wordbreaker.h
index 919922f94e899e90168bda455f3e61c0aa111ed1..8d8bc3202e2c189deed4f62d41366f2859e785ab 100644 (file)
@@ -3,4 +3,3 @@
  *
  */
 
-char *serv_fulltext_init(void);
index dbf664b4dbc6f0adc48f91ba364f3cf167211f3c..e133d6b0b50a9c858f002c2c1bc5b4f9672d3dce 100644 (file)
Binary files a/citadel/serv_fulltext.o and b/citadel/serv_fulltext.o differ