Definition of ContestNode.Ref and locating remote object #5
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
maleszka/wbij#5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Platforms I wanted to support are:
I started working on implementing other backends than sim to check whether the current design works well with different platforms. And I'm surprised to see how much of a different approach some platforms take on identifying contests/rounds/problems.
Basing on sim, I decided that:
ContestNode.Refis a packed struct that contains data necessary to download more information about given entity from remote serverContestNode.Refis backed byu64which is then used as vertex id in the graphContestNode.Refis thus unique for all nodes; it serves a role of primary key in thecontest_nodesrelationBut we have 2 problems with it:
ContestNodeancestors are needed to download info about specific node; i.e. it's not possible to tell, which contest does given problem belong to without knowing ancestor ids, cause all api calls asking about specific problem need to also have the contest context specifiedProblem 1 is quite easy to solve, cause we can just add an
ancestors: []const platforms.data.ContestNodeargument to methods inPlatformAPI.Problem 2 is much harder, cause it tells us that we actually have two things to solve:
There are two things that I think we have to do nonetheless:
ancestorsargument toPlatformAPImethodsContestNodethat will be a serialized implementation-internal struct, which will contain additional information (although I hope that we will avoid that)When it comes to the vertex id, we have 3 options:
[]const u8as primary key; will need to change implementation ofRelationandfetcher.ContestGraphbut will give us this flexibility that key can be of arbitrary lengthu64beingstd.crypto.hashon something that is unique for the contest node; currently, sim has 6500 contest nodes, codeforces has about 20000 nodes; assuming 10^7 nodes at most, probability of collision withu64is 0.0002% and ridiculously small withu128Reftou256, which allows for storing 42 chars long string in base64; we can assume that codename is simply some url-safe base64 value (they never go beyond [a-zA-Z0-9-_] alphabet).I would stick with option 2, for now. It does not require any changes in the codebase and the probability seems very small. We can bump Ref to
u128in the worst case.