func newSegmentTermsEnum(r *FieldReader) *SegmentTermsEnum { ans := &SegmentTermsEnum{ FieldReader: r, stack: make([]*segmentTermsEnumFrame, 0), scratchReader: store.NewEmptyByteArrayDataInput(), term: make([]byte, 0), arcs: make([]*util.Arc, 1), fstOutputs: util.ByteSequenceOutputsSingleton(), } ans.TermsEnumImpl = newTermsEnumImpl(ans) log.Println("BTTR.init seg=%v", r.segment) // Used to hold seek by TermState, or cached seek ans.staticFrame = newFrame(ans, -1) if r.index != nil { ans.fstReader = r.index.BytesReader() } // Init w/ root block; don't use index since it may // not (and need not) have been loaded for i, _ := range ans.arcs { ans.arcs[i] = &util.Arc{} } ans.currentFrame = ans.staticFrame var arc *util.Arc if r.index != nil { arc = r.index.FirstArc(ans.arcs[0]) // Empty string prefix must have an output in the index! if !arc.IsFinal() { panic("assert fail") } } ans.currentFrame = ans.staticFrame ans.validIndexPrefix = 0 log.Printf("init frame state %v", ans.currentFrame.ord) ans.printSeekState() // ans.computeBlockStats() return ans }
/* Reads but does not decode the byte[] blob holding metadata for the current terms block */ func (r *Lucene41PostingsReader) ReadTermsBlock(termsIn store.IndexInput, fieldInfo FieldInfo, _termState *BlockTermState) (err error) { termState := _termState.Self.(*intBlockTermState) numBytes, err := asInt(termsIn.ReadVInt()) if err != nil { return err } if termState.bytes == nil { // TODO over-allocate termState.bytes = make([]byte, numBytes) termState.bytesReader = store.NewEmptyByteArrayDataInput() } else if len(termState.bytes) < numBytes { // TODO over-allocate termState.bytes = make([]byte, numBytes) } err = termsIn.ReadBytes(termState.bytes) if err != nil { return err } termState.bytesReader.Reset(termState.bytes) return nil }