Skip to content

feat: Add Elias-Fano encoding - #235

Open
limakzi wants to merge 2 commits into
mainfrom
feature/change-encoding
Open

feat: Add Elias-Fano encoding#235
limakzi wants to merge 2 commits into
mainfrom
feature/change-encoding

Conversation

@limakzi

@limakzi limakzi commented Mar 6, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings March 6, 2026 00:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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/GetEntry for base-(n^n) packed integer encoding of multiplication tables.
  • Update SmallAntimagma, AllSmallAntimagmas, and ReallyAllSmallAntimagmas to decode metadata using the new encoding.
  • Add a dedicated test suite for the new encoding and update the packaged .g.gz metadata 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.

Comment thread lib/helper.gd Outdated
Comment thread lib/helper.gd Outdated
Comment thread lib/helper.gd Outdated
Comment thread lib/helper.gd Outdated
Comment thread lib/helper.gd Outdated
@limakzi limakzi changed the title feat: Change encoding feat: Add Elies-Fano encoding Mar 6, 2026
@limakzi limakzi changed the title feat: Add Elies-Fano encoding feat: Add Elias-Fano encoding Mar 6, 2026

Copilot AI commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

@limakzi I've opened a new pull request, #236, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

@limakzi I've opened a new pull request, #237, to work on those changes. Once the pull request is ready, I'll request review from you.

Comment thread lib/helper.gd Outdated
@limakzi
limakzi force-pushed the feature/change-encoding branch from abdffc4 to 717ecdf Compare July 14, 2026 21:26
@olexandr-konovalov

Copy link
Copy Markdown
Member

@limakzi oops, why CI fails now...

@limakzi
limakzi force-pushed the feature/change-encoding branch from 717ecdf to 59de591 Compare July 15, 2026 07:29
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.84%. Comparing base (e70d952) to head (852f930).

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              
Files with missing lines Coverage Δ
data/2/small_2.g.gz 100.00% <ø> (ø)
data/3/small_3.g.gz 100.00% <ø> (ø)
data/4/small_4.g.gz 100.00% <ø> (ø)
lib/helper.gd 84.41% <100.00%> (+11.08%) ⬆️
lib/properties.gd 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@limakzi
limakzi force-pushed the feature/change-encoding branch from 59de591 to 333d8a5 Compare July 15, 2026 07:38

@olexandr-konovalov olexandr-konovalov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not a continuation of Step 4 - maybe think of another header?

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.

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]]);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 ] ]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 ] ]

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.

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");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe add checks that an error is produced when it's expected?

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants