github.com/balzaczyy/golucene@v0.0.0-20151210033525-d0be9ee89713/core/codec/spi/termsConsumer.go (about)

     1  package spi
     2  
     3  import (
     4  	. "github.com/balzaczyy/golucene/core/codec"
     5  )
     6  
     7  /*
     8  Abstract API that consumes terms for an individual field.
     9  
    10  The lifecycle is:
    11  	- TermsConsumer is returned for each field by FieldsConsumer.addField().
    12  	- TermsConsumer returns a PostingsCOnsumer for each term in startTerm().
    13  	- When the producer (e.g. IndexWriter) is done adding documents for
    14  	the term, it calls finishTerm(), passing in the accumulated term statistics.
    15  	- Producer calls finish() with the accumulated collection
    16  	statistics when it is finished adding terms to the field.
    17  */
    18  type TermsConsumer interface {
    19  	// Starts a ew term in this field; this may be called with no
    20  	// corresponding call to finish if the term had no docs.
    21  	StartTerm([]byte) (PostingsConsumer, error)
    22  	// Finishes the current term; numDocs must be > 0.
    23  	// stats.totalTermFreq will be -1 when term frequencies are omitted
    24  	// for the field.
    25  	FinishTerm([]byte, *TermStats) error
    26  	// Called when we are done adding terms to this field.
    27  	// sumTotalTermFreq will be -1 when term frequencies are omitted
    28  	// for the field.
    29  	Finish(sumTotalTermFreq, sumDocFreq int64, docCount int) error
    30  	// Return the BytesRef comparator used to sort terms before feeding
    31  	// to this API.
    32  	Comparator() func(a, b []byte) bool
    33  }