feat: Add Elias-Fano encoding - #235
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates how small antimagmas’ multiplication tables are serialized in package metadata by switching from the old Convert/Reverse representation to a new packed integer encoding, and wires the new decode path into the public constructors.
Changes:
- Add cached helpers plus
MultiplicationTableEncode/Decode/GetEntryfor base-(n^n) packed integer encoding of multiplication tables. - Update
SmallAntimagma,AllSmallAntimagmas, andReallyAllSmallAntimagmasto decode metadata using the new encoding. - Add a dedicated test suite for the new encoding and update the packaged
.g.gzmetadata files accordingly.
Reviewed changes
Copilot reviewed 4 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
lib/helper.gd |
Adds encoding/decoding helpers and caching used to interpret metadata as packed integers. |
lib/smallantimagmas.gi |
Switches magma construction to use MultiplicationTableDecode(..., order) on metadata entries. |
lib/utils.gi |
Minor refactor to name the tuples enumerator before filtering. |
tst/test_helper_multiplication_table_encoding.tst |
New tests for caches, encode/decode round-trips, injectivity, and old/new equivalence. |
data/non-isomorphic/{2,3,4}/small_*.g.gz |
Updated non-isomorphic metadata content to match the new encoding format. |
data/all/{2,3}/small_*.g.gz |
Updated “all” metadata content to match the new encoding format. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
abdffc4 to
717ecdf
Compare
|
@limakzi oops, why CI fails now... |
717ecdf to
59de591
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #235 +/- ##
==========================================
+ Coverage 90.96% 91.84% +0.87%
==========================================
Files 10 10
Lines 299 331 +32
==========================================
+ Hits 272 304 +32
Misses 27 27
🚀 New features to boost your workflow:
|
59de591 to
333d8a5
Compare
olexandr-konovalov
left a comment
There was a problem hiding this comment.
The code seems to work, but maybe one should add more safety mechanisms to check for the allowed values of arguments?
| @@ -0,0 +1,100 @@ | |||
| gap> START_TEST("test_helper_tables_encode_decode.tst"); | |||
There was a problem hiding this comment.
I think this is quite thorough testing, with lots of corner cases and property checks. Should the description be here or moved closer to the code in lib/helper.gd though?
| gap> __SmallAntimagmaHelper.TablesDecode(2, [7, 3, 2]); | ||
| [ [ 2, 4 ], [ 3, 3 ], [ 4, 1 ] ] | ||
|
|
||
| # Duplicates survive encoding as deltas equal to 0. |
There was a problem hiding this comment.
This is not a continuation of Step 4 - maybe think of another header?
There was a problem hiding this comment.
In general, we will move these comments to helper.gd, the comments about the test MUST document the test-case.
| # Step 1: a table in row form is a base-(n^n) number. | ||
| # For n = 2 the base is 2^2 = 4, digits are (row index - 1). | ||
| # [3, 3] -> (3 - 1) * 4 + (3 - 1) = 10, first delta is taken from 0. | ||
| gap> __SmallAntimagmaHelper.TablesEncode(2, [[3, 3]]); |
There was a problem hiding this comment.
Should there be any input control? What happens if the number is larger than n^n?
gap> __SmallAntimagmaHelper.TablesEncode(2, [[5]]);
[ 4 ]
gap> __SmallAntimagmaHelper.TablesDecode(2, [4]);
[ [ 2, 1 ] ]
There was a problem hiding this comment.
Some other anomalies:
gap> __SmallAntimagmaHelper.TablesEncode(2, [[3,0]]);
[ 7 ]
gap> __SmallAntimagmaHelper.TablesDecode(2, [7]);
[ [ 2, 4 ] ]
and
gap> __SmallAntimagmaHelper.TablesEncode(2, [[0,3]]);
[ -2 ]
gap> __SmallAntimagmaHelper.TablesDecode(2, [-2]);
[ [ 1, -1 ] ]
There was a problem hiding this comment.
As we discussed, its not surprising it works, but we will implement validation.
For encoding - yes; for decoding - nice to have, but not necessary.
| > __SmallAntimagmaHelper.getSmallAntimagmaMetadata(n)())); | ||
| true | ||
|
|
||
| gap> STOP_TEST("test_helper_tables_encode_decode.tst"); |
There was a problem hiding this comment.
Maybe add checks that an error is produced when it's expected?
No description provided.