func (ms *master) convertMigPkg(pkg []byte, head *proto.PkgHead) ([]byte, error) { _, err := head.Decode(pkg) if err != nil { return nil, err } if !ms.migration { return pkg, nil } switch head.Cmd { case proto.CmdIncr: fallthrough case proto.CmdDel: fallthrough case proto.CmdSet: var p proto.PkgOneOp _, err = p.Decode(pkg) if err != nil { return nil, err } if ms.slotId == ctrl.GetSlotId(p.DbId, p.TableId, p.RowKey) { return pkg, nil } else { return nil, nil } case proto.CmdSync: fallthrough case proto.CmdMIncr: fallthrough case proto.CmdMDel: fallthrough case proto.CmdMSet: var p proto.PkgMultiOp _, err = p.Decode(pkg) if err != nil { return nil, err } var kvs []proto.KeyValue for i := 0; i < len(p.Kvs); i++ { if ms.slotId == ctrl.GetSlotId(p.DbId, p.Kvs[i].TableId, p.Kvs[i].RowKey) { kvs = append(kvs, p.Kvs[i]) } } if len(kvs) == 0 { return nil, nil } else { p.Kvs = kvs pkg = make([]byte, p.Length()) _, err = p.Encode(pkg) if err != nil { return nil, err } return pkg, nil } } return nil, nil }