示例#1
0
func (visitor *DocumentStoredFieldVisitor) stringField(fi model.FieldInfo, value string) error {
	ft := NewFieldTypeFrom(TEXT_FIELD_TYPE_STORED)
	ft.storeTermVectors = fi.HasVectors()
	ft.indexed = fi.IsIndexed()
	ft._omitNorms = fi.OmitsNorms()
	ft._indexOptions = fi.IndexOptions()
	visitor.doc.Add(NewStringField(fi.Name, value, ft))
	return nil
}
示例#2
0
func newBlockDocsEnum(owner *Lucene41PostingsReader,
	fieldInfo model.FieldInfo) *blockDocsEnum {

	return &blockDocsEnum{
		Lucene41PostingsReader: owner,
		docDeltaBuffer:         make([]int, MAX_DATA_SIZE),
		freqBuffer:             make([]int, MAX_DATA_SIZE),
		startDocIn:             owner.docIn,
		docIn:                  nil,
		indexHasFreq:           fieldInfo.IndexOptions() >= model.INDEX_OPT_DOCS_AND_FREQS,
		indexHasPos:            fieldInfo.IndexOptions() >= model.INDEX_OPT_DOCS_AND_FREQS_AND_POSITIONS,
		indexHasOffsets:        fieldInfo.IndexOptions() >= model.INDEX_OPT_DOCS_AND_FREQS_AND_POSITIONS,
		indexHasPayloads:       fieldInfo.HasPayloads(),
		encoded:                make([]byte, MAX_ENCODED_SIZE),
	}
}
示例#3
0
func (de *blockDocsEnum) canReuse(docIn store.IndexInput, fieldInfo model.FieldInfo) bool {
	return docIn == de.startDocIn &&
		de.indexHasFreq == (fieldInfo.IndexOptions() >= model.INDEX_OPT_DOCS_AND_FREQS) &&
		de.indexHasPos == (fieldInfo.IndexOptions() >= model.INDEX_OPT_DOCS_AND_FREQS_AND_POSITIONS) &&
		de.indexHasPayloads == fieldInfo.HasPayloads()
}
示例#4
0
func (r *Lucene41PostingsReader) nextTerm(fieldInfo model.FieldInfo,
	_termState *BlockTermState) (err error) {

	termState := _termState.Self.(*intBlockTermState)
	isFirstTerm := termState.termBlockOrd == 0
	fieldHasPositions := fieldInfo.IndexOptions() >= model.INDEX_OPT_DOCS_AND_FREQS_AND_POSITIONS
	fieldHasOffsets := fieldInfo.IndexOptions() >= model.INDEX_OPT_DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS
	fieldHasPayloads := fieldInfo.HasPayloads()

	in := termState.bytesReader
	if isFirstTerm {
		if termState.docFreq == 1 {
			termState.singletonDocID, err = asInt(in.ReadVInt())
			if err != nil {
				return err
			}
			termState.docStartFP = 0
		} else {
			termState.singletonDocID = -1
			termState.docStartFP, err = in.ReadVLong()
			if err != nil {
				return err
			}
		}
		if fieldHasPositions {
			termState.posStartFP, err = in.ReadVLong()
			if err != nil {
				return err
			}
			if termState.totalTermFreq > LUCENE41_BLOCK_SIZE {
				termState.lastPosBlockOffset, err = in.ReadVLong()
				if err != nil {
					return err
				}
			} else {
				termState.lastPosBlockOffset = -1
			}
			if (fieldHasPayloads || fieldHasOffsets) && termState.totalTermFreq >= LUCENE41_BLOCK_SIZE {
				termState.payStartFP, err = in.ReadVLong()
				if err != nil {
					return err
				}
			} else {
				termState.payStartFP = -1
			}
		}
	} else {
		if termState.docFreq == 1 {
			termState.singletonDocID, err = asInt(in.ReadVInt())
			if err != nil {
				return err
			}
		} else {
			termState.singletonDocID = -1
			delta, err := in.ReadVLong()
			if err != nil {
				return err
			}
			termState.docStartFP += delta
		}
		if fieldHasPositions {
			delta, err := in.ReadVLong()
			if err != nil {
				return err
			}
			termState.posStartFP += delta
			if termState.totalTermFreq > LUCENE41_BLOCK_SIZE {
				termState.lastPosBlockOffset, err = in.ReadVLong()
				if err != nil {
					return err
				}
			} else {
				termState.lastPosBlockOffset = -1
			}
			if (fieldHasPayloads || fieldHasOffsets) && termState.totalTermFreq >= LUCENE41_BLOCK_SIZE {
				delta, err = in.ReadVLong()
				if err != nil {
					return err
				}
				if termState.payStartFP == -1 {
					termState.payStartFP = delta
				} else {
					termState.payStartFP += delta
				}
			}
		}
	}

	if termState.docFreq > LUCENE41_BLOCK_SIZE {
		termState.skipOffset, err = in.ReadVLong()
		if err != nil {
			return err
		}
	} else {
		termState.skipOffset = -1
	}

	return nil
}