1
// Copyright (c) 2014 Couchbase, Inc.
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
7
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
24
"github.com/golang/protobuf/proto"
27
const ByteSeparator byte = 0xff
29
type UpsideDownCouchRowStream chan UpsideDownCouchRow
31
type UpsideDownCouchRow interface {
33
KeyTo([]byte) (int, error)
37
ValueTo([]byte) (int, error)
40
func ParseFromKeyValue(key, value []byte) (UpsideDownCouchRow, error) {
44
return NewVersionRowKV(key, value)
46
return NewFieldRowKV(key, value)
48
return NewDictionaryRowKV(key, value)
50
return NewTermFrequencyRowKV(key, value)
52
return NewBackIndexRowKV(key, value)
54
return NewStoredRowKV(key, value)
56
return NewInternalRowKV(key, value)
58
return nil, fmt.Errorf("Unknown field type '%s'", string(key[0]))
60
return nil, fmt.Errorf("Invalid empty key")
65
type VersionRow struct {
69
func (v *VersionRow) Key() []byte {
73
func (v *VersionRow) KeySize() int {
77
func (v *VersionRow) KeyTo(buf []byte) (int, error) {
82
func (v *VersionRow) Value() []byte {
83
return []byte{byte(v.version)}
86
func (v *VersionRow) ValueSize() int {
90
func (v *VersionRow) ValueTo(buf []byte) (int, error) {
95
func (v *VersionRow) String() string {
96
return fmt.Sprintf("Version: %d", v.version)
99
func NewVersionRow(version uint8) *VersionRow {
105
func NewVersionRowKV(key, value []byte) (*VersionRow, error) {
107
buf := bytes.NewBuffer(value)
108
err := binary.Read(buf, binary.LittleEndian, &rv.version)
117
type InternalRow struct {
122
func (i *InternalRow) Key() []byte {
123
buf := make([]byte, i.KeySize())
124
size, _ := i.KeyTo(buf)
128
func (i *InternalRow) KeySize() int {
129
return len(i.key) + 1
132
func (i *InternalRow) KeyTo(buf []byte) (int, error) {
134
actual := copy(buf[1:], i.key)
135
return 1 + actual, nil
138
func (i *InternalRow) Value() []byte {
142
func (i *InternalRow) ValueSize() int {
146
func (i *InternalRow) ValueTo(buf []byte) (int, error) {
147
actual := copy(buf, i.val)
151
func (i *InternalRow) String() string {
152
return fmt.Sprintf("InternalStore - Key: %s (% x) Val: %s (% x)", i.key, i.key, i.val, i.val)
155
func NewInternalRow(key, val []byte) *InternalRow {
162
func NewInternalRowKV(key, value []byte) (*InternalRow, error) {
171
type FieldRow struct {
176
func (f *FieldRow) Key() []byte {
177
buf := make([]byte, f.KeySize())
178
size, _ := f.KeyTo(buf)
182
func (f *FieldRow) KeySize() int {
186
func (f *FieldRow) KeyTo(buf []byte) (int, error) {
188
binary.LittleEndian.PutUint16(buf[1:3], f.index)
192
func (f *FieldRow) Value() []byte {
193
return append([]byte(f.name), ByteSeparator)
196
func (f *FieldRow) ValueSize() int {
197
return len(f.name) + 1
200
func (f *FieldRow) ValueTo(buf []byte) (int, error) {
201
size := copy(buf, f.name)
202
buf[size] = ByteSeparator
206
func (f *FieldRow) String() string {
207
return fmt.Sprintf("Field: %d Name: %s", f.index, f.name)
210
func NewFieldRow(index uint16, name string) *FieldRow {
217
func NewFieldRowKV(key, value []byte) (*FieldRow, error) {
220
buf := bytes.NewBuffer(key)
221
_, err := buf.ReadByte() // type
225
err = binary.Read(buf, binary.LittleEndian, &rv.index)
230
buf = bytes.NewBuffer(value)
231
rv.name, err = buf.ReadString(ByteSeparator)
235
rv.name = rv.name[:len(rv.name)-1] // trim off separator byte
242
const DictionaryRowMaxValueSize = binary.MaxVarintLen64
244
type DictionaryRow struct {
250
func (dr *DictionaryRow) Key() []byte {
251
buf := make([]byte, dr.KeySize())
252
size, _ := dr.KeyTo(buf)
256
func (dr *DictionaryRow) KeySize() int {
257
return dictionaryRowKeySize(dr.term)
260
func dictionaryRowKeySize(term []byte) int {
264
func (dr *DictionaryRow) KeyTo(buf []byte) (int, error) {
265
return dictionaryRowKeyTo(buf, dr.field, dr.term), nil
268
func dictionaryRowKeyTo(buf []byte, field uint16, term []byte) int {
270
binary.LittleEndian.PutUint16(buf[1:3], field)
271
size := copy(buf[3:], term)
275
func (dr *DictionaryRow) Value() []byte {
276
buf := make([]byte, dr.ValueSize())
277
size, _ := dr.ValueTo(buf)
281
func (dr *DictionaryRow) ValueSize() int {
282
return DictionaryRowMaxValueSize
285
func (dr *DictionaryRow) ValueTo(buf []byte) (int, error) {
286
used := binary.PutUvarint(buf, dr.count)
290
func (dr *DictionaryRow) String() string {
291
return fmt.Sprintf("Dictionary Term: `%s` Field: %d Count: %d ", string(dr.term), dr.field, dr.count)
294
func NewDictionaryRow(term []byte, field uint16, count uint64) *DictionaryRow {
295
return &DictionaryRow{
302
func NewDictionaryRowKV(key, value []byte) (*DictionaryRow, error) {
303
rv, err := NewDictionaryRowK(key)
308
err = rv.parseDictionaryV(value)
316
func NewDictionaryRowK(key []byte) (*DictionaryRow, error) {
317
rv := &DictionaryRow{}
318
err := rv.parseDictionaryK(key)
325
func (dr *DictionaryRow) parseDictionaryK(key []byte) error {
326
dr.field = binary.LittleEndian.Uint16(key[1:3])
328
dr.term = dr.term[:0]
330
dr.term = append(dr.term, key[3:]...)
334
func (dr *DictionaryRow) parseDictionaryV(value []byte) error {
335
count, err := dictionaryRowParseV(value)
343
func dictionaryRowParseV(value []byte) (uint64, error) {
344
count, nread := binary.Uvarint(value)
346
return 0, fmt.Errorf("DictionaryRow parse Uvarint error, nread: %d", nread)
351
// TERM FIELD FREQUENCY
353
type TermVector struct {
355
arrayPositions []uint64
361
func (tv *TermVector) String() string {
362
return fmt.Sprintf("Field: %d Pos: %d Start: %d End %d ArrayPositions: %#v", tv.field, tv.pos, tv.start, tv.end, tv.arrayPositions)
365
type TermFrequencyRow struct {
369
vectors []*TermVector
374
func (tfr *TermFrequencyRow) Term() []byte {
378
func (tfr *TermFrequencyRow) Freq() uint64 {
382
func (tfr *TermFrequencyRow) ScanPrefixForField() []byte {
383
buf := make([]byte, 3)
385
binary.LittleEndian.PutUint16(buf[1:3], tfr.field)
389
func (tfr *TermFrequencyRow) ScanPrefixForFieldTermPrefix() []byte {
390
buf := make([]byte, 3+len(tfr.term))
392
binary.LittleEndian.PutUint16(buf[1:3], tfr.field)
393
copy(buf[3:], tfr.term)
397
func (tfr *TermFrequencyRow) ScanPrefixForFieldTerm() []byte {
398
buf := make([]byte, 3+len(tfr.term)+1)
400
binary.LittleEndian.PutUint16(buf[1:3], tfr.field)
401
termLen := copy(buf[3:], tfr.term)
402
buf[3+termLen] = ByteSeparator
406
func (tfr *TermFrequencyRow) Key() []byte {
407
buf := make([]byte, tfr.KeySize())
408
size, _ := tfr.KeyTo(buf)
412
func (tfr *TermFrequencyRow) KeySize() int {
413
return termFrequencyRowKeySize(tfr.term, tfr.doc)
416
func termFrequencyRowKeySize(term, doc []byte) int {
417
return 3 + len(term) + 1 + len(doc)
420
func (tfr *TermFrequencyRow) KeyTo(buf []byte) (int, error) {
421
return termFrequencyRowKeyTo(buf, tfr.field, tfr.term, tfr.doc), nil
424
func termFrequencyRowKeyTo(buf []byte, field uint16, term, doc []byte) int {
426
binary.LittleEndian.PutUint16(buf[1:3], field)
427
termLen := copy(buf[3:], term)
428
buf[3+termLen] = ByteSeparator
429
docLen := copy(buf[3+termLen+1:], doc)
430
return 3 + termLen + 1 + docLen
433
func (tfr *TermFrequencyRow) KeyAppendTo(buf []byte) ([]byte, error) {
434
keySize := tfr.KeySize()
435
if cap(buf) < keySize {
436
buf = make([]byte, keySize)
438
actualSize, err := tfr.KeyTo(buf[0:keySize])
439
return buf[0:actualSize], err
442
func (tfr *TermFrequencyRow) DictionaryRowKey() []byte {
443
dr := NewDictionaryRow(tfr.term, tfr.field, 0)
447
func (tfr *TermFrequencyRow) DictionaryRowKeySize() int {
448
dr := NewDictionaryRow(tfr.term, tfr.field, 0)
452
func (tfr *TermFrequencyRow) DictionaryRowKeyTo(buf []byte) (int, error) {
453
dr := NewDictionaryRow(tfr.term, tfr.field, 0)
457
func (tfr *TermFrequencyRow) Value() []byte {
458
buf := make([]byte, tfr.ValueSize())
459
size, _ := tfr.ValueTo(buf)
463
func (tfr *TermFrequencyRow) ValueSize() int {
464
bufLen := binary.MaxVarintLen64 + binary.MaxVarintLen64
465
for _, vector := range tfr.vectors {
466
bufLen += (binary.MaxVarintLen64 * 4) + (1+len(vector.arrayPositions))*binary.MaxVarintLen64
471
func (tfr *TermFrequencyRow) ValueTo(buf []byte) (int, error) {
472
used := binary.PutUvarint(buf[:binary.MaxVarintLen64], tfr.freq)
474
normuint32 := math.Float32bits(tfr.norm)
475
newbuf := buf[used : used+binary.MaxVarintLen64]
476
used += binary.PutUvarint(newbuf, uint64(normuint32))
478
for _, vector := range tfr.vectors {
479
used += binary.PutUvarint(buf[used:used+binary.MaxVarintLen64], uint64(vector.field))
480
used += binary.PutUvarint(buf[used:used+binary.MaxVarintLen64], vector.pos)
481
used += binary.PutUvarint(buf[used:used+binary.MaxVarintLen64], vector.start)
482
used += binary.PutUvarint(buf[used:used+binary.MaxVarintLen64], vector.end)
483
used += binary.PutUvarint(buf[used:used+binary.MaxVarintLen64], uint64(len(vector.arrayPositions)))
484
for _, arrayPosition := range vector.arrayPositions {
485
used += binary.PutUvarint(buf[used:used+binary.MaxVarintLen64], arrayPosition)
491
func (tfr *TermFrequencyRow) String() string {
492
return fmt.Sprintf("Term: `%s` Field: %d DocId: `%s` Frequency: %d Norm: %f Vectors: %v", string(tfr.term), tfr.field, string(tfr.doc), tfr.freq, tfr.norm, tfr.vectors)
495
func InitTermFrequencyRow(tfr *TermFrequencyRow, term []byte, field uint16, docID []byte, freq uint64, norm float32) *TermFrequencyRow {
504
func NewTermFrequencyRow(term []byte, field uint16, docID []byte, freq uint64, norm float32) *TermFrequencyRow {
505
return &TermFrequencyRow{
514
func NewTermFrequencyRowWithTermVectors(term []byte, field uint16, docID []byte, freq uint64, norm float32, vectors []*TermVector) *TermFrequencyRow {
515
return &TermFrequencyRow{
525
func NewTermFrequencyRowK(key []byte) (*TermFrequencyRow, error) {
526
rv := &TermFrequencyRow{}
527
err := rv.parseK(key)
534
func (tfr *TermFrequencyRow) parseK(key []byte) error {
537
return fmt.Errorf("invalid term frequency key, no valid field")
539
tfr.field = binary.LittleEndian.Uint16(key[1:3])
541
termEndPos := bytes.IndexByte(key[3:], ByteSeparator)
543
return fmt.Errorf("invalid term frequency key, no byte separator terminating term")
545
tfr.term = key[3 : 3+termEndPos]
547
docLen := keyLen - (3 + termEndPos + 1)
549
return fmt.Errorf("invalid term frequency key, empty docid")
551
tfr.doc = key[3+termEndPos+1:]
556
func (tfr *TermFrequencyRow) parseKDoc(key []byte, term []byte) error {
557
tfr.doc = key[3+len(term)+1:]
558
if len(tfr.doc) <= 0 {
559
return fmt.Errorf("invalid term frequency key, empty docid")
565
func (tfr *TermFrequencyRow) parseV(value []byte, includeTermVectors bool) error {
567
tfr.freq, bytesRead = binary.Uvarint(value)
569
return fmt.Errorf("invalid term frequency value, invalid frequency")
571
currOffset := bytesRead
574
norm, bytesRead = binary.Uvarint(value[currOffset:])
576
return fmt.Errorf("invalid term frequency value, no norm")
578
currOffset += bytesRead
580
tfr.norm = math.Float32frombits(uint32(norm))
583
if !includeTermVectors {
588
field, bytesRead = binary.Uvarint(value[currOffset:])
590
currOffset += bytesRead
592
tv.field = uint16(field)
593
// at this point we expect at least one term vector
594
if tfr.vectors == nil {
595
tfr.vectors = make([]*TermVector, 0)
598
tv.pos, bytesRead = binary.Uvarint(value[currOffset:])
600
return fmt.Errorf("invalid term frequency value, vector contains no position")
602
currOffset += bytesRead
604
tv.start, bytesRead = binary.Uvarint(value[currOffset:])
606
return fmt.Errorf("invalid term frequency value, vector contains no start")
608
currOffset += bytesRead
610
tv.end, bytesRead = binary.Uvarint(value[currOffset:])
612
return fmt.Errorf("invalid term frequency value, vector contains no end")
614
currOffset += bytesRead
616
var arrayPositionsLen uint64 = 0
617
arrayPositionsLen, bytesRead = binary.Uvarint(value[currOffset:])
619
return fmt.Errorf("invalid term frequency value, vector contains no arrayPositionLen")
621
currOffset += bytesRead
623
if arrayPositionsLen > 0 {
624
tv.arrayPositions = make([]uint64, arrayPositionsLen)
625
for i := 0; uint64(i) < arrayPositionsLen; i++ {
626
tv.arrayPositions[i], bytesRead = binary.Uvarint(value[currOffset:])
628
return fmt.Errorf("invalid term frequency value, vector contains no arrayPosition of index %d", i)
630
currOffset += bytesRead
634
tfr.vectors = append(tfr.vectors, &tv)
635
// try to read next record (may not exist)
636
field, bytesRead = binary.Uvarint(value[currOffset:])
638
if len(value[currOffset:]) > 0 && bytesRead <= 0 {
639
return fmt.Errorf("invalid term frequency value, vector field invalid")
645
func NewTermFrequencyRowKV(key, value []byte) (*TermFrequencyRow, error) {
646
rv, err := NewTermFrequencyRowK(key)
651
err = rv.parseV(value, true)
659
type BackIndexRow struct {
661
termsEntries []*BackIndexTermsEntry
662
storedEntries []*BackIndexStoreEntry
665
func (br *BackIndexRow) AllTermKeys() [][]byte {
669
rv := make([][]byte, 0, len(br.termsEntries)) // FIXME this underestimates severely
670
for _, termsEntry := range br.termsEntries {
671
for i := range termsEntry.Terms {
672
termRow := NewTermFrequencyRow([]byte(termsEntry.Terms[i]), uint16(termsEntry.GetField()), br.doc, 0, 0)
673
rv = append(rv, termRow.Key())
679
func (br *BackIndexRow) AllStoredKeys() [][]byte {
683
rv := make([][]byte, len(br.storedEntries))
684
for i, storedEntry := range br.storedEntries {
685
storedRow := NewStoredRow(br.doc, uint16(storedEntry.GetField()), storedEntry.GetArrayPositions(), 'x', []byte{})
686
rv[i] = storedRow.Key()
691
func (br *BackIndexRow) Key() []byte {
692
buf := make([]byte, br.KeySize())
693
size, _ := br.KeyTo(buf)
697
func (br *BackIndexRow) KeySize() int {
698
return len(br.doc) + 1
701
func (br *BackIndexRow) KeyTo(buf []byte) (int, error) {
703
used := copy(buf[1:], br.doc)
707
func (br *BackIndexRow) Value() []byte {
708
buf := make([]byte, br.ValueSize())
709
size, _ := br.ValueTo(buf)
713
func (br *BackIndexRow) ValueSize() int {
714
birv := &BackIndexRowValue{
715
TermsEntries: br.termsEntries,
716
StoredEntries: br.storedEntries,
721
func (br *BackIndexRow) ValueTo(buf []byte) (int, error) {
722
birv := &BackIndexRowValue{
723
TermsEntries: br.termsEntries,
724
StoredEntries: br.storedEntries,
726
return birv.MarshalTo(buf)
729
func (br *BackIndexRow) String() string {
730
return fmt.Sprintf("Backindex DocId: `%s` Terms Entries: %v, Stored Entries: %v", string(br.doc), br.termsEntries, br.storedEntries)
733
func NewBackIndexRow(docID []byte, entries []*BackIndexTermsEntry, storedFields []*BackIndexStoreEntry) *BackIndexRow {
734
return &BackIndexRow{
736
termsEntries: entries,
737
storedEntries: storedFields,
741
func NewBackIndexRowKV(key, value []byte) (*BackIndexRow, error) {
744
buf := bytes.NewBuffer(key)
745
_, err := buf.ReadByte() // type
750
rv.doc, err = buf.ReadBytes(ByteSeparator)
751
if err == io.EOF && len(rv.doc) < 1 {
752
err = fmt.Errorf("invalid doc length 0 - % x", key)
754
if err != nil && err != io.EOF {
756
} else if err == nil {
757
rv.doc = rv.doc[:len(rv.doc)-1] // trim off separator byte
760
var birv BackIndexRowValue
761
err = proto.Unmarshal(value, &birv)
765
rv.termsEntries = birv.TermsEntries
766
rv.storedEntries = birv.StoredEntries
773
type StoredRow struct {
776
arrayPositions []uint64
781
func (s *StoredRow) Key() []byte {
782
buf := make([]byte, s.KeySize())
783
size, _ := s.KeyTo(buf)
787
func (s *StoredRow) KeySize() int {
788
return 1 + len(s.doc) + 1 + 2 + (binary.MaxVarintLen64 * len(s.arrayPositions))
791
func (s *StoredRow) KeyTo(buf []byte) (int, error) {
795
buf[1+docLen] = ByteSeparator
796
binary.LittleEndian.PutUint16(buf[1+docLen+1:], s.field)
797
bytesUsed := 1 + docLen + 1 + 2
798
for _, arrayPosition := range s.arrayPositions {
799
varbytes := binary.PutUvarint(buf[bytesUsed:], arrayPosition)
800
bytesUsed += varbytes
802
return bytesUsed, nil
805
func (s *StoredRow) Value() []byte {
806
buf := make([]byte, s.ValueSize())
807
size, _ := s.ValueTo(buf)
811
func (s *StoredRow) ValueSize() int {
812
return len(s.value) + 1
815
func (s *StoredRow) ValueTo(buf []byte) (int, error) {
817
used := copy(buf[1:], s.value)
821
func (s *StoredRow) String() string {
822
return fmt.Sprintf("Document: %s Field %d, Array Positions: %v, Type: %s Value: %s", s.doc, s.field, s.arrayPositions, string(s.typ), s.value)
825
func (s *StoredRow) ScanPrefixForDoc() []byte {
827
buf := make([]byte, 1+docLen+1)
830
buf[1+docLen] = ByteSeparator
834
func NewStoredRow(docID []byte, field uint16, arrayPositions []uint64, typ byte, value []byte) *StoredRow {
838
arrayPositions: arrayPositions,
844
func NewStoredRowK(key []byte) (*StoredRow, error) {
847
buf := bytes.NewBuffer(key)
848
_, err := buf.ReadByte() // type
853
rv.doc, err = buf.ReadBytes(ByteSeparator)
854
if len(rv.doc) < 2 { // 1 for min doc id length, 1 for separator
855
err = fmt.Errorf("invalid doc length 0")
859
rv.doc = rv.doc[:len(rv.doc)-1] // trim off separator byte
861
err = binary.Read(buf, binary.LittleEndian, &rv.field)
866
rv.arrayPositions = make([]uint64, 0)
867
nextArrayPos, err := binary.ReadUvarint(buf)
869
rv.arrayPositions = append(rv.arrayPositions, nextArrayPos)
870
nextArrayPos, err = binary.ReadUvarint(buf)
875
func NewStoredRowKV(key, value []byte) (*StoredRow, error) {
876
rv, err := NewStoredRowK(key)
885
type backIndexFieldTermVisitor func(field uint32, term []byte)
887
// visitBackIndexRow is designed to process a protobuf encoded
888
// value, without creating unnecessary garbage. Instead values are passed
889
// to a callback, inspected first, and only copied if necessary.
890
// Due to the fact that this borrows from generated code, it must be marnually
891
// updated if the protobuf definition changes.
893
// This code originates from:
894
// func (m *BackIndexRowValue) Unmarshal(data []byte) error
895
// the sections which create garbage or parse unintersting sections
896
// have been commented out. This was done by design to allow for easier
897
// merging in the future if that original function is regenerated
898
func visitBackIndexRow(data []byte, callback backIndexFieldTermVisitor) error {
903
for shift := uint(0); ; shift += 7 {
905
return io.ErrUnexpectedEOF
909
wire |= (uint64(b) & 0x7F) << shift
914
fieldNum := int32(wire >> 3)
915
wireType := int(wire & 0x7)
919
return fmt.Errorf("proto: wrong wireType = %d for field TermsEntries", wireType)
922
for shift := uint(0); ; shift += 7 {
924
return io.ErrUnexpectedEOF
928
msglen |= (int(b) & 0x7F) << shift
933
postIndex := iNdEx + msglen
935
return ErrInvalidLengthUpsidedown
938
return io.ErrUnexpectedEOF
940
// dont parse term entries
941
// m.TermsEntries = append(m.TermsEntries, &BackIndexTermsEntry{})
942
// if err := m.TermsEntries[len(m.TermsEntries)-1].Unmarshal(data[iNdEx:postIndex]); err != nil {
945
// instead, inspect them
946
if err := visitBackIndexRowFieldTerms(data[iNdEx:postIndex], callback); err != nil {
952
return fmt.Errorf("proto: wrong wireType = %d for field StoredEntries", wireType)
955
for shift := uint(0); ; shift += 7 {
957
return io.ErrUnexpectedEOF
961
msglen |= (int(b) & 0x7F) << shift
966
postIndex := iNdEx + msglen
968
return ErrInvalidLengthUpsidedown
971
return io.ErrUnexpectedEOF
973
// don't parse stored entries
974
// m.StoredEntries = append(m.StoredEntries, &BackIndexStoreEntry{})
975
// if err := m.StoredEntries[len(m.StoredEntries)-1].Unmarshal(data[iNdEx:postIndex]); err != nil {
989
skippy, err := skipUpsidedown(data[iNdEx:])
994
return ErrInvalidLengthUpsidedown
996
if (iNdEx + skippy) > l {
997
return io.ErrUnexpectedEOF
999
// don't track unrecognized data
1000
//m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
1008
// visitBackIndexRowFieldTerms is designed to process a protobuf encoded
1009
// sub-value within the BackIndexRowValue, without creating unnecessary garbage.
1010
// Instead values are passed to a callback, inspected first, and only copied if
1011
// necessary. Due to the fact that this borrows from generated code, it must
1012
// be marnually updated if the protobuf definition changes.
1014
// This code originates from:
1015
// func (m *BackIndexTermsEntry) Unmarshal(data []byte) error {
1016
// the sections which create garbage or parse uninteresting sections
1017
// have been commented out. This was done by design to allow for easier
1018
// merging in the future if that original function is regenerated
1019
func visitBackIndexRowFieldTerms(data []byte, callback backIndexFieldTermVisitor) error {
1022
var hasFields [1]uint64
1027
for shift := uint(0); ; shift += 7 {
1029
return io.ErrUnexpectedEOF
1033
wire |= (uint64(b) & 0x7F) << shift
1038
fieldNum := int32(wire >> 3)
1039
wireType := int(wire & 0x7)
1043
return fmt.Errorf("proto: wrong wireType = %d for field Field", wireType)
1046
for shift := uint(0); ; shift += 7 {
1048
return io.ErrUnexpectedEOF
1052
v |= (uint32(b) & 0x7F) << shift
1059
hasFields[0] |= uint64(0x00000001)
1062
return fmt.Errorf("proto: wrong wireType = %d for field Terms", wireType)
1064
var stringLen uint64
1065
for shift := uint(0); ; shift += 7 {
1067
return io.ErrUnexpectedEOF
1071
stringLen |= (uint64(b) & 0x7F) << shift
1076
postIndex := iNdEx + int(stringLen)
1078
return io.ErrUnexpectedEOF
1080
//m.Terms = append(m.Terms, string(data[iNdEx:postIndex]))
1081
callback(theField, data[iNdEx:postIndex])
1093
skippy, err := skipUpsidedown(data[iNdEx:])
1098
return ErrInvalidLengthUpsidedown
1100
if (iNdEx + skippy) > l {
1101
return io.ErrUnexpectedEOF
1103
//m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
1107
// if hasFields[0]&uint64(0x00000001) == 0 {
1108
// return new(github_com_golang_protobuf_proto.RequiredNotSetError)