Documentation ¶
Overview ¶
Package cos provides common low-level types and utilities for all aistore projects.
- Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects.
- Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects.
- Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects.
- Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
Package cmn provides common constants, types, and utilities for AIS clients and AIStore.
- Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects.
- Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
Package cmn provides common constants, types, and utilities for AIS clients and AIStore.
- Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects.
- Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects.
- Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
Index ¶
- Constants
- Variables
- func Abs(a int) int
- func AbsI64(a int64) int64
- func AnyHasPrefixInSlice(prefix string, arr []string) bool
- func Assert(cond bool)
- func AssertMsg(cond bool, msg string)
- func AssertNoErr(err error)
- func Assertf(cond bool, f string, a ...any)
- func BHead(b []byte) string
- func CapitalizeString(s string) string
- func CeilAlign(val, align uint) uint
- func CeilAlignInt64(val, align int64) int64
- func ClearfAtomic(f *uint64, flags uint64) (ok bool)
- func Close(closer io.Closer)
- func ConvertToString(value any) (valstr string, err error)
- func CopyStruct(dst, src any)
- func CreateDir(dir string) error
- func CreateFile(fqn string) (*os.File, error)
- func CryptoRandS(n int) string
- func DamerauLevenstheinDistance(s, t string) int
- func DivCeil(a, b int64) int64
- func DivRound(a, b int64) int64
- func DivRoundU64(a, b uint64) uint64
- func DrainReader(r io.Reader)
- func Either(lhs, rhs string) string
- func Err2ClientURLErr(err error) (uerr *url.Error)
- func Errorf(format string, a ...any)
- func ExitLog(a ...any)
- func ExitLogf(f string, a ...any)
- func Exitf(f string, a ...any)
- func ExpandPath(path string) string
- func FastLog2(c uint64) uint
- func FastLog2Ceil(c uint64) uint
- func FloodWriter(w io.Writer, n int64) error
- func FlushClose(file *os.File) (err error)
- func FormatMilli(tm time.Duration) string
- func FormatNanoTime(unixnano int64, format string) string
- func FormatNowStamp() string
- func FormatTime(t time.Time, format string) string
- func FreeMemToOS(d ...time.Duration)
- func GenDaemonID() string
- func GenTestingDaemonID(suffix string) string
- func GenTie() string
- func GenUUID() (uuid string)
- func HomeConfigDir(subdir string) (configDir string)
- func HomeDir() (string, error)
- func Infof(format string, a ...any)
- func InitShortID(seed uint64)
- func IsAlphaNice(s string) bool
- func IsAlphaPlus(s string) bool
- func IsAnySetfAtomic(f *uint64, flags uint64) (yes bool)
- func IsAzureURL(u *url.URL) bool
- func IsEOF(err error) bool
- func IsErrBadCksum(err error) bool
- func IsErrBrokenPipe(err error) (yes bool)
- func IsErrClientURLTimeout(err error) bool
- func IsErrConnectionNotAvail(err error) (yes bool)
- func IsErrConnectionRefused(err error) (yes bool)
- func IsErrConnectionReset(err error) (yes bool)
- func IsErrNotFound(err error) bool
- func IsErrOOS(err error) bool
- func IsErrSyscallTimeout(err error) bool
- func IsErrXattrNotFound(err error) bool
- func IsGoogleAPIURL(u *url.URL) bool
- func IsGoogleStorageURL(u *url.URL) bool
- func IsHTTP(url string) bool
- func IsHTTPS(url string) bool
- func IsIOError(err error) bool
- func IsParseBool(s string) bool
- func IsRetriableConnErr(err error) (yes bool)
- func IsS3URL(link string) bool
- func IsSetfAtomic(f *uint64, flags uint64) (yes bool)
- func IsTimeZero(t time.Time) bool
- func IsUnreachable(err error, status int) bool
- func IsValidAtime(atime int64) bool
- func IsValidUUID(uuid string) bool
- func JoinPath(url, path string) string
- func JoinWords(w string, words ...string) (path string)
- func Max(xs ...int) int
- func MaxDuration(a, b time.Duration) time.Duration
- func MaxI32(a, b int32) int32
- func MaxI64(a, b int64) int64
- func MaxU64(a, b uint64) uint64
- func MaxUint(a, b uint) uint
- func Min(xs ...int) int
- func MinDuration(a, b time.Duration) time.Duration
- func MinF64(a, b float64) float64
- func MinI32(a, b int32) int32
- func MinI64(a, b int64) int64
- func MinTime(a, b time.Time) time.Time
- func MinU64(a, b uint64) uint64
- func MinUint(a, b uint) uint
- func MorphMarshal(data, v any) error
- func MustMarshal(v any) []byte
- func MustMarshalToString(v any) string
- func MustMorphMarshal(data, v any)
- func NewCRC32C() hash.Hash
- func NewErrDataCksum(a, b *Cksum, context ...string) error
- func NewErrMetaCksum(a, b uint64, context ...string) error
- func NopReader(size int64) io.Reader
- func NowRand() *rand.Rand
- func PackedStrLen(s string) int
- func ParseBool(s string) (value bool, err error)
- func ParseSize(size, units string) (int64, error)
- func ParseURL(s string) (u *url.URL, valid bool)
- func Plural(num int) (s string)
- func ProbingFrequency(dur time.Duration) time.Duration
- func RandStringWithSrc(src rand.Source, n int) string
- func Ratio(high, low, curr int64) float32
- func RatioPct(high, low, curr int64) int64
- func ReadLines(filename string, cb func(string) error) error
- func ReadOneInt64(filename string) (int64, error)
- func ReadOneLine(filename string) (string, error)
- func ReadOneUint64(filename string) (uint64, error)
- func RemoveFile(path string) (err error)
- func Rename(src, dst string) (err error)
- func ReparseQuery(r *http.Request)
- func S2Duration(s string) (time.Duration, error)
- func S2UnixNano(s string) (int64, error)
- func SHead(s string) string
- func SetfAtomic(f *uint64, flags uint64) (ok bool)
- func Stat(path string) error
- func StrSlicesEqual(lhs, rhs []string) bool
- func StrToSentence(str string) string
- func StringInSlice(s string, arr []string) bool
- func StringSliceToIntSlice(strs []string) ([]int64, error)
- func SupportedChecksums() (types []string)
- func ToSizeIEC(b int64, digits int) string
- func UnixNano2S(unixnano int64) string
- func UnsafeB(s string) []byte
- func UnsafeS(b []byte) string
- func UnwrapSyscallErr(err error) error
- func ValidateCksumType(ty string, emptyOK ...bool) (err error)
- func ValidateDaemonID(id string) error
- func ValidateNiceID(id string, minlen int, tag string) (err error)
- func Warningf(format string, a ...any)
- type BitFlags
- type Bits
- type ByteHandle
- type BytePack
- func (bw *BytePack) Bytes() []byte
- func (bw *BytePack) WriteAny(st Packer)
- func (bw *BytePack) WriteBool(b bool)
- func (bw *BytePack) WriteByte(b byte)
- func (bw *BytePack) WriteBytes(b []byte)
- func (bw *BytePack) WriteInt16(i int16)
- func (bw *BytePack) WriteInt32(i int32)
- func (bw *BytePack) WriteInt64(i int64)
- func (bw *BytePack) WriteMapStrUint16(mp MapStrUint16)
- func (bw *BytePack) WriteString(s string)
- func (bw *BytePack) WriteUint16(i uint16)
- func (bw *BytePack) WriteUint32(i uint32)
- func (bw *BytePack) WriteUint64(i uint64)
- type ByteUnpack
- func (br *ByteUnpack) Bytes() []byte
- func (br *ByteUnpack) Len() int
- func (br *ByteUnpack) ReadAny(st Unpacker) error
- func (br *ByteUnpack) ReadBool() (bool, error)
- func (br *ByteUnpack) ReadByte() (byte, error)
- func (br *ByteUnpack) ReadBytes() ([]byte, error)
- func (br *ByteUnpack) ReadInt16() (int16, error)
- func (br *ByteUnpack) ReadInt32() (int32, error)
- func (br *ByteUnpack) ReadInt64() (int64, error)
- func (br *ByteUnpack) ReadMapStrUint16() (MapStrUint16, error)
- func (br *ByteUnpack) ReadString() (string, error)
- func (br *ByteUnpack) ReadUint16() (uint16, error)
- func (br *ByteUnpack) ReadUint32() (uint32, error)
- func (br *ByteUnpack) ReadUint64() (uint64, error)
- type CallbackROC
- type Cksum
- func (ck *Cksum) Clone() *Cksum
- func (ck *Cksum) Equal(to *Cksum) bool
- func (ck *Cksum) Get() (string, string)
- func (ck *Cksum) IsEmpty() bool
- func (ck *Cksum) MarshalJSON() ([]byte, error)
- func (ck *Cksum) String() string
- func (ck *Cksum) Ty() string
- func (ck *Cksum) Type() string
- func (ck *Cksum) Val() string
- func (ck *Cksum) Value() string
- type CksumHash
- func CopyAndChecksum(w io.Writer, r io.Reader, buf []byte, cksumType string) (n int64, cksum *CksumHash, err error)
- func CopyFile(src, dst string, buf []byte, cksumType string) (written int64, cksum *CksumHash, err error)
- func NewCksumHash(ty string) (ck *CksumHash)
- func SaveReader(fqn string, reader io.Reader, buf []byte, cksumType string, size int64) (cksum *CksumHash, err error)
- func SaveReaderSafe(tmpfqn, fqn string, reader io.Reader, buf []byte, cksumType string, size int64) (cksum *CksumHash, err error)
- type CksumHashSize
- type Duration
- type DynSemaphore
- type ErrBadCksum
- type ErrNotFound
- type ErrSignal
- type ErrTemplate
- type ErrValue
- type FS
- type FileHandle
- type FileSectionHandle
- type FsID
- type JSONRawMsgs
- type LimitedWaitGroup
- type MapStrUint16
- type MultiSyncMap
- type NamedVal64
- type NopLocker
- type OAH
- type Packer
- type ParsedQuantity
- type ParsedTemplate
- type ReadCloseSizer
- type ReadOpenCloseSizer
- type ReadOpenCloser
- type ReadReaderAt
- type ReadSizer
- type ReadWrapperFunc
- type ReaderArgs
- type ReaderWithArgs
- type Runner
- type SectionHandle
- type Semaphore
- type SetSizeFunc
- type SimpleOAH
- func (s SimpleOAH) AtimeUnix() int64
- func (SimpleOAH) Checksum() *Cksum
- func (SimpleOAH) GetCustomKey(string) (string, bool)
- func (SimpleOAH) GetCustomMD() StrKVs
- func (SimpleOAH) SetCustomKey(_, _ string)
- func (s SimpleOAH) SizeBytes(...bool) int64
- func (SimpleOAH) String() string
- func (SimpleOAH) Version(...bool) string
- type SizeIEC
- type StatsUpdater
- type StopCh
- type StrKVs
- type StrSet
- func (ss StrSet) Add(keys ...string)
- func (ss StrSet) All(xs ...string) bool
- func (ss StrSet) Clone() StrSet
- func (ss StrSet) Contains(key string) (yes bool)
- func (ss StrSet) Delete(key string)
- func (ss StrSet) Intersection(other StrSet) StrSet
- func (ss StrSet) Set(key string)
- func (ss StrSet) String() string
- func (ss StrSet) ToSlice() []string
- type TemplateRange
- type TimeoutGroup
- type Unpacker
- type WG
- type WriteSizer
- type WriterAt
- type WriterMulti
- type WriterOnly
Constants ¶
const ( ChecksumNone = "none" ChecksumXXHash = "xxhash" ChecksumMD5 = "md5" ChecksumCRC32C = "crc32c" ChecksumSHA256 = "sha256" // crypto.SHA512_256 (SHA-2) ChecksumSHA512 = "sha512" // crypto.SHA512 (SHA-2) )
checksums
const ( PermRWR os.FileMode = 0o640 PermRWRR os.FileMode = 0o644 // (archived) PermRWXRX os.FileMode = 0o750 )
POSIX permissions
const ( CtxReadWrapper contextID = "readWrapper" // context key for ReadWrapperFunc CtxSetSize contextID = "setSize" // context key for SetSizeFunc CtxOriginalURL contextID = "origURL" // context key for OriginalURL for HTTP cloud )
const ( ContentJSON = "application/json" ContentJSONCharsetUTF = "application/json; charset=utf-8" ContentMsgPack = "application/msgpack" ContentXML = "application/xml" ContentBinary = "application/octet-stream" // not currently used: ContentZip = "application/zip" ContentTar = "application/x-tar" // not present in IANA reg, mozilla.org has it though )
standard MIME types - https://www.iana.org/assignments/media-types/media-types.xhtml - https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
const ( // range to read: HdrRange = "Range" // Ref: https://www.rfc-editor.org/rfc/rfc7233#section-2.1 HdrRangeValPrefix = "bytes=" // range read response: HdrContentRange = "Content-Range" HdrContentRangeValPrefix = "bytes " // Ref: https://tools.ietf.org/html/rfc7233#section-4.2 HdrAcceptRanges = "Accept-Ranges" // content length & type HdrContentType = "Content-Type" HdrContentTypeOptions = "X-Content-Type-Options" HdrContentLength = "Content-Length" // misc. gen HdrUserAgent = "User-Agent" HdrAccept = "Accept" HdrLocation = "Location" HdrServer = "Server" HdrETag = "ETag" // Ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Hdrs/ETag )
Ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
const ( // https://cloud.google.com/storage/docs/xml-api/reference-headers GsCksumHeader = "x-goog-hash" GsVersionHeader = "x-goog-generation" // https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html // https://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonResponseHeaders.html S3CksumHeader = "ETag" S3VersionHeader = "x-amz-version-id" // s3 api request headers S3HdrObjSrc = "x-amz-copy-source" S3HdrMptCnt = "x-amz-mp-parts-count" S3HdrContentSHA256 = "x-amz-content-sha256" S3HdrBckRegion = "x-amz-bucket-region" S3ChecksumCRC32 = "x-amz-checksum-crc32" S3ChecksumCRC32C = "x-amz-checksum-crc32c" S3ChecksumSHA1 = "x-amz-checksum-sha1" S3ChecksumSHA256 = "x-amz-checksum-sha256" S3LastModified = "Last-Modified" S3MetadataChecksumType = "x-amz-meta-ais-cksum-type" S3MetadataChecksumVal = "x-amz-meta-ais-cksum-val" // https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob-properties#response-headers AzCksumHeader = "Content-MD5" AzVersionHeader = "ETag" )
provider-specific headers (=> custom props, and more)
const ( QuantityPercent = "percent" QuantityBytes = "bytes" )
const ( LetterRunes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" LenRunes = len(LetterRunes) )
const ( UnitsIEC = "iec" // default UnitsSI = "si" // NOTE: currently, SI system is CLI-only (compare with cmn/cos/size.go) UnitsRaw = "raw" )
const ( KiB = 1024 MiB = 1024 * KiB GiB = 1024 * MiB TiB = 1024 * GiB )
IEC (binary) units
const ( KB = 1000 MB = 1000 * KB GB = 1000 * MB TB = 1000 * GB )
IS (metric) units
const ( StampMicro = "15:04:05.000000" // time.StampMicro without a date, same as glog StampSec = "15:04:05" // time.Stamp without a date // S3 ListObjectsV2 // https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html ISO8601 = "2006-01-02T15:04:05.000Z" // S3 HeadObject // https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html#API_HeadObject_Examples RFC1123GMT = "Mon, 17 Dec 2012 02:14:10 GMT" )
in addition to standard layouts at /usr/local/go/src/time/format.go
const ( SizeofI64 = int(unsafe.Sizeof(uint64(0))) SizeofI32 = int(unsafe.Sizeof(uint32(0))) SizeofI16 = int(unsafe.Sizeof(uint16(0))) )
assorted common constants
const ( OnlyNice = "may only contain letters, numbers, dashes (-), underscores (_), and dots (.)" OnlyPlus = OnlyNice + ", and dots (.)" )
const ContentLengthUnknown = -1
const MLCG32 = 1103515245 // xxhash seed
const (
// Number of sync maps
MultiSyncMapCount = 0x40
)
const SizeofLen = SizeofI32
Internally size of byte slice or string is packed as this integer type. Since binary packed structs are used for fairly small amount of data, it is possible to use int32 instead of int64 to keep the length of the data.
Variables ¶
var ( ErrInvalidQuantityUsage = errors.New("invalid quantity, format should be '81%' or '1GB'") ErrInvalidQuantityPercent = errors.New("percent must be in the range (0, 100)") ErrInvalidQuantityBytes = errors.New("value (bytes) must be non-negative") )
var ErrBufferUnderrun = errors.New("buffer underrun")
var ErrEmptyTemplate = errors.New("empty range template")
var JSON jsoniter.API
JSON is used to Marshal/Unmarshal API json messages and is initialized in init function.
var NoneCksum = NewCksum(ChecksumNone, "")
Functions ¶
func AnyHasPrefixInSlice ¶
func AssertMsg ¶
NOTE: when using Sprintf and such, `if (!cond) { AssertMsg(false, msg) }` is the preferable usage.
func AssertNoErr ¶
func AssertNoErr(err error)
func CapitalizeString ¶
func CeilAlign ¶
CeilAlign returns smallest number bigger or equal to val, which is divisible by align
func CeilAlignInt64 ¶
func ClearfAtomic ¶
func ConvertToString ¶
func CreateDir ¶
CreateDir creates directory if does not exist. Does not return error when directory already exists.
func CreateFile ¶
CreateFile creates a new write-only (O_WRONLY) file with default cos.PermRWR permissions. NOTE: if the file pathname doesn't exist it'll be created. NOTE: if the file already exists it'll be also silently truncated.
func CryptoRandS ¶
func DamerauLevenstheinDistance ¶
based on Wikipedia https://en.wikipedia.org/wiki/Damerau–Levenshtein_distance
func DivRoundU64 ¶
func DrainReader ¶
DrainReader reads and discards all the data from a reader. No need for `io.CopyBuffer` as `io.Discard` has efficient `io.ReaderFrom` implementation.
func Err2ClientURLErr ¶
func ExpandPath ¶
ExpandPath replaces common abbreviations in file path (eg. `~` with absolute path to the current user home directory) and cleans the path.
func FastLog2Ceil ¶
func FloodWriter ¶
FloodWriter writes `n` random bytes to provided writer.
func FlushClose ¶
func FormatMilli ¶
FormatMilli returns a duration formatted as milliseconds. For values bigger than millisecond, it returns an integer number "#ms". For values smaller than millisecond, the function returns fractional number "0.##ms"
func FormatNanoTime ¶
`unixnano` here is expected to be "nanoseconds since January 1, 1970 UTC"
func FormatNowStamp ¶
func FormatNowStamp() string
func FreeMemToOS ¶
FreeMemToOS calls GC and returns allocated memory to OS after that Use to clean up memory after a huge amount of memory becomes "free" to return it to OS immediately without waiting for GC does it automatically Params:
d - a delay before starting memory cleanup
func GenDaemonID ¶
func GenDaemonID() string
func HomeConfigDir ¶
func InitShortID ¶
func InitShortID(seed uint64)
func IsAlphaNice ¶
letters and numbers w/ '-' and '_' permitted with limitations (below) (see OnlyNice above)
func IsAlphaPlus ¶
alpha-numeric++ including letters, numbers, dashes (-), and underscores (_) period (.) is allowed except for '..' (see OnlyPlus above)
func IsAnySetfAtomic ¶
func IsAzureURL ¶
func IsEOF ¶
including "unexpecting EOF" to accommodate unsized streaming and early termination of the other side (prior to sending the first byte)
func IsErrBadCksum ¶
func IsErrBrokenPipe ¶
func IsErrClientURLTimeout ¶
func IsErrConnectionNotAvail ¶
likely out of socket descriptors
func IsErrConnectionReset ¶
func IsErrNotFound ¶
func IsErrSyscallTimeout ¶
func IsErrXattrNotFound ¶
func IsGoogleAPIURL ¶
func IsGoogleStorageURL ¶
func IsIOError ¶
Checks if the error is generated by any IO operation and if the error is severe enough to run the FSHC for mountpath testing
For mountpath definition, see fs/mountfs.go
func IsParseBool ¶
func IsRetriableConnErr ¶
func IsSetfAtomic ¶
func IsTimeZero ¶
func IsUnreachable ¶
func IsValidAtime ¶
access time validity; prefetch special (negative) case - sets atime=-now 946771140000000000 = time.Parse(time.RFC3339Nano, "2000-01-01T23:59:00Z").UnixNano()
func IsValidUUID ¶
func JoinPath ¶
JoinPath joins two path elements that may (or may not) be prefixed/suffixed with a slash.
func JoinWords ¶
JoinWords uses forward slash to join any number of words into a single path. Returned path is prefixed with a slash.
func MaxDuration ¶
MaxDuration returns min value of a and b time.Duration types
func MinDuration ¶
MinDuration returns min value of a and b time.Duration types
func MorphMarshal ¶
func MustMarshal ¶
MustMarshal marshals v and panics if error occurs.
func MustMarshalToString ¶
func MustMorphMarshal ¶
func MustMorphMarshal(data, v any)
func NewErrDataCksum ¶
func NewErrMetaCksum ¶
func PackedStrLen ¶
PackedStrLen returns the size occupied by a given string in the output
func ParseBool ¶
ParseBool converts string to bool (case-insensitive):
y, yes, on -> true n, no, off, <empty value> -> false
strconv handles the following:
1, true, t -> true 0, false, f -> false
func ProbingFrequency ¶
wait duration => probing frequency
func ReadLines ¶
Read a file line by line and call a callback for each line until the file ends or a callback returns io.EOF
func ReadOneInt64 ¶
Read only the first line of a file and return it as int64 Do not use for big files: it reads all the content and then extracts the first line. Use for files that may contains a few lines with trailing EOL
func ReadOneLine ¶
Read only the first line of a file. Do not use for big files: it reads all the content and then extracts the first line. Use for files that may contains a few lines with trailing EOL
func ReadOneUint64 ¶
Read only the first line of a file and return it as uint64 Do not use for big files: it reads all the content and then extracts the first line. Use for files that may contains a few lines with trailing EOL
func RemoveFile ¶
RemoveFile removes path; returns nil upon success or if the path does not exist.
func ReparseQuery ¶
WARNING: `ReparseQuery` might affect non-tensorflow clients using S3-compatible API with AIStore. To be used with caution.
func S2UnixNano ¶
func SetfAtomic ¶
func StrSlicesEqual ¶
StrSlicesEqual compares content of two string slices. It is replacement for reflect.DeepEqual because the latter returns false if slices have the same values but in different order.
func StrToSentence ¶
func StringInSlice ¶
func StringSliceToIntSlice ¶
func SupportedChecksums ¶
func SupportedChecksums() (types []string)
func UnixNano2S ¶
func UnwrapSyscallErr ¶
func ValidateCksumType ¶
func ValidateDaemonID ¶
Types ¶
type ByteHandle ¶
ByteHandle is a byte buffer(made from []byte) that implements ReadOpenCloser interface
func NewByteHandle ¶
func NewByteHandle(bt []byte) *ByteHandle
func (*ByteHandle) Close ¶
func (*ByteHandle) Close() error
func (*ByteHandle) Open ¶
func (b *ByteHandle) Open() (ReadOpenCloser, error)
type BytePack ¶
type BytePack struct {
// contains filtered or unexported fields
}
func (*BytePack) WriteBytes ¶
func (*BytePack) WriteInt16 ¶
func (*BytePack) WriteInt32 ¶
func (*BytePack) WriteInt64 ¶
func (*BytePack) WriteMapStrUint16 ¶
func (bw *BytePack) WriteMapStrUint16(mp MapStrUint16)
func (*BytePack) WriteString ¶
func (*BytePack) WriteUint16 ¶
func (*BytePack) WriteUint32 ¶
func (*BytePack) WriteUint64 ¶
type ByteUnpack ¶
type ByteUnpack struct {
// contains filtered or unexported fields
}
func NewUnpacker ¶
func NewUnpacker(buf []byte) *ByteUnpack
func (*ByteUnpack) Bytes ¶
func (br *ByteUnpack) Bytes() []byte
func (*ByteUnpack) Len ¶
func (br *ByteUnpack) Len() int
func (*ByteUnpack) ReadAny ¶
func (br *ByteUnpack) ReadAny(st Unpacker) error
func (*ByteUnpack) ReadBool ¶
func (br *ByteUnpack) ReadBool() (bool, error)
func (*ByteUnpack) ReadByte ¶
func (br *ByteUnpack) ReadByte() (byte, error)
func (*ByteUnpack) ReadBytes ¶
func (br *ByteUnpack) ReadBytes() ([]byte, error)
func (*ByteUnpack) ReadInt16 ¶
func (br *ByteUnpack) ReadInt16() (int16, error)
func (*ByteUnpack) ReadInt32 ¶
func (br *ByteUnpack) ReadInt32() (int32, error)
func (*ByteUnpack) ReadInt64 ¶
func (br *ByteUnpack) ReadInt64() (int64, error)
func (*ByteUnpack) ReadMapStrUint16 ¶
func (br *ByteUnpack) ReadMapStrUint16() (MapStrUint16, error)
func (*ByteUnpack) ReadString ¶
func (br *ByteUnpack) ReadString() (string, error)
func (*ByteUnpack) ReadUint16 ¶
func (br *ByteUnpack) ReadUint16() (uint16, error)
func (*ByteUnpack) ReadUint32 ¶
func (br *ByteUnpack) ReadUint32() (uint32, error)
func (*ByteUnpack) ReadUint64 ¶
func (br *ByteUnpack) ReadUint64() (uint64, error)
type CallbackROC ¶
type CallbackROC struct {
// contains filtered or unexported fields
}
readers
func NewCallbackReadOpenCloser ¶
func NewCallbackReadOpenCloser(r ReadOpenCloser, readCb func(int, error), reportedBytes ...int) *CallbackROC
func (*CallbackROC) Close ¶
func (r *CallbackROC) Close() error
func (*CallbackROC) Open ¶
func (r *CallbackROC) Open() (ReadOpenCloser, error)
type Cksum ¶
type Cksum struct {
// contains filtered or unexported fields
}
func ChecksumBytes ¶
ChecksumBytes computes checksum of given bytes using additional buffer.
func (*Cksum) MarshalJSON ¶
type CksumHash ¶
func CopyAndChecksum ¶
func CopyAndChecksum(w io.Writer, r io.Reader, buf []byte, cksumType string) (n int64, cksum *CksumHash, err error)
CopyAndChecksum reads from `r` and writes to `w`; returns num bytes copied and checksum, or error
func CopyFile ¶
func CopyFile(src, dst string, buf []byte, cksumType string) (written int64, cksum *CksumHash, err error)
and computes checksum if requested
func NewCksumHash ¶
func SaveReader ¶
func SaveReader(fqn string, reader io.Reader, buf []byte, cksumType string, size int64) (cksum *CksumHash, err error)
Saves the reader directly to `fqn`, checksums if requested
func SaveReaderSafe ¶
type CksumHashSize ¶
type DynSemaphore ¶
type DynSemaphore struct {
// contains filtered or unexported fields
}
DynSemaphore implements sempahore which can change its size during usage.
func NewDynSemaphore ¶
func NewDynSemaphore(n int) *DynSemaphore
func (*DynSemaphore) Acquire ¶
func (s *DynSemaphore) Acquire(cnts ...int)
func (*DynSemaphore) Release ¶
func (s *DynSemaphore) Release(cnts ...int)
func (*DynSemaphore) SetSize ¶
func (s *DynSemaphore) SetSize(n int)
func (*DynSemaphore) Size ¶
func (s *DynSemaphore) Size() int
type ErrBadCksum ¶
type ErrBadCksum struct {
// contains filtered or unexported fields
}
func (*ErrBadCksum) Error ¶
func (e *ErrBadCksum) Error() string
type ErrNotFound ¶
type ErrNotFound struct {
// contains filtered or unexported fields
}
func NewErrNotFound ¶
func NewErrNotFound(format string, a ...any) *ErrNotFound
func (*ErrNotFound) Error ¶
func (e *ErrNotFound) Error() string
type ErrSignal ¶
type ErrSignal struct {
// contains filtered or unexported fields
}
func NewSignalError ¶
type ErrTemplate ¶
type ErrTemplate struct {
// contains filtered or unexported fields
}
func (*ErrTemplate) Error ¶
func (e *ErrTemplate) Error() string
type FileHandle ¶
handles (and more readers)
func NewFileHandle ¶
func NewFileHandle(fqn string) (*FileHandle, error)
func (*FileHandle) Open ¶
func (f *FileHandle) Open() (ReadOpenCloser, error)
type FileSectionHandle ¶
type FileSectionHandle struct {
// contains filtered or unexported fields
}
FileSectionHandle opens a file and reads a section of it with optional padding. It implements the ReadOpenCloser interface.
func NewFileSectionHandle ¶
func NewFileSectionHandle(fqn string, offset, size int64) (*FileSectionHandle, error)
NewFileSectionHandle opens file which is expected at `fqn` and defines a SectionHandle on it to only read a specified section.
func (*FileSectionHandle) Close ¶
func (f *FileSectionHandle) Close() error
func (*FileSectionHandle) Open ¶
func (f *FileSectionHandle) Open() (ReadOpenCloser, error)
type FsID ¶
type FsID [2]int32
FsID is unified and cross-platform syscall.Fsid type which implements JSON marshaling.
func (FsID) MarshalJSON ¶
func (*FsID) UnmarshalJSON ¶
type JSONRawMsgs ¶
type JSONRawMsgs map[string]jsoniter.RawMessage
type LimitedWaitGroup ¶
type LimitedWaitGroup struct {
// contains filtered or unexported fields
}
LimitedWaitGroup is helper struct which combines standard wait group and semaphore to limit the number of goroutines created.
func (*LimitedWaitGroup) Add ¶
func (lwg *LimitedWaitGroup) Add(n int)
func (*LimitedWaitGroup) Done ¶
func (lwg *LimitedWaitGroup) Done()
func (*LimitedWaitGroup) Wait ¶
func (lwg *LimitedWaitGroup) Wait()
type MapStrUint16 ¶
type MultiSyncMap ¶
type MultiSyncMap struct {
M [MultiSyncMapCount]sync.Map
}
type NamedVal64 ¶
type ParsedQuantity ¶
func ParseQuantity ¶
func ParseQuantity(quantity string) (ParsedQuantity, error)
func (ParsedQuantity) String ¶
func (pq ParsedQuantity) String() string
type ParsedTemplate ¶
type ParsedTemplate struct { Prefix string Ranges []TemplateRange // contains filtered or unexported fields }
func NewParsedTemplate ¶
func NewParsedTemplate(template string) (ParsedTemplate, error)
func ParseAtTemplate ¶
func ParseAtTemplate(template string) (pt ParsedTemplate, err error)
e.g. multi-range template: "prefix-@00001-gap-@100-suffix"
single range: "prefix@00100suffix"
func ParseBashTemplate ¶
func ParseBashTemplate(template string) (pt ParsedTemplate, err error)
examples - single-range: "prefix{0001..0010}suffix" - multi-range: "prefix-{00001..00010..2}-gap-{001..100..2}-suffix" (both prefix and suffix are optional, here and elsewhere)
func ParseFmtTemplate ¶
func ParseFmtTemplate(template string) (pt ParsedTemplate, err error)
template: "prefix-%06d-suffix" (both prefix and suffix are optional, here and elsewhere)
func (*ParsedTemplate) Count ¶
func (pt *ParsedTemplate) Count() int64
func (*ParsedTemplate) InitIter ¶
func (pt *ParsedTemplate) InitIter()
func (*ParsedTemplate) Next ¶
func (pt *ParsedTemplate) Next() (string, bool)
func (*ParsedTemplate) ToSlice ¶
func (pt *ParsedTemplate) ToSlice(maxLen ...int) []string
maxLen specifies maximum objects to be returned
type ReadCloseSizer ¶
type ReadCloseSizer interface { io.ReadCloser Size() int64 }
ReadCloseSizer is the interface that adds Size method to io.ReadCloser.
func NewDeferRCS ¶
func NewDeferRCS(r ReadCloseSizer, cb func()) ReadCloseSizer
func NewSizedRC ¶
func NewSizedRC(r io.ReadCloser, size int64) ReadCloseSizer
type ReadOpenCloseSizer ¶
type ReadOpenCloseSizer interface { ReadOpenCloser Size() int64 }
ReadOpenCloseSizer is the interface that adds Size method to ReadOpenCloser.
type ReadOpenCloser ¶
type ReadOpenCloser interface { io.ReadCloser Open() (ReadOpenCloser, error) }
readers
func NopOpener ¶
func NopOpener(r io.ReadCloser) ReadOpenCloser
type ReadWrapperFunc ¶
type ReadWrapperFunc func(r io.ReadCloser) io.ReadCloser
type ReaderArgs ¶
readers
type ReaderWithArgs ¶
type ReaderWithArgs struct {
// contains filtered or unexported fields
}
readers
func NewReaderWithArgs ¶
func NewReaderWithArgs(args ReaderArgs) *ReaderWithArgs
func (*ReaderWithArgs) Close ¶
func (r *ReaderWithArgs) Close() (err error)
func (*ReaderWithArgs) Open ¶
func (*ReaderWithArgs) Open() (ReadOpenCloser, error)
func (*ReaderWithArgs) Size ¶
func (r *ReaderWithArgs) Size() int64
type SectionHandle ¶
type SectionHandle struct {
// contains filtered or unexported fields
}
SectionHandle is a section of reader with optional padding that implements ReadOpenCloser interface.
func NewSectionHandle ¶
func NewSectionHandle(r io.ReaderAt, offset, size, padding int64) *SectionHandle
func (*SectionHandle) Close ¶
func (*SectionHandle) Close() error
func (*SectionHandle) Open ¶
func (f *SectionHandle) Open() (ReadOpenCloser, error)
type Semaphore ¶
type Semaphore struct {
// contains filtered or unexported fields
}
Semaphore implements sempahore which is just a nice wrapper on `chan struct{}`.
func NewSemaphore ¶
func (*Semaphore) TryAcquire ¶
func (s *Semaphore) TryAcquire() <-chan struct{}
type SetSizeFunc ¶
type SetSizeFunc func(size int64)
type SimpleOAH ¶
convenience/shortcut
func (SimpleOAH) GetCustomMD ¶
func (SimpleOAH) SetCustomKey ¶
type StatsUpdater ¶
type StopCh ¶
type StopCh struct {
// contains filtered or unexported fields
}
StopCh is specialized channel for stopping things.
type StrKVs ¶
func (StrKVs) ContainsAnyMatch ¶
type TemplateRange ¶
type TimeoutGroup ¶
type TimeoutGroup struct {
// contains filtered or unexported fields
}
TimeoutGroup is similar to sync.WaitGroup with the difference on Wait where we only allow timing out.
WARNING: It should not be used in critical code as it may have worse performance than sync.WaitGroup - use only if its needed.
WARNING: It is not safe to wait on completion in multiple threads!
WARNING: It is not recommended to reuse the TimeoutGroup - it was not designed for that and bugs can be expected, especially when previous group was not called with successful (without timeout) WaitTimeout.
func NewTimeoutGroup ¶
func NewTimeoutGroup() *TimeoutGroup
func (*TimeoutGroup) Add ¶
func (twg *TimeoutGroup) Add(n int)
func (*TimeoutGroup) Done ¶
func (twg *TimeoutGroup) Done()
Done decrements number of jobs left to do. Panics if the number jobs left is less than 0.
func (*TimeoutGroup) Wait ¶
func (twg *TimeoutGroup) Wait()
Wait waits until the Added pending count goes to zero. NOTE: must be invoked after _all_ Adds.
func (*TimeoutGroup) WaitTimeout ¶
func (twg *TimeoutGroup) WaitTimeout(timeout time.Duration) bool
Wait waits until the Added pending count goes to zero _or_ timeout. NOTE: must be invoked after _all_ Adds.
func (*TimeoutGroup) WaitTimeoutWithStop ¶
func (twg *TimeoutGroup) WaitTimeoutWithStop(timeout time.Duration, stop <-chan struct{}) (timed, stopped bool)
Wait waits until the Added pending count goes to zero _or_ timeout _or_ stop. NOTE: must be invoked after _all_ Adds.
type Unpacker ¶
type Unpacker interface {
Unpack(unpacker *ByteUnpack) error
}
Every object that is going to use binary representation instead of JSON must implement two following methods
type WG ¶
type WG interface { Add(int) Done() Wait() }
WG is an interface for wait group
func NewLimitedWaitGroup ¶
usage: no more than `limit` goroutines in parallel
type WriterMulti ¶
type WriterMulti struct {
// contains filtered or unexported fields
}
writers
func NewWriterMulti ¶
func NewWriterMulti(w ...io.Writer) *WriterMulti
type WriterOnly ¶
WriterOnly is helper struct to hide `io.ReaderFrom` implementation which can use some heuristics to improve performance but can result in not using `buffer` provided in `io.CopyBuffer`. See: https://golang.org/doc/go1.15#os.
Source Files ¶
- assert.go
- bitflags.go
- bytepack.go
- cksum.go
- common.go
- context.go
- convert.go
- duration.go
- err.go
- err_linux.go
- fs.go
- fs_unix.go
- homedir.go
- http_headers.go
- io.go
- math.go
- namedrunner.go
- oah.go
- quantity.go
- rand.go
- size.go
- slice.go
- stats.go
- strings.go
- sync.go
- template.go
- time_utils.go
- unsafe.go
- url.go
- uuid.go