0
0
Fork 0

fixing err handling in UTs, name changes

This commit is contained in:
Sreekanth Sivasankaran 2018-01-10 22:00:26 +05:30
parent 4c256f5669
commit 53aef2104e
4 changed files with 21 additions and 26 deletions

View File

@ -184,10 +184,6 @@ func (s *Segment) VisitDocumentFieldTerms(localDocNum uint64, fields []string,
// persisted doc value terms ready to be visitable using the
// VisitDocumentFieldTerms method.
func (s *Segment) VisitableDocValueFields() ([]string, error) {
if len(s.fieldsInv) == 0 {
return nil, nil
}
var rv []string
for fieldID, field := range s.fieldsInv {
if dvIter, ok := s.fieldDvIterMap[uint16(fieldID)]; ok &&
@ -195,6 +191,5 @@ func (s *Segment) VisitableDocValueFields() ([]string, error) {
rv = append(rv, field)
}
}
return rv, nil
}

View File

@ -40,7 +40,7 @@ func TestOpen(t *testing.T) {
defer func() {
cerr := segment.Close()
if cerr != nil {
t.Fatalf("error closing segment: %v", err)
t.Fatalf("error closing segment: %v", cerr)
}
}()
@ -340,7 +340,7 @@ func TestOpenMulti(t *testing.T) {
defer func() {
cerr := segment.Close()
if cerr != nil {
t.Fatalf("error closing segment: %v", err)
t.Fatalf("error closing segment: %v", cerr)
}
}()
@ -440,7 +440,7 @@ func TestOpenMultiWithTwoChunks(t *testing.T) {
defer func() {
cerr := segment.Close()
if cerr != nil {
t.Fatalf("error closing segment: %v", err)
t.Fatalf("error closing segment: %v", cerr)
}
}()
@ -533,11 +533,6 @@ func TestSegmentVisitableDocValueFieldsList(t *testing.T) {
t.Fatalf("error opening segment: %v", err)
}
cerr := seg.Close()
if cerr != nil {
t.Fatalf("error closing segment: %v", err)
}
if zaps, ok := seg.(segment.DocumentFieldTermVisitable); ok {
fields, err := zaps.VisitableDocValueFields()
if err != nil {
@ -549,6 +544,10 @@ func TestSegmentVisitableDocValueFieldsList(t *testing.T) {
}
}
err = seg.Close()
if err != nil {
t.Fatalf("error closing segment: %v", err)
}
_ = os.RemoveAll("/tmp/scorch.zap")
memSegment, expectedFields := buildMemSegmentWithDefaultFieldMapping()
@ -561,10 +560,11 @@ func TestSegmentVisitableDocValueFieldsList(t *testing.T) {
if err != nil {
t.Fatalf("error opening segment: %v", err)
}
defer func() {
cerr := seg.Close()
if cerr != nil {
t.Fatalf("error closing segment: %v", err)
t.Fatalf("error closing segment: %v", cerr)
}
}()

View File

@ -26,9 +26,9 @@ import (
// control the default behavior for dynamic fields (those not explicitly mapped)
var (
IndexDynamic = true
StoreDynamic = true
DocValues = true // TODO revisit default?
IndexDynamic = true
StoreDynamic = true
DocValuesDynamic = true // TODO revisit default?
)
// A FieldMapping describes how a specific item
@ -77,7 +77,7 @@ func newTextFieldMappingDynamic(im *IndexMappingImpl) *FieldMapping {
rv := NewTextFieldMapping()
rv.Store = im.StoreDynamic
rv.Index = im.IndexDynamic
rv.DocValues = im.DocValues
rv.DocValues = im.DocValuesDynamic
return rv
}
@ -96,7 +96,7 @@ func newNumericFieldMappingDynamic(im *IndexMappingImpl) *FieldMapping {
rv := NewNumericFieldMapping()
rv.Store = im.StoreDynamic
rv.Index = im.IndexDynamic
rv.DocValues = im.DocValues
rv.DocValues = im.DocValuesDynamic
return rv
}
@ -115,7 +115,7 @@ func newDateTimeFieldMappingDynamic(im *IndexMappingImpl) *FieldMapping {
rv := NewDateTimeFieldMapping()
rv.Store = im.StoreDynamic
rv.Index = im.IndexDynamic
rv.DocValues = im.DocValues
rv.DocValues = im.DocValuesDynamic
return rv
}
@ -134,7 +134,7 @@ func newBooleanFieldMappingDynamic(im *IndexMappingImpl) *FieldMapping {
rv := NewBooleanFieldMapping()
rv.Store = im.StoreDynamic
rv.Index = im.IndexDynamic
rv.DocValues = im.DocValues
rv.DocValues = im.DocValuesDynamic
return rv
}

View File

@ -50,7 +50,7 @@ type IndexMappingImpl struct {
DefaultField string `json:"default_field"`
StoreDynamic bool `json:"store_dynamic"`
IndexDynamic bool `json:"index_dynamic"`
DocValues bool `json:"docvalues,omitempty"`
DocValuesDynamic bool `json:"docvalues_dynamic,omitempty"`
CustomAnalysis *customAnalysis `json:"analysis,omitempty"`
cache *registry.Cache
}
@ -155,7 +155,7 @@ func NewIndexMapping() *IndexMappingImpl {
DefaultField: defaultField,
IndexDynamic: IndexDynamic,
StoreDynamic: StoreDynamic,
DocValues: DocValues,
DocValuesDynamic: DocValuesDynamic,
CustomAnalysis: newCustomAnalysis(),
cache: registry.NewCache(),
}
@ -219,7 +219,7 @@ func (im *IndexMappingImpl) UnmarshalJSON(data []byte) error {
im.TypeMapping = make(map[string]*DocumentMapping)
im.StoreDynamic = StoreDynamic
im.IndexDynamic = IndexDynamic
im.DocValues = DocValues
im.DocValuesDynamic = DocValuesDynamic
var invalidKeys []string
for k, v := range tmp {
@ -274,8 +274,8 @@ func (im *IndexMappingImpl) UnmarshalJSON(data []byte) error {
if err != nil {
return err
}
case "docvalues":
err := json.Unmarshal(v, &im.DocValues)
case "docvalues_dynamic":
err := json.Unmarshal(v, &im.DocValuesDynamic)
if err != nil {
return err
}