fixing err handling in UTs, name changes
This commit is contained in:
parent
4c256f5669
commit
53aef2104e
|
@ -184,10 +184,6 @@ func (s *Segment) VisitDocumentFieldTerms(localDocNum uint64, fields []string,
|
||||||
// persisted doc value terms ready to be visitable using the
|
// persisted doc value terms ready to be visitable using the
|
||||||
// VisitDocumentFieldTerms method.
|
// VisitDocumentFieldTerms method.
|
||||||
func (s *Segment) VisitableDocValueFields() ([]string, error) {
|
func (s *Segment) VisitableDocValueFields() ([]string, error) {
|
||||||
if len(s.fieldsInv) == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var rv []string
|
var rv []string
|
||||||
for fieldID, field := range s.fieldsInv {
|
for fieldID, field := range s.fieldsInv {
|
||||||
if dvIter, ok := s.fieldDvIterMap[uint16(fieldID)]; ok &&
|
if dvIter, ok := s.fieldDvIterMap[uint16(fieldID)]; ok &&
|
||||||
|
@ -195,6 +191,5 @@ func (s *Segment) VisitableDocValueFields() ([]string, error) {
|
||||||
rv = append(rv, field)
|
rv = append(rv, field)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv, nil
|
return rv, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ func TestOpen(t *testing.T) {
|
||||||
defer func() {
|
defer func() {
|
||||||
cerr := segment.Close()
|
cerr := segment.Close()
|
||||||
if cerr != nil {
|
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() {
|
defer func() {
|
||||||
cerr := segment.Close()
|
cerr := segment.Close()
|
||||||
if cerr != nil {
|
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() {
|
defer func() {
|
||||||
cerr := segment.Close()
|
cerr := segment.Close()
|
||||||
if cerr != nil {
|
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)
|
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 {
|
if zaps, ok := seg.(segment.DocumentFieldTermVisitable); ok {
|
||||||
fields, err := zaps.VisitableDocValueFields()
|
fields, err := zaps.VisitableDocValueFields()
|
||||||
if err != nil {
|
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")
|
_ = os.RemoveAll("/tmp/scorch.zap")
|
||||||
|
|
||||||
memSegment, expectedFields := buildMemSegmentWithDefaultFieldMapping()
|
memSegment, expectedFields := buildMemSegmentWithDefaultFieldMapping()
|
||||||
|
@ -561,10 +560,11 @@ func TestSegmentVisitableDocValueFieldsList(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error opening segment: %v", err)
|
t.Fatalf("error opening segment: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
cerr := seg.Close()
|
cerr := seg.Close()
|
||||||
if cerr != nil {
|
if cerr != nil {
|
||||||
t.Fatalf("error closing segment: %v", err)
|
t.Fatalf("error closing segment: %v", cerr)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@ import (
|
||||||
|
|
||||||
// control the default behavior for dynamic fields (those not explicitly mapped)
|
// control the default behavior for dynamic fields (those not explicitly mapped)
|
||||||
var (
|
var (
|
||||||
IndexDynamic = true
|
IndexDynamic = true
|
||||||
StoreDynamic = true
|
StoreDynamic = true
|
||||||
DocValues = true // TODO revisit default?
|
DocValuesDynamic = true // TODO revisit default?
|
||||||
)
|
)
|
||||||
|
|
||||||
// A FieldMapping describes how a specific item
|
// A FieldMapping describes how a specific item
|
||||||
|
@ -77,7 +77,7 @@ func newTextFieldMappingDynamic(im *IndexMappingImpl) *FieldMapping {
|
||||||
rv := NewTextFieldMapping()
|
rv := NewTextFieldMapping()
|
||||||
rv.Store = im.StoreDynamic
|
rv.Store = im.StoreDynamic
|
||||||
rv.Index = im.IndexDynamic
|
rv.Index = im.IndexDynamic
|
||||||
rv.DocValues = im.DocValues
|
rv.DocValues = im.DocValuesDynamic
|
||||||
return rv
|
return rv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ func newNumericFieldMappingDynamic(im *IndexMappingImpl) *FieldMapping {
|
||||||
rv := NewNumericFieldMapping()
|
rv := NewNumericFieldMapping()
|
||||||
rv.Store = im.StoreDynamic
|
rv.Store = im.StoreDynamic
|
||||||
rv.Index = im.IndexDynamic
|
rv.Index = im.IndexDynamic
|
||||||
rv.DocValues = im.DocValues
|
rv.DocValues = im.DocValuesDynamic
|
||||||
return rv
|
return rv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ func newDateTimeFieldMappingDynamic(im *IndexMappingImpl) *FieldMapping {
|
||||||
rv := NewDateTimeFieldMapping()
|
rv := NewDateTimeFieldMapping()
|
||||||
rv.Store = im.StoreDynamic
|
rv.Store = im.StoreDynamic
|
||||||
rv.Index = im.IndexDynamic
|
rv.Index = im.IndexDynamic
|
||||||
rv.DocValues = im.DocValues
|
rv.DocValues = im.DocValuesDynamic
|
||||||
return rv
|
return rv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ func newBooleanFieldMappingDynamic(im *IndexMappingImpl) *FieldMapping {
|
||||||
rv := NewBooleanFieldMapping()
|
rv := NewBooleanFieldMapping()
|
||||||
rv.Store = im.StoreDynamic
|
rv.Store = im.StoreDynamic
|
||||||
rv.Index = im.IndexDynamic
|
rv.Index = im.IndexDynamic
|
||||||
rv.DocValues = im.DocValues
|
rv.DocValues = im.DocValuesDynamic
|
||||||
return rv
|
return rv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ type IndexMappingImpl struct {
|
||||||
DefaultField string `json:"default_field"`
|
DefaultField string `json:"default_field"`
|
||||||
StoreDynamic bool `json:"store_dynamic"`
|
StoreDynamic bool `json:"store_dynamic"`
|
||||||
IndexDynamic bool `json:"index_dynamic"`
|
IndexDynamic bool `json:"index_dynamic"`
|
||||||
DocValues bool `json:"docvalues,omitempty"`
|
DocValuesDynamic bool `json:"docvalues_dynamic,omitempty"`
|
||||||
CustomAnalysis *customAnalysis `json:"analysis,omitempty"`
|
CustomAnalysis *customAnalysis `json:"analysis,omitempty"`
|
||||||
cache *registry.Cache
|
cache *registry.Cache
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ func NewIndexMapping() *IndexMappingImpl {
|
||||||
DefaultField: defaultField,
|
DefaultField: defaultField,
|
||||||
IndexDynamic: IndexDynamic,
|
IndexDynamic: IndexDynamic,
|
||||||
StoreDynamic: StoreDynamic,
|
StoreDynamic: StoreDynamic,
|
||||||
DocValues: DocValues,
|
DocValuesDynamic: DocValuesDynamic,
|
||||||
CustomAnalysis: newCustomAnalysis(),
|
CustomAnalysis: newCustomAnalysis(),
|
||||||
cache: registry.NewCache(),
|
cache: registry.NewCache(),
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ func (im *IndexMappingImpl) UnmarshalJSON(data []byte) error {
|
||||||
im.TypeMapping = make(map[string]*DocumentMapping)
|
im.TypeMapping = make(map[string]*DocumentMapping)
|
||||||
im.StoreDynamic = StoreDynamic
|
im.StoreDynamic = StoreDynamic
|
||||||
im.IndexDynamic = IndexDynamic
|
im.IndexDynamic = IndexDynamic
|
||||||
im.DocValues = DocValues
|
im.DocValuesDynamic = DocValuesDynamic
|
||||||
|
|
||||||
var invalidKeys []string
|
var invalidKeys []string
|
||||||
for k, v := range tmp {
|
for k, v := range tmp {
|
||||||
|
@ -274,8 +274,8 @@ func (im *IndexMappingImpl) UnmarshalJSON(data []byte) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case "docvalues":
|
case "docvalues_dynamic":
|
||||||
err := json.Unmarshal(v, &im.DocValues)
|
err := json.Unmarshal(v, &im.DocValuesDynamic)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue