Encode encodes the hint entry to bytes
()
| 104 | |
| 105 | // Encode encodes the hint entry to bytes |
| 106 | func (h *HintEntry) Encode() []byte { |
| 107 | keySize := len(h.Key) |
| 108 | h.KeySize = uint32(keySize) |
| 109 | |
| 110 | buf := make([]byte, h.Size()) |
| 111 | index := 0 |
| 112 | |
| 113 | index += binary.PutUvarint(buf[index:], h.BucketId) |
| 114 | index += binary.PutUvarint(buf[index:], uint64(keySize)) |
| 115 | index += binary.PutUvarint(buf[index:], uint64(h.ValueSize)) |
| 116 | index += binary.PutUvarint(buf[index:], h.Timestamp) |
| 117 | index += binary.PutUvarint(buf[index:], uint64(h.TTL)) |
| 118 | index += binary.PutUvarint(buf[index:], uint64(h.Flag)) |
| 119 | index += binary.PutUvarint(buf[index:], uint64(h.Status)) |
| 120 | index += binary.PutUvarint(buf[index:], uint64(h.Ds)) |
| 121 | index += binary.PutUvarint(buf[index:], h.DataPos) |
| 122 | index += binary.PutVarint(buf[index:], h.FileID) |
| 123 | |
| 124 | copy(buf[index:], h.Key) |
| 125 | index += keySize |
| 126 | |
| 127 | return buf[:index] |
| 128 | } |
| 129 | |
| 130 | // Decode decodes the hint entry from bytes |
| 131 | func (h *HintEntry) Decode(buf []byte) error { |