Skip to content

Commit

Permalink
fix descending queries
Browse files Browse the repository at this point in the history
* did not handle cached values correctly
* sort shards by time in either ascending or descending
  order depending on the RPC request ordering to ensure they
  are traversed in the correct order.
  • Loading branch information
stuartcarnie committed Nov 14, 2017
1 parent 48e21e6 commit 2e04e87
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 152 deletions.
7 changes: 7 additions & 0 deletions services/storage/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package storage
import (
"context"
"errors"
"sort"
"strings"
"time"

Expand Down Expand Up @@ -71,6 +72,12 @@ func (s *Store) Read(ctx context.Context, req *ReadRequest) (*ResultSet, error)
return nil, nil
}

if req.Descending {
sort.Sort(sort.Reverse(meta.ShardGroupInfos(groups)))
} else {
sort.Sort(meta.ShardGroupInfos(groups))
}

shardIDs := make([]uint64, 0, len(groups[0].Shards)*len(groups))
for _, g := range groups {
for _, si := range g.Shards {
Expand Down
Loading

0 comments on commit 2e04e87

Please sign in to comment.