github.com/balzaczyy/golucene@v0.0.0-20151210033525-d0be9ee89713/core/index/invertedDocEndConsumer.go (about) 1 package index 2 3 // import ( 4 // "github.com/balzaczyy/golucene/core/index/model" 5 // "github.com/balzaczyy/golucene/core/util" 6 // ) 7 8 // type InvertedDocEndConsumer interface { 9 // flush(map[string]InvertedDocEndConsumerPerField, *model.SegmentWriteState) error 10 // abort() 11 // addField(*DocInverterPerField, *model.FieldInfo) InvertedDocEndConsumerPerField 12 // startDocument() 13 // finishDocument() 14 // } 15 16 // /* 17 // Writes norms. Each thread X field accumlates the norms for the 18 // doc/fields it saw, then the flush method below merges all of these 19 // together into a single _X.nrm file. 20 // */ 21 // type NormsConsumer struct { 22 // } 23 24 // func (nc *NormsConsumer) abort() {} 25 26 // func (nc *NormsConsumer) flush(fieldsToFlush map[string]InvertedDocEndConsumerPerField, 27 // state *model.SegmentWriteState) (err error) { 28 // var success = false 29 // var normsConsumer DocValuesConsumer 30 // defer func() { 31 // if success { 32 // err = mergeError(err, util.Close(normsConsumer)) 33 // } else { 34 // util.CloseWhileSuppressingError(normsConsumer) 35 // } 36 // }() 37 38 // if state.FieldInfos.HasNorms { 39 // normsFormat := state.SegmentInfo.Codec().(Codec).NormsFormat() 40 // assert(normsFormat != nil) 41 // normsConsumer, err = normsFormat.NormsConsumer(state) 42 // if err != nil { 43 // return err 44 // } 45 46 // for _, fi := range state.FieldInfos.Values { 47 // toWrite := fieldsToFlush[fi.Name].(*NormsConsumerPerField) 48 // // we must check the final value of omitNorms for the fieldinfo, 49 // // it could have changed for this field since the first time we 50 // // added it. 51 // if !fi.OmitsNorms() { 52 // if toWrite != nil && !toWrite.isEmpty() { 53 // err = toWrite.flush(state, normsConsumer) 54 // if err != nil { 55 // return err 56 // } 57 // assert(fi.NormType() == model.DOC_VALUES_TYPE_NUMERIC) 58 // } else if fi.IsIndexed() { 59 // assertn(int(fi.NormType()) == 0, "got %v; field=%v", fi.NormType(), fi.Name) 60 // } 61 // } 62 // } 63 // } 64 // success = true 65 // return nil 66 // } 67 68 // func (nc *NormsConsumer) finishDocument() {} 69 70 // func (nc *NormsConsumer) startDocument() {} 71 72 // func (nc *NormsConsumer) addField(docInverterPerField *DocInverterPerField, 73 // fieldInfo *model.FieldInfo) InvertedDocEndConsumerPerField { 74 // return newNormsConsumerPerField(docInverterPerField, fieldInfo, nc) 75 // }