inc/trix.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  trix
struct  trixSearchResult

Defines

#define trixPrefixSize   5

Functions

trixtrixOpen (char *ixFile)
void trixClose (struct trix **pTrix)
trixSearchResulttrixSearch (struct trix *trix, int wordCount, char **words, boolean expand)
void trixSearchResultFree (struct trixSearchResult **pTsr)
void trixSearchResultFreeList (struct trixSearchResult **pList)


Define Documentation

#define trixPrefixSize   5

Definition at line 25 of file trix.h.

Referenced by trixCopyToPrefix(), trixFindIndexStartLine(), and trixOpen().


Function Documentation

void trixClose ( struct trix **  pTrix  ) 

Definition at line 92 of file trix.c.

References freeHitCallback(), freeMem(), freez(), hashFree, hashTraverseVals(), trix::ixx, and trix::wordHitHash.

00094 {
00095 struct trix *trix = *pTrix;
00096 if (trix != NULL)
00097     {
00098     freeMem(trix->ixx);
00099     hashTraverseVals(trix->wordHitHash, freeHitCallback);
00100     hashFree(&trix->wordHitHash);       /* Need to free items? */
00101     freez(pTrix);
00102     }
00103 }

Here is the call graph for this function:

struct trix* trixOpen ( char *  ixFile  )  [read]

Definition at line 194 of file trix.c.

References initUnhexTable(), trix::lf, lineFileClose(), lineFileNext(), lineFileOpen(), PATH_LEN, safef(), trixAddToIxx(), trixNew(), trixPrefixSize, TRUE, and unhex().

00196 {
00197 char ixxFile[PATH_LEN];
00198 struct trix *trix;
00199 struct lineFile *lf;
00200 char *line;
00201 
00202 initUnhexTable();
00203 safef(ixxFile, sizeof(ixxFile), "%sx", ixFile);
00204 lf = lineFileOpen(ixxFile, TRUE);
00205 trix = trixNew();
00206 while (lineFileNext(lf, &line, NULL))
00207     {
00208     off_t pos = unhex(line+trixPrefixSize);
00209     trixAddToIxx(trix, pos, line);
00210     }
00211 lineFileClose(&lf);
00212 trix->lf = lineFileOpen(ixFile, TRUE);
00213 return trix;
00214 }

Here is the call graph for this function:

struct trixSearchResult* trixSearch ( struct trix trix,
int  wordCount,
char **  words,
boolean  expand 
) [read]

Definition at line 654 of file trix.c.

References AllocVar, FALSE, findMultipleWordHits(), trixWordResult::hitList, trixHitPos::itemId, trixSearchResult::itemId, trixSearchResult::leftoverLetters, trixHitPos::leftoverLetters, trixHitPos::next, trixSearchResult::orderedSpan, sameString, slAddHead, slReverse(), slSort(), trixSearchResultCmp(), trixSearchWordResults(), trixWordResultFreeList(), TRUE, trixSearchResult::unorderedSpan, trixHitPos::wordIx, and trixSearchResult::wordPos.

00661 {
00662 struct trixWordResult *twr, *twrList = NULL;
00663 struct trixSearchResult *ts, *tsList = NULL;
00664 int wordIx;
00665 boolean gotMiss = FALSE;
00666 
00667 if (wordCount == 1)
00668     {
00669     struct trixHitPos *hit;
00670     char *lastId = "";
00671     twr = twrList = trixSearchWordResults(trix, words[0], expand);
00672     if (twr == NULL)
00673         return NULL;
00674     for (hit = twr->hitList; hit != NULL; hit = hit->next)
00675         {
00676         if (!sameString(lastId, hit->itemId))
00677             {
00678             lastId = hit->itemId;
00679             AllocVar(ts);
00680             ts->itemId = hit->itemId;   /* Transfer itemId */
00681             hit->itemId = NULL;
00682             ts->orderedSpan = 1;
00683             ts->unorderedSpan = 1;
00684             ts->wordPos = hit->wordIx;
00685             ts->leftoverLetters = hit->leftoverLetters;
00686             slAddHead(&tsList, ts);
00687             }
00688         }
00689     }
00690 else
00691     {
00692     for (wordIx=0; wordIx<wordCount; ++wordIx)
00693         {
00694         char *searchWord = words[wordIx];
00695         twr = trixSearchWordResults(trix, searchWord, expand);
00696         if (twr == NULL)
00697             {
00698             gotMiss = TRUE;
00699             break;
00700             }
00701         slAddHead(&twrList, twr);
00702 #ifdef DEBUG
00703         trwDump(twr);
00704 #endif /* DEBUG */
00705         }
00706     if (!gotMiss)
00707         {
00708         slReverse(&twrList);
00709         tsList = findMultipleWordHits(twrList);
00710         }
00711     }
00712 trixWordResultFreeList(&twrList);
00713 slSort(&tsList, trixSearchResultCmp);
00714 return tsList;
00715 }

Here is the call graph for this function:

void trixSearchResultFree ( struct trixSearchResult **  pTsr  ) 

Definition at line 105 of file trix.c.

References freeMem(), freez(), and trixSearchResult::itemId.

Referenced by trixSearchResultFreeList().

00107 {
00108 struct trixSearchResult *tsr = *pTsr;
00109 if (tsr != NULL)
00110     {
00111     freeMem(tsr->itemId);
00112     freez(pTsr);
00113     }
00114 }

Here is the call graph for this function:

Here is the caller graph for this function:

void trixSearchResultFreeList ( struct trixSearchResult **  pList  ) 

Definition at line 116 of file trix.c.

References trixSearchResult::next, and trixSearchResultFree().

00118 {
00119 struct trixSearchResult *el, *next;
00120 for (el = *pList; el != NULL; el = next)
00121     {
00122     next = el->next;
00123     trixSearchResultFree(&el);
00124     }
00125 *pList = NULL;
00126 }

Here is the call graph for this function:


Generated on Tue Dec 25 19:17:54 2007 for blat by  doxygen 1.5.2