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 1 : func SetSeqNum(repr []byte, seqNum base.SeqNum) { 17 1 : binary.LittleEndian.PutUint64(repr[:countOffset], uint64(seqNum)) 18 1 : } 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 1 : func SetCount(repr []byte, count uint32) { 24 1 : binary.LittleEndian.PutUint32(repr[countOffset:HeaderLen], count) 25 1 : }