io_handler

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DataFilePermission fs.FileMode = 0644

DataFilePermission permission of every single data file

Variables

This section is empty.

Functions

This section is empty.

Types

type FileIO

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

FileIO Standard file I/O

func NewFileIO

func NewFileIO(filePath string) (*FileIO, error)

func (*FileIO) Close

func (fio *FileIO) Close() error

func (*FileIO) Read

func (fio *FileIO) Read(data []byte, offset int64) (int, error)

func (*FileIO) Size

func (fio *FileIO) Size() (int64, error)

func (*FileIO) Sync

func (fio *FileIO) Sync() error

func (*FileIO) Write

func (fio *FileIO) Write(data []byte) (int, error)

type IOHandler

type IOHandler interface {
	// Read Read corresponding data from the specific position of a file
	Read([]byte, int64) (int, error)
	// Write Write data to a file
	Write([]byte) (int, error)
	// Sync Persistent data
	Sync() error
	// Close Close a file
	Close() error
	// Size Get the size of a data file (unit: B)
	Size() (int64, error)
}

IOHandler Abstract I/O interface

func NewIOHandler

func NewIOHandler(t IOHandlerType, filePath string) (IOHandler, error)

NewIOHandler Constructs an IOHandler, such as FileIO

type IOHandlerType

type IOHandlerType = int8
const (
	FileIOHandler IOHandlerType = iota + 1
	MMapIOHandler
)

type MMap

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

MMap in-memory mapper

func NewMMap

func NewMMap(filePath string) (*MMap, error)

NewMMap initializes a MMap

func (*MMap) Close

func (m *MMap) Close() error

Close Close a file

func (*MMap) Read

func (m *MMap) Read(b []byte, n int64) (int, error)

Read Read corresponding data from the specific position of a file

func (*MMap) Size

func (m *MMap) Size() (int64, error)

Size Get the size of a data file (unit: B)

func (*MMap) Sync

func (m *MMap) Sync() error

Sync Persistent data

func (*MMap) Write

func (m *MMap) Write(b []byte) (int, error)

Write Write data to a file

Jump to

Keyboard shortcuts

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