CodableDatastore
CodableDatastore copied to clipboard
Indexed values should be required to conform to IndexComparable
trafficstars
This protocol should return an agnostic representation of a comparable structure in a format that the datastore natively understands. Take a look at foundation db for inspiration, as their binary key paths could be a good format. However, since the goal is to still have human readable files on disk, the default format could be an array of enum primitives to be sorted accordingly? One benefit to Comparable is the ability to add new sorting capabilities, so some investigation should be placed into supporting that well.
Some ideas:
- A series of comparable components separated by
. - A component can itself be a series of components being wrapped in
[and] - Little-end comparison is the default (ie. for strings)
- Big-end comparison prefixed with
#(ie. for numbers of variable length) - Strings marked with
", and\is used as a de-facto escape character (ie.\.→.even if there is no special meaning to.) - Hex numbers/strings prefixed with
x - Probably need a symbol for "nil", both one that appears before and one that appears after other members. (
<and>?) - Floating point numbers can use
,, or we define another symbol. - Might need additional symbols for different forms of string normalization
- Each component class has a stable sort relative to one-another.
- Unknown component classes should also have a stable sort for backwards compatibility.
There should be a binary compatible coding scheme that uses the least amount of space.