utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package utils holds the list of code helpers

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMMapIsClosed means that it was an attempt to read data
	// from the closed region
	ErrMMapIsClosed = errors.New("MMap file is closed")

	// ErrMMapInvalidOffset means that it was an attempt to read data
	// from the invalid offset
	ErrMMapInvalidOffset = errors.New("out of range")
)

Functions

func Max

func Max(a, b int) int

Max returns the maximum value

func Min

func Min(a, b int) int

Min returns the minimum value

func Pack

func Pack(a, b uint32) uint64

Pack packs 2 uint32 into uint64

func UnpackLeft

func UnpackLeft(v uint64) uint32

UnpackLeft explodes uint64 into 2 uint32 and returns the first uint32 value

func UnpackRight

func UnpackRight(v uint64) uint32

UnpackRight explodes uint64 into 2 uint32 and returns the second uint32 value

Types

type AtomicFloat64

type AtomicFloat64 struct {
	// contains filtered or unexported fields
}

AtomicFloat64 is an atomic wrapper around float64 inspired https://github.com/uber-go/atomic/blob/master/atomic.go

func (*AtomicFloat64) Load

func (u *AtomicFloat64) Load() float64

Load atomically loads stored float64 value

func (*AtomicFloat64) Store

func (u *AtomicFloat64) Store(val float64)

Store atomically stores float64 value

type MMapReader

type MMapReader struct {
	// contains filtered or unexported fields
}

MMapReader wraps Read methods by using mmap

func NewMMapReader

func NewMMapReader(filename string) (*MMapReader, error)

NewMMapReader returns new instance of MMapReader

func (*MMapReader) Bytes

func (r *MMapReader) Bytes() ([]byte, error)

Bytes returns a mapped region of data

func (*MMapReader) Close

func (r *MMapReader) Close() error

Close releases unmap of the chosen region

func (*MMapReader) ReadAt

func (r *MMapReader) ReadAt(p []byte, off int64) (int, error)

ReadAt reads and copies data to p from the offset off

Jump to

Keyboard shortcuts

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