backend

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHashALGO        = "BLAKE3"
	DefaultCompressionALGO = "zstd"
)
View Source
const (
	BLANK_BLOB = "af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262"
)
View Source
const (
	DefaultPackThreshold = 50 * 1024 * 1024 // 50M
)
View Source
const (
	// ZstandardMagic: https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#frames
	ZstandardMagic = 0xFD2FB528
)

Variables

View Source
var (
	BLANK_BLOB_HASH = plumbing.NewHash(BLANK_BLOB)
)
View Source
var (
	ErrCanceled = context.Canceled
)
View Source
var (
	ErrUncacheableObject = errors.New("uncacheable object")
)

Functions

func IsErrMismatchedObjectType

func IsErrMismatchedObjectType(err error) bool

func Join

func Join(root string, oid plumbing.Hash) string

func NewErrMismatchedObjectType

func NewErrMismatchedObjectType(oid plumbing.Hash, t string) error

func PackObjects

func PackObjects(ctx context.Context, opts *PackOptions) error

Types

type CompressMethod

type CompressMethod uint16
const (
	STORE   CompressMethod = 0
	ZSTD    CompressMethod = 1
	BROTLI  CompressMethod = 2
	DEFLATE CompressMethod = 3
	XZ      CompressMethod = 4
	BZ2     CompressMethod = 5
)

type Database

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

func NewDatabase

func NewDatabase(root string, opts ...Option) (*Database, error)

func (*Database) Blob

func (d *Database) Blob(_ context.Context, oid plumbing.Hash) (blob *object.Blob, err error)

func (*Database) Close

func (d *Database) Close() error

Close closes the *Database

If Close() has already been called, this function will return an error.

func (*Database) Commit

func (d *Database) Commit(ctx context.Context, oid plumbing.Hash) (*object.Commit, error)

func (*Database) CompressionALGO

func (d *Database) CompressionALGO() string

func (*Database) Exists

func (d *Database) Exists(oid plumbing.Hash, metadata bool) error

func (*Database) Fragments

func (d *Database) Fragments(ctx context.Context, oid plumbing.Hash) (*object.Fragments, error)

func (*Database) HashTo

func (d *Database) HashTo(ctx context.Context, r io.Reader, size int64) (oid plumbing.Hash, err error)

HashTo:

size == -1: unknown file size, need to detect file size.
size == 0: empty file, returns the specified BLOB.
size > 0: the file size is known.

func (*Database) JoinPart

func (d *Database) JoinPart(oid plumbing.Hash) string

func (*Database) NewFD

func (d *Database) NewFD(oid plumbing.Hash) (*os.File, error)

NewFD: new file fd

func (*Database) NewTruncateFD

func (d *Database) NewTruncateFD(oid plumbing.Hash) (*os.File, error)

func (*Database) NewUnpacker

func (d *Database) NewUnpacker(entries uint32, metadata bool) (*Unpacker, error)

func (*Database) NewUnpackerEx

func (d *Database) NewUnpackerEx(entries uint32, metadata bool, method CompressMethod) (*Unpacker, error)

func (*Database) Object

func (d *Database) Object(_ context.Context, oid plumbing.Hash) (any, error)

Object: find object and set backend decode and set backend

func (*Database) OpenReader

func (d *Database) OpenReader(oid plumbing.Hash, meta bool) (io.ReadCloser, error)

func (*Database) ParseRevEx

func (d *Database) ParseRevEx(ctx context.Context, oid plumbing.Hash) (*object.Commit, []plumbing.Hash, error)

func (*Database) PruneObject

func (d *Database) PruneObject(ctx context.Context, oid plumbing.Hash, metadata bool) error

func (*Database) PruneObjects

func (d *Database) PruneObjects(ctx context.Context, largeSize int64) ([]plumbing.Hash, int64, error)

func (*Database) Reload

func (d *Database) Reload() error

func (*Database) Root

func (d *Database) Root() string

func (*Database) Search

func (d *Database) Search(prefix string) (oid plumbing.Hash, err error)

func (*Database) Size

func (d *Database) Size(oid plumbing.Hash, meta bool) (size int64, err error)

func (*Database) SizeReader

func (d *Database) SizeReader(oid plumbing.Hash, meta bool) (SizeReader, error)

func (*Database) Tag

func (d *Database) Tag(ctx context.Context, oid plumbing.Hash) (*object.Tag, error)

func (*Database) Tree

func (d *Database) Tree(ctx context.Context, oid plumbing.Hash) (*object.Tree, error)

func (*Database) ValidateFD

func (d *Database) ValidateFD(fd *os.File, oid plumbing.Hash) error

func (*Database) ValidatePart

func (d *Database) ValidatePart(saveTo string, oid plumbing.Hash) error

func (*Database) WriteEncoded

func (d *Database) WriteEncoded(e object.Encoder) (oid plumbing.Hash, err error)

func (*Database) WriteTo

func (d *Database) WriteTo(ctx context.Context, oid plumbing.Hash, r io.Reader) error

type ErrMismatchedObjectType

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

func (*ErrMismatchedObjectType) Error

func (e *ErrMismatchedObjectType) Error() string

type ExtendWriter

type ExtendWriter interface {
	io.ReaderFrom
	io.Writer
}

type Indicators

type Indicators interface {
	Add(n int)
	Wait()
	Run(ctx context.Context)
}

type LooseObject

type LooseObject struct {
	Hash         plumbing.Hash
	Size         int64
	Modification int64
}

type LooseObjects

type LooseObjects []*LooseObject

type NewIndicators

type NewIndicators func(description, completed string, total uint64, quiet bool) Indicators

type Option

type Option func(*Database)

func WithAbstractBackend

func WithAbstractBackend(backend object.Backend) Option

func WithCompressionALGO

func WithCompressionALGO(compressionALGO string) Option

func WithEnableLRU

func WithEnableLRU(enableLRU bool) Option

func WithSharingRoot

func WithSharingRoot(sharingRoot string) Option

type PackOptions

type PackOptions struct {
	ZetaDir         string
	SharingRoot     string
	Quiet           bool
	CompressionALGO string
	PackThreshold   int64
	Logger          func(format string, a ...any)
	NewIndicators   NewIndicators
}

func (*PackOptions) Printf

func (opts *PackOptions) Printf(format string, a ...any)

type SizeReader

type SizeReader interface {
	io.Reader
	io.Closer
	Size() int64
}

type Unpacker

type Unpacker struct {
	*pack.Writer
	// contains filtered or unexported fields
}

func (*Unpacker) Close

func (u *Unpacker) Close() error

func (*Unpacker) HashTo

func (u *Unpacker) HashTo(r io.Reader, size int64, modification int64) (oid plumbing.Hash, err error)

func (*Unpacker) Preserve

func (u *Unpacker) Preserve() error

func (*Unpacker) WriteEncoded

func (u *Unpacker) WriteEncoded(e object.Encoder, squeeze bool, modification int64) (plumbing.Hash, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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