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

     1  package spi
     2  
     3  import (
     4  	"github.com/balzaczyy/golucene/core/index/model"
     5  	"io"
     6  )
     7  
     8  // codecs/TermVectorsReader.java
     9  
    10  type TermVectorsReader interface {
    11  	io.Closer
    12  	Get(doc int) model.Fields
    13  	Clone() TermVectorsReader
    14  }
    15  
    16  // codecs/TermVectorsWriter.java
    17  
    18  /*
    19  Codec API for writing term vecrors:
    20  
    21  1. For every document, StartDocument() is called, informing the Codec
    22  how may fields will be written.
    23  2. StartField() is called for each field in the document, informing
    24  the codec how many terms will be written for that field, and whether
    25  or not positions, offsets, or payloads are enabled.
    26  3. Within each field, StartTerm() is called for each term.
    27  4. If offsets and/or positions are enabled, then AddPosition() will
    28  be called for each term occurrence.
    29  5. After all documents have been written, Finish() is called for
    30  verification/sanity-checks.
    31  6. Finally the writer is closed.
    32  */
    33  type TermVectorsWriter interface {
    34  	io.Closer
    35  	// Called before writing the term vectors of the document.
    36  	// startField() will be called numVectorsFields times. Note that if
    37  	// term vectors are enabled, this is called even if the document
    38  	// has no vector fields, in this case numVectorFields will be zero.
    39  	StartDocument(int) error
    40  	// Called after a doc and all its fields have been added
    41  	FinishDocument() error
    42  	// Aborts writing entirely, implementation should remove any
    43  	// partially-written files, etc.
    44  	Abort()
    45  	// Called before Close(), passing in the number of documents that
    46  	// were written. Note that this is intentionally redendant
    47  	// (equivalent to the number of calls to startDocument(int)), but a
    48  	// Codec should check that this is the case to detect the JRE bug
    49  	// described in LUCENE-1282.
    50  	Finish(model.FieldInfos, int) error
    51  }