diff --git a/maX.go b/maX.go index a6cde8c..ee4dd4c 100644 --- a/maX.go +++ b/maX.go @@ -136,13 +136,12 @@ func (mxl *MaXList) RPush(sm *MaX) (Sample, error) { mxl.List = append(mxl.List, sm) return nil, nil } - return nil, nil } // 冒泡排序 func (mxl *MaXList) RecursiveBubbleS(length int, ctype string) error { if length == 0 { - return nil + return errors.New("length is zero") } realLength := len(mxl.List) //FIXME:在对这个List进行排序时,List中途长度变了,就会报错: @@ -166,6 +165,6 @@ func (mxl *MaXList) RecursiveBubbleS(length int, ctype string) error { } } length-- - mxl.RecursiveBubbleS(length, ctype) - return nil + err := mxl.RecursiveBubbleS(length, ctype) + return err } diff --git a/plate.go b/plate.go index db146ad..178274b 100644 --- a/plate.go +++ b/plate.go @@ -113,19 +113,22 @@ func (pl *Plate) MakeCoaster(cr *Core, period string) error { if err != nil { return err } - cdl.RecursiveBubbleS(len(cdl.List), "asc") + err = cdl.RecursiveBubbleS(len(cdl.List), "asc") setName7 := "ma7|" + setName setName30 := "ma30|" + setName mxl7, err := cr.GetRangeMaXSortedSet(setName7, pl.Count, lastTime) if err != nil { return err } - mxl7.RecursiveBubbleS(len(mxl7.List), "asc") + err = mxl7.RecursiveBubbleS(len(mxl7.List), "asc") + if err != nil { + return err + } mxl30, err := cr.GetRangeMaXSortedSet(setName30, pl.Count, lastTime) if err != nil { return err } - mxl30.RecursiveBubbleS(len(mxl30.List), "asc") + err = mxl30.RecursiveBubbleS(len(mxl30.List), "asc") coaster := Coaster{ InstID: pl.InstID, Period: period,