Commit 2b2118c
committed
fix: restore mempalace compress after stats rename (MemPalace#159)
The honest-stats rename in PR MemPalace#147 changed the keys returned by
Dialect.compression_stats() (ratio -> size_ratio, compressed_chars ->
summary_chars, original_tokens / compressed_tokens ->
original_tokens_est / summary_tokens_est). cmd_compress still reads
the old names, so mempalace compress throws KeyError on the first
drawer it touches and the feature is effectively dead.
Also fix the summary line at the bottom of cmd_compress. It called
count_tokens("x" * total_original), but count_tokens is word-based
(max(1, int(len(text.split()) * 1.3))), and a string of repeated
xs is a single "word", so both totals were always 1. Accumulate
the per-drawer estimates during the main loop instead, and use a
token-based ratio so the summary line is self-consistent with the
per-drawer dry-run output.
The storage metadata key names on the compressed collection
(compression_ratio, original_tokens) stay the same for compatibility
with anything already reading them. Only the source of the values
is updated.
Fixes MemPalace#159 (points 1 and 2)1 parent 0fdd086 commit 2b2118c
1 file changed
Lines changed: 11 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
313 | | - | |
| 312 | + | |
| 313 | + | |
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
320 | | - | |
321 | | - | |
| 320 | + | |
| 321 | + | |
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
331 | | - | |
| 331 | + | |
| 332 | + | |
332 | 333 | | |
333 | 334 | | |
334 | 335 | | |
| |||
339 | 340 | | |
340 | 341 | | |
341 | 342 | | |
342 | | - | |
343 | | - | |
| 343 | + | |
| 344 | + | |
344 | 345 | | |
345 | 346 | | |
346 | 347 | | |
| |||
353 | 354 | | |
354 | 355 | | |
355 | 356 | | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
361 | 360 | | |
362 | 361 | | |
363 | 362 | | |
| |||
0 commit comments