carstore

package
v0.0.0-...-efe2ce5 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0, MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const BigShardThreshold = 2 << 20
View Source
const MaxSliceLength = 2 << 20

Variables

View Source
var CacheHits int64
View Source
var CacheMiss int64
View Source
var ErrRepoBaseMismatch = fmt.Errorf("attempted a delta session on top of the wrong previous head")

Functions

func BlockDiff

func BlockDiff(ctx context.Context, bs blockstore.Blockstore, oldroot cid.Cid, newcids map[cid.Cid]blockformat.Block, skipcids map[cid.Cid]bool) (map[cid.Cid]bool, error)

func LdWrite

func LdWrite(w io.Writer, d ...[]byte) (int64, error)

func WriteCarHeader

func WriteCarHeader(w io.Writer, root cid.Cid) (int64, error)

Types

type CarShard

type CarShard struct {
	ID        uint `gorm:"primarykey"`
	CreatedAt time.Time

	Root      models.DbCID `gorm:"index"`
	DataStart int64
	Seq       int `gorm:"index:idx_car_shards_seq;index:idx_car_shards_usr_seq,priority:2,sort:desc"`
	Path      string
	Usr       models.Uid `gorm:"index:idx_car_shards_usr;index:idx_car_shards_usr_seq,priority:1"`
	Rev       string
}

type CarStore

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

func NewCarStore

func NewCarStore(meta *gorm.DB, root string) (*CarStore, error)

func (*CarStore) CompactUserShards

func (cs *CarStore) CompactUserShards(ctx context.Context, user models.Uid, skipBigShards bool) (*CompactionStats, error)

func (*CarStore) GetCompactionTargets

func (cs *CarStore) GetCompactionTargets(ctx context.Context, shardCount int) ([]CompactionTarget, error)

func (*CarStore) GetUserRepoHead

func (cs *CarStore) GetUserRepoHead(ctx context.Context, user models.Uid) (cid.Cid, error)

func (*CarStore) GetUserRepoRev

func (cs *CarStore) GetUserRepoRev(ctx context.Context, user models.Uid) (string, error)

func (*CarStore) ImportSlice

func (cs *CarStore) ImportSlice(ctx context.Context, uid models.Uid, since *string, carslice []byte) (cid.Cid, *DeltaSession, error)

func (*CarStore) NewDeltaSession

func (cs *CarStore) NewDeltaSession(ctx context.Context, user models.Uid, since *string) (*DeltaSession, error)

func (*CarStore) ReadOnlySession

func (cs *CarStore) ReadOnlySession(user models.Uid) (*DeltaSession, error)

func (*CarStore) ReadUserCar

func (cs *CarStore) ReadUserCar(ctx context.Context, user models.Uid, sinceRev string, incremental bool, w io.Writer) error

func (*CarStore) Stat

func (cs *CarStore) Stat(ctx context.Context, usr models.Uid) ([]UserStat, error)

func (*CarStore) WipeUserData

func (cs *CarStore) WipeUserData(ctx context.Context, user models.Uid) error

type CompactionStats

type CompactionStats struct {
	TotalRefs     int `json:"totalRefs"`
	StartShards   int `json:"startShards"`
	NewShards     int `json:"newShards"`
	SkippedShards int `json:"skippedShards"`
	ShardsDeleted int `json:"shardsDeleted"`
	DupeCount     int `json:"dupeCount"`
}

type CompactionTarget

type CompactionTarget struct {
	Usr       models.Uid
	NumShards int
}

type DeltaSession

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

func (*DeltaSession) AllKeysChan

func (ds *DeltaSession) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)

func (*DeltaSession) BaseCid

func (ds *DeltaSession) BaseCid() cid.Cid

func (*DeltaSession) CalcDiff

func (ds *DeltaSession) CalcDiff(ctx context.Context, skipcids map[cid.Cid]bool) error

func (*DeltaSession) CloseWithRoot

func (ds *DeltaSession) CloseWithRoot(ctx context.Context, root cid.Cid, rev string) ([]byte, error)

CloseWithRoot writes all new blocks in a car file to the writer with the given cid as the 'root'

func (*DeltaSession) DeleteBlock

func (ds *DeltaSession) DeleteBlock(ctx context.Context, c cid.Cid) error

func (*DeltaSession) Get

func (ds *DeltaSession) Get(ctx context.Context, c cid.Cid) (blockformat.Block, error)

func (*DeltaSession) GetSize

func (ds *DeltaSession) GetSize(ctx context.Context, c cid.Cid) (int, error)

func (*DeltaSession) Has

func (ds *DeltaSession) Has(ctx context.Context, c cid.Cid) (bool, error)

func (*DeltaSession) HashOnRead

func (ds *DeltaSession) HashOnRead(hor bool)

func (*DeltaSession) Put

func (*DeltaSession) PutMany

func (ds *DeltaSession) PutMany(ctx context.Context, bs []blockformat.Block) error

type UserInfo

type UserInfo struct {
	gorm.Model
	Head string
}

type UserStat

type UserStat struct {
	Seq     int
	Root    string
	Created time.Time
}

Jump to

Keyboard shortcuts

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