Merge pull request #681 from steveyen/scorch
scorch simplify err check after vellum load
This commit is contained in:
commit
43e3d4e1dd
@ -159,8 +159,8 @@ func (s *Segment) Dictionary(field string) (segment.TermDictionary, error) {
|
|||||||
return dict, err
|
return dict, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Segment) dictionary(field string) (*Dictionary, error) {
|
func (s *Segment) dictionary(field string) (rv *Dictionary, err error) {
|
||||||
rv := &Dictionary{
|
rv = &Dictionary{
|
||||||
segment: s,
|
segment: s,
|
||||||
field: field,
|
field: field,
|
||||||
}
|
}
|
||||||
@ -170,19 +170,15 @@ func (s *Segment) dictionary(field string) (*Dictionary, error) {
|
|||||||
rv.fieldID = rv.fieldID - 1
|
rv.fieldID = rv.fieldID - 1
|
||||||
|
|
||||||
dictStart := s.fieldsOffsets[rv.fieldID]
|
dictStart := s.fieldsOffsets[rv.fieldID]
|
||||||
|
|
||||||
if dictStart > 0 {
|
if dictStart > 0 {
|
||||||
// read the length of the vellum data
|
// read the length of the vellum data
|
||||||
vellumLen, read := binary.Uvarint(s.mm[dictStart : dictStart+binary.MaxVarintLen64])
|
vellumLen, read := binary.Uvarint(s.mm[dictStart : dictStart+binary.MaxVarintLen64])
|
||||||
fstBytes := s.mm[dictStart+uint64(read) : dictStart+uint64(read)+vellumLen]
|
fstBytes := s.mm[dictStart+uint64(read) : dictStart+uint64(read)+vellumLen]
|
||||||
if fstBytes != nil {
|
if fstBytes != nil {
|
||||||
fst, err := vellum.Load(fstBytes)
|
rv.fst, err = vellum.Load(fstBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("dictionary field %s vellum err: %v", field, err)
|
return nil, fmt.Errorf("dictionary field %s vellum err: %v", field, err)
|
||||||
}
|
}
|
||||||
if err == nil {
|
|
||||||
rv.fst = fst
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user