Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,11 @@ func (t *txn) Query(q dsq.Query) (dsq.Results, error) {
txn := t.txn

it := txn.NewIterator(opt)
it.Seek(prefix)
if len(q.SeekPrefix) > 0 {
it.Seek([]byte(q.SeekPrefix))
} else {
it.Seek(prefix)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably seek to the "later" prefix (in case the seek prefix comes before the Prefix).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this all depends on the ordering. If we've reversed the order, we'd want to seek to the "earlier" prefix.

Speaking of ordering, we technically need to apply the "seek" prefix after the order. Badger internally handles ordering by key (ascending or descending) but we have to apply all other orderings (e.g., by value) after the fact.

So, if we aren't applying any additional orders len(order) == 0, we're all good. Otherwise, we should either return a not supported error or apply a naive seek after ordering.

if q.Offset > 0 {
for j := 0; j < q.Offset; j++ {
it.Next()
Expand Down