Repository navigation
feat(asinfo): add allocation_status and load asndata.asn_allocation - #50
Merged
Merged
Conversation
The first line of a delegated-stats file (2|ripencc|... or ARIN's 2.3|arin|...) is a version record: every field is a file-level fact. It is seven fields wide, so it passed the shape check and was parsed as a record whose registry was the format version, which is how five of them ended up in asndata.delegated.
An AsInfo row could not answer whether an ASN is allocated at all: delegated was None both for private-use space and for numbers no RIR ever allocated, and reserved records were dropped along with the rest. AllocationStatus states the verdict on every record. The positive values come from the delegated record's status; Private and the special-purpose part of Reserved come from IANA's special-purpose AS table, which no RIR file restates and which is now public so loaders store the same ranges instead of a copy. Records written before the field existed deserialize as unallocated.
One row per allocation range from the five delegated files plus the nine IANA special-purpose ranges, with a GiST index on int8range(start_asn, end_asn). Ranges rather than per-ASN rows: the RFC 6996 private blocks cover about 95 million ASNs. Measured on the 2026-10-23 files: 104,397 ranges, of which 71,282 allocated, 31,928 assigned, 1,185 reserved and 2 private.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An
AsInforow could not say whether an ASN is allocated at all:delegatedwasNoneboth for private-use space and for numbers no RIR ever allocated, andreservedrecords were dropped along with everything that was notallocated/assigned.This adds
allocation_statusto every record (allocated,assigned,reserved,private,unallocated). The positive values come from the delegated record's status;privateand the special-purpose part ofreservedcome from IANA's special-purpose AS table, which no RIR file restates and which is now public so loaders store the same ranges instead of a second copy. Records written before the field existed deserialize asunallocated.It also fixes the parser swallowing each file's version record (
2|ripencc|..., ARIN's2.3|arin|...): seven fields wide, it passed the shape check and was stored as a record whose registry was the format version, which is how five of them ended up inasndata.delegated.pg_insertergains anallocationstask that loadsasndata.asn_allocation, one row per allocation range (the five delegated files plus the nine IANA ranges) with a GiST index onint8range(start_asn, end_asn). Ranges rather than per-ASN rows because the RFC 6996 private blocks cover about 95 million ASNs.Measured against the 2026-10-23 files: 104,397 ranges (71,282 allocated, 31,928 assigned, 1,185 reserved, 2 private).