Documentation ¶
Index ¶
- Constants
- Variables
- func NewBlockAndHeader() interface{}
- func SegmentFileName(dirPath string, fileSuffix string, id uint32) string
- type BlockAndHeader
- type BlockID
- type ChunkPosition
- type ChunkType
- type Options
- type Reader
- type Segment
- func (s *Segment) Close() error
- func (s *Segment) NewSegmentReader() *SegmentReader
- func (s *Segment) Read(blockID BlockID, chunkOffset int64) ([]byte, error)
- func (s *Segment) Remove() error
- func (s *Segment) Size() uint64
- func (s *Segment) Sync() error
- func (s *Segment) Write(data []byte) (pos *ChunkPosition, err error)
- func (s *Segment) WriteAll(data [][]byte) (positions []*ChunkPosition, err error)
- type SegmentID
- type SegmentReader
- type WAL
- func (wal *WAL) Close() error
- func (wal *WAL) Delete() error
- func (wal *WAL) GetActiveSegmentID() SegmentID
- func (wal *WAL) IsEmpty() bool
- func (wal *WAL) NewReader() *Reader
- func (wal *WAL) NewReaderWithMax(sid SegmentID) *Reader
- func (wal *WAL) NewReaderWithStart(pos *ChunkPosition) (*Reader, error)
- func (wal *WAL) Read(pos *ChunkPosition) ([]byte, error)
- func (wal *WAL) Sync() error
- func (wal *WAL) Write(data []byte) (*ChunkPosition, error)
Constants ¶
View Source
const ( B = 1 KB = 1024 * B MB = 1024 * KB GB = 1024 * MB )
View Source
const ( CHUNK_HEADER_SIZE = 7 * B // chunk header is CRC(4B), length(2B), type(1B) BLOCK_SIZE = 32 * KB // block size is 32KB FILE_MODE_PERM = 0644 // mode: -rx-r--r-- MAX_LEN = binary.MaxVarintLen32*3 + binary.MaxVarintLen64 )
View Source
const (
INITIAL_SEGMENT_ID = 0
)
Variables ¶
View Source
var ( ErrClosed = errors.New("the segment file is closed") ErrCRC = errors.New("invalid crc, the data may be corrupted") )
Functions ¶
func NewBlockAndHeader ¶
func NewBlockAndHeader() interface{}
Types ¶
type BlockAndHeader ¶
type BlockAndHeader struct {
// contains filtered or unexported fields
}
type ChunkPosition ¶
type ChunkPosition struct { SegmentId SegmentID BlockId BlockID ChunkOffset int64 ChunkSize uint32 }
func DecodeChunkPosition ¶
func DecodeChunkPosition(buf []byte) *ChunkPosition
func (*ChunkPosition) Encode ¶
func (cp *ChunkPosition) Encode() []byte
func (*ChunkPosition) EncodeFixedSize ¶
func (cp *ChunkPosition) EncodeFixedSize() []byte
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
func (*Reader) CurrentChunkPosition ¶
func (r *Reader) CurrentChunkPosition() *ChunkPosition
func (*Reader) CurrentSegmentId ¶
func (*Reader) SkipCurrentSegment ¶
func (r *Reader) SkipCurrentSegment()
type Segment ¶
type Segment struct {
// contains filtered or unexported fields
}
func OpenSegmentFile ¶
func (*Segment) NewSegmentReader ¶
func (s *Segment) NewSegmentReader() *SegmentReader
type SegmentReader ¶
type SegmentReader struct {
// contains filtered or unexported fields
}
func (*SegmentReader) Next ¶
func (r *SegmentReader) Next() ([]byte, *ChunkPosition, error)
type WAL ¶
type WAL struct {
// contains filtered or unexported fields
}
func (*WAL) GetActiveSegmentID ¶
func (*WAL) NewReaderWithMax ¶
func (*WAL) NewReaderWithStart ¶
func (wal *WAL) NewReaderWithStart(pos *ChunkPosition) (*Reader, error)
Click to show internal directories.
Click to hide internal directories.