encodeLogRecordKeyWithSeq Key+Seq Number coding
(key []byte, seqNo uint64)
| 153 | |
| 154 | // encodeLogRecordKeyWithSeq Key+Seq Number coding |
| 155 | func encodeLogRecordKeyWithSeq(key []byte, seqNo uint64) []byte { |
| 156 | seq := make([]byte, binary.MaxVarintLen64) |
| 157 | n := binary.PutUvarint(seq[:], seqNo) |
| 158 | |
| 159 | // Create a byte slice to hold the encoded key |
| 160 | encodeKey := make([]byte, n+len(key)) |
| 161 | |
| 162 | // Copy the sequence number bytes to the encodeKey slice |
| 163 | copy(encodeKey[:n], seq[:n]) |
| 164 | |
| 165 | // Copy the original key bytes to the encodeKey slice starting from offset n |
| 166 | copy(encodeKey[n:], key) |
| 167 | |
| 168 | return encodeKey |
| 169 | } |
| 170 | |
| 171 | // Parse the LogRecord key to get the actual key and transaction sequence number seq |
| 172 | func parseLogRecordKeyAndSeq(key []byte) ([]byte, uint64) { |