-
Notifications
You must be signed in to change notification settings - Fork 0
Storage Compression Subsystem
github-actions[bot] edited this page Jun 27, 2026
·
1 revision
The io.github.solaceharmony.core.storage.compression package in jvmMain provides a mechanism to transparently compress and decompress data being persisted through the Storage interface.
This interface defines the contract for various compression and serialization algorithms.
- Purpose: To allow pluggable strategies for data compression and the necessary serialization/deserialization steps before/after compression.
-
Key Methods:
-
fun compress(data: ByteArray): ByteArray: Compresses the input byte array. -
fun decompress(data: ByteArray): ByteArray: Decompresses the input byte array. -
fun serialize(value: Any): ByteArray: Converts an arbitrary object into a byte array suitable for compression. -
fun <T> deserialize(data: ByteArray, clazz: Class<T>): T: Converts a byte array (typically after decompression) back into an object of typeT, requiring theClass<T>due to JVM type erasure.
-
A concrete implementation of CompressionStrategy using the GZIP algorithm.
-
Compression/Decompression: Uses
java.util.zip.GZIPOutputStreamandjava.util.zip.GZIPInputStream. Thecompressmethod only returns compressed data if it's smaller than the original. -
Serialization/Deserialization:
- Uses
kotlinx.serialization.json.Json(configured withignoreUnknownKeys = true,isLenient = true). -
serialize(value: Any): HandlesByteArray,String, and primitive types directly. ForMap<*, *>it builds aJsonObject. Other types are attempted to be JSON serialized directly; on failure, it falls back to serializingvalue.toString()(potentially wrapped). -
deserialize<T>(data: ByteArray, clazz: Class<T>): HandlesByteArray,String, and primitives. ForMap, it manually parses the JSON. For other types, it attempts to deserialize a wrapped string or, as a last resort, returns the raw string ifclazzisString.
- Uses
A decorator class that wraps an existing Storage<K, V> implementation to add compression capabilities.
-
Implements:
Storage<K, V>. -
Constructor:
CompressedStorage<K, V>(storage: Storage<K, V>, compressionStrategy: CompressionStrategy = GZIPCompressionStrategy(), compressionThreshold: Int = 1024, valueClass: Class<V>)-
storage: The underlying storage instance. -
compressionStrategy: The strategy for compression/decompression and serialization/deserialization (defaults toGZIPCompressionStrategy). -
compressionThreshold: Values (in bytes, after serialization) smaller than this threshold will not be compressed (default 1KB). -
valueClass: Class<V>: Required for type-safe deserialization by theCompressionStrategy.
-
-
Operation:
-
store():- Serializes the value using
compressionStrategy.serialize(). - If the serialized size meets the
compressionThreshold, it compresses the data usingcompressionStrategy.compress(). - Stores special metadata keys:
COMPRESSED_KEY: BooleanandORIGINAL_SIZE_KEY: Int. - Delegates to the underlying
storage.store()with the (potentially compressed) value and augmented metadata.
- Serializes the value using
-
retrieve():- Retrieves data and metadata from the underlying
storage. - Checks the
COMPRESSED_KEYin metadata. - If compressed, it decompresses using
compressionStrategy.decompress()and then deserializes usingcompressionStrategy.deserialize(decompressedData, valueClass).
- Retrieves data and metadata from the underlying
- Other
Storagemethods (listKeys,delete,exists) largely delegate to the underlying storage, withupdateMetadatataking care to preserve compression-related metadata.
-
-
Additional Functionality: Provides methods like
getCompressionRatio(key)to inspect compression effectiveness. -
Thread Safety: Uses a
Mutexfor compression-related operations andDispatchers.IOfor underlying storage calls.
classDiagram
direction LR
package "io.github.solaceharmony.core.storage" {
interface "Storage<K, V>" { <<Interface>> }
}
package "io.github.solaceharmony.core.storage.compression" {
interface CompressionStrategy {
<<Interface>>
+compress(data: ByteArray): ByteArray
+decompress(data: ByteArray): ByteArray
+serialize(value: Any): ByteArray
+deserialize(data: ByteArray, clazz: Class<T>): T
}
class GZIPCompressionStrategy {
+compress(data: ByteArray): ByteArray
+decompress(data: ByteArray): ByteArray
+serialize(value: Any): ByteArray
+deserialize(data: ByteArray, clazz: Class<T>): T
}
CompressionStrategy <|-- GZIPCompressionStrategy
class "CompressedStorage<K, V>" {
-storage: Storage<K, V>
-compressionStrategy: CompressionStrategy
-compressionThreshold: Int
-valueClass: Class<V>
+store(key: K, value: V, metadata: Map): Boolean
+retrieve(key: K): Pair<V, Map>?
}
"Storage<K, V>" <|-- "CompressedStorage<K, V>"
"CompressedStorage" o-- "Storage" : decorates
"CompressedStorage" o-- CompressionStrategy : uses
}
SolaceCore SSOT wiki · published from wiki/ by .github/workflows/publish-wiki.yml · edit the source in the repo, not the wiki.
Orientation
- Architectural Deep Dive
- Architecture Overview
- Design vs Implementation
- Framework Actor System
- Framework Architectural Vision
- Framework Concurrency and Communication
- Framework Data Storage and Management
- Framework Deployment and Containerization
- Framework Development Roadmap
- Framework Hot-Pluggable System
- Framework Implementation Status
- Framework Observability and Monitoring
- Framework Port System
- Framework System Architecture
- Framework Workflow Management
- Project Status
- Project Status Report
- Quick Status
- Solace Core Framework Architecture
- SolaceCore Architecture Overview
- Vision & Solace AI
Runtime
- Actor Builder
- Actor Communication Sequence Diagram
- Actor Core Definitions
- Actor Graph View
- Actor Metrics
- Actor Module Architecture
- Actor Queue Hibernation and Correlation
- Actor Roadmap
- Actor State Recovery Subsystem
- Actor State Serialization Subsystem
- Actor Supervision Module
- Actor System Architecture
- Actor System Class Diagram
- Actor Usage Examples
- Compose App Features
- JVM Scripting Implementations
- Kernel & Ports
- Kernel Channel System
- Kernel Future Enhancements
- Kernel Module Architecture
- Kernel Port Implementations and Exceptions
- Kernel Port Usage Example
- Kernel Testing Strategy
- Lifecycle Class Diagram
- Lifecycle Management Architecture
- Pipeline DSL
- Real-Time UI Implementation
- Scripting Module Architecture
- Scripting Module Design
- Scripting Supporting Components
- Shared Memory
- Storage & Persistence
- Storage Abstractions Architecture
- Storage Caching Subsystem
- Storage Checklist
- Storage Compression Subsystem
- Storage Core Interfaces
- Storage Encryption Subsystem
- Storage File-Based Architecture
- Storage File-Based Implementations
- Storage In-Memory Architecture
- Storage In-Memory Implementations
- Storage JVM Serialization Utilities
- Storage Module Architecture
- Storage Serialization Compression Encryption
- Storage Specialized Interfaces Architecture
- Storage Status and Future Plans
- Storage Testing
- Storage Thread Safety Guide
- Storage Thread Safety and Deadlock Prevention
- Storage Transactions
- Storage Usage Examples
- Supervisor and Hot Swap
- SupervisorActor
- System Architecture Diagram
- Workflow Management Architecture
- Workflow Management Design Concept
- Workflow Orchestration
Solace AI
- Confusion Corrector
- Inference Cube
- Inference Cube Technical Architecture
- Long-Term Memory
- MCP and Tool Format
- Memory & Reflection
- Memory Compression
- Memory Feature Overview
- Memory Retrieval
- Mood & Emotional Model
- Mood Module Implementation
- Mouth Tool Technical Spec
- Multimodal Nudging
- Perception Actors
- Provider Specs
- Reflection Memory
- Solace AI Overview
- Supervisor AI
- Supervisor Emotional Model Integration
- Time Actor
- Voice & Mouth Tool
- Working Memory
- Zoom Level Technical Spec
- Zoom Levels
Reference
- Advanced Workflow Example
- Basic Actor Usage
- Build System and Dependencies
- Development Tooling and Practices
- Documentation Catalog
- Documentation Index
- Feature Index
- Glossary
- How the Wiki Publishes
- JVM Utilities
- Kotlin Implementation Details
- Kotlin-Aligned Architecture Overview
- Kotlin-Aligned Contributing
- Kotlin-Aligned Core Architectural Principles
- Kotlin-Aligned Daily Development Workflow
- Kotlin-Aligned Development Examples
- Kotlin-Aligned Development Workflow
- Kotlin-Aligned Documentation
- Kotlin-Aligned Implementation Status
- Kotlin-Aligned Key Concepts
- Kotlin-Aligned Known Issues
- Kotlin-Aligned Quick Start
- Kotlin-Aligned Running the System
- Kotlin-Aligned System Architecture
- LangChain Actor Code Changes
- LangChain Actor Usage Improvements
- LangChain ActorInterface Code Changes
- LangChain Best Practices
- LangChain Bugs
- LangChain Chain Implementation
- LangChain Code Changes
- LangChain Code Changes Rollout and Impact
- LangChain Configuration Management Improvements
- LangChain Configuration Recommendations
- LangChain Core Architecture Recommendations
- LangChain Directory Structure Changes
- LangChain Documentation Improvements
- LangChain Dynamic Wiring Rollout Notes
- LangChain Fix Proposal
- LangChain Implementation Priorities
- LangChain Lifecycle Management Improvements
- LangChain Memory Integration Recommendations
- LangChain Metrics and Observability Recommendations
- LangChain Migration Strategy
- LangChain New Files Needed
- LangChain New Packages to Add
- LangChain Package-by-Package Improvements
- LangChain Patterns
- LangChain Port Code Changes
- LangChain Port System Recommendations
- LangChain Port Usability Improvements
- LangChain Prompt Management Recommendations
- LangChain Recommendations
- LangChain Recommendations Rollout Plan
- LangChain Required Interface Changes
- LangChain Testing Changes
- LangChain Testing Improvements
- LangChain Testing Recommendations
- LangChain Tool Integration Recommendations
- LangChain Type-Safe Dynamic Wiring
- LangChain Type-Safe Dynamic Wiring System
- LangChain Usage Design Improvements
- Master Checklist
- Roadmap
- Roadmap Issues
- Roadmap Phase 1 Stability and Testing
- Roadmap Phase 2 Production Infrastructure
- Roadmap Phase 3 Documentation and Developer Experience
- Roadmap Phase 4 Graph Database Integration
- Roadmap Phase 5 Security Framework
- Roadmap Phase 6 Distributed System
- Roadmap Phase 7 Advanced Features
- Roadmap Phase 8 Ecosystem Development
- Roadmap Timeline and Success Metrics
- Setup Instructions
- Sketch Architecture
- Status Documentation
- Task 1 Core Tests
- Task 2 Connection Wiring
- Task 3 Concurrency Issues
- Task 4 Dynamic Registration
- Task 5 Integration Tests
- Task 6 Deadlock Detection
- Task Documentation
- Test Coverage Checklist
- Testing Strategy