From 1abbfadf0dca26a1dcfc0721fb1bdc57e0538af5 Mon Sep 17 00:00:00 2001 From: Steve Yen Date: Tue, 19 Dec 2017 22:26:17 -0800 Subject: [PATCH] scorch simplify err check after vellum load --- index/scorch/segment/zap/segment.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/index/scorch/segment/zap/segment.go b/index/scorch/segment/zap/segment.go index 62c147a2..e78ac392 100644 --- a/index/scorch/segment/zap/segment.go +++ b/index/scorch/segment/zap/segment.go @@ -159,8 +159,8 @@ func (s *Segment) Dictionary(field string) (segment.TermDictionary, error) { return dict, err } -func (s *Segment) dictionary(field string) (*Dictionary, error) { - rv := &Dictionary{ +func (s *Segment) dictionary(field string) (rv *Dictionary, err error) { + rv = &Dictionary{ segment: s, field: field, } @@ -170,19 +170,15 @@ func (s *Segment) dictionary(field string) (*Dictionary, error) { rv.fieldID = rv.fieldID - 1 dictStart := s.fieldsOffsets[rv.fieldID] - if dictStart > 0 { // read the length of the vellum data vellumLen, read := binary.Uvarint(s.mm[dictStart : dictStart+binary.MaxVarintLen64]) fstBytes := s.mm[dictStart+uint64(read) : dictStart+uint64(read)+vellumLen] if fstBytes != nil { - fst, err := vellum.Load(fstBytes) + rv.fst, err = vellum.Load(fstBytes) if err != nil { return nil, fmt.Errorf("dictionary field %s vellum err: %v", field, err) } - if err == nil { - rv.fst = fst - } } }