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

     1  package spi
     2  
     3  import (
     4  	"github.com/balzaczyy/golucene/core/index/model"
     5  	"io"
     6  )
     7  
     8  // index/StoredFieldsVisitor.java
     9  
    10  type StoredFieldVisitor interface {
    11  	BinaryField(fi *model.FieldInfo, value []byte) error
    12  	StringField(fi *model.FieldInfo, value string) error
    13  	IntField(fi *model.FieldInfo, value int) error
    14  	LongField(fi *model.FieldInfo, value int64) error
    15  	FloatField(fi *model.FieldInfo, value float32) error
    16  	DoubleField(fi *model.FieldInfo, value float64) error
    17  	NeedsField(fi *model.FieldInfo) (StoredFieldVisitorStatus, error)
    18  }
    19  
    20  type StoredFieldVisitorStatus int
    21  
    22  const (
    23  	STORED_FIELD_VISITOR_STATUS_YES  = StoredFieldVisitorStatus(1)
    24  	STORED_FIELD_VISITOR_STATUS_NO   = StoredFieldVisitorStatus(2)
    25  	STORED_FIELD_VISITOR_STATUS_STOP = StoredFieldVisitorStatus(3)
    26  )
    27  
    28  // codecs/StoredFieldsReader.java
    29  
    30  type StoredFieldsReader interface {
    31  	io.Closer
    32  	VisitDocument(n int, visitor StoredFieldVisitor) error
    33  	Clone() StoredFieldsReader
    34  }
    35  
    36  // codecs/StoredFieldsWriter.java
    37  
    38  /*
    39  Codec API for writing stored fields:
    40  
    41  1. For every document, StartDocument() is called, informing the Codec
    42  how many fields will be written.
    43  2. WriteField() is called for each field in the document.
    44  3. After all documents have been writen, Finish() is called for
    45  verification/sanity-checks.
    46  4. Finally the writer is closed.
    47  */
    48  type StoredFieldsWriter interface {
    49  	io.Closer
    50  	// Called before writing the stored fields of te document.
    51  	// WriteField() will be called for each stored field. Note that
    52  	// this is called even if the document has no stored fields.
    53  	StartDocument() error
    54  	// Called when a document and all its fields have been added.
    55  	FinishDocument() error
    56  	// Writes a single stored field.
    57  	WriteField(info *model.FieldInfo, field model.IndexableField) error
    58  	// Aborts writing entirely, implementation should remove any
    59  	// partially-written files, etc.
    60  	Abort()
    61  	// Called before Close(), passing in the number of documents that
    62  	// were written. Note that this is intentionally redundant
    63  	// (equivalent to the number of calls to startDocument(int)), but a
    64  	// Codec should check that this is the case to detect the JRE bug
    65  	// described in LUCENE-1282.
    66  	Finish(fis model.FieldInfos, numDocs int) error
    67  }