Repository navigation
Add index to the LWT representation - #921
Conversation
|
📖 Docs for this PR can be previewed here |
bf2772d to
d13efbe
Compare
|
I recommend merging #916 first then asking mergify to rebase before review. |
Codecov Report
@@ Coverage Diff @@
## main #921 +/- ##
==========================================
- Coverage 93.40% 93.40% -0.01%
==========================================
Files 25 25
Lines 20335 20357 +22
Branches 824 825 +1
==========================================
+ Hits 18994 19014 +20
- Misses 1304 1306 +2
Partials 37 37
Continue to review full report at Codecov.
|
| @endrst | ||
|
|
||
| @param self A pointer to a tsk_table_collection_t object. | ||
| @param edge_insertion_order Array of tsk_id_t edge ids |
There was a problem hiding this comment.
Full stop missing here and next
| } | ||
|
|
||
| /* index */ | ||
| value = get_table_dict_value(tables_dict, "index", false); |
There was a problem hiding this comment.
Probably best to call this "indexes" just for consistency with the C struct?
There was a problem hiding this comment.
For consistency we should also change the python property on TableCollection to indexes but then that is inconsistent with build_index and has_index which would be breaking changes to move to indexes... we may have to live with the python API being index and the c struct being indexes.
|
Need to do some tests where we add bad indexes from the dict encoding. Things like:
|
As it was nothing happened as indexes were always rebuilt on |
6861686 to
89f158c
Compare
|
Almost there, needs a few more tests so setting to draft. |
ae950d1 to
c8d6d44
Compare
|
@jeromekelleher I think this is ready to go - I've changed the sematics such that |
jeromekelleher
left a comment
There was a problem hiding this comment.
I'm not sure None is the right encoding for missing indexes here - see comment above.
| [0.1.2] - 2020-10-22 | ||
| -------------------- | ||
|
|
||
| - Added optional top-level key ``index`` which has contains ``edge_insertion_order`` and |
| goto out; | ||
| } | ||
|
|
||
| if (!tsk_table_collection_has_index(self->tables, 0)) { |
There was a problem hiding this comment.
I don't know about this. I think it would be logical to return an empty dictionary. That way we're more robust to adding more indexes in the future, where the dictionary may contain the current edge_x indexes, but also maybe any future indexes. So, we might have to deal with the situation where the dictionary contains a variable number of keys - logically then, it makes sense to treat the zero-keys situation in the same way.
Think of tsk_table_collection_has_index(self, 0) as saying "do you have all possible indexes". So, we'd have (roughly)
dict = PyDict_New();
if (tsk_table_collection_has_index(self->tables, 0)) {
// add key-value pairs for each edge_insertion and edge_removal
}
We can see how this is then extensible to having more indexes in the future - we can just test the existance of the each index on a case-by-case basis.
jeromekelleher
left a comment
There was a problem hiding this comment.
Not sure the lwt encoding version is the same as the output of asdict() now? We should probably add a test that these are identical, somewhere.
| }; | ||
|
|
||
| for (j = 0; j < sizeof(table_descs) / sizeof(*table_descs); j++) { | ||
| if (strcmp(table_descs[j].name, "indexes") == 0 |
There was a problem hiding this comment.
Do we need to do this? I think it'd be better if the dict encoding had the empty dictionary as the output rather than excluding the key. This is what the TableCollection does, right?
c3a2feb to
4d81529
Compare
|
@jeromekelleher I've tidied this up and added the test for identical contents in the dicts. |
|
LGTM, merge away whenever |
4d81529 to
89295ea
Compare
Add index to the LWT representation
Description
Adds indexes (optionally) to the LWT interface. Based on #916 as it needs python access to indexes.
Fixes #870
PR Checklist: