0

I am planning on implementing a queue and persisting the objects into a Bolt DB instance. I was wondering how to determine the sortedness of the items when reloading my application and determining head/tail.

To quote the Bolt DB project on insertion of items to a bucket:

Bolt stores its keys in byte-sorted order within a bucket

So basically the keys for the DB are byte [arrays] and sorted. I see an implementation online that uses the following line to convert an int to a byte array in little endian.

key := make([]byte, 8)
binary.BigEndian.PutUint64(key, id)

What other ways are there to convert the keys to byte arrays for sortedness?

Thanks

jim
  • 8,670
  • 15
  • 78
  • 149
  • 1
    If you're using `NextSequence` to generate keys, they'll already be in order. – Adrian Jul 17 '18 at 19:46
  • @Adrian sweet? Shall I still convert that uint64 to byte array using the Big endian function? Thanks – jim Jul 18 '18 at 10:21

0 Answers0