Line data Source code
1 : // Copyright 2024 The LevelDB-Go and Pebble Authors. All rights reserved. Use 2 : // of this source code is governed by a BSD-style license that can be found in 3 : // the LICENSE file. 4 : 5 : package batchrepr 6 : 7 : import ( 8 : "encoding/binary" 9 : 10 : "github.com/cockroachdb/pebble/internal/base" 11 : ) 12 : 13 : // SetSeqNum mutates the provided batch representation, storing the provided 14 : // sequence number in its header. The provided byte slice must already be at 15 : // least HeaderLen bytes long or else SetSeqNum will panic. 16 2 : func SetSeqNum(repr []byte, seqNum base.SeqNum) { 17 2 : binary.LittleEndian.PutUint64(repr[:countOffset], uint64(seqNum)) 18 2 : } 19 : 20 : // SetCount mutates the provided batch representation, storing the provided 21 : // count in its header. The provided byte slice must already be at least 22 : // HeaderLen bytes long or else SetCount will panic. 23 2 : func SetCount(repr []byte, count uint32) { 24 2 : binary.LittleEndian.PutUint32(repr[countOffset:HeaderLen], count) 25 2 : }