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

     1  package lucene42
     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/util/packed"
     7  )
     8  
     9  // lucene42/Lucene42NormsFormat.java
    10  
    11  /*
    12  Lucene 4.2 score normalization format.
    13  
    14  NOTE: this uses the same format as Lucene42DocValuesFormat Numeric
    15  DocValues, but with different fiel extensions, and passing FASTEST
    16  for uncompressed encoding: trading off space for performance.
    17  
    18  Fields:
    19  - .nvd: DocValues data
    20  - .nvm: DocValues metadata
    21  */
    22  type Lucene42NormsFormat struct {
    23  	acceptableOverheadRatio float32
    24  }
    25  
    26  func NewLucene42NormsFormat() *Lucene42NormsFormat {
    27  	// note: we choose FASTEST here (otherwise our norms are half as big
    28  	// but 15% slower than previous lucene)
    29  	return newLucene42NormsFormatWithOverhead(packed.PackedInts.FASTEST)
    30  }
    31  
    32  func newLucene42NormsFormatWithOverhead(acceptableOverheadRatio float32) *Lucene42NormsFormat {
    33  	return &Lucene42NormsFormat{acceptableOverheadRatio}
    34  }
    35  
    36  func (f *Lucene42NormsFormat) NormsConsumer(state *SegmentWriteState) (w DocValuesConsumer, err error) {
    37  	panic("this codec can only be used for reading")
    38  }
    39  
    40  func (f *Lucene42NormsFormat) NormsProducer(state SegmentReadState) (r DocValuesProducer, err error) {
    41  	return newLucene42DocValuesProducer(state, "Lucene41NormsData", "nvd", "Lucene41NormsMetadata", "nvm")
    42  }