spacejam / sled

the champagne of beta embedded databases
Apache License 2.0
8.2k stars 384 forks source link

Feature: custom ordering #308

Open dbkaplun opened 6 years ago

dbkaplun commented 6 years ago

It would be great if custom ordering was allowed for non-lexicographic datasets, perhaps allowing a fallback to default ordering.

Thanks for considering!

spacejam commented 6 years ago

similar to how a merge operator can be provided, it would be nice to support a custom prefix extractor / comparator

do you have a specific use case in mind for this?

dbkaplun commented 6 years ago

Nope, just looking into some database designs and noticed that RocksDB supports custom ordering, which seems useful.

tomcumming commented 5 years ago

@spacejam I am really missing this feature. I am using bincode to serialize my keys which are slices (of things which aren't u8), but bincode will write the length first, changing the order. So i have have to serialize each item in the slice and then concat them to get the correct sorting behaviour.

Also it would be nice if someone could write a wrapper that does the binary serialization internally so that functions like this are exposed get(key: K) -> Option<V> where K&V: Ord + Serializable