chunkers

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 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

This section is empty.

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 ultracdc's default sizes (min 2 KiB, normal 10 KiB, max 64 KiB). 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