index

package
v0.0.0-...-8be083b Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IndexFull = func(idx *Index) bool {
	idx.m.RLock()
	defer idx.m.RUnlock()

	log.Debugf("checking whether index %p is full", idx)

	var blobs uint
	for typ := range idx.byType {
		blobs += idx.byType[typ].len()
	}
	age := time.Since(idx.created)

	switch {
	case age >= indexMaxAge:
		log.Debugf("index %p is old enough", idx, age)
		return true
	case blobs >= indexMaxBlobs:
		log.Debugf("index %p has %d blobs", idx, blobs)
		return true
	}

	log.Debugf("index %p only has %d blobs and is too young (%v)", idx, blobs, age)
	return false

}

IndexFull returns true iff the index is "full enough" to be saved as a preliminary index.

Functions

This section is empty.

Types

type Index

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

func NewIndex

func NewIndex() *Index

func (*Index) Encode

func (idx *Index) Encode(w io.Writer) error

Encode writes the JSON serialization of the index to the writer w.

func (*Index) Final

func (idx *Index) Final() bool

Final returns true iff the index is already written to the repository, it is finalized.

func (*Index) Finalize

func (idx *Index) Finalize()

func (*Index) Has

func (idx *Index) Has(bh rest.BlobHandle) bool

Has returns true iff the id is listed in the index.

func (*Index) IDs

func (idx *Index) IDs() (rest.IDs, error)

IDs returns the IDs of the index, if available. If the index is not yet finalized, an error is returned.

func (*Index) Lookup

func (idx *Index) Lookup(bh rest.BlobHandle, pbs []rest.PackedBlob) []rest.PackedBlob

Lookup queries the index for the blob ID and returns all entries including duplicates. Adds found entries to blobs and returns the result.

func (*Index) LookupSize

func (idx *Index) LookupSize(bh rest.BlobHandle) (plaintextLength uint, found bool)

LookupSize returns the length of the plaintext content of the blob with the given id.

func (*Index) SaveIndex

func (idx *Index) SaveIndex(ctx context.Context, repo rest.SaverUnpacked) (rest.ID, error)

SaveIndex saves an index in the repository.

func (*Index) SetID

func (idx *Index) SetID(id rest.ID) error

SetID sets the ID the index has been written to. This requires that Finalize() has been called before, otherwise an error is returned.

func (*Index) StorePack

func (idx *Index) StorePack(id rest.ID, blobs []rest.Blob)

StorePack remembers the ids of all blobs of a given pack in the index

type MasterIndex

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

func NewMasterIndex

func NewMasterIndex() *MasterIndex

func (*MasterIndex) AddPending

func (mi *MasterIndex) AddPending(bh rest.BlobHandle) bool

AddPending adds a given blob to list of pending Blobs Before doing so it checks if this blob is already known. Returns true if adding was successful and false if the blob was already known

func (*MasterIndex) Lookup

func (mi *MasterIndex) Lookup(bh rest.BlobHandle) (pbs []rest.PackedBlob)

Lookup queries all known Indexes for the ID and returns all matches.

func (*MasterIndex) LookupSize

func (mi *MasterIndex) LookupSize(bh rest.BlobHandle) (uint, bool)

LookupSize queries all known Indexes for the ID and returns the first match.

func (*MasterIndex) MergeFinalIndexes

func (mi *MasterIndex) MergeFinalIndexes() error

MergeFinalIndexes merges all final indexes together. After calling, there will be only one big final index in MasterIndex containing all final index contents. Indexes that are not final are left untouched. This merging can only be called after all index files are loaded - as removing of superseded index contents is only possible for unmerged indexes.

func (*MasterIndex) SaveFullIndex

func (mi *MasterIndex) SaveFullIndex(ctx context.Context, r rest.SaverUnpacked) error

SaveFullIndex saves all full indexes in the backend.

func (*MasterIndex) SaveIndex

func (mi *MasterIndex) SaveIndex(ctx context.Context, r rest.SaverUnpacked) error

SaveIndex saves all new indexes in the backend.

func (*MasterIndex) StorePack

func (mi *MasterIndex) StorePack(id rest.ID, blobs []rest.Blob)

StorePack remembers the id and pack in the index.

Jump to

Keyboard shortcuts

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