Skip to content

[C API] Add TSK_NO_EDGE_METADATA option  #585

Closed

Description

@jeromekelleher

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

ret = tsk_edge_table_init(&edge_table, TSK_NO_METADATA);

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)?

Activity

  1. added this to the C API 0.99.3 milestone on May 6, 2020
  2. jeromekelleher commented on May 6, 2020

    @jeromekelleher
    MemberAuthor

    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.

  3. petrelharp commented on May 6, 2020

    @petrelharp
    Contributor

    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...)

  4. petrelharp commented on May 6, 2020

    @petrelharp
    Contributor

    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.

  5. benjeffery commented on May 6, 2020

    @benjeffery
    Member

    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.

  6. jeromekelleher commented on May 7, 2020

    @jeromekelleher
    MemberAuthor

    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.

  7. petrelharp commented on May 7, 2020

    @petrelharp
    Contributor

    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.

  8. jeromekelleher commented on May 7, 2020

    @jeromekelleher
    MemberAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions