Changeset 308 for trunk/gsdl/src
- Timestamp:
- 1999-06-28T20:56:29+12:00 (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/colservr/mgq.c
r115 r308 12 12 /* 13 13 $Log$ 14 Revision 1.4 1999/06/28 08:56:29 rjmcnab 15 A bit of hacking to remove the restriction that the index to get 16 a document must be a level 2 index. Now both level 2 and level 3 17 indexes can be used to get the text of a document. 18 14 19 Revision 1.3 1999/01/19 01:38:16 rjmcnab 20 15 21 Made the source more portable. 16 22 … … 120 126 return 0; 121 127 } 128 129 static int GetParaNumFromDocNum(query_data *qd, int docnum) { 130 int Documents = qd->td->cth.num_of_docs; 131 int *Paragraph = qd->paragraph; 132 133 if (docnum > 0 && docnum <= Documents) 134 return Paragraph[docnum-1]+1; 135 return 0; 136 } 122 137 #endif 123 138 … … 133 148 static int ProcessDocs (query_data * qd, int skip, int howmany, 134 149 enum result_kinds kind, 135 int (*sender)(char *,int,int,float,void *), void *ptr) 136 { 150 int (*sender)(char *,int,int,float,void *), void *ptr) { 137 151 int max_buf = 0, output_failure = 0; 138 152 int DocCount = 0; 139 153 int need_text = (kind == result_docs); 140 141 for (;;) { 142 if (skip <= 0) break; 154 155 /* skip the requested number of documents */ 156 while (skip > 0) { 157 if (!NextDoc(qd)) return 0; 143 158 skip--; 144 if (!NextDoc(qd)) return 0; 145 } 146 147 if (need_text) 148 { 149 max_buf = atoi (GetDefEnv ("buffer", "1048576")); 150 } 151 152 do 153 { 154 u_char *UDoc = NULL; 155 unsigned long ULen=0; 159 } 160 161 /* find out the maximum size for the text buffer */ 162 if (need_text) max_buf = atoi (GetDefEnv ("buffer", "1048576")); 163 164 /* process each document */ 165 do { 166 u_char *UDoc = NULL; 167 unsigned long ULen=0; 168 169 #if defined(PARADOCNUM) || defined(NZDL) 170 /* adjust the document number for paragraph level result_docs */ 171 /* this is a bit of a hack ... */ 172 if (kind==result_docs && qd->id->ifh.InvfLevel == 3 && 173 qd->DL != NULL && (int)qd->doc_pos < (int)qd->DL->num) 174 qd->DL->DE[qd->doc_pos].DocNum = GetParaNumFromDocNum(qd, qd->DL->DE[qd->doc_pos].DocNum); 175 #endif 176 177 if (need_text) { 178 /* load the compressed text */ 179 if (LoadCompressedText (qd, max_buf)) 180 MGQError("Unable to load compressed text(memory?)."); 181 182 /* uncompress the loaded text */ 183 UDoc = GetDocText (qd, &ULen); 184 if (UDoc == NULL) MGQError("UDoc is unexpectedly NULL"); 185 } 156 186 157 if (need_text) 158 { 159 /* load the compressed text */ 160 if (LoadCompressedText (qd, max_buf)) 161 { 162 MGQError("Unable to load compressed text(memory?)."); 163 } 164 /* uncompress the loaded text */ 165 UDoc = GetDocText (qd, &ULen); 166 if (UDoc == NULL) 167 MGQError("UDoc is unexpectedly NULL"); 168 } 187 if (UDoc != NULL || kind == result_docnums) { 188 int docnum = GetDocNum(qd); 189 #if defined(PARADOCNUM) || defined(NZDL) 190 if (qd->id->ifh.InvfLevel == 3) docnum = GetDocNumFromParaNum(qd, docnum); 191 #endif 192 switch (kind) { 193 case result_docnums: 194 if (sender != NULL) 195 output_failure = (*sender)("",0,docnum,GetDocWeight(qd),ptr); 196 break; 197 case result_docs: 198 if (sender != NULL) 199 output_failure = (*sender)((char *)UDoc,ULen,docnum,GetDocWeight(qd),ptr); 200 break; 201 default: 202 break; 203 } 204 } 205 DocCount++; 169 206 170 if (UDoc != NULL || kind == result_docnums) 171 { 172 int docnum = GetDocNum(qd); 173 #if defined(PARADOCNUM) || defined(NZDL) 174 if (qd->id->ifh.InvfLevel == 3) docnum = GetDocNumFromParaNum(qd, docnum); 175 #endif 176 switch (kind) 177 { 178 case result_docnums: 179 if (sender != NULL) 180 output_failure = (*sender)("",0,docnum,GetDocWeight(qd),ptr); 181 break; 182 case result_docs: 183 if (sender != NULL) 184 output_failure = (*sender)((char *)UDoc,ULen,docnum,GetDocWeight(qd),ptr); 185 break; 186 default: 187 break; 188 } 189 } 190 DocCount++; 191 192 } 193 while (NextDoc (qd) && output_failure == 0 && --howmany > 0); 194 195 if (need_text) 196 { 197 FreeTextBuffer (qd); 198 } 207 } while (NextDoc (qd) && output_failure == 0 && --howmany > 0); 208 209 if (need_text) FreeTextBuffer (qd); 199 210 200 211 return (DocCount); … … 311 322 } 312 323 313 /* search_doc_collect will search for an index which */ 314 /* belongs to a certain collection and which has a document */ 315 /* level index. It returns -1 if none could be found. */ 324 /* search_collect will search for an index which */ 325 /* belongs to a certain collection It returns -1 if none could be found. */ 316 326 /* init_dbcache should be called before this function */ 317 static int search_ doc_collect (char *collection) {327 static int search_collect (char *collection) { 318 328 int i = 0; 319 329 … … 321 331 if ((dbcache[i].accessnum >= 0) && 322 332 (dbcache[i].qd != NULL) && 323 (strcmp (collection, dbcache[i].collection) == 0) && 324 (dbcache[i].qd->id->ifh.InvfLevel == 2)) { 333 (strcmp (collection, dbcache[i].collection) == 0) 334 /* && (dbcache[i].qd->id->ifh.InvfLevel == 2)*/ 335 ) { 325 336 dbcache[i].accessnum = get_next_accessnum (); 326 337 return i; … … 331 342 } 332 343 333 /* search_ doc_collectwill search for an index which */344 /* search_gensuffix will search for an index which */ 334 345 /* has a certain gensuffix. It returns -1 if none could be found. */ 335 346 /* init_dbcache should be called before this function */ … … 608 619 } 609 620 610 /* load_text_database tries to make a level 2index of the */621 /* load_text_database tries to make an index of the */ 611 622 /* specified collection current */ 612 623 int load_text_database (char *collection) { … … 615 626 616 627 /* search for the index */ 617 i = search_ doc_collect (collection);628 i = search_collect (collection); 618 629 619 630 /* return if none were found */
Note:
See TracChangeset
for help on using the changeset viewer.