Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/couchbase/vellum"
)

const Version uint32 = 14
const Version uint32 = 15

const Type string = "zap"

Expand Down
7 changes: 6 additions & 1 deletion merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,12 @@ func mergeTermFreqNormLocs(fieldsMap map[string]uint16, term []byte, postItr *Po
newRoaring.Add(uint32(hitNewDocNum))

nextFreq := next.Frequency()
nextNorm := uint64(math.Float32bits(float32(next.Norm())))
var nextNorm uint64
if pi, ok := next.(*Posting); ok {
nextNorm = pi.NormUint64()
} else {
return 0, 0, 0, nil, fmt.Errorf("unexpected posting type %T", next)
}

locs := next.Locations()

Expand Down
2 changes: 1 addition & 1 deletion new.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ func (s *interim) processDocument(docNum uint64,
// now that it's been rolled up into fieldTFs, walk that
for fieldID, tfs := range fieldTFs {
dict := s.Dicts[fieldID]
norm := float32(1.0 / math.Sqrt(float64(fieldLens[fieldID])))
norm := math.Float32frombits(uint32(fieldLens[fieldID]))

for term, tf := range tfs {
pid := dict[term] - 1
Expand Down
9 changes: 7 additions & 2 deletions posting.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func under32Bits(x uint64) bool {

const DocNum1HitFinished = math.MaxUint64

var NormBits1Hit = uint64(math.Float32bits(float32(1)))
var NormBits1Hit = uint64(1)

// PostingsList is an in-memory representation of a postings list
type PostingsList struct {
Expand Down Expand Up @@ -748,14 +748,19 @@ func (p *Posting) Frequency() uint64 {

// Norm returns the normalization factor for this posting
func (p *Posting) Norm() float64 {
return float64(p.norm)
return float64(float32(1.0 / math.Sqrt(float64(math.Float32bits(p.norm)))))
}

// Locations returns the location information for each occurrence
func (p *Posting) Locations() []segment.Location {
return p.locs
}

// NormUint64 returns the norm value as uint64
func (p *Posting) NormUint64() uint64 {
return uint64(math.Float32bits(p.norm))
}

// Location represents the location of a single occurrence
type Location struct {
field string
Expand Down