github.com/pachyderm/pachyderm@v1.13.4/src/client/pfs/pfs.go (about) 1 package pfs 2 3 import ( 4 "crypto/sha512" 5 "encoding/base64" 6 "encoding/hex" 7 "fmt" 8 "hash" 9 ) 10 11 var ( 12 // ChunkSize is the size of file chunks when resumable upload is used 13 ChunkSize = int64(512 * 1024 * 1024) // 512 MB 14 // EmptyStr is included in the description of output commits from failed jobs. 15 EmptyStr = "(empty)" 16 ) 17 18 // FullID prints repoName/CommitID 19 func (c *Commit) FullID() string { 20 return fmt.Sprintf("%s/%s", c.Repo.Name, c.ID) 21 } 22 23 // NewHash returns a hash that PFS uses internally to compute checksums. 24 func NewHash() hash.Hash { 25 return sha512.New() 26 } 27 28 // EncodeHash encodes a hash into a readable format. 29 func EncodeHash(bytes []byte) string { 30 return hex.EncodeToString(bytes) 31 } 32 33 // DecodeHash decodes a hash into bytes. 34 func DecodeHash(hash string) ([]byte, error) { 35 return hex.DecodeString(hash) 36 } 37 38 // GetBlock encodes a hash into a readable format in the form of a Block. 39 func GetBlock(hash hash.Hash) *Block { 40 return &Block{ 41 Hash: base64.URLEncoding.EncodeToString(hash.Sum(nil)), 42 } 43 }