chunkers

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: GPL-3.0, LGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package chunkers provides the two content-defined chunkers the fstree uses: a byte chunker (ultracdc) for file content, and an item chunker for the index/entry streams (architecture/fstree.md, "Content-defined chunking").

Index

Constants

View Source
const (
	DefaultMinSize    = 32 << 10
	DefaultNormalSize = 512 << 10
	DefaultMaxSize    = 1 << 20
)

The default byte-chunker sizes: min 32 KiB, normal (target) 512 KiB, max 1 MiB. They determine every Blob boundary and so every file key, so two stores dedup against each other only when they chunk with the same sizes.

Variables

This section is empty.

Functions

func SplitBytes

func SplitBytes(r io.Reader, opts *ByteOpts, fn func(chunk []byte) error) error

SplitBytes runs the ultracdc content-defined chunker over r and calls fn once per chunk, in order. Each chunk passed to fn is a fresh copy, so fn may retain it (the underlying chunker reuses its read buffer between calls). A nil opts uses the default sizes (DefaultMinSize, DefaultNormalSize, DefaultMaxSize), and so does every zero field of a non-nil opts. An empty reader yields zero chunks.

Types

type ByteOpts

type ByteOpts = gocdc.ChunkerOpts

ByteOpts configures the ultracdc byte chunker (re-exported so callers need not import the upstream package).

type ItemChunker

type ItemChunker struct {
	MinRun int
	MaxRun int
	// contains filtered or unexported fields
}

ItemChunker decides chunk boundaries between whole items (a child key, a directory entry, or a [sepName, childKey] pair). A boundary ends the current run when the low k bits of BLAKE3(item encoding) are zero (average run 2^k), bounded by MinRun and MaxRun so an item is never split and variance is capped.

func NewItemChunker

func NewItemChunker(bits int) ItemChunker

NewItemChunker returns an item chunker with average run 2^bits and derived bounds MinRun = 2^bits / 4 (at least 2) and MaxRun = 2^bits * 4.

func (ItemChunker) IsBoundary

func (c ItemChunker) IsBoundary(enc []byte, runLen int) bool

IsBoundary reports whether the run should end after the item whose canonical encoding is enc, given the current run length (including this item).

Jump to

Keyboard shortcuts

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