content

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package content reconstructs full artifact content from Fossil's delta-chain storage.

Fossil stores blobs either as full content or as deltas against a source blob. Expand walks the delta chain from a given RID back to the root, decompresses each link, and applies deltas in sequence to produce the original content. Cycle detection prevents infinite loops.

Verify expands a blob and compares its hash (SHA1 or SHA3-256) against the stored UUID. IsPhantom checks whether a blob is a placeholder awaiting delivery during sync.

Index

Constants

View Source
const (
	// ClusterThreshold is the minimum number of unclustered, non-phantom blobs
	// before cluster generation triggers.
	ClusterThreshold = 100

	// ClusterMaxSize is the maximum number of M-cards per cluster artifact.
	ClusterMaxSize = 800
)

Variables

This section is empty.

Functions

func Expand

func Expand(q db.Querier, rid libfossil.FslID) (result []byte, err error)

func GenerateClusters

func GenerateClusters(q db.Querier) (int, error)

GenerateClusters creates cluster artifacts for unclustered blobs that are not phantoms, shunned, or private. Returns the number of clusters created.

func IsPhantom

func IsPhantom(q db.Querier, rid libfossil.FslID) (bool, error)

func IsPrivate

func IsPrivate(q db.Querier, rid int64) bool

IsPrivate returns true if the blob with the given rid is in the private table.

func MakePrivate

func MakePrivate(q db.Querier, rid int64) error

MakePrivate inserts the rid into the private table (no-op if already present).

func MakePublic

func MakePublic(q db.Querier, rid int64) error

MakePublic removes the rid from the private table (no-op if not present).

func Verify

func Verify(q db.Querier, rid libfossil.FslID) error

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is a concurrency-safe LRU cache for expanded blob content. It reduces redundant delta-chain walks by caching the fully-expanded result of Expand, keyed by rid.

A nil *Cache is valid and acts as a passthrough to Expand.

func NewCache

func NewCache(maxBytes int64) *Cache

NewCache creates a cache bounded by maxBytes of expanded content.

func (*Cache) Clear

func (c *Cache) Clear()

Clear removes all entries from the cache.

func (*Cache) Expand

func (c *Cache) Expand(q db.Querier, rid libfossil.FslID) ([]byte, error)

Expand returns the expanded content for rid, serving from cache when possible. On a cache miss, it delegates to the package-level Expand and caches the result. A nil receiver falls through to Expand directly.

func (*Cache) Invalidate

func (c *Cache) Invalidate(rid libfossil.FslID)

Invalidate removes a single rid from the cache.

func (*Cache) Stats

func (c *Cache) Stats() CacheStats

Stats returns a snapshot of cache statistics.

type CacheStats

type CacheStats struct {
	Hits    int64
	Misses  int64
	Size    int64
	MaxSize int64
	Entries int
}

CacheStats reports cache hit/miss statistics and current memory usage.

Jump to

Keyboard shortcuts

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