From 9b09a5ff483aef05dc5b4d9ab0fd0243d21cb1d3 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sat, 12 Jun 2021 19:20:47 -0400 Subject: Use SEARCH for a subset of thread roots This does way less duplicate work by fetching all threads and all thread root envelopes once, then doing searches for subsets of thread roots. --- archive.h | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'archive.h') diff --git a/archive.h b/archive.h index 7740b98..d6b9608 100644 --- a/archive.h +++ b/archive.h @@ -44,7 +44,7 @@ #define PATH_THREAD "thread/[messageID].[type]" #define PATH_ATTACHMENT \ "attachment/[messageID]/[section]/[name][disposition][.][subtype]" -#define PATH_SEARCH "[name].[type]" +#define PATH_INDEX "[name].[type]" #define MBOX_HEADERS \ "Date Subject From Sender Reply-To To Cc Bcc " \ @@ -60,6 +60,13 @@ extern const char *baseMailto; extern const char *baseSubscribe; extern const char *baseStylesheet; +extern struct Search { + size_t cap; + size_t len; + char **names; + char **exprs; +} search; + static inline struct U32 { char s[sizeof("4294967295")]; } u32(uint32_t u) { @@ -215,15 +222,18 @@ bool exportFetch(FILE *imap, enum Atom tag, struct List threads); bool exportData(FILE *imap, enum Atom tag, struct List items); extern const char *concatHead; -extern size_t concatSearchEntries; +extern size_t concatIndexEntries; void concatFetch(FILE *imap, enum Atom tag, struct List threads); +void concatSearch( + FILE *imap, enum Atom tag, struct List threads, const char *expr +); void concatData( struct List threads, struct Envelope *envelopes, struct List items ); void concatThreads(struct List threads, const struct Envelope *envelopes); -void concatSearch( - const char *name, struct List threads, const struct Envelope *envelopes, - char *searches[const], size_t len +void concatIndex( + const char *name, struct List roots, + struct List threads, const struct Envelope *envelopes ); int mboxFrom(FILE *file); @@ -235,8 +245,8 @@ int atomContent(FILE *file, const char *content); int atomEntryClose(FILE *file); int atomThreadOpen(FILE *file, const struct Envelope *envelope); int atomThreadClose(FILE *file); -int atomSearchOpen(FILE *file, const char *name); -int atomSearchClose(FILE *file); +int atomIndexOpen(FILE *file, const char *name); +int atomIndexClose(FILE *file); int htmlMessageOpen(FILE *file, const struct Envelope *envelope, bool nested); int htmlInline(FILE *file, const struct BodyPart *part, const char *content); @@ -251,11 +261,9 @@ int htmlThreadOpen(FILE *file, const struct Envelope *envelope); int htmlSubthreadOpen(FILE *file, struct List thread); int htmlSubthreadClose(FILE *file); int htmlThreadClose(FILE *file); -int htmlSearchHead(FILE *file, const char *name); -int htmlSearchOpen( - FILE *file, const char *name, char *searches[const], size_t len -); -int htmlSearchThread( +int htmlIndexHead(FILE *file, const char *name); +int htmlIndexOpen(FILE *file, const char *name); +int htmlIndexThread( FILE *file, const struct Envelope *envelope, struct List thread ); -int htmlSearchClose(FILE *file); +int htmlIndexClose(FILE *file); -- cgit 1.4.1