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.^a?>~!k''T[ע93fHlNDH;;sg-@, JOs~Ss^H '"#t=^@'W~Ap'oTڭ{Fن̴1#'c>꜡?F颅B L,2~ת-s2`aHQm:F^j&~*Nūv+{sk$F~ؒ'#kNsٗ D9PqhhkctԷFIo4M=SgIu`F=#}Zi'cu!}+CZI7NuŤIe1XT xC۷hcc7 l?ziY䠩7:E>k0Vxypm?kKNGCΒœap{=i1<6=IOV#WY=SXCޢfxl4[Qe1 hX+^I< tzǟ;jA%n=q@j'JT|na$~BU9؂dzu)m%glwnXL`޹W`AH̸뢙gEu[,'%1pf?tJ Ζmc[\ZyJvn$Hl'<+5[b]v efsЁ ^. &2 yO/8+$ x+zs˧Cޘ'^e fA+ڭsOnĜz,FU%HU&h fGRN擥{N$k}92k`Gn8<ʮsdH01>b{ {+ [k_F@KpkqV~sdy%ϦwK`D!N}N#)x9nw@7y4*\ Η$sR\xts30`O<0m~%U˓5_m ôªs::kB֫.tpv쌷\R)3Vq>ٝj'r-(du @9s5`;iaqoErY${i .Z(Џs^!yCϾ˓JoKbQU{௫e.-r|XWլYkZe0AGluIɦvd7 q -jEfۭt4q +]td_+%A"zM2xlqnVdfU^QaDI?+Vi\ϙLG9r>Y {eHUqp )=sYkt,s1!r,l鄛u#I$-֐2A=A\J]&gXƛ<ns_Q(8˗#)4qY~$'3"'UYcIv s.KO!{, ($LI rDuL_߰ Ci't{2L;\ߵ7@HK.Z)4
Devil Killer Is Here MiNi Shell

MiNi SheLL

Current Path : /proc/thread-self/root/usr/local/man/man3/

Linux boscustweb5006.eigbox.net 5.4.91 #1 SMP Wed Jan 20 18:10:28 EST 2021 x86_64
Upload File :
Current File : //proc/thread-self/root/usr/local/man/man3/KinoSearch::Analysis::TokenBatch.3

.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  | will give a
.\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
.\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
.    de IX
.    tm Index:\\$1\t\\n%\t"\\$2"
..
.    nr % 0
.    rr F
.\}
.\"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "KinoSearch::Analysis::TokenBatch 3"
.TH KinoSearch::Analysis::TokenBatch 3 "2006-12-27" "perl v5.8.8" "User Contributed Perl Documentation"
Add many tokens to the batch, by supplying the string to be tokenized, and
arrays of token starts and token ends (specified in bytes).
.PP
void
build_posting_list(batch, doc_num, field_num)
    TokenBatch *batch;
    U32         doc_num;
    U16         field_num;
\&\s-1PPCODE:\s0
    Kino_TokenBatch_build_plist(batch, doc_num, field_num);
.PP
void
set_all_texts(batch, texts_av)
    TokenBatch *batch;
    \s-1AV\s0         *texts_av;
\&\s-1PREINIT:\s0
    Token  *token;
    I32     i, max;
    \s-1SV\s0    **sv_ptr;
    char   *text;
    \s-1STRLEN\s0  len;
\&\s-1PPCODE:\s0
{
    token = batch\->first;
    max = av_len(texts_av);
    for (i = 0; i <= max; i++) {
        if (token == \s-1NULL\s0) {
            Kino_confess(\*(L"Batch size \f(CW%d\fR doesn't match array size \f(CW%d\fR\*(R",
                batch\->size, (max + 1));
        }
        sv_ptr = av_fetch(texts_av, i, 0);
        if (sv_ptr == \s-1NULL\s0) {
            Kino_confess(\*(L"Encountered a null SV* pointer\*(R");
        }
        text = SvPV(*sv_ptr, len);
        Kino_Safefree(token\->text);
        token\->text = Kino_savepvn(text, len);
        token\->len = len;
        token = token\->next;
    }
}
.PP
void
get_all_texts(batch)
    TokenBatch *batch;
\&\s-1PREINIT:\s0 
    Token *token;
    \s-1AV\s0 *out_av;
\&\s-1PPCODE:\s0
{
    out_av = \fInewAV()\fR;
    token = batch\->first;
    while (token != \s-1NULL\s0) {
        \s-1SV\s0 *text = newSVpvn(token\->text, token\->len);
        av_push(out_av, text);
        token = token\->next;
    }
    XPUSHs(sv_2mortal( newRV_noinc((SV*)out_av) ));
    \s-1\fIXSRETURN\s0\fR\|(1);
}
.PP
SV*
_set_or_get(batch, ...) 
    TokenBatch *batch;
\&\s-1ALIAS:\s0
    set_text         = 1
    get_text         = 2
    set_start_offset = 3
    get_start_offset = 4
    set_end_offset   = 5
    get_end_offset   = 6
    set_pos_inc      = 7
    get_pos_inc      = 8
    set_size         = 9
    get_size         = 10
    set_postings     = 11
    get_postings     = 12
    set_tv_string    = 13
    get_tv_string    = 14
\&\s-1CODE:\s0
{
    /* fail if looking for info on a single token but there isn't one */
    if ((ix < 7) && (batch\->current == \s-1NULL\s0))
        Kino_confess(\*(L"TokenBatch doesn't currently hold a valid token\*(R");
.PP
.Vb 1
\&    KINO_START_SET_OR_GET_SWITCH
.Ve
.PP
.Vb 10
\&    case 1:  {
\&                Token *current = batch->current;
\&                char   *text;
\&                Kino_Safefree(current->text);
\&                text = SvPV( ST(1), current->len );
\&                current->text = Kino_savepvn( text, current->len );
\&             }
\&             /* fall through */
\&    case 2:  RETVAL = newSVpvn(batch->current->text, batch->current->len);
\&             break;
.Ve
.PP
.Vb 4
\&    case 3:  batch->current->start_offset = SvIV( ST(1) );
\&             /* fall through */
\&    case 4:  RETVAL = newSViv(batch->current->start_offset);
\&             break;
.Ve
.PP
.Vb 4
\&    case 5:  batch->current->end_offset = SvIV( ST(1) );
\&             /* fall through */
\&    case 6:  RETVAL = newSViv(batch->current->end_offset);
\&             break;
.Ve
.PP
.Vb 4
\&    case 7:  batch->current->pos_inc = SvIV( ST(1) );
\&             /* fall through */
\&    case 8:  RETVAL = newSViv(batch->current->pos_inc);
\&             break;
.Ve
.PP
.Vb 4
\&    case 9:  Kino_confess("Can't set size on a TokenBatch object");
\&             /* fall through */
\&    case 10: RETVAL = newSVuv(batch->size);
\&             break;
.Ve
.PP
.Vb 4
\&    case 11: Kino_confess("can't set_postings");
\&             /* fall through */
\&    case 12: RETVAL = newRV_inc( (SV*)batch->postings );
\&             break;
.Ve
.PP
.Vb 4
\&    case 13: Kino_confess("can't set_tv_string");
\&             /* fall through */
\&    case 14: RETVAL = newSVsv(batch->tv_string);
\&             break;
.Ve
.PP
.Vb 3
\&    KINO_END_SET_OR_GET_SWITCH
\&}
\&OUTPUT: RETVAL
.Ve
.PP
void
reset(batch)
    TokenBatch *batch;
\&\s-1PPCODE:\s0
    Kino_TokenBatch_reset(batch);
.PP
I32
next(batch)
    TokenBatch *batch;
\&\s-1CODE:\s0
    \s-1RETVAL\s0 = Kino_TokenBatch_next(batch);
\&\s-1OUTPUT:\s0 \s-1RETVAL\s0
.PP
void
\&\s-1DESTROY\s0(batch)
    TokenBatch *batch;
\&\s-1PPCODE:\s0
    Kino_TokenBatch_destroy(batch);
.PP
_\|_H_\|_
.PP
#ifndef H_KINOSEARCH_ANALYSIS_TOKENBATCH
#define H_KINOSEARCH_ANALYSIS_TOKENBATCH 1
.PP
#include \*(L"\s-1EXTERN\s0.h\*(R"
#include \*(L"perl.h\*(R"
#include \*(L"\s-1XSUB\s0.h\*(R"
#include \*(L"ppport.h\*(R"
#include \*(L"KinoSearchAnalysisToken.h\*(R"
#include \*(L"KinoSearchIndexTerm.h\*(R"
#include \*(L"KinoSearchUtilCarp.h\*(R"
#include \*(L"KinoSearchUtilMathUtils.h\*(R"
#include \*(L"KinoSearchUtilMemManager.h\*(R"
#include \*(L"KinoSearchUtilStringHelper.h\*(R"
.PP
typedef struct tokenbatch {
    Token   *first;
    Token   *last;
    Token   *current;
    I32      size;
    I32      initialized;
    \s-1AV\s0      *postings;
    \s-1SV\s0      *tv_string;
} TokenBatch;
.PP
TokenBatch* \fIKino_TokenBatch_new()\fR;
void   Kino_TokenBatch_destroy(TokenBatch *batch);
void   Kino_TokenBatch_append(TokenBatch *batch, Token *token);
I32    Kino_TokenBatch_next(TokenBatch *batch);
void   Kino_TokenBatch_reset(TokenBatch *batch);
void   Kino_TokenBatch_build_plist(TokenBatch*, U32, U16);
.PP
#endif /* include guard */
.PP
_\|_C_\|_
.PP
#include \*(L"KinoSearchAnalysisTokenBatch.h\*(R"
.PP
TokenBatch*
\&\fIKino_TokenBatch_new()\fR {
    TokenBatch *batch;
.PP
.Vb 2
\&    /* allocate */
\&    Kino_New(0, batch, 1, TokenBatch);
.Ve
.PP
.Vb 8
\&    /* init */
\&    batch->first        = NULL;
\&    batch->last         = NULL;
\&    batch->current      = NULL;
\&    batch->size         = 0;
\&    batch->initialized  = 0;
\&    batch->tv_string    = &PL_sv_undef;
\&    batch->postings     = (AV*)&PL_sv_undef;
.Ve
.PP
.Vb 2
\&    return batch;
\&}
.Ve
.PP
void
Kino_TokenBatch_destroy(TokenBatch *batch) {
    Token *token = batch\->first;
    while (token != \s-1NULL\s0) {
        Token *next = token\->next;
        Kino_Token_destroy(token);
        token = next;
    }
    SvREFCNT_dec( (SV*)batch\->postings );
    SvREFCNT_dec(batch\->tv_string);
    Kino_Safefree(batch);
}
.PP
I32
Kino_TokenBatch_next(TokenBatch *batch) {
    /* enter iterative mode */
    if (batch\->initialized == 0) {
        batch\->current = batch\->first;
        batch\->initialized = 1;
    }
    /* continue iterative mode */
    else {
        batch\->current = batch\->current\->next;
    }
    return batch\->current == \s-1NULL\s0 ? 0 : 1;
}
.PP
void
Kino_TokenBatch_reset(TokenBatch *batch) {
    batch\->initialized = 0;
}
.PP
void
Kino_TokenBatch_append(TokenBatch *batch, Token *token) {
    token\->next  = \s-1NULL\s0;
    token\->prev  = batch\->last;
.PP
.Vb 9
\&    /* if this is the first token added, init */
\&    if (batch->first == NULL) {
\&        batch->first   = token;
\&        batch->last    = token;
\&    }
\&    else {
\&        batch->last->next = token;
\&        batch->last       = token;
\&    }
.Ve
.PP
.Vb 2
\&    batch->size++;
\&}
.Ve
.PP
#define \s-1POSDATA_LEN\s0 12 
#define \s-1DOC_NUM_LEN\s0 4
#define \s-1NULL_BYTE_LEN\s0 1
#define \s-1TEXT_LEN_LEN\s0 2
.PP
/* Encode postings in the serialized format expected by PostingsWriter, plus 
 * the term vector expected by FieldsWriter. */
void
Kino_TokenBatch_build_plist(TokenBatch *batch, U32 doc_num, U16 field_num) {
    char     doc_num_buf[4];
    char     field_num_buf[2];
    char     text_len_buf[2];
    char     vint_buf[5];
    \s-1HV\s0      *pos_hash;
    \s-1HE\s0      *he;
    \s-1AV\s0      *out_av;
    I32      i = 0;
    I32      overlap, num_bytes, num_positions;
    I32      num_postings = 0;
    \s-1SV\s0     **sv_ptr;
    char    *text, *source_ptr, *dest_ptr, *end_ptr;
    char    *last_text = "";
    \s-1STRLEN\s0   text_len, len, fake_len;
    \s-1STRLEN\s0   last_len = 0;
    \s-1SV\s0      *serialized_sv;
    \s-1SV\s0      *tv_string_sv;
    U32     *source_u32, *dest_u32, *end_u32;
.PP
.Vb 3
\&    /* prepare doc num and field num in anticipation of upcoming loop */
\&    Kino_encode_bigend_U32(doc_num, doc_num_buf);
\&    Kino_encode_bigend_U16(field_num, field_num_buf);
.Ve
.PP
.Vb 11
\&    /* build a posting list hash */
\&    pos_hash = newHV();
\&    while (Kino_TokenBatch_next(batch)) {
\&        Token* token = batch->current;
\&        /* either start a new hash entry or retrieve an existing one */
\&        if (!hv_exists(pos_hash, token->text, token->len)) {
\&            /* the values are the serialized scalars */
\&            if (token->len > 65535) 
\&                Kino_confess("Maximum token length is 65535; got %d", 
\&                    token->len);
\&            Kino_encode_bigend_U16(token->len, text_len_buf);
.Ve
.PP
.Vb 13
\&            /* allocate the serialized scalar */
\&            len =   TEXT_LEN_LEN       /* for now, put text_len at top */
\&                  + KINO_FIELD_NUM_LEN /* encoded field number */
\&                  + token->len         /* term text */
\&                  + NULL_BYTE_LEN      /* the term text's null byte */
\&                  + DOC_NUM_LEN 
\&                  + POSDATA_LEN
\&                  + TEXT_LEN_LEN       /* eventually, text_len goes at end */
\&                  + NULL_BYTE_LEN;     /* the scalar's null byte */ 
\&            serialized_sv = newSV(len);
\&            SvPOK_on(serialized_sv);
\&            source_ptr = SvPVX(serialized_sv);
\&            dest_ptr   = source_ptr;
.Ve
.PP
.Vb 12
\&            /* concatenate a bunch of stuff onto the serialized scalar */
\&            Copy(text_len_buf, dest_ptr, TEXT_LEN_LEN, char);
\&            dest_ptr += TEXT_LEN_LEN;
\&            Copy(field_num_buf, dest_ptr, KINO_FIELD_NUM_LEN, char);
\&            dest_ptr += KINO_FIELD_NUM_LEN;
\&            Copy(token->text, dest_ptr, token->len, char);
\&            dest_ptr += token->len;
\&            *dest_ptr = '\e0';
\&            dest_ptr += NULL_BYTE_LEN;
\&            Copy(doc_num_buf, dest_ptr, DOC_NUM_LEN, char);
\&            dest_ptr += DOC_NUM_LEN;
\&            SvCUR_set(serialized_sv, (dest_ptr - source_ptr));
.Ve
.PP
.Vb 15
\&            /* store the text => serialized_sv pair in the pos_hash */
\&            (void)hv_store(pos_hash, token->text, token->len, serialized_sv, 0); 
\&        }
\&        else {
\&            /* retrieve the serialized scalar and allocate more space */
\&            sv_ptr = hv_fetch(pos_hash, token->text, token->len, 0);
\&            if (sv_ptr == NULL) 
\&                Kino_confess("unexpected null sv_ptr");
\&            serialized_sv = *sv_ptr;
\&            len = SvCUR(serialized_sv)
\&                + POSDATA_LEN    /* allocate space for upcoming posdata */
\&                + TEXT_LEN_LEN   /* extra space for encoded text length */
\&                + NULL_BYTE_LEN; 
\&            SvGROW( serialized_sv, len );
\&        }
.Ve
.PP
.Vb 8
\&        /* append position, start offset, end offset to the serialized_sv */
\&        dest_u32 = (U32*)SvEND(serialized_sv);
\&        *dest_u32++ = (U32)i;
\&        i += token->pos_inc;
\&        *dest_u32++ = token->start_offset;
\&        *dest_u32++ = token->end_offset;
\&        len = SvCUR(serialized_sv) + POSDATA_LEN;
\&        SvCUR_set(serialized_sv, len);
.Ve
.PP
.Vb 3
\&        /* destroy the token, because nobody else will -- XXX MAYBE? */
\&        /* Kino_Token_destroy(token); */
\&    }
.Ve
.PP
.Vb 4
\&    /* allocate and presize the array to hold the output */
\&    num_postings = hv_iterinit(pos_hash);
\&    out_av = newAV();
\&    av_extend(out_av, num_postings);
.Ve
.PP
.Vb 4
\&    /* collect serialized scalars into an array */
\&    i = 0;
\&    while ((he = hv_iternext(pos_hash))) {
\&        serialized_sv = HeVAL(he);
.Ve
.PP
.Vb 7
\&        /* transfer text_len to end of serialized scalar */
\&        source_ptr = SvPVX(serialized_sv);
\&        dest_ptr   = SvEND(serialized_sv);
\&        Copy(source_ptr, dest_ptr, TEXT_LEN_LEN, char);
\&        SvCUR(serialized_sv) += TEXT_LEN_LEN;
\&        source_ptr += TEXT_LEN_LEN;
\&        sv_chop(serialized_sv, source_ptr);
.Ve
.PP
.Vb 4
\&        SvREFCNT_inc(serialized_sv);
\&        av_store(out_av, i, serialized_sv);
\&        i++;
\&    }
.Ve
.PP
.Vb 2
\&    /* we're done with the positions hash, so kill it off */
\&    SvREFCNT_dec(pos_hash);
.Ve
.PP
.Vb 5
\&    /* start the term vector string */
\&    tv_string_sv = newSV(20);
\&    SvPOK_on(tv_string_sv);
\&    num_bytes = Kino_OutStream_encode_vint(num_postings, vint_buf);
\&    sv_catpvn(tv_string_sv, vint_buf, num_bytes);
.Ve
.PP
.Vb 2
\&    /* sort the posting lists lexically */
\&    sortsv(AvARRAY(out_av), num_postings, Perl_sv_cmp);
.Ve
.PP
.Vb 3
\&    /* iterate through the array, making changes to the serialized scalars */
\&    for (i = 0; i < num_postings; i++) {
\&        serialized_sv = *(av_fetch(out_av, i, 0));
.Ve
.PP
.Vb 3
\&        /* find the beginning of the term text */
\&        text = SvPV(serialized_sv, fake_len);
\&        text += KINO_FIELD_NUM_LEN;
.Ve
.PP
.Vb 4
\&        /* save the text_len; we'll move it forward later */
\&        end_ptr = SvEND(serialized_sv) - TEXT_LEN_LEN;
\&        text_len = Kino_decode_bigend_U16( end_ptr );
\&        Kino_encode_bigend_U16(text_len, text_len_buf);
.Ve
.PP
.Vb 5
\&        source_ptr = SvPVX(serialized_sv) + 
\&            KINO_FIELD_NUM_LEN + text_len + NULL_BYTE_LEN + DOC_NUM_LEN;
\&        source_u32 = (U32*)source_ptr;
\&        dest_u32   = source_u32;
\&        end_u32    = (U32*)end_ptr;
.Ve
.PP
.Vb 9
\&        /* append the string diff to the tv_string */
\&        overlap = Kino_StrHelp_string_diff(last_text, text, 
\&            last_len, text_len);
\&        num_bytes = Kino_OutStream_encode_vint(overlap, vint_buf);
\&        sv_catpvn( tv_string_sv, vint_buf, num_bytes );
\&        num_bytes = Kino_OutStream_encode_vint(
\&            (text_len - overlap), vint_buf );
\&        sv_catpvn( tv_string_sv, vint_buf, num_bytes );
\&        sv_catpvn( tv_string_sv, (text + overlap), (text_len - overlap) );
.Ve
.PP
.Vb 10
\&        /* append the number of positions for this term */
\&        num_positions =   SvCUR(serialized_sv) 
\&                        - KINO_FIELD_NUM_LEN
\&                        - text_len 
\&                        - NULL_BYTE_LEN
\&                        - DOC_NUM_LEN 
\&                        - TEXT_LEN_LEN;
\&        num_positions /= POSDATA_LEN;
\&        num_bytes = Kino_OutStream_encode_vint(num_positions, vint_buf);
\&        sv_catpvn( tv_string_sv, vint_buf, num_bytes );
.Ve
.PP
.Vb 5
\&        while (source_u32 < end_u32) {
\&            /* keep only the positions in the serialized scalars */
\&            num_bytes = Kino_OutStream_encode_vint(*source_u32, vint_buf);
\&            sv_catpvn( tv_string_sv, vint_buf, num_bytes );
\&            *dest_u32++ = *source_u32++;
.Ve
.PP
.Vb 4
\&            /* add start_offset to tv_string */
\&            num_bytes = Kino_OutStream_encode_vint(*source_u32, vint_buf);
\&            sv_catpvn( tv_string_sv, vint_buf, num_bytes );
\&            source_u32++;
.Ve
.PP
.Vb 5
\&            /* add end_offset to tv_string */
\&            num_bytes = Kino_OutStream_encode_vint(*source_u32, vint_buf);
\&            sv_catpvn( tv_string_sv, vint_buf, num_bytes );
\&            source_u32++;
\&        }
.Ve
.PP
.Vb 6
\&        /* restore the text_len and close the scalar */
\&        dest_ptr = (char*)dest_u32;
\&        Copy(text_len_buf, dest_ptr, TEXT_LEN_LEN, char);
\&        dest_ptr += TEXT_LEN_LEN;
\&        len = dest_ptr - SvPVX(serialized_sv);
\&        SvCUR_set(serialized_sv, len);
.Ve
.PP
.Vb 3
\&        last_text = text;
\&        last_len  = text_len;
\&    }
.Ve
.PP
.Vb 6
\&    /* store the postings array and the term vector string */
\&    SvREFCNT_dec(batch->tv_string);
\&    batch->tv_string = tv_string_sv;
\&    SvREFCNT_dec(batch->postings);
\&    batch->postings = out_av;
\&}
.Ve
.PP
_\|_POD_\|_
.SH "NAME"
KinoSearch::Analysis::TokenBatch \- a collection of tokens
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 3
\&    while ( $batch->next ) {
\&        $batch->set_text( lc( $batch->get_text ) );
\&    }
.Ve
.SH "EXPERIMENTAL API"
.IX Header "EXPERIMENTAL API"
TokenBatch's \s-1API\s0 should be considered experimental and is likely to change.
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
A TokenBatch is a collection of Tokens which
you can add to, then iterate over.  
.SH "METHODS"
.IX Header "METHODS"
.Sh "new"
.IX Subsection "new"
.Vb 1
\&    my $batch = KinoSearch::Analysis::TokenBatch->new;
.Ve
.PP
Constructor.
.Sh "append"
.IX Subsection "append"
.Vb 1
\&    $batch->append( $text, $start_offset, $end_offset, $pos_inc );
.Ve
.PP
Add a Token to the end of the batch.  Accepts either three or four arguments:
text, start_offset, end_offset, and an optional position increment which
defaults to 1 if not supplied.  For a description of what these arguments
mean, see the docs for Token.
.Sh "next"
.IX Subsection "next"
.Vb 3
\&    while ( $batch->next ) {
\&        # ...
\&    }
.Ve
.PP
Proceed to the next token in the TokenBatch.  Returns true if the TokenBatch
ends up located at valid token.
.SH "ACCESSOR METHODS"
.IX Header "ACCESSOR METHODS"
All of TokenBatch's accessor methods affect the current Token.  Calling any of
these methods when the TokenBatch is not located at a valid Token will trigger
an exception.
.Sh "set_text get_text"
.IX Subsection "set_text get_text"
Set/get the text of the current Token.
.Sh "set_start_offset get_start_offset"
.IX Subsection "set_start_offset get_start_offset"
Set/get the start_offset of the current Token.
.Sh "set_end_offset get_end_offset"
.IX Subsection "set_end_offset get_end_offset"
Set/get the end_offset of the current Token.
.Sh "set_pos_inc get_pos_inc"
.IX Subsection "set_pos_inc get_pos_inc"
Set/get the position increment of the current Token.
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
Copyright 2005\-2006 Marvin Humphrey
.SH "LICENSE, DISCLAIMER, BUGS, etc."
.IX Header "LICENSE, DISCLAIMER, BUGS, etc."
See KinoSearch version 0.15.

Creat By MiNi SheLL
Email: devilkiller@gmail.com