Documentation ¶
Index ¶
- Constants
- Variables
- func AssertTrue(b bool)
- func Copy(a []byte) []byte
- func CreateSyncedFile(filename string, sync bool) (*os.File, error)
- func FileSync(f *os.File) error
- func Madvise(b []byte, readahead bool) error
- func Mmap(fd *os.File, writable bool, size int64) ([]byte, error)
- func Munmap(b []byte) error
- func OpenExistingFile(filename string, flags uint32) (*os.File, error)
- func OpenSyncedFile(filename string, sync bool) (*os.File, error)
- func OpenTruncFile(filename string, sync bool) (*os.File, error)
- func SafeCopy(a, src []byte) []byte
- func Wrap(err error) error
- func Wrapf(err error, format string, args ...interface{}) error
- type Closer
- type FileLoadingMode
- type Throttle
Constants ¶
const ( // Sync indicates that O_DSYNC should be set on the underlying file, // ensuring that data writes do not return until the data is flushed // to disk. Sync = 1 << iota // ReadOnly opens the underlying file on a read-only basis. ReadOnly )
Variables ¶
var ErrEOF = errors.New("End of mapped region")
ErrEOF indicates an end of file when trying to read from a memory mapped file and encountering the end of slice.
Functions ¶
func AssertTrue ¶
func AssertTrue(b bool)
AssertTrue asserts that b is true. Otherwise, it would log fatal.
func CreateSyncedFile ¶
CreateSyncedFile creates a new file (using O_EXCL), errors if it already existed.
func FileSync ¶
FileSync calls os.File.Sync with the right parameters. This function can be removed once we stop supporting Go 1.11 on MacOS.
More info: https://golang.org/issue/26650.
func Madvise ¶
Madvise uses the madvise system call to give advise about the use of memory when using a slice that is memory-mapped to a file. Set the readahead flag to false if page references are expected in random order.
func Mmap ¶
Mmap uses the mmap system call to memory-map a file. If writable is true, memory protection of the pages is set so that they may be written to as well.
func OpenExistingFile ¶
OpenExistingFile opens an existing file, errors if it doesn't exist.
func OpenSyncedFile ¶
OpenSyncedFile creates the file if one doesn't exist.
func OpenTruncFile ¶
OpenTruncFile opens the file with O_RDWR | O_CREATE | O_TRUNC
Types ¶
type Closer ¶
type Closer struct {
// contains filtered or unexported fields
}
Closer holds the two things we need to close a goroutine and wait for it to finish: a chan to tell the goroutine to shut down, and a WaitGroup with which to wait for it to finish shutting down.
func (*Closer) AddRunning ¶
AddRunning Add()'s delta to the WaitGroup.
func (*Closer) HasBeenClosed ¶
func (lc *Closer) HasBeenClosed() <-chan struct{}
HasBeenClosed gets signaled when Signal() is called.
func (*Closer) SignalAndWait ¶
func (lc *Closer) SignalAndWait()
SignalAndWait calls Signal(), then Wait().
type FileLoadingMode ¶
type FileLoadingMode int
FileLoadingMode specifies how data in LSM table files and value log files should be loaded.
const ( // FileIO indicates that files must be loaded using standard I/O FileIO FileLoadingMode = iota // LoadToRAM indicates that file must be loaded into RAM LoadToRAM // MemoryMap indicates that that the file must be memory-mapped MemoryMap )
type Throttle ¶
type Throttle struct {
// contains filtered or unexported fields
}
Throttle allows a limited number of workers to run at a time. It also provides a mechanism to check for errors encountered by workers and wait for them to finish.
func NewThrottle ¶
NewThrottle creates a new throttle with a max number of workers.
func (*Throttle) Do ¶
Do should be called by workers before they start working. It blocks if there are already maximum number of workers working. If it detects an error from previously Done workers, it would return it.
func (*Throttle) Done ¶
Done should be called by workers when they finish working. They can also pass the error status of work done.