本文整理匯總了Golang中github.com/balzaczyy/golucene/store.IndexInput.ReadVLong方法的典型用法代碼示例。如果您正苦於以下問題:Golang IndexInput.ReadVLong方法的具體用法?Golang IndexInput.ReadVLong怎麽用?Golang IndexInput.ReadVLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/balzaczyy/golucene/store.IndexInput
的用法示例。
在下文中一共展示了IndexInput.ReadVLong方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newCompressingStoredFieldsIndexReader
func newCompressingStoredFieldsIndexReader(fieldsIndexIn store.IndexInput, si SegmentInfo) (r *CompressingStoredFieldsIndexReader, err error) {
r = &CompressingStoredFieldsIndexReader{}
r.maxDoc = int(si.docCount)
r.docBases = make([]int, 0, 16)
r.startPointers = make([]int64, 0, 16)
r.avgChunkDocs = make([]int, 0, 16)
r.avgChunkSizes = make([]int64, 0, 16)
r.docBasesDeltas = make([]util.PackedIntsReader, 0, 16)
r.startPointersDeltas = make([]util.PackedIntsReader, 0, 16)
packedIntsVersion, err := fieldsIndexIn.ReadVInt()
if err != nil {
return nil, err
}
for blockCount := 0; ; blockCount++ {
numChunks, err := fieldsIndexIn.ReadVInt()
if err != nil {
return nil, err
}
if numChunks == 0 {
break
}
{ // doc bases
n, err := fieldsIndexIn.ReadVInt()
if err != nil {
return nil, err
}
r.docBases = append(r.docBases, int(n))
n, err = fieldsIndexIn.ReadVInt()
if err != nil {
return nil, err
}
r.avgChunkDocs = append(r.avgChunkDocs, int(n))
bitsPerDocBase, err := fieldsIndexIn.ReadVInt()
if err != nil {
return nil, err
}
if bitsPerDocBase > 32 {
return nil, errors.New(fmt.Sprintf("Corrupted bitsPerDocBase (resource=%v)", fieldsIndexIn))
}
pr, err := util.NewPackedReaderNoHeader(fieldsIndexIn, util.PACKED, packedIntsVersion, numChunks, uint32(bitsPerDocBase))
if err != nil {
return nil, err
}
r.docBasesDeltas = append(r.docBasesDeltas, pr)
}
{ // start pointers
n, err := fieldsIndexIn.ReadVLong()
if err != nil {
return nil, err
}
r.startPointers = append(r.startPointers, n)
n, err = fieldsIndexIn.ReadVLong()
if err != nil {
return nil, err
}
r.avgChunkSizes = append(r.avgChunkSizes, n)
bitsPerStartPointer, err := fieldsIndexIn.ReadVInt()
if err != nil {
return nil, err
}
if bitsPerStartPointer > 64 {
return nil, errors.New(fmt.Sprintf("Corrupted bitsPerStartPonter (resource=%v)", fieldsIndexIn))
}
pr, err := util.NewPackedReaderNoHeader(fieldsIndexIn, util.PACKED, packedIntsVersion, numChunks, uint32(bitsPerStartPointer))
if err != nil {
return nil, err
}
r.startPointersDeltas = append(r.startPointersDeltas, pr)
}
}
return r, nil
}
示例2: newBlockTreeTermsReader
func newBlockTreeTermsReader(dir store.Directory, fieldInfos FieldInfos, info SegmentInfo,
postingsReader PostingsReaderBase, ctx store.IOContext,
segmentSuffix string, indexDivisor int) (p FieldsProducer, err error) {
log.Print("Initializing BlockTreeTermsReader...")
fp := &BlockTreeTermsReader{
postingsReader: postingsReader,
fields: make(map[string]FieldReader),
segment: info.name,
}
fp.in, err = dir.OpenInput(util.SegmentFileName(info.name, segmentSuffix, BTT_EXTENSION), ctx)
if err != nil {
return fp, err
}
success := false
var indexIn store.IndexInput
defer func() {
if !success {
log.Print("Failed to initialize BlockTreeTermsReader.")
if err != nil {
log.Print("DEBUG ", err)
}
// this.close() will close in:
util.CloseWhileSuppressingError(indexIn, fp)
}
}()
fp.version, err = fp.readHeader(fp.in)
if err != nil {
return fp, err
}
log.Printf("Version: %v", fp.version)
if indexDivisor != -1 {
indexIn, err = dir.OpenInput(util.SegmentFileName(info.name, segmentSuffix, BTT_INDEX_EXTENSION), ctx)
if err != nil {
return fp, err
}
indexVersion, err := fp.readIndexHeader(indexIn)
if err != nil {
return fp, err
}
log.Printf("Index version: %v", indexVersion)
if int(indexVersion) != fp.version {
return fp, errors.New(fmt.Sprintf("mixmatched version files: %v=%v,%v=%v", fp.in, fp.version, indexIn, indexVersion))
}
}
// Have PostingsReader init itself
postingsReader.Init(fp.in)
// Read per-field details
fp.seekDir(fp.in, fp.dirOffset)
if indexDivisor != -1 {
fp.seekDir(indexIn, fp.indexDirOffset)
}
numFields, err := fp.in.ReadVInt()
if err != nil {
return fp, err
}
log.Printf("Fields number: %v", numFields)
if numFields < 0 {
return fp, errors.New(fmt.Sprintf("invalid numFields: %v (resource=%v)", numFields, fp.in))
}
for i := int32(0); i < numFields; i++ {
log.Printf("Next field...")
field, err := fp.in.ReadVInt()
if err != nil {
return fp, err
}
log.Printf("Field: %v", field)
numTerms, err := fp.in.ReadVLong()
if err != nil {
return fp, err
}
// assert numTerms >= 0
log.Printf("Terms number: %v", numTerms)
numBytes, err := fp.in.ReadVInt()
if err != nil {
return fp, err
}
log.Printf("Bytes number: %v", numBytes)
rootCode := make([]byte, numBytes)
err = fp.in.ReadBytes(rootCode)
if err != nil {
return fp, err
}
fieldInfo := fieldInfos.byNumber[field]
// assert fieldInfo != nil
var sumTotalTermFreq int64
if fieldInfo.indexOptions == INDEX_OPT_DOCS_ONLY {
sumTotalTermFreq = -1
} else {
sumTotalTermFreq, err = fp.in.ReadVLong()
//.........這裏部分代碼省略.........