bloom

package
v0.1.76 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package bloom provides a bloom filter implementation used for changed-path filters in Git commit graphs.

Index

Constants

View Source
const (
	// DataHeaderSize is the size of the BDAT header in commit-graph files.
	DataHeaderSize = 3 * 4
	// DefaultMaxChange matches Git's default max-changed-paths behavior.
	DefaultMaxChange = 512
)

Variables

View Source
var ErrInvalid = errors.New("bloom: invalid data")

Functions

This section is empty.

Types

type Filter

type Filter struct {
	Data []byte

	HashVersion    uint32
	NumHashes      uint32
	BitsPerEntry   uint32
	MaxChangePaths uint32
}

Filter represents a changed-paths Bloom filter associated with a commit.

The filter encodes which paths changed between a commit and its first parent. Paths are expected to be in Git's slash-separated form and are queried using a path and its prefixes (e.g. "a/b/c", "a/b", "a").

func NewFilter

func NewFilter(data []byte, settings Settings) *Filter

NewFilter constructs one query-ready bloom filter from raw data/settings.

func (*Filter) MightContain

func (f *Filter) MightContain(path []byte) (bool, error)

MightContain reports whether the Bloom filter may contain the given path.

Evaluated against the full path and each of its directory prefixes. A true result indicates a possible match; false means the path definitely did not change.

type Settings

type Settings struct {
	HashVersion    uint32
	NumHashes      uint32
	BitsPerEntry   uint32
	MaxChangePaths uint32
}

Settings describe the changed-paths Bloom filter parameters stored in commit-graph BDAT chunks.

Obviously, they must match the repository's commit-graph settings to interpret filters correctly.

func ParseSettings

func ParseSettings(bdat []byte) (*Settings, error)

ParseSettings reads Bloom filter settings from a BDAT chunk header.

Jump to

Keyboard shortcuts

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