Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling for empty vellum data #150

Merged
merged 2 commits into from
May 4, 2023
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: 0 additions & 2 deletions posting.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ type PostingsList struct {

chunkSize uint64

// atomic access to this variable
bytesRead uint64
}

Expand Down Expand Up @@ -349,7 +348,6 @@ type PostingsIterator struct {
includeFreqNorm bool
includeLocs bool

// atomic access to this variable
bytesRead uint64
}

Expand Down
6 changes: 5 additions & 1 deletion segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type SegmentBase struct {
fieldDvNames []string // field names cached in fieldDvReaders
size uint64

// atomic access to this variable
// atomic access to these variables
bytesRead uint64
bytesWritten uint64

Expand Down Expand Up @@ -319,6 +319,10 @@ func (sb *SegmentBase) dictionary(field string) (rv *Dictionary, err error) {
if rv.fst, ok = sb.fieldFSTs[rv.fieldID]; !ok {
// read the length of the vellum data
vellumLen, read := binary.Uvarint(sb.mem[dictStart : dictStart+binary.MaxVarintLen64])
if vellumLen == 0 {
sb.m.Unlock()
return nil, fmt.Errorf("empty dictionary for field: %v", field)
}
fstBytes := sb.mem[dictStart+uint64(read) : dictStart+uint64(read)+vellumLen]
rv.incrementBytesRead(uint64(read) + vellumLen)
rv.fst, err = vellum.Load(fstBytes)
Expand Down