codec

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeMetadata

func EncodeMetadata(meta *Metadata) ([]byte, error)

EncodeMetadata encodes metadata into JSON format.

Types

type ChunkEntry

type ChunkEntry struct {
	Location [3]uint               `json:"loc"`
	Time     [2]uint               `json:"time"`
	Actors   map[uint32]IndexEntry `json:"act,omitempty"`
}

ChunkEntry represents a chunk entry stored in metadata.

func NewChunkEntry

func NewChunkEntry(offset uint64, bitmapSize, logSize uint32, startTime, endTime uint32, actors map[uint32]IndexEntry) ChunkEntry

NewChunkEntry creates a new chunk entry.

func (ChunkEntry) Between

func (e ChunkEntry) Between(start, end uint32) bool

Between checks if the chunk overlaps with the given time range.

func (ChunkEntry) BitmapAt

func (e ChunkEntry) BitmapAt() uint32

BitmapAt calculates the offset to the bitmap section within the merged file.

func (ChunkEntry) BitmapSize

func (e ChunkEntry) BitmapSize() uint32

BitmapSize returns the bitmap size.

func (ChunkEntry) DataAt

func (e ChunkEntry) DataAt() uint32

DataAt calculates the offset to the log section within the merged file.

func (ChunkEntry) DataSize

func (e ChunkEntry) DataSize() uint32

DataSize returns the log size.

func (ChunkEntry) From

func (e ChunkEntry) From() uint32

From returns the chunk start time in seconds.

func (ChunkEntry) Offset

func (e ChunkEntry) Offset() uint64

Offset returns the chunk offset.

func (ChunkEntry) Size

func (e ChunkEntry) Size() uint32

Size calculates the total size of the merged file.

func (ChunkEntry) Until

func (e ChunkEntry) Until() uint32

Until returns the chunk end time in seconds.

type Codec

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

Codec handles ZSTD compression and decompression operations.

func NewCodec

func NewCodec() (*Codec, error)

NewCodec creates a new codec with ZSTD encoder and decoder.

func (*Codec) Close

func (c *Codec) Close()

Close closes the encoder and decoder.

func (*Codec) Compress

func (c *Codec) Compress(data []byte) ([]byte, error)

Compress compresses data using ZSTD compression.

func (*Codec) Decompress

func (c *Codec) Decompress(compressed []byte) ([]byte, error)

Decompress decompresses ZSTD compressed data.

type CompressionError

type CompressionError struct {
	Operation string
	Err       error
}

CompressionError represents a compression/decompression error.

func (*CompressionError) Error

func (e *CompressionError) Error() string

func (*CompressionError) Unwrap

func (e *CompressionError) Unwrap() error

type IndexEntry

type IndexEntry [3]uint

IndexEntry represents metadata about an actor bitmap within a chunk.

func NewIndexEntry

func NewIndexEntry(timestamp uint32, offset uint64, size uint32) IndexEntry

NewIndexEntry allocates a new index entry.

type LogEntry

type LogEntry []byte

LogEntry represents a single log entry as raw bytes

func NewLogEntry

func NewLogEntry(sequenceID uint32, text string, actors []uint32) (LogEntry, error)

NewLogEntry creates a new log entry from components

func (LogEntry) Actors

func (e LogEntry) Actors() iter.Seq[uint32]

Actors extracts the actor IDs from a log entry as an iterator

func (LogEntry) ID

func (e LogEntry) ID() uint32

ID extracts the sequence ID from a log entry

func (LogEntry) Size

func (e LogEntry) Size() uint32

ID extracts the sequence ID from a log entry Size returns the total size of the log entry in bytes.

func (LogEntry) Text

func (e LogEntry) Text() string

Text extracts the text from a log entry

func (LogEntry) Time

func (e LogEntry) Time(dayStart time.Time) time.Time

ID extracts the sequence ID from a log entry Time reconstructs the timestamp from the day-start and sequence ID.

type Metadata

type Metadata struct {
	Date   int64        `json:"date"`
	Length uint32       `json:"length"`
	Chunks []ChunkEntry `json:"chunks"`
}

Metadata represents the metadata structure for log files.

func DecodeMetadata

func DecodeMetadata(data []byte) (*Metadata, error)

DecodeMetadata decodes metadata from JSON format.

func NewMetadata

func NewMetadata(dayStart time.Time) *Metadata

NewMetadata creates a new metadata instance with default values.

func (*Metadata) Append

func (m *Metadata) Append(offset uint64, bitmapSize, logSize uint32, startTime, endTime uint32, actors map[uint32]IndexEntry) *Metadata

Append adds a new chunk with section sizes.

Jump to

Keyboard shortcuts

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