Skip to content

Commit

Permalink
Refactor sectionInvertedIndex -> sectionInvertedTextIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavdangeti committed Nov 1, 2023
1 parent 917078e commit 0a295c4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docvalues.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func (s *SegmentBase) VisitDocValues(localDocNum uint64, fields []string,
continue
}
fieldID := fieldIDPlus1 - 1
if dvIter, exists := s.fieldDvReaders[sectionInvertedIndex][fieldID]; exists &&
if dvIter, exists := s.fieldDvReaders[sectionInvertedTextIndex][fieldID]; exists &&
dvIter != nil {
dvs.dvrs[fieldID] = dvIter.cloneInto(dvs.dvrs[fieldID])
}
Expand Down
4 changes: 2 additions & 2 deletions section.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ type resetable interface {
}

const (
sectionInvertedIndex = iota
sectionInvertedTextIndex = iota
sectionVectorIndex
)

var segmentSections = map[uint16]section{
sectionInvertedIndex: &invertedTextIndexSection{},
sectionInvertedTextIndex: &invertedTextIndexSection{},
}
8 changes: 4 additions & 4 deletions section_inverted_text_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func mergeAndPersistInvertedSection(segments []*SegmentBase, dropsIn []*roaring.
}

fieldIDPlus1 := uint16(segment.fieldsMap[fieldName])
if dvIter, exists := segment.fieldDvReaders[sectionInvertedIndex][fieldIDPlus1-1]; exists &&
if dvIter, exists := segment.fieldDvReaders[sectionInvertedTextIndex][fieldIDPlus1-1]; exists &&
dvIter != nil {
fdvReadersAvailable = true
dvIterClone = dvIter.cloneInto(dvIterClone)
Expand Down Expand Up @@ -816,10 +816,10 @@ func (i *invertedIndexOpaque) allocateSpace() {
}

func (i *invertedTextIndexSection) getInvertedIndexOpaque(opaque map[int]resetable) *invertedIndexOpaque {
if _, ok := opaque[sectionInvertedIndex]; !ok {
opaque[sectionInvertedIndex] = i.InitOpaque(nil)
if _, ok := opaque[sectionInvertedTextIndex]; !ok {
opaque[sectionInvertedTextIndex] = i.InitOpaque(nil)
}
return opaque[sectionInvertedIndex].(*invertedIndexOpaque)
return opaque[sectionInvertedTextIndex].(*invertedIndexOpaque)
}

func (i *invertedIndexOpaque) getOrDefineField(fieldName string) int {
Expand Down
10 changes: 5 additions & 5 deletions segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func (s *SegmentBase) loadFieldNew(fieldID uint16, addr uint64,
fieldSectionAddr := binary.BigEndian.Uint64(s.mem[pos : pos+8])
pos += 8
fieldSectionMap[fieldSectionType] = fieldSectionAddr
if fieldSectionType == sectionInvertedIndex {
if fieldSectionType == sectionInvertedTextIndex {
// for the fields which don't have the inverted index, the offset is
// 0 and during query time, because there is no valid dictionary we
// will just have follow a no-op path.
Expand Down Expand Up @@ -765,12 +765,12 @@ func (s *Segment) loadDvReadersLegacy() error {
if fieldDvReader != nil {
// older file formats have docValues corresponding only to inverted index
// ignore the rest.
if s.fieldDvReaders[sectionInvertedIndex] == nil {
s.fieldDvReaders[sectionInvertedIndex] = make(map[uint16]*docValueReader)
if s.fieldDvReaders[sectionInvertedTextIndex] == nil {
s.fieldDvReaders[sectionInvertedTextIndex] = make(map[uint16]*docValueReader)
}
// fix the structure of fieldDvReaders
// currently it populates the inverted index doc values
s.fieldDvReaders[sectionInvertedIndex][uint16(fieldID)] = fieldDvReader
s.fieldDvReaders[sectionInvertedTextIndex][uint16(fieldID)] = fieldDvReader
s.fieldDvNames = append(s.fieldDvNames, s.fieldsInv[fieldID])
}
}
Expand Down Expand Up @@ -832,7 +832,7 @@ func (s *SegmentBase) loadDvReaders() error {
return fmt.Errorf("loadDvReaders: failed to read the dataLoc "+
"offset for sectionID %v field %v", secID, s.fieldsInv[fieldID])
}
if secID == sectionInvertedIndex {
if secID == sectionInvertedTextIndex {
s.dictLocs = append(s.dictLocs, dataLoc)
}
fieldDvReader, err := s.loadFieldDocValueReader(s.fieldsInv[fieldID], fieldLocStart, fieldLocEnd)
Expand Down

0 comments on commit 0a295c4

Please sign in to comment.