Changeset 244
- Timestamp:
- 03/28/06 13:48:18 (6 years ago)
- Location:
- Search-Namazu/trunk/Search-Namazu
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
Search-Namazu/trunk/Search-Namazu/ChangeLog
r217 r244 1 2006-03-28 NOKUBI Takatsugu <knok@daionet.gr.jp> 2 3 * Namazu.{xs,pm}: Added maxget parameter. 4 1 5 2006-03-27 NOKUBI Takatsugu <knok@daionet.gr.jp> 2 6 -
Search-Namazu/trunk/Search-Namazu/Namazu.pm
r217 r244 131 131 Speciry maximum numbers of hits. Same as MaxHit directive in namazurc. 132 132 133 =head4 returnas 133 =head3 maxget 134 135 Speciry result object numbers of hits to limit too many results. 136 If the parameter was omitted, it is assumed same value as maxhit. 137 138 =head3 returnas 134 139 135 140 Specify return method, if the parameter is set as 'reference', it … … 234 239 my $lang = $args{'lang'}; 235 240 my $query = $args{'query'}; 236 my $maxhit = $args{'maxhit'} ;241 my $maxhit = $args{'maxhit'} || 10000; 237 242 my $returnas = $args{'returnas'}; 243 my $maxget = $args{'maxget'} || $maxhit; 238 244 239 245 # initialize … … 283 289 nmz_setlang($lang); 284 290 } 285 nmz_setmaxhit($maxhit) if defined $maxhit;291 nmz_setmaxhit($maxhit); 286 292 287 293 # query and get hlist … … 294 300 295 301 if ($returnas eq 'reference') { 296 my $hlistref = call_search_main_ref($query );302 my $hlistref = call_search_main_ref($query, $maxget); 297 303 my $status = nmz_getstatus(); 298 304 if ($status != NMZ_SUCCESS) { … … 302 308 return $hlistref; 303 309 } else { 304 my @hlists = call_search_main($query );310 my @hlists = call_search_main($query, $maxget); 305 311 my $status = nmz_getstatus(); 306 312 if ($status != NMZ_SUCCESS) { -
Search-Namazu/trunk/Search-Namazu/Namazu.xs
r217 r244 59 59 static int status = 0; 60 60 61 AV * call_search_main_c(char *query )61 AV * call_search_main_c(char *query, int maxget) 62 62 { 63 63 AV *retar; … … 67 67 status = 0; 68 68 retar = newAV(); 69 av_extend(retar, hlist.num - 1); 69 70 hlist = nmz_search(query); 70 71 status = hlist.stat; 71 72 for (i = 0; i < hlist.num; i ++) { 73 if (i < maxget) { 72 74 SV *ohlist = perl_eval_pv("new Search::Namazu::Result", TRUE); 73 75 dSP; … … 92 94 perl_call_method("set", G_DISCARD); 93 95 SvREFCNT_inc(ohlist); 94 av_ push(retar, ohlist);96 av_store(retar, i, ohlist); 95 97 FREETMPS; 96 98 LEAVE; 99 } else { 100 av_store(retar, i, &PL_sv_undef); 101 } 97 102 } 98 103 nmz_free_hlist(hlist); … … 105 110 106 111 void 107 call_search_main(query )112 call_search_main(query, maxget) 108 113 SV *query 114 int maxget 109 115 110 116 PPCODE: … … 117 123 nmz_codeconv_query(qstr); 118 124 strcpy(cqstr, qstr); 119 retar = call_search_main_c(cqstr );125 retar = call_search_main_c(cqstr, maxget); 120 126 #if ! defined(PERL_VERSION) 121 127 { /* workaround for only one result */ … … 130 136 131 137 SV* 132 call_search_main_ref(query )138 call_search_main_ref(query, maxget) 133 139 SV *query 140 int maxget 134 141 135 142 CODE: … … 142 149 nmz_codeconv_query(qstr); 143 150 strcpy(cqstr, qstr); 144 retar = call_search_main_c(cqstr );151 retar = call_search_main_c(cqstr, maxget); 145 152 nmz_free_internal(); 146 153 RETVAL = newRV_inc((SV*) retar); … … 203 210 void 204 211 nmz_setmaxhit(max) 205 int max ;212 int max 206 213 207 214 CODE:
