From 3fae3f70eb1c9bbc082b25ab9df5a483b0b17b01 Mon Sep 17 00:00:00 2001 From: Josh Baker Date: Mon, 24 Jul 2017 08:42:12 -0700 Subject: [PATCH] allow KNN cursors --- controller/scanner.go | 6 +++++- controller/search.go | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/controller/scanner.go b/controller/scanner.go index d912c097..e467d192 100644 --- a/controller/scanner.go +++ b/controller/scanner.go @@ -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 } @@ -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 diff --git a/controller/search.go b/controller/search.go index 402de04a..6742a20f 100644 --- a/controller/search.go +++ b/controller/search.go @@ -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)