dgraph-io / badger

Fast key-value DB in Go.
https://dgraph.io/badger
Apache License 2.0
14.04k stars 1.19k forks source link

Q: Iterator ordering guarantee #398

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hi, if I only append new records(ie. key is never duplicated), does Badger guarantee proper(time-based) ordering of records in the same order they were written?

I am using https://github.com/segmentio/ksuid for keys

deepakjois commented 6 years ago

The iterator has a guaranteed order, but it isnt ‘time-based’. It is based on the lexicographically sorted order of the byte value of the keys.

A cursory reading of the ksuid docs suggest that they are lexicographically sorted: https://github.com/segmentio/ksuid#3-lexographically-sortable-portable-representations

Does that answer your question?