scanlib

package
v0.8.9 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package scanlib implements a basic reachability scanner for FFS data blobs, files, and root pointers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scanner

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

A Scanner scans all the blobs reachable from a collection of root and file pointers.

func NewScanner

func NewScanner(src blob.CAS) *Scanner

NewScanner creates a new empty Scanner that reads data from src.

func (*Scanner) All

func (s *Scanner) All() iter.Seq2[string, byte]

All returns an iterator over all the key/value pairs in s. The value for each key is 'R' for a root, 'F' for a file, and '-' for a data blob.

func (*Scanner) Blob

func (s *Scanner) Blob(key string)

Blob adds the specified data blob to s.

func (*Scanner) Chunks

func (s *Scanner) Chunks(n int) iter.Seq[[]string]

Chunks returns consecutive chunks of the keys in s each having at most n elements and together spanning the complete set of keys recorded. The keys are returned in lexicographic order.

func (*Scanner) File

func (s *Scanner) File(ctx context.Context, fp *file.File) error

File adds all the files and data blobs reachable from fp to s.

func (*Scanner) IsRoot

func (s *Scanner) IsRoot(key string) bool

IsRoot reports whether key is recorded as a root pointer in s.

func (*Scanner) Len

func (s *Scanner) Len() int

Len reports the total number of keys in s, of all kinds.

func (*Scanner) Remove

func (s *Scanner) Remove(key string)

Remove removes the specified key from s.

func (*Scanner) Root

func (s *Scanner) Root(ctx context.Context, rootKey string, rp *root.Root) error

Root adds the specified root, its index (if any), and all files reachable from its file pointer to s.

func (*Scanner) RootOnly

func (s *Scanner) RootOnly(rootKey string, rp *root.Root)

RootOnly adds the specified root to the scan, including its index (if any), but excluding any blobs reachable from its file pointer.

Use Scanner.Root to completely scan a root.

func (*Scanner) Stats

func (s *Scanner) Stats() Stats

Stats returns aggregate statistics about everything scanned in s.

type Stats

type Stats struct {
	NumRoots int // number of distinct roots
	NumFiles int // number of distinct files
	NumBlobs int // number of distinct data blobs
}

Stats records aggregate statistics about a scan.

Jump to

Keyboard shortcuts

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