util

package
v2.8.3 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const GCSFUSE_PARENT_PROCESS_DIR = "gcsfuse-parent-process-dir"
View Source
const HeapSizeToRssConversionFactor float64 = 2

HeapSizeToRssConversionFactor is a constant factor which we multiply to the calculated heap-size to get the corresponding resident set size.

View Source
const MaxMiBsInUint64 uint64 = math.MaxUint64 >> 20
View Source
const Random = "Random"
View Source
const Sequential = "Sequential"

Constants for read types - Sequential/Random

Variables

This section is empty.

Functions

func BytesToHigherMiBs

func BytesToHigherMiBs(bytes uint64) uint64

BytesToHigherMiBs returns the MiBs equivalent to the given number of bytes. If bytes is not an exact number of MiBs, then it returns the next higher no. of MiBs. For reference, each MiB = 2^20 bytes.

func GenerateRandomBytes

func GenerateRandomBytes(length int) []byte

func GetResolvedPath

func GetResolvedPath(filePath string) (resolvedPath string, err error)

1. Returns the same filepath in case of absolute path or empty filename. 2. For child process, it resolves relative path like, ./test.txt, test.txt ../test.txt etc, with respect to GCSFUSE_PARENT_PROCESS_DIR because we execute the child process from different directory and input files are provided with respect to GCSFUSE_PARENT_PROCESS_DIR. 3. For relative path starting with ~, it resolves with respect to home dir.

func MiBsToBytes

func MiBsToBytes(mibs uint64) uint64

MiBsToBytes returns the bytes equivalent of given number of MiBs. For reference, each MiB = 2^20 bytes. It supports only upto 2^44-1 MiBs (~4 Tebi MiBs, or ~4 Ebi bytes) as inputs, and panics for higher inputs.

func NestedSizeOfGcsMinObject

func NestedSizeOfGcsMinObject(m *gcs.MinObject) (size int)

NestedSizeOfGcsMinObject returns the full nested memory size of the gcs.MinObject pointed by the passed pointer. Improvement scope: This can be generalized to a general-struct but that needs better understanding of the reflect package and other related packages.

func Stringify

func Stringify(input any) (string, error)

Stringify marshals an object (only exported attribute) to a JSON string. If marshalling fails, it returns an empty string.

func UnsafeSizeOf

func UnsafeSizeOf[T any](ptr *T) int

UnsafeSizeOf returns the unsafe.Sizeof or raw-size of the object pointed to by the given pointer. It does not account for the pointer's size on memory itself. For e.g. if an int is 8 bytes and an empty string is 16 bytes, then UnsafeSizeOf(&struct{int, string}) return 24 (8+16).

Types

This section is empty.

Jump to

Keyboard shortcuts

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