Skip to content

Commit

Permalink
allow KNN cursors
Browse files Browse the repository at this point in the history
  • Loading branch information
tidwall committed Jul 24, 2017
1 parent 3006357 commit 3fae3f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 5 additions & 1 deletion controller/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (sw *scanWriter) writeHead() {
func (sw *scanWriter) writeFoot() {
sw.mu.Lock()
defer sw.mu.Unlock()
cursor := sw.numberItems + sw.cursor
cursor := sw.cursor + sw.numberItems
if !sw.hitLimit {
cursor = 0
}
Expand Down Expand Up @@ -275,9 +275,13 @@ func (sw *scanWriter) writeObject(opts ScanWriterParams) bool {
return true
}
sw.count++
if sw.count <= sw.cursor {
return true
}
if sw.output == outputCount {
return true
}

switch sw.msg.OutputType {
case server.JSON:
var wr bytes.Buffer
Expand Down
3 changes: 1 addition & 2 deletions controller/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ func (c *Controller) cmdSearchArgs(cmd string, vs []resp.Value, types []string)
if cmd == "nearby" {
// possible that this is KNN search
s.knn = s.searchScanBaseTokens.ulimit && // must be true
!s.searchScanBaseTokens.usparse && // must be false
s.searchScanBaseTokens.cursor == 0 // must be zero
!s.searchScanBaseTokens.usparse // must be false
}
if !s.knn {
err = errInvalidArgument(slat)
Expand Down

0 comments on commit 3fae3f7

Please sign in to comment.