Fixed fields being shuffled after AOFSHRINK

This commit is contained in:
tidwall 2020-11-09 14:45:40 -07:00
parent dd53091be1
commit 9ce20331e4
1 changed files with 9 additions and 5 deletions

View File

@ -94,6 +94,7 @@ func (server *Server) aofshrink() {
return return
} }
var fnames = col.FieldArr() // reload an array of field names to match each object var fnames = col.FieldArr() // reload an array of field names to match each object
var fmap = col.FieldMap() //
var exm *rhh.Map // the expiration map var exm *rhh.Map // the expiration map
if value, ok := server.expires.Get(keys[0]); ok { if value, ok := server.expires.Get(keys[0]); ok {
exm = value.(*rhh.Map) exm = value.(*rhh.Map)
@ -114,11 +115,14 @@ func (server *Server) aofshrink() {
values = append(values, "set") values = append(values, "set")
values = append(values, keys[0]) values = append(values, keys[0])
values = append(values, id) values = append(values, id)
for i, fvalue := range fields { if len(fields) > 0 {
if fvalue != 0 { fvs := orderFields(fmap, fnames, fields)
values = append(values, "field") for _, fv := range fvs {
values = append(values, fnames[i]) if fv.value != 0 {
values = append(values, strconv.FormatFloat(fvalue, 'f', -1, 64)) values = append(values, "field")
values = append(values, fv.field)
values = append(values, strconv.FormatFloat(fv.value, 'f', -1, 64))
}
} }
} }
if exm != nil { if exm != nil {