Documentation
¶
Index ¶
- Constants
- Variables
- func BlockCeilIdx(off, blockSize int64) int64
- func BlockIdx(off, blockSize int64) int64
- func BlockOffset(idx, blockSize int64) int64
- func BlocksOffsets(size, blockSize int64) []int64
- func Equal(a, b []BuildMap) bool
- func IsEmptyBlock(block []byte, blockSize int64) (bool, error)
- func Layers(mappings []BuildMap) *map[uuid.UUID]struct{}
- func Serialize(metadata *Metadata, mappings []BuildMap) ([]byte, error)
- func TotalBlocks(size, blockSize int64) int64
- func ValidateMappings(mappings []BuildMap, size, blockSize uint64) error
- func Visualize(mappings []BuildMap, size, blockSize, cols uint64, ...) string
- type BuildMap
- type DiffMetadata
- type DiffMetadataBuilder
- type Header
- type Metadata
Constants ¶
const ( PageSize = 4 << 10 // 4 KiB HugepageSize = 2 << 20 // 2 MiB RootfsBlockSize = 4 << 10 // 4 KiB )
const ( SkippedBlockChar = '░' DirtyBlockChar1 = '▓' DirtyBlockChar2 = '█' )
const NormalizeFixVersion = 3
Variables ¶
var ( EmptyHugePage = make([]byte, HugepageSize) EmptyBlock = make([]byte, RootfsBlockSize) )
Functions ¶
func BlockCeilIdx ¶
BlockCeilIdx returns the index of the first block after byte offset off (ceiling division).
func BlockIdx ¶
BlockIdx returns the index of the block containing byte offset off (floor division).
func BlockOffset ¶
func BlocksOffsets ¶
func TotalBlocks ¶
func ValidateMappings ¶
ValidateMappings validates the mappings. It is used to check if the mappings are valid.
It checks if the mappings are contiguous and if the length of each mapping is a multiple of the block size. It also checks if the mappings cover the whole size.
func Visualize ¶
func Visualize(mappings []BuildMap, size, blockSize, cols uint64, bottomGroup, topGroup *map[uuid.UUID]struct{}) string
Visualize returns a string representation of the mappings as a grid of blocks. It is used for debugging and visualization.
You can pass maps to visualize different groups of buildIds.
Types ¶
type BuildMap ¶
type BuildMap struct {
// Offset defines which block of the current layer this mapping starts at
Offset uint64
Length uint64
BuildId uuid.UUID
BuildStorageOffset uint64
}
Start, Length and SourceStart are in bytes of the data file Length will be a multiple of BlockSize The list of block mappings will be in order of increasing Start, covering the entire file
func CreateMapping ¶
func MergeMappings ¶
MergeMappings merges two sets of mappings.
The mapping are stored in a sorted order. The baseMapping must cover the whole size.
It returns a new set of mappings that covers the whole size.
func NormalizeMappings ¶
NormalizeMappings joins adjacent mappings that have the same buildId.
type DiffMetadata ¶
func NewDiffMetadata ¶
func NewDiffMetadata(blockSize int64, dirty *roaring.Bitmap) *DiffMetadata
func (*DiffMetadata) ToDiffHeader ¶
type DiffMetadataBuilder ¶
type DiffMetadataBuilder struct {
// contains filtered or unexported fields
}
func NewDiffMetadataBuilder ¶
func NewDiffMetadataBuilder(blockSize int64) *DiffMetadataBuilder
func (*DiffMetadataBuilder) Build ¶
func (b *DiffMetadataBuilder) Build() *DiffMetadata
type Header ¶
func DeserializeBytes ¶
func (*Header) GetShiftedMapping ¶
func (*Header) IsNormalizeFixApplied ¶
IsNormalizeFixApplied is a helper method to soft fail for older versions of the header where fix for normalization was not applied. This should be removed in the future.