snap

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultChunkThreshold is the default size threshold (4KB) for chunking containers
	DefaultChunkThreshold = 4096
)

Variables

This section is empty.

Functions

func FromSnap

func FromSnap(w io.Writer, s Snapshot, patches []*ir.Node) (int, error)

FromSnap writes the index and chunks to w resulting from applying patches to the ir.Node represented by s. patches are associated with kpaths representing the path at which the patches will be applied in order. If patches target chunked containers, those containers are reconstructed from chunks, patches are applied, and the result is either kept as a regular node (if small) or re-chunked (if large).

func WriteFromIR

func WriteFromIR(w io.Writer, node *ir.Node) (int, error)

WriteFromIR writes the index and chunks to w representing node and returns the number of bytes written.

Types

type ReaderAtCloser

type ReaderAtCloser interface {
	io.ReaderAt
	io.Closer
}

ReaderAtCloser combines io.ReaderAt and io.Closer

type Snapshot

type Snapshot interface {
	Index() (*ir.Node, error)
	// Load loads a !snap-loc or !snap-range node
	Load(*ir.Node) (*ir.Node, error)
	Close() error
}

func Open

func Open(r io.ReaderAt) (Snapshot, error)

Open reads a snapshot from the reader. The index node is read into memory, and data chunks are loaded lazily via Load().

On-disk format:

[4 bytes: uint32 index length][index node bytes][data chunks...]

The index length is big-endian uint32. After reading the index, the remaining data contains chunks at offsets specified in the index (offsets are relative to the start of the data section, i.e., after the index).

The reader must implement io.ReaderAt for random access to data chunks. This allows efficient lazy loading without reading the entire snapshot into memory. If the reader also implements io.Closer, Close() will be called when the snapshot is closed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL