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

     1  package lucene40
     2  
     3  import (
     4  	. "github.com/balzaczyy/golucene/core/codec/spi"
     5  	// . "github.com/balzaczyy/golucene/core/index/model"
     6  	// "github.com/balzaczyy/golucene/core/store"
     7  )
     8  
     9  // lucene40/Lucene40SegmentInfoFormat.java
    10  
    11  /*
    12  Lucene 4.0 Segment info format.
    13  
    14  Files:
    15  - .si: Header, SegVersion, SegSize, IsCompoundFile, Diagnostics, Attributes, Files
    16  
    17  Data types:
    18  - Header --> CodecHeader
    19  - SegSize --> int32
    20  - SegVersion --> string
    21  - Files --> set[string]
    22  - Diagnostics, Attributes --> map[string]string
    23  - IsCompoundFile --> byte
    24  
    25  Field Descriptions:
    26  - SegVersion is the code version that created the segment.
    27  - SegSize is the number of documents contained in the segment index.
    28  - IsCompoundFile records whether the segment is written as a compound
    29    file or not. If this is -1, the segment is not a compound file. If
    30    it is 1, the segment is a compound file.
    31  - Checksum contains the CRC32 checksum of all bytes in the segments_N
    32    file up until the checksum. This is used to verify integrity of the
    33    file on opening the index.
    34  - The Diagnostics Map is privately written by IndexWriter, as a debugging
    35    for each segment it creates. It includes metadata like the current
    36    Lucene version, OS, Java version, why the segment was created (merge,
    37    flush, addIndexes), etc.
    38  - Attributes: a key-value map of codec-pivate attributes.
    39  - Files is a list of files referred to by this segment.
    40  */
    41  type Lucene40SegmentInfoFormat struct {
    42  	reader SegmentInfoReader
    43  	writer SegmentInfoWriter
    44  }
    45  
    46  func NewLucene40SegmentInfoFormat() *Lucene40SegmentInfoFormat {
    47  	return &Lucene40SegmentInfoFormat{
    48  		reader: new(Lucene40SegmentInfoReader),
    49  		writer: new(Lucene40SegmentInfoWriter),
    50  	}
    51  }
    52  
    53  func (f *Lucene40SegmentInfoFormat) SegmentInfoReader() SegmentInfoReader {
    54  	return f.reader
    55  }
    56  
    57  func (f *Lucene40SegmentInfoFormat) SegmentInfoWriter() SegmentInfoWriter {
    58  	return f.writer
    59  }
    60  
    61  const (
    62  	LUCENE40_SI_EXTENSION    = "si"
    63  	LUCENE40_CODEC_NAME      = "Lucene40SegmentInfo"
    64  	LUCENE40_VERSION_START   = 0
    65  	LUCENE40_VERSION_CURRENT = LUCENE40_VERSION_START
    66  )