(key string, incomingData []byte, codec codec.Codec, deleted bool, updateTime time.Time)
| 1719 | } |
| 1720 | |
| 1721 | func (m *KV) mergeBytesValueForKey(key string, incomingData []byte, codec codec.Codec, deleted bool, updateTime time.Time) (Mergeable, uint, bool, time.Time, error) { |
| 1722 | // Even if there is no change to the Mergeable, we still may need to update the timestamp and deleted state. |
| 1723 | if len(incomingData) == 0 { |
| 1724 | incomingData = emptySnappyEncodedData |
| 1725 | } |
| 1726 | decodedValue, err := codec.Decode(incomingData) |
| 1727 | if err != nil { |
| 1728 | return nil, 0, false, time.Time{}, fmt.Errorf("failed to decode value: %v", err) |
| 1729 | } |
| 1730 | |
| 1731 | incomingValue, ok := decodedValue.(Mergeable) |
| 1732 | if !ok { |
| 1733 | return nil, 0, false, time.Time{}, fmt.Errorf("expected Mergeable, got: %T", decodedValue) |
| 1734 | } |
| 1735 | |
| 1736 | // No need to clone this "incomingValue", since we have just decoded it from bytes, and won't be using it. |
| 1737 | return m.mergeValueForKey(key, incomingValue, false, 0, codec.CodecID(), deleted, updateTime) |
| 1738 | } |
| 1739 | |
| 1740 | // Merges incoming value with value we have in our store. Returns "a change" that can be sent to other |
| 1741 | // cluster members to update their state, and new version of the value. |
no test coverage detected