Skip to content

Add defragmentation and fix/test read/write/read/write cycle of maps - #183

Merged
erykoff merged 17 commits into
mainfrom
defrag_and_readwrite
Sep 11, 2026
Merged

erykoff merged 17 commits into
mainfrom
defrag_and_readwrite

Conversation

@erykoff

@erykoff erykoff commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

There were a couple of bad bugs related to memory ownership and reserved fits keywords that meant that it was difficult to read in a map, modify it, and save it again.

This fixes those bugs and adds extensive tests.

This also adds defragmentation (which didn't work properly because of these serialization bugs!)

@erykoff
erykoff force-pushed the defrag_and_readwrite branch from 04891be to 6f5095d Compare September 10, 2026 21:02
sparse_map_size = (defrag_n_cov + 1) * nfine_per_cov

if self.is_bit_packed_map:
defrag_sparse_map = _PackedBoolArray(size=sparse_map_size)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be very big for bit packed footprints of a survey

To avoid the high memory usage you can use rustfits to create the output file. Then rustfits supports writing into the file using the same slice notation you use for numpy arrays, so the algorithm below can I think be unchanged. https://rustfits.readthedocs.io/en/latest/tutorial/images.html#writing-pixels-back

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a temporary up to 2x memory usage which I don't think is the worst thing... I was thinking this wasn't a common operation anyway, and you should have some memory overhead when making a giant footprint (vs using it). But I do see the point of having a minimal-memory-usage version and can consider that in the future.

@erykoff
erykoff merged commit 1a53641 into main Sep 11, 2026
5 checks passed
@erykoff
erykoff deleted the defrag_and_readwrite branch September 11, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants