/** * Run-Length Encoding (RLE) for consecutive repetitive values * * Compresses sequences where the same value appears consecutively. * Highly effective for status fields, boolean flags, and categorical data. * * Example: * Original: ["active", "active", "active", "inactive", "inactive"] * RLE: ["active*3", "inactive*2"] * Savings: ~40% for highly repetitive data * * Format: value*count * - Single occurrences remain as-is * - Multiple consecutive occurrences: value*N */ import type { RLEOptions } from './types.js'; /** * Run-length encoding analysis result */ export interface RLEAnalysis { totalRuns: number; avgRunLength: number; maxRunLength: number; compressionRatio: number; recommended: boolean; savings: number; } /** * Run-length encoder for consecutive repetitive values */ export declare class RunLengthEncoder { private options; constructor(options?: Partial); /** * Analyze values for RLE suitability * * @param values - Array of values (any type) * @returns Analysis with recommendations */ analyzeSequence(values: any[]): RLEAnalysis; /** * Encode values using run-length encoding * * @param values - Array of values * @returns Encoded values with run-length notation */ encode(values: any[]): string[]; /** * Encode a single run and append to result array * * @param value - The value * @param count - Number of consecutive occurrences * @param result - Array to append encoded values to */ private encodeRun; /** * Decode run-length encoded values * * @param encoded - RLE-encoded values * @returns Original values */ decode(encoded: string[]): string[]; /** * Generate RLE directive * * Format: @rle columnName * * @param columnName - Column name * @returns TONL directive string */ generateDirective(columnName: string): string; /** * Parse RLE directive * * @param directive - TONL directive like "@rle status" * @returns Column name */ parseDirective(directive: string): string; /** * Check if RLE would be beneficial * * @param values - Values to analyze * @param minCompressionRatio - Minimum compression ratio (default: 0.15 = 15%) * @returns True if RLE is recommended */ shouldEncode(values: any[], minCompressionRatio?: number): boolean; /** * Encode with automatic analysis * * Only applies RLE if beneficial * * @param values - Array of values * @returns Encoded values or original if not beneficial */ smartEncode(values: any[]): string[]; /** * Estimate byte savings from RLE * * @param values - Original values * @returns Estimated bytes saved */ estimateSavings(values: any[]): number; } /** * Run-length decoder for restoring original values */ export declare class RunLengthDecoder { private rleColumns; /** * Parse and register RLE directive * * @param directive - TONL directive like "@rle status" */ parseDirective(directive: string): void; /** * Check if a column uses RLE * * @param columnName - Column name * @returns True if column is RLE-encoded */ isRLEEncoded(columnName: string): boolean; /** * Decode RLE-encoded values * * @param columnName - Column name * @param values - Encoded values * @returns Decoded values */ decode(columnName: string, values: string[]): string[]; /** * Get all RLE-encoded column names * * @returns Array of column names */ getRLEColumns(): string[]; /** * Clear all RLE directives */ clear(): void; } //# sourceMappingURL=rle.d.ts.map