Changeset 244

Show
Ignore:
Timestamp:
03/28/06 13:48:18 (6 years ago)
Author:
knok
Message:

Added maxget parameter.

Location:
Search-Namazu/trunk/Search-Namazu
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • Search-Namazu/trunk/Search-Namazu/ChangeLog

    r217 r244  
     12006-03-28  NOKUBI Takatsugu  <knok@daionet.gr.jp> 
     2 
     3        * Namazu.{xs,pm}: Added maxget parameter. 
     4 
    152006-03-27  NOKUBI Takatsugu  <knok@daionet.gr.jp> 
    26 
  • Search-Namazu/trunk/Search-Namazu/Namazu.pm

    r217 r244  
    131131Speciry maximum numbers of hits. Same as MaxHit directive in namazurc. 
    132132 
    133 =head4 returnas 
     133=head3 maxget 
     134 
     135Speciry result object numbers of hits to limit too many results. 
     136If the parameter was omitted, it is assumed same value as maxhit. 
     137 
     138=head3 returnas 
    134139 
    135140Specify return method, if the parameter is set as 'reference', it 
     
    234239    my $lang = $args{'lang'}; 
    235240    my $query = $args{'query'}; 
    236     my $maxhit = $args{'maxhit'}; 
     241    my $maxhit = $args{'maxhit'} || 10000; 
    237242    my $returnas = $args{'returnas'}; 
     243    my $maxget = $args{'maxget'} || $maxhit; 
    238244 
    239245# initialize 
     
    283289        nmz_setlang($lang); 
    284290    } 
    285     nmz_setmaxhit($maxhit) if defined $maxhit; 
     291    nmz_setmaxhit($maxhit); 
    286292 
    287293# query and get hlist 
     
    294300 
    295301    if ($returnas eq 'reference') { 
    296         my $hlistref = call_search_main_ref($query); 
     302        my $hlistref = call_search_main_ref($query, $maxget); 
    297303        my $status = nmz_getstatus(); 
    298304        if ($status != NMZ_SUCCESS) { 
     
    302308        return $hlistref; 
    303309    } else { 
    304         my @hlists = call_search_main($query); 
     310        my @hlists = call_search_main($query, $maxget); 
    305311        my $status = nmz_getstatus(); 
    306312        if ($status != NMZ_SUCCESS) { 
  • Search-Namazu/trunk/Search-Namazu/Namazu.xs

    r217 r244  
    5959static int status = 0; 
    6060 
    61 AV * call_search_main_c(char *query) 
     61AV * call_search_main_c(char *query, int maxget) 
    6262{ 
    6363        AV *retar; 
     
    6767        status = 0; 
    6868        retar = newAV(); 
     69        av_extend(retar, hlist.num - 1); 
    6970        hlist = nmz_search(query); 
    7071        status = hlist.stat; 
    7172        for (i = 0; i < hlist.num; i ++) { 
     73            if (i < maxget) { 
    7274                SV *ohlist = perl_eval_pv("new Search::Namazu::Result", TRUE); 
    7375                dSP; 
     
    9294                perl_call_method("set", G_DISCARD); 
    9395                SvREFCNT_inc(ohlist); 
    94                 av_push(retar, ohlist); 
     96                av_store(retar, i, ohlist); 
    9597                FREETMPS; 
    9698                LEAVE; 
     99            } else { 
     100                av_store(retar, i, &PL_sv_undef); 
     101            }       
    97102        } 
    98103        nmz_free_hlist(hlist); 
     
    105110 
    106111void 
    107 call_search_main(query) 
     112call_search_main(query, maxget) 
    108113        SV *query 
     114        int maxget 
    109115 
    110116        PPCODE: 
     
    117123                nmz_codeconv_query(qstr); 
    118124                strcpy(cqstr, qstr); 
    119                 retar = call_search_main_c(cqstr); 
     125                retar = call_search_main_c(cqstr, maxget); 
    120126#if ! defined(PERL_VERSION) 
    121127                { /* workaround for only one result */ 
     
    130136 
    131137SV* 
    132 call_search_main_ref(query) 
     138call_search_main_ref(query, maxget) 
    133139        SV *query 
     140        int maxget 
    134141 
    135142        CODE: 
     
    142149                nmz_codeconv_query(qstr); 
    143150                strcpy(cqstr, qstr); 
    144                 retar = call_search_main_c(cqstr); 
     151                retar = call_search_main_c(cqstr, maxget); 
    145152                nmz_free_internal(); 
    146153                RETVAL = newRV_inc((SV*) retar); 
     
    203210void 
    204211nmz_setmaxhit(max) 
    205         int max; 
     212        int max 
    206213 
    207214        CODE: