common

package
v0.0.0-...-c07845e Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2015 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const AddrSize = 20
View Source
const BlockSize = 1 << 18

BlockSize is the exact size of one block in the CAS, in bytes.

Why 2**18? Because the most common SSD erase block sizes are 128KiB and 256KiB, and we want to avoid the fragmentation that results at granularities smaller than an erase block.

View Source
const BlockSizeHuman = "256KiB"

BlockSizeHuman is an expression of BlockSize in human units.

View Source
const URL = "https://github.com/cloud9-tools/go-cas"
View Source
const Version = "(unreleased)"

Variables

View Source
var ErrBadDialSpec = errors.New("bad dial spec; must start with 'tcp:' or 'unix:'")
View Source
var ErrBlockTooLong = errors.New("go-cas: block is too long")

Functions

func ParseDialSpec

func ParseDialSpec(in string) (network string, address string, err error)

func ShowVersion

func ShowVersion()

func Verify

func Verify(expected, actual Addr) error

Verify confirms that expected == actual, or else returns an error.

Types

type Addr

type Addr [AddrSize]byte

Addr is the "address" (hash) of a CAS block.

func (*Addr) Clear

func (addr *Addr) Clear()

Clear sets this Addr to the zero Addr.

func (Addr) Cmp

func (a Addr) Cmp(b Addr) internal.Comparison

Cmp lexically compares a to b.

func (Addr) GoString

func (addr Addr) GoString() string

func (Addr) IsZero

func (addr Addr) IsZero() bool

IsZero returns true iff this Addr is the zero Addr.

func (Addr) Less

func (a Addr) Less(b Addr) bool

Less returns true iff a is lexically before b.

func (*Addr) Parse

func (addr *Addr) Parse(in string) error

Parse decodes the input as 64 hex digits, or else returns an error.

func (Addr) String

func (addr Addr) String() string

type Block

type Block [BlockSize]byte

Block is a single CAS block. Size information is not preserved. To store large objects, split them into multiple CAS blocks.

func (*Block) Addr

func (block *Block) Addr() Addr

Addr hashes this CAS block to compute its address.

func (*Block) Clear

func (block *Block) Clear()

Clear sets this CAS block to all zeroes.

func (*Block) GoString

func (block *Block) GoString() string

func (*Block) IsZero

func (block *Block) IsZero() bool

func (*Block) Pad

func (block *Block) Pad(raw []byte) error

Pad sets this CAS block to the given data, padding with zeroes as needed.

func (*Block) String

func (block *Block) String() string

func (*Block) Trim

func (block *Block) Trim() []byte

Trim returns the contents of this CAS block with trailing zeroes removed.

type VersionFlag

type VersionFlag struct{}

func (VersionFlag) Get

func (_ VersionFlag) Get() interface{}

func (VersionFlag) IsBoolFlag

func (_ VersionFlag) IsBoolFlag() bool

func (VersionFlag) Set

func (_ VersionFlag) Set(str string) error

func (VersionFlag) String

func (_ VersionFlag) String() string

Jump to

Keyboard shortcuts

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