]> code.citadel.org Git - citadel.git/commitdiff
* Finished the indexer *and* deindexer! The search API is now working
authorArt Cancro <ajc@citadel.org>
Wed, 18 May 2005 22:09:01 +0000 (22:09 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 18 May 2005 22:09:01 +0000 (22:09 +0000)
  flawlessly too.  Now all we have to do is glue it to IMAP and other
  user-facing functionality.  (The SRCH command is for testing only.)

citadel/ChangeLog
citadel/ft_wordbreaker.c
citadel/ft_wordbreaker.h
citadel/ft_wordbreaker.o
citadel/msgbase.c
citadel/serv_fulltext.c
citadel/serv_fulltext.o

index c4420cdf06f9081d5b6b9b55729681c80b624f10..16ad753c9252e2a7cdc005f877f66a3e4d7d978e 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 647.10  2005/05/18 22:09:01  ajc
+ * Finished the indexer *and* deindexer!  The search API is now working
+   flawlessly too.  Now all we have to do is glue it to IMAP and other
+   user-facing functionality.  (The SRCH command is for testing only.)
+
  Revision 647.9  2005/05/18 04:02:54  ajc
  * Completed the "search for all of these words" functionality.  All we need
    to do now is genericize its calling syntax so it can be called from the
@@ -6717,4 +6722,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index fc59ee0b7edb9bb04d9f2950b31b379e4d82d8cc..0386eb6516eaa091079c5ed9c350bc330838ecb6 100644 (file)
@@ -133,7 +133,7 @@ void wordbreaker(char *text, int *num_tokens, int **tokens) {
                for (i=0; i<(wb_num_tokens-1); ++i) {
                        if (wb_tokens[i] == wb_tokens[i+1]) {
                                memmove(&wb_tokens[i], &wb_tokens[i+1],
-                                       ((wb_num_tokens - i)*sizeof(int)));
+                                       ((wb_num_tokens - i - 1)*sizeof(int)));
                                --wb_num_tokens;
                        }
                }
index 15166cf1112d0f52f9e080f2fab6b12aa2dd1bff..7f947f41125e71791a40df699fae8fad34e6fc70 100644 (file)
@@ -9,7 +9,7 @@
  * later on, or even if we update this one, we can use a different ID so the
  * system knows it needs to throw away the existing index and rebuild it.
  */
-#define        FT_WORDBREAKER_ID       0x0008
+#define        FT_WORDBREAKER_ID       0x000a
 
 /*
  * Minimum and maximum length of words to index
index c4988d38e7c0719a5890f42438ca676d04e412d3..2eb81eaf1a22e465f415ff134abf0b625efff22e 100644 (file)
Binary files a/citadel/ft_wordbreaker.o and b/citadel/ft_wordbreaker.o differ
index f9e2acab189f9df40a8b46e73699b206645a4f7d..0ee40f6ee84b6fc919ff08d75a693fd37f9d396e 100644 (file)
@@ -3181,12 +3181,16 @@ void AdjRefCount(long msgnum, int incr)
         */
        if (smi.meta_refcount == 0) {
                lprintf(CTDL_DEBUG, "Deleting message <%ld>\n", msgnum);
-               /* ft_index_message(msgnum, 0);  remove from fulltext index */
+
+               /* Remove from fulltext index */
+               ft_index_message(msgnum, 0);
+
+               /* Remove from message base */
                delnum = msgnum;
                cdb_delete(CDB_MSGMAIN, &delnum, (int)sizeof(long));
                cdb_delete(CDB_BIGMSGS, &delnum, (int)sizeof(long));
 
-               /* We have to delete the metadata record too! */
+               /* Remove metadata record */
                delnum = (0L - msgnum);
                cdb_delete(CDB_MSGMAIN, &delnum, (int)sizeof(long));
        }
index c3a3806599c1f3e49f9863a1726f9c724626b307..28aeeba8a6f7d70c452ff26e87b73450bf509d61 100644 (file)
@@ -118,16 +118,27 @@ void ft_index_message(long msgnum, int op) {
                        }
 
                        if (op == 0) {  /* remove from index */
-                               /* FIXME do this */
+                               if (num_msgs >= 1) {
+                               msgs = (long *) cdb_bucket->ptr;
+                                       for (j=0; j<num_msgs; ++j) {
+                                               if (msgs[j] == msgnum) {
+                                                       lprintf(CTDL_DEBUG, "nix0ring %ld\n", msgs[j]);
+                                                       memmove(&msgs[j], &msgs[j+1],
+                                                               ((num_msgs - j - 1)*sizeof(long)));
+                                                       --num_msgs;
+                                               }
+                                       }
+                               }
                        }
 
                        /* sort and purge dups */
-                       if (num_msgs > 1) {
+                       if ( (op == 1) && (num_msgs > 1) ) {
+                               msgs = (long *) cdb_bucket->ptr;
                                qsort(msgs, num_msgs, sizeof(long), longcmp);
                                for (j=0; j<(num_msgs-1); ++j) {
                                        if (msgs[j] == msgs[j+1]) {
                                                memmove(&msgs[j], &msgs[j+1],
-                                                       ((num_msgs - j)*sizeof(long)));
+                                                       ((num_msgs - j - 1)*sizeof(long)));
                                                --num_msgs;
                                        }
                                }
@@ -224,7 +235,7 @@ void do_fulltext_indexing(void) {
                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 - i - 1)*sizeof(long)));
                                --ft_num_msgs;
                        }
                }
@@ -280,8 +291,11 @@ void ft_search(int *fts_num_msgs, long **fts_msgs, char *search_string) {
                                msgs = (long *)cdb_bucket->ptr;
 
                                num_all_msgs += num_msgs;
-                               all_msgs = realloc(all_msgs, num_all_msgs*sizeof(long) );
-                               memcpy(&all_msgs[num_all_msgs - num_msgs], msgs, num_msgs*sizeof(long) );
+                               if (num_all_msgs > 0) {
+                                       all_msgs = realloc(all_msgs, num_all_msgs*sizeof(long) );
+                                       memcpy(&all_msgs[num_all_msgs - num_msgs], msgs,
+                                               num_msgs*sizeof(long) );
+                               }
 
                                cdb_free(cdb_bucket);
                        }
index 4824b08d074a71c0a5d6ce943720726e3c717587..c9743a61b000f2bfba26aee33b35f5ccba1b49df 100644 (file)
Binary files a/citadel/serv_fulltext.o and b/citadel/serv_fulltext.o differ