flatdata icon indicating copy to clipboard operation
flatdata copied to clipboard

Specify sorting order in schema

Open VeaaC opened this issue 5 years ago • 0 comments

Flatdata archives often utilize sorted resources, and a binary search to find elements withing those. It is easy to mess up the sorting when creating archive, though, leading to (sometimes) subtle bugs.

In order to avoid such bugs, it would be a nice feature if one could specify the ordering criteria for a collection directly in the flatdata specification. This may not be possible for all collections (i.e., when the ordering criteria are not simple). But it could be helpful for most cases.

When the ordering criteria are specified, flatdata could auto-generate:

  • method(s) to find an element (or range of elements) in the collection
  • method(s) to validate sort order (e.g., when serializing a collection, flatdata generated code could throw an exception of the items being serialized are not in correct order).

VeaaC avatar Nov 09 '20 12:11 VeaaC