disk

package
v0.58.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package disk implements read write fraction routines

Index

Constants

View Source
const (
	DocBlockHeaderLen = 33
)
View Source
const (
	IndexBlockHeaderSize = 33
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockFormer

type BlockFormer struct {
	Buf []byte
	// contains filtered or unexported fields
}

func NewBlockFormer

func NewBlockFormer(blockType string, writer *BlocksWriter, blockSize int, buf []byte) *BlockFormer

func (*BlockFormer) FlushForced

func (b *BlockFormer) FlushForced(options ...FlushOption) error

func (*BlockFormer) FlushIfNeeded

func (b *BlockFormer) FlushIfNeeded(options ...FlushOption) (bool, error)

func (*BlockFormer) GetStats

func (b *BlockFormer) GetStats() *BlockStats

type BlockStats

type BlockStats struct {
	Name     string
	Raw      uint64
	Comp     uint64
	Blocks   uint64
	Duration time.Duration
}

func (*BlockStats) WriteLogs

func (s *BlockStats) WriteLogs()

type BlocksWriter

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

func NewBlocksWriter

func NewBlocksWriter(ws io.WriteSeeker) *BlocksWriter

func (*BlocksWriter) GetBlockIndex

func (w *BlocksWriter) GetBlockIndex() uint32

func (*BlocksWriter) WriteBlock

func (w *BlocksWriter) WriteBlock(blockType string, data []byte, compress bool, zstdLevel int, ext1, ext2 uint64) (uint32, error)

func (*BlocksWriter) WriteBlocksRegistry

func (w *BlocksWriter) WriteBlocksRegistry() error

func (*BlocksWriter) WriteEmptyBlock

func (w *BlocksWriter) WriteEmptyBlock()

type Codec

type Codec byte
const (
	CodecNo Codec = iota
	CodecLZ4
	CodecZSTD
)

type DocBlock

type DocBlock []byte

func CompressDocBlock

func CompressDocBlock(src []byte, dst DocBlock, zstdLevel int) DocBlock

func NewBlock

func NewBlock() DocBlock

func PackDocBlock

func PackDocBlock(payload []byte, dst DocBlock) DocBlock

func (DocBlock) CalcLen

func (b DocBlock) CalcLen()

func (DocBlock) Codec

func (b DocBlock) Codec() Codec

func (DocBlock) DecompressTo

func (b DocBlock) DecompressTo(dst []byte) ([]byte, error)

DecompressTo always put the result in `dst` regardless of whether unpacking is required or part of the DocBlock can be enough.

So DocBlock does not share the same data with `dst` and can be used safely

func (DocBlock) FullLen

func (b DocBlock) FullLen() uint64

func (DocBlock) GetExt1

func (b DocBlock) GetExt1() uint64

func (DocBlock) GetExt2

func (b DocBlock) GetExt2() uint64

func (DocBlock) Len

func (b DocBlock) Len() uint64

func (DocBlock) Payload

func (b DocBlock) Payload() []byte

func (DocBlock) RawLen

func (b DocBlock) RawLen() uint64

func (DocBlock) SetCodec

func (b DocBlock) SetCodec(codecVal Codec)

func (DocBlock) SetExt1

func (b DocBlock) SetExt1(x uint64)

func (DocBlock) SetExt2

func (b DocBlock) SetExt2(x uint64)

func (DocBlock) SetLen

func (b DocBlock) SetLen(val uint64)

func (DocBlock) SetRawLen

func (b DocBlock) SetRawLen(x uint64)

type DocBlocksReader

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

func NewDocBlocksReader

func NewDocBlocksReader(reader *ReadLimiter, file *os.File) DocBlocksReader

func (*DocBlocksReader) ReadDocBlock

func (r *DocBlocksReader) ReadDocBlock(offset int64) ([]byte, uint64, error)

func (*DocBlocksReader) ReadDocBlockPayload

func (r *DocBlocksReader) ReadDocBlockPayload(offset int64) ([]byte, uint64, error)

type DocsReader

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

func NewDocsReader

func NewDocsReader(reader *ReadLimiter, file *os.File, docsCache *cache.Cache[[]byte]) DocsReader

func (*DocsReader) ReadDocs

func (r *DocsReader) ReadDocs(blockOffset uint64, docOffsets []uint64) ([][]byte, error)

func (*DocsReader) ReadDocsFunc

func (r *DocsReader) ReadDocsFunc(blockOffset uint64, docOffsets []uint64, cb func([]byte) error) error

type FlushOption

type FlushOption func(*FlushOptions)

func WithExt

func WithExt(ext1, ext2 uint64) FlushOption

func WithZstdCompressLevel

func WithZstdCompressLevel(level int) FlushOption

type FlushOptions

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

func NewDefaultFlushOptions

func NewDefaultFlushOptions() *FlushOptions

type IndexBlockHeader

type IndexBlockHeader []byte

func NewEmptyIndexBlockHeader

func NewEmptyIndexBlockHeader() IndexBlockHeader

func NewIndexBlockHeader

func NewIndexBlockHeader(pos int64, ext1, ext2 uint64, origBuff, finalBuf []byte, codec Codec) IndexBlockHeader

func (IndexBlockHeader) Codec

func (b IndexBlockHeader) Codec() Codec

func (IndexBlockHeader) GetExt1

func (b IndexBlockHeader) GetExt1() uint64

func (IndexBlockHeader) GetExt2

func (b IndexBlockHeader) GetExt2() uint64

func (IndexBlockHeader) GetPos

func (b IndexBlockHeader) GetPos() uint64

func (IndexBlockHeader) Len

func (b IndexBlockHeader) Len() uint32

func (IndexBlockHeader) RawLen

func (b IndexBlockHeader) RawLen() uint32

func (IndexBlockHeader) SetCodec

func (b IndexBlockHeader) SetCodec(codecVal Codec)

func (IndexBlockHeader) SetExt1

func (b IndexBlockHeader) SetExt1(x uint64)

func (IndexBlockHeader) SetExt2

func (b IndexBlockHeader) SetExt2(x uint64)

func (IndexBlockHeader) SetLen

func (b IndexBlockHeader) SetLen(val uint32)

func (IndexBlockHeader) SetPos

func (b IndexBlockHeader) SetPos(x uint64)

func (IndexBlockHeader) SetRawLen

func (b IndexBlockHeader) SetRawLen(x uint32)

type IndexReader

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

func NewIndexReader

func NewIndexReader(reader *ReadLimiter, file *os.File, registryCache *cache.Cache[[]byte]) IndexReader

func (*IndexReader) GetBlockHeader

func (r *IndexReader) GetBlockHeader(index uint32) (IndexBlockHeader, error)

func (*IndexReader) ReadIndexBlock

func (r *IndexReader) ReadIndexBlock(blockIndex uint32, dst []byte) ([]byte, uint64, error)

type ReadLimiter

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

func NewReadLimiter

func NewReadLimiter(maxReadsNum int, counter prometheus.Counter) *ReadLimiter

func (*ReadLimiter) ReadAt

func (r *ReadLimiter) ReadAt(f *os.File, buf []byte, offset int64) (int, error)

type SealingStats

type SealingStats []*BlockStats

func (SealingStats) WriteLogs

func (s SealingStats) WriteLogs()

Jump to

Keyboard shortcuts

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