Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Automatic branch deduplication #6569

paulovap started this conversation in Ideas
Discussion options

This is an open question for now as I haven't done much research.

Flex/Flat protocol has the concept of reference, which create interesting properties to the payload, such as enabling random access without parsing and deduplicating data by just keeping one instance of the data and insert the reference to it for every other entry.

By exposing an API to add those "references", users can manually perform the deduplication. This is a straightforward approach and already can save a lot of data. But at cost of hand-coding those checks.

My question now is: Is it possible to automatically add branch deduplication, automatically, and efficient enough to be used in real scenarios?

An initial naive solution that come to mind is: Before writing maps and arrays into the buffer, we calculate it's hash we compare against previously stored hashes of the same type. If we have a match we deeply compare both branches and adds a reference if they are deeply equal.

Other things it comes to mind:

  • Do we think this is worthy?
  • Does it make sense to have a general solution to apply on fbs as well?
  • Given we have lot of meta information about the elements, can we figure out a way to do a "perfect hash" and avoid deeply comparisons
  • Any other alternative ideas?
You must be logged in to vote

Replies: 1 comment

Comment options

We have this for strings of course in some languages.

Doing it for tables sounds pretty "heavy" to me in cost, and it seems that use cases of sharing tables are fairly niche, i.e. the user will be very aware if they want it, or not.

That said, nothing against providing it as an option if its useful.

I guess the first step would an optional hash function for all tables/structs, maybe? One based on combining sub-hashes with XOR so it can be hierarchically be combined. Having such a function could be useful by itself, and would make it easier to track your own duplicates.

Of course, none of this should ever be automatically on, not just in terms of cost, but also because it would interfere with --gen-mutable etc.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /