Rename maybeDecompressedStringAsNumber and propagate mayContainCompressedIds to non-leaf nodes#26980
Conversation
…ds to non leaf nodes as well
There was a problem hiding this comment.
Pull request overview
This PR clarifies and refines how UniformChunks represent and interpret ID-compressed values by renaming the leaf opt-in flag, introducing a derived mayContainCompressedIds signal for entire shapes, and using that signal to avoid retaining an idCompressor reference when it cannot be needed.
Changes:
- Replaced the old leaf-only flag with a clearer leaf opt-in (
maybeCompressedIdLeaf) and a derived shape-wide indicator (mayContainCompressedIds) that propagates from descendants. - Updated
UniformChunkto only retainidCompressorwhen the chunk’s shape indicates compressed IDs may be present. - Updated/added tests to validate invalid flag usage and propagation of
mayContainCompressedIds.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/dds/tree/src/feature-libraries/chunked-forest/uniformChunk.ts | Adds mayContainCompressedIds, derives it from child shapes, updates cursor decompression logic, and conditionally retains idCompressor. |
| packages/dds/tree/src/feature-libraries/chunked-forest/chunkTree.ts | Updates JSDoc around when UniformChunk compression applies. |
| packages/dds/tree/src/test/feature-libraries/chunked-forest/uniformChunk.spec.ts | Switches to assertion-based failure validation and adds propagation tests for mayContainCompressedIds. |
| // Slow path: walk shape and cursor together, inserting values. | ||
| if (shape.hasValue) { | ||
| if ( | ||
| shape.mayContainCompressedIds && |
There was a problem hiding this comment.
this "fix" is not as important as it might seem, since we do not support unions in uniform chunks currently, so this could never put a compressed id where a number is valid. Therefor there could have been no impacted users. With this change however, where we discard the id compressor, this change is required to ensure decode always works.
Co-authored-by: Joshua Smithrud <54606601+Josmithr@users.noreply.github.com>
…Chunk.ts Co-authored-by: Joshua Smithrud <54606601+Josmithr@users.noreply.github.com>
…ssedIds to non-leaf nodes (microsoft#26980) ## Description Improves clarity around how compressed ids are handled in UniformChunks, and tracks if a chunk might use them (deeply) in the shape. As a memory optimization, avoid storing idCompressor when unneeded. For small leaf chunks (as is common currently) this should help memory use a little as there are a very large number of such chunks.
Description
Improves clarity around how compressed ids are handled in UniformChunks, and tracks if a chunk might use them (deeply) in the shape.
As a memory optimization, avoid storing idCompressor when unneeded. For small leaf chunks (as is common currently) this should help memory use a little as there are a very large number of such chunks.
Reviewer Guidance
The review process is outlined on this wiki page.