You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Metadata will sometimes be useful for edges, but when we're working with large edge tables (for example, in forwards simulators like SLiM) the extra memory overhead will not be welcome.
Add a flag TSK_NO_METADATA, which allows a table to work without having a metadata column. It would be used like
It's up to the user to make sure that they call, e.g., add_row with the appropriate arguments. In this case, the value of the metadata and metadata_offset columns is undefined (which we should document).
We should implement this for the Edge table anyway, and then either implement it for other tables (if it's easy) or throw an error if it is supplied and it doesn't make sense (like, say, the population table).
To make this available then to people who are working with a table collection, we add a flag TSK_NO_EDGE_METADATA to tsk_table_collection_init, which passes the TSK_NO_METADATA to edge_table_init.
@petrelharp - does this sound like a workable solution for the SLiM case? Are there other tables where we'd want to drop metadata to reduce memory overheads (say, node table)?
To be clear, this would just happen when we're creating tables. When we read in tables from file, we always have metadata/metadata_offset columns allocated.
When we read in tables from file, we always have metadata/metadata_offset columns allocated.
Huh. Not sure about this, because SLiM reads tables in from a file if it wants to start a new simulatoin from the state of a previous one? I forget - maybe it copies those tables over to a newly init-'ed one, but there are some issues here I'm unclear about.
It is all the zeros in the offset column when not using metadata that are the concern here, right? This might be too clever and complicated - but it would be possible to delay initialisation of the offset column until the first non-zero-length metadata was added. It would mean putting checking at every place you use the offset - but I think you'd have to do that anyway if init'ing the metadata is optional.
Hmm. We could provide the TSK_NO_EDGE_METADATA as an option to table_collection_load() then. Then, we pass TSK_NO_EDGE_METADATA to tsk_table_collection_init and ignore the metadata column when we're reading the kastore in the edge table, if self->options & TSK_NO_METADATA. This is consistent with the above usage I think and reasonably simple to do.
I do want the default to be that we have all the columns defined and pointing to valid memory regardless of the inputs. If the user says "it's OK by me if these specific columns are NULL" then that's fine, but in general client code shouldn't have to worry about columns being undefined.
I guess the only downstream user other than API clients is the tsk_treeseq_t. It'll probably need to do a check on whether the TSK_NO_METADATA flag is set on tables when metadata is accessed, I guess. Although, I think we're taking a copy at the moment, so it might all just work out.
Activity
jeromekelleher commentedon May 6, 2020
To be clear, this would just happen when we're creating tables. When we read in tables from file, we always have metadata/metadata_offset columns allocated.
petrelharp commentedon May 6, 2020
This will work for SLiM. And, will tehre be a way to tell whether a table has metadata or not? (seems like there should be...)
petrelharp commentedon May 6, 2020
Huh. Not sure about this, because SLiM reads tables in from a file if it wants to start a new simulatoin from the state of a previous one? I forget - maybe it copies those tables over to a newly init-'ed one, but there are some issues here I'm unclear about.
benjeffery commentedon May 6, 2020
It is all the zeros in the offset column when not using metadata that are the concern here, right? This might be too clever and complicated - but it would be possible to delay initialisation of the offset column until the first non-zero-length metadata was added. It would mean putting checking at every place you use the offset - but I think you'd have to do that anyway if init'ing the metadata is optional.
jeromekelleher commentedon May 7, 2020
Hmm. We could provide the
TSK_NO_EDGE_METADATAas an option totable_collection_load()then. Then, we pass TSK_NO_EDGE_METADATA totsk_table_collection_initand ignore the metadata column when we're reading the kastore in the edge table, ifself->options & TSK_NO_METADATA. This is consistent with the above usage I think and reasonably simple to do.I do want the default to be that we have all the columns defined and pointing to valid memory regardless of the inputs. If the user says "it's OK by me if these specific columns are NULL" then that's fine, but in general client code shouldn't have to worry about columns being undefined.
petrelharp commentedon May 7, 2020
Sounds good. I'm still pretty fuzzy on the downstream implications of what code this will affect, but that'll become clear doing it, I guess.
jeromekelleher commentedon May 7, 2020
I guess the only downstream user other than API clients is the
tsk_treeseq_t. It'll probably need to do a check on whether theTSK_NO_METADATAflag is set on tables when metadata is accessed, I guess. Although, I think we're taking a copy at the moment, so it might all just work out.