Ejemplo n.º 1
0
func (a *CharTermAttributeImpl) Clone() util.AttributeImpl {
	clone := new(CharTermAttributeImpl)
	// do a deep clone
	clone.termBuffer = make([]rune, a.termLength)
	copy(clone.termBuffer, a.termBuffer[:a.termLength])
	clone.termLength = a.termLength
	clone.bytes = util.NewBytesRefBuilder()
	clone.bytes.Copy(a.bytes.Bytes())
	return clone
}
Ejemplo n.º 2
0
func newTermsWriter(owner *BlockTreeTermsWriter,
	fieldInfo *FieldInfo) *TermsWriter {
	owner.postingsWriter.SetField(fieldInfo)
	ans := &TermsWriter{
		owner:        owner,
		fieldInfo:    fieldInfo,
		lastTerm:     util.NewBytesRefBuilder(),
		prefixStarts: make([]int, 8),
		suffixWriter: store.NewRAMOutputStreamBuffer(),
		statsWriter:  store.NewRAMOutputStreamBuffer(),
		metaWriter:   store.NewRAMOutputStreamBuffer(),
		bytesWriter:  store.NewRAMOutputStreamBuffer(),
	}
	ans.longsSize = owner.postingsWriter.SetField(fieldInfo)
	ans.longs = make([]int64, ans.longsSize)
	return ans
}
Ejemplo n.º 3
0
func newSegmentTermsEnum(r *FieldReader) *SegmentTermsEnum {
	ans := &SegmentTermsEnum{
		fr:            r,
		stack:         make([]*segmentTermsEnumFrame, 0),
		scratchReader: store.NewEmptyByteArrayDataInput(),
		term:          util.NewBytesRefBuilder(),
		arcs:          make([]*fst.Arc, 1),
	}
	ans.TermsEnumImpl = NewTermsEnumImpl(ans)
	// fmt.Printf("BTTR.init seg=%v\n", r.parent.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] = &fst.Arc{}
	}

	ans.currentFrame = ans.staticFrame
	var arc *fst.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.validIndexPrefix = 0
	// fmt.Printf("init frame state %v\n", ans.currentFrame.ord)
	ans.printSeekState()

	// ans.computeBlockStats()

	return ans
}
Ejemplo n.º 4
0
func newCharTermAttributeImpl() *CharTermAttributeImpl {
	return &CharTermAttributeImpl{
		termBuffer: make([]rune, util.Oversize(MIN_BUFFER_SIZE, util.NUM_BYTES_CHAR)),
		bytes:      util.NewBytesRefBuilder(),
	}
}