Documentation
¶
Index ¶
- type BaseSelectionType
- type BinaryDelta
- type DeltaAlgorithm
- type DeltaChain
- type DeltaCompression
- func (dc *DeltaCompression) Compress(data []byte) []byte
- func (dc *DeltaCompression) GetStats() DeltaStats
- func (dc *DeltaCompression) GetWithDelta(hash string) ([]byte, bool, error)
- func (dc *DeltaCompression) OptimizeChains()
- func (dc *DeltaCompression) StoreWithDelta(hash string, data []byte) (*DeltaEntry, bool, error)
- type DeltaEntry
- type DeltaInstruction
- type DeltaMatch
- type DeltaPacket
- type DeltaStats
- type DeltaType
- type InstructionType
- type VCDIFFDelta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseSelectionType ¶
type BaseSelectionType int
BaseSelectionType defines algorithms for selecting base objects
const ( BaseSelectionSimilarity BaseSelectionType = iota // Select most similar object BaseSelectionRecent // Select most recent object BaseSelectionFrequent // Select most frequently accessed BaseSelectionHybrid // Combination of factors )
type BinaryDelta ¶
type BinaryDelta struct {
// contains filtered or unexported fields
}
BinaryDelta implements simple binary delta compression
func NewBinaryDelta ¶
func NewBinaryDelta(blockSize int) *BinaryDelta
BinaryDelta implements simple binary delta compression
func (*BinaryDelta) ApplyDelta ¶
func (bd *BinaryDelta) ApplyDelta(baseData, deltaData []byte) ([]byte, error)
ApplyDelta applies binary delta
func (*BinaryDelta) CompressionRatio ¶
func (bd *BinaryDelta) CompressionRatio(baseData, targetData, deltaData []byte) float64
CompressionRatio calculates compression ratio
func (*BinaryDelta) CreateDelta ¶
func (bd *BinaryDelta) CreateDelta(baseData, targetData []byte) ([]byte, error)
CreateDelta creates a simple binary delta
type DeltaAlgorithm ¶
type DeltaAlgorithm interface {
CreateDelta(baseData, targetData []byte) ([]byte, error)
ApplyDelta(baseData, deltaData []byte) ([]byte, error)
CompressionRatio(baseData, targetData, deltaData []byte) float64
}
DeltaAlgorithm defines interface for delta algorithms
type DeltaChain ¶
type DeltaChain struct {
BaseHash string `json:"base_hash"` // Hash of base object
Deltas []*DeltaEntry `json:"deltas"` // Ordered list of deltas
TotalSize int `json:"total_size"` // Total size of all deltas
ChainLength int `json:"chain_length"` // Current chain length
LastAccess time.Time `json:"last_access"` // Last access time
}
DeltaChain manages a sequence of deltas
type DeltaCompression ¶
type DeltaCompression struct {
// contains filtered or unexported fields
}
DeltaCompression provides efficient storage for high-frequency commits Critical for reducing storage overhead in MMO applications with 72K commits/hour
func NewDeltaCompression ¶
func NewDeltaCompression() *DeltaCompression
NewDeltaCompression creates a new delta compression system
func (*DeltaCompression) Compress ¶
func (dc *DeltaCompression) Compress(data []byte) []byte
Compress applies delta compression to data
func (*DeltaCompression) GetStats ¶
func (dc *DeltaCompression) GetStats() DeltaStats
GetStats returns current delta compression statistics
func (*DeltaCompression) GetWithDelta ¶
func (dc *DeltaCompression) GetWithDelta(hash string) ([]byte, bool, error)
GetWithDelta retrieves an object, decompressing deltas if necessary
func (*DeltaCompression) OptimizeChains ¶
func (dc *DeltaCompression) OptimizeChains()
OptimizeChains optimizes delta chains for better performance
func (*DeltaCompression) StoreWithDelta ¶
func (dc *DeltaCompression) StoreWithDelta(hash string, data []byte) (*DeltaEntry, bool, error)
StoreWithDelta stores an object using delta compression if beneficial
type DeltaEntry ¶
type DeltaEntry struct {
Hash string `json:"hash"` // Hash of the delta object
BaseHash string `json:"base_hash"` // Hash of the base object
DeltaData []byte `json:"delta_data"` // Compressed delta
OriginalSize int `json:"original_size"` // Size of original object
DeltaSize int `json:"delta_size"` // Size of delta
CreatedAt time.Time `json:"created_at"` // When delta was created
AccessCount int64 `json:"access_count"` // How often accessed
ChainDepth int `json:"chain_depth"` // Depth in delta chain
}
DeltaEntry represents a compressed delta
type DeltaInstruction ¶
type DeltaInstruction struct {
Type InstructionType `json:"type"`
Offset int `json:"offset,omitempty"` // For copy instructions
Length int `json:"length"`
Data []byte `json:"data,omitempty"` // For add instructions
}
DeltaInstruction represents a delta instruction
type DeltaMatch ¶
type DeltaMatch struct {
BaseStart int `json:"base_start"`
TargetStart int `json:"target_start"`
Length int `json:"length"`
}
DeltaMatch represents a match found during delta creation
type DeltaPacket ¶
type DeltaPacket struct {
Type DeltaType `json:"type"`
BaseSize int `json:"base_size,omitempty"`
TargetSize int `json:"target_size,omitempty"`
Length int `json:"length,omitempty"` // For full type
Data []byte `json:"data,omitempty"` // For full type
Instructions []*DeltaInstruction `json:"instructions,omitempty"` // For delta type
}
DeltaPacket represents a delta packet
func ParseDeltaPacket ¶
func ParseDeltaPacket(data []byte) (*DeltaPacket, error)
ParseDeltaPacket parses binary delta packet
func (*DeltaPacket) Serialize ¶
func (dp *DeltaPacket) Serialize() []byte
Serialize converts delta packet to binary format
type DeltaStats ¶
type DeltaStats struct {
TotalObjects int64 `json:"total_objects"`
DeltaObjects int64 `json:"delta_objects"`
BaseObjects int64 `json:"base_objects"`
TotalOriginalSize int64 `json:"total_original_size"`
TotalCompressedSize int64 `json:"total_compressed_size"`
CompressionRatio float64 `json:"compression_ratio"`
AverageChainLength float64 `json:"average_chain_length"`
DeltaCreations int64 `json:"delta_creations"`
BasePromotions int64 `json:"base_promotions"`
ChainBreaks int64 `json:"chain_breaks"`
DecompressionTime time.Duration `json:"decompression_time"`
CompressionTime time.Duration `json:"compression_time"`
}
DeltaStats tracks compression statistics
type InstructionType ¶
type InstructionType byte
InstructionType defines delta instruction types
const ( InstructionTypeAdd InstructionType = 0x01 // Add literal data InstructionTypeCopy InstructionType = 0x02 // Copy from base )
type VCDIFFDelta ¶
type VCDIFFDelta struct {
// contains filtered or unexported fields
}
VCDIFFDelta implements VCDIFF-based delta compression
func NewVCDIFFDelta ¶
func NewVCDIFFDelta(windowSize, minMatchSize int) *VCDIFFDelta
VCDIFFDelta implements VCDIFF-inspired delta compression
func (*VCDIFFDelta) ApplyDelta ¶
func (vd *VCDIFFDelta) ApplyDelta(baseData, deltaData []byte) ([]byte, error)
ApplyDelta applies delta to base data to reconstruct target
func (*VCDIFFDelta) CompressionRatio ¶
func (vd *VCDIFFDelta) CompressionRatio(baseData, targetData, deltaData []byte) float64
CompressionRatio calculates the compression ratio
func (*VCDIFFDelta) CreateDelta ¶
func (vd *VCDIFFDelta) CreateDelta(baseData, targetData []byte) ([]byte, error)
CreateDelta creates a delta from base to target using VCDIFF-inspired algorithm