fio

package
v0.0.0-...-d2c5623 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: GPL-3.0, GPL-3.0-or-later Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const DataFilePerm = 0644

Variables

This section is empty.

Functions

This section is empty.

Types

type FileIOType

type FileIOType byte
const (
	FIOStandar   FileIOType = iota // 标准文件 IO
	FIOMemoryMap                   // 内存映射文件 IO
)

type FileIo

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

FileIo 标准系统文件 IO

func NewFileManager

func NewFileManager(filename string) (*FileIo, error)

NewFileManager 初始化标准文件 IO

func (*FileIo) Close

func (fio *FileIo) Close() error

func (*FileIo) Read

func (fio *FileIo) Read(b []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(b []byte) (int, error)

type IOManager

type IOManager interface {
	// Read 从文件的给定位置读取数据
	Read([]byte, int64) (int, error)
	// Write 写入字节数组到文件中
	Write([]byte) (int, error)
	// Sync 持久化数据
	Sync() error
	// Close 关闭文件
	Close() error

	// Size 返回文件大小
	Size() (int64, error)
}

IOManager 抽象文件 IO 接口, 可以接入不同的文件 IO 类型,目前支持标准文件 IO

func NewIOManager

func NewIOManager(filePath string, ioType FileIOType) (IOManager, error)

NewIOManager 初始化 IOManager, 当前仅支持标准文件 IO

type MMap

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

MMap IO, 内存映射文件 IO

func NewMMapIOManager

func NewMMapIOManager(filename string) (*MMap, error)

NewMMapIOManager 初始化内存映射文件 IO

func (*MMap) Close

func (m *MMap) Close() error

func (*MMap) Read

func (m *MMap) Read(bytes []byte, i int64) (int, error)

func (*MMap) Size

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

func (*MMap) Sync

func (m *MMap) Sync() error

func (*MMap) Write

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

Jump to

Keyboard shortcuts

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