refactoring to typed Size
Go is amazing with refactoring!
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
type NeedleValue struct {
|
||||
Key NeedleId
|
||||
Offset Offset `comment:"Volume offset"` //since aligned to 8 bytes, range is 4G*8=32G
|
||||
Size uint32 `comment:"Size of the data portion"`
|
||||
Size Size `comment:"Size of the data portion"`
|
||||
}
|
||||
|
||||
func (this NeedleValue) Less(than btree.Item) bool {
|
||||
@@ -21,10 +21,10 @@ func (nv NeedleValue) ToBytes() []byte {
|
||||
return ToBytes(nv.Key, nv.Offset, nv.Size)
|
||||
}
|
||||
|
||||
func ToBytes(key NeedleId, offset Offset, size uint32) []byte {
|
||||
func ToBytes(key NeedleId, offset Offset, size Size) []byte {
|
||||
bytes := make([]byte, NeedleIdSize+OffsetSize+SizeSize)
|
||||
NeedleIdToBytes(bytes[0:NeedleIdSize], key)
|
||||
OffsetToBytes(bytes[NeedleIdSize:NeedleIdSize+OffsetSize], offset)
|
||||
util.Uint32toBytes(bytes[NeedleIdSize+OffsetSize:NeedleIdSize+OffsetSize+SizeSize], size)
|
||||
util.Uint32toBytes(bytes[NeedleIdSize+OffsetSize:NeedleIdSize+OffsetSize+SizeSize], uint32(size))
|
||||
return bytes
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user