fio

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DataFilePerm = 0644 //0644 表示创建了一个文件,文件所有者可以读写,其他人只能读
View Source
const DefaultMemMapSize = 256 * 1024 * 1024

DefaultMemMapSize 最大映射内存大小

Variables

This section is empty.

Functions

This section is empty.

Types

type Bufio

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

Bufio File IO with buffer

func NewBufIOManager

func NewBufIOManager(path string) (*Bufio, error)

NewBufIOManager init Bufio

func (*Bufio) Close

func (b *Bufio) Close() error

Close file

func (*Bufio) Flush

func (b *Bufio) Flush() error

Flush buffer

func (*Bufio) Read

func (b *Bufio) Read(bytes []byte, offset int64) (int, error)

Read bytes from offset

func (*Bufio) Size

func (b *Bufio) Size() (int64, error)

Size of file

func (*Bufio) Sync

func (b *Bufio) Sync() error

Sync file

func (*Bufio) Write

func (b *Bufio) Write(bytes []byte) (int, error)

Write bytes to file

type FileIO

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

FileIO 标准系统文件IO

func NewFileIOManager

func NewFileIOManager(fileName string) (*FileIO, error)

NewFileIOManager 初始化标准文件 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 get file size
	Size() (int64, error)
}

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

func NewIOManager

func NewIOManager(filename string) (IOManager, error)

type MMapIO added in v1.0.4

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

MMapIO 标准系统文件IO

func NewMMapIOManager added in v1.0.4

func NewMMapIOManager(fileName string) (*MMapIO, error)

NewMMapIOManager 初始化标准文件 IO

func (*MMapIO) Close added in v1.0.4

func (mio *MMapIO) Close() (err error)

func (*MMapIO) Read added in v1.0.4

func (mio *MMapIO) Read(b []byte, offset int64) (int, error)

func (*MMapIO) Size added in v1.0.4

func (mio *MMapIO) Size() (int64, error)

func (*MMapIO) Sync added in v1.0.4

func (mio *MMapIO) Sync() error

func (*MMapIO) UnMap added in v1.0.4

func (mio *MMapIO) UnMap() error

func (*MMapIO) Write added in v1.0.4

func (mio *MMapIO) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

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