Documentation ¶
Overview ¶
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 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-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-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 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-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-2021, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
Package cos provides common low-level types and utilities for all aistore projects
- Copyright (c) 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-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-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) 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 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-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-2021, 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-2021, 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 B2S(b int64, digits int) string
- func BHead(b []byte) string
- func BoolExtVar(f *flag.FlagSet, p *BoolExt, name, usage 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 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 DurationExtVar(f *flag.FlagSet, p *DurationExt, name string, defValue time.Duration, ...)
- func Either(lhs, rhs string) string
- func Errorf(format string, 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 FormatTimestamp(tm time.Time) string
- func FormatUnixNano(unixnano int64, 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 IsAlphaPlus(s string, withPeriod bool) 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 IsErrConnectionNotAvail(err error) (yes bool)
- func IsErrConnectionRefused(err error) (yes bool)
- func IsErrConnectionReset(err error) (yes bool)
- func IsErrOOS(err error) bool
- func IsErrXattrNotFound(err error) bool
- func IsGoogleAPIURL(u *url.URL) bool
- func IsGoogleStorageURL(u *url.URL) bool
- func IsGzipped(filename string) 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 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 Mime(mime, filename string) (ext string, err error)
- 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 NewBadDataCksumError(a, b *Cksum, context ...string) error
- func NewBadMetaCksumError(a, b uint64, context ...string) error
- func NewCRC32C() hash.Hash
- func NopReader(size int64) io.Reader
- func NounEnding(count int) string
- func NowRand() *rand.Rand
- func OpenTarForAppend(objName, workFQN string) (*os.File, error)
- func PackedStrLen(s string) int
- func ParseBool(s string) (value bool, err error)
- func ParseEnvVariables(fpath string, delimiter ...string) map[string]string
- func ParseURL(s string) (u *url.URL, valid bool)
- func Plural(num int) (s string)
- func ProbingFrequency(dur time.Duration) time.Duration
- func RandStringStrong(n int) string
- 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 S2B(s string) (int64, error)
- 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 UnixNano2S(unixnano int64) string
- func UnsafeS(b []byte) string
- func UnsignedB2S(b uint64, digits int) string
- func UnwrapSyscallErr(err error) error
- func ValidateCksumType(ty string, emptyOK ...bool) (err error)
- func ValidateDaemonID(id string) error
- func ValidateEtlID(id string) error
- func Warningf(format string, a ...any)
- type BitFlags
- type Bits
- type BoolExt
- 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 DurationExt
- type DynSemaphore
- type ErrBadCksum
- type ErrSignal
- type ErrTemplate
- type ErrUnknownMime
- type ErrValue
- type FileHandle
- type FileSectionHandle
- type FsID
- type JSONRawMsgs
- type LimitedWaitGroup
- type MapStrUint16
- type MemCPUInfo
- type MultiSyncMap
- type NamedVal64
- 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 Size
- type StatsTracker
- 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) 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 ( ExtTar = ".tar" ExtTgz = ".tgz" ExtTarTgz = ".tar.gz" ExtZip = ".zip" // msgpack doesn't have a "common extension", see for instance: // * https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types // however, there seems to be a de-facto agreement wrt Content-Type // * application/msgpack // * application/x-msgpack (<<< recommended) // * application/*+msgpack // AIS uses the following single constant for both the default file extension // and for the Content-Type (the latter with offset [1:]) ExtMsgpack = ".msgpack" )
supported archive types (file extensions)
const ( ChecksumNone = "none" ChecksumXXHash = "xxhash" ChecksumMD5 = "md5" ChecksumCRC32C = "crc32c" ChecksumSHA256 = "sha256" // crypto.SHA512_256 (SHA-2) ChecksumSHA512 = "sha512" // crypto.SHA512 (SHA-2) )
checksums
const ( KiB = 1024 MiB = 1024 * KiB GiB = 1024 * MiB TiB = 1024 * GiB )
IEC (binary) units
const ( SizeofI64 = int(unsafe.Sizeof(uint64(0))) SizeofI32 = int(unsafe.Sizeof(uint32(0))) SizeofI16 = int(unsafe.Sizeof(uint16(0))) MLCG32 = 1103515245 // xxhash seed PermRWR os.FileMode = 0o640 // POSIX perms PermRWXRX os.FileMode = 0o750 )
assorted common constants
const ( HdrRange = "Range" // Ref: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35 HdrRangeValPrefix = "bytes=" HdrContentRange = "Content-Range" HdrContentRangeValPrefix = "bytes " // Ref: https://tools.ietf.org/html/rfc7233#section-4.2 HdrAcceptRanges = "Accept-Ranges" HdrContentType = "Content-Type" HdrContentTypeOptions = "X-Content-Type-Options" HdrContentLength = "Content-Length" HdrUserAgent = "User-Agent" HdrAccept = "Accept" HdrLocation = "Location" HdrServer = "Server" HdrETag = "ETag" // Ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Hdrs/ETag )
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 ( ContentJSON = "application/json" ContentJSONCharsetUTF = "application/json; charset=utf-8" ContentMsgPack = "application/msgpack" ContentXML = "application/xml" ContentBinary = "application/octet-stream" )
Ref: https://www.iana.org/assignments/media-types/media-types.xhtml
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 ( QuantityPercent = "percent" QuantityBytes = "bytes" )
const ( LetterRunes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" LenRunes = len(LetterRunes) )
const ContentLengthUnknown = -1
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.
const TarBlockSize = 512 // Size of each block in a tar stream
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 ArchExtensions = []string{ExtTar, ExtTgz, ExtTarTgz, ExtZip, ExtMsgpack}
var ErrBufferUnderrun = errors.New("buffer underrun")
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 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 DurationExtVar ¶
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 FormatTimestamp ¶
func FormatUnixNano ¶
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 GenTestingDaemonID ¶
func HomeConfigDir ¶
func InitShortID ¶
func InitShortID(seed uint64)
func IsAlphaPlus ¶
alpha-numeric++ including letters, numbers, dashes (-), and underscores (_) period (.) is allowed conditionally except for '..'
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 IsErrConnectionNotAvail ¶
likely out of socket descriptors
func IsErrConnectionReset ¶
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 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 Mime ¶
Map user-specified mime type OR the filename's extension to one of the supported ArchExtensions
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 NewBadDataCksumError ¶
func NewBadMetaCksumError ¶
func NounEnding ¶
func OpenTarForAppend ¶
OpenTarForAppend opens a TAR and uses tar's reader Next() to skip to the position right _after_ the last file in the TAR (padding bytes including).
Background:
TAR file is padded with one or more 512-byte blocks of zero bytes. The blocks must be overwritten, otherwise newly added files won't be accessible. Different TAR formats (such as `ustar`, `pax` and `GNU`) write different number of zero blocks.
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 ParseEnvVariables ¶
ParseEnvVariables takes in a .env file and parses its contents
func ProbingFrequency ¶
wait duration => probing frequency
func RandStringStrong ¶
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 UnsafeS ¶
UnsafeS casts bytes to an immutable string. ***** CAUTION! the resulting string must never change *****
func UnsignedB2S ¶
func UnwrapSyscallErr ¶
func ValidateCksumType ¶
func ValidateDaemonID ¶
func ValidateEtlID ¶
Types ¶
type BoolExt ¶
func (*BoolExt) IsBoolFlag ¶
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 io.Reader and writes io.Writer; returns bytes written, checksum, and 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, dirMustExist string) (cksum *CksumHash, err error)
Saves the reader directly to a local file, xxhash-checksums if requested
type CksumHashSize ¶
type DurationExt ¶
func (*DurationExt) Get ¶
func (d *DurationExt) Get() any
func (*DurationExt) IsBoolFlag ¶
func (*DurationExt) IsBoolFlag() bool
func (*DurationExt) Set ¶
func (d *DurationExt) Set(s string) (err error)
func (*DurationExt) String ¶
func (d *DurationExt) String() string
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 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 ErrUnknownMime ¶
type ErrUnknownMime struct {
// contains filtered or unexported fields
}
func NewUnknownMimeError ¶
func NewUnknownMimeError(d string) *ErrUnknownMime
func (*ErrUnknownMime) Error ¶
func (e *ErrUnknownMime) 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 MemCPUInfo ¶
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)
e.g. single-range template: "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 StatsTracker ¶
type StatsTracker interface { Add(name string, val int64) Get(name string) int64 AddMany(namedVal64 ...NamedVal64) }
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 ¶
- archive.go
- assert.go
- bitflags.go
- bytepack.go
- cksum.go
- common.go
- const_http.go
- context.go
- convert.go
- duration.go
- err.go
- err_linux.go
- flag.go
- fs.go
- fs_unix.go
- homedir.go
- io.go
- math.go
- namedrunner.go
- quantity.go
- rand.go
- size.go
- slice.go
- stats.go
- strings.go
- sync.go
- template.go
- time_utils.go
- url.go
- uuid.go