/* Reads but does not decode the byte[] blob holding metadata for the current terms block */ func (r *Lucene41PostingsReader) ReadTermsBlock(termsIn store.IndexInput, fieldInfo model.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 }
func readBytesRef(in store.IndexInput) ([]byte, error) { length, err := asInt(in.ReadVInt()) if err != nil { return nil, err } bytes := make([]byte, length) if err = in.ReadBytes(bytes); err != nil { return nil, err } return bytes, nil }