mirror of https://github.com/tidwall/tile38.git
allow KNN cursors
This commit is contained in:
parent
300635727a
commit
3fae3f70eb
|
@ -154,7 +154,7 @@ func (sw *scanWriter) writeHead() {
|
||||||
func (sw *scanWriter) writeFoot() {
|
func (sw *scanWriter) writeFoot() {
|
||||||
sw.mu.Lock()
|
sw.mu.Lock()
|
||||||
defer sw.mu.Unlock()
|
defer sw.mu.Unlock()
|
||||||
cursor := sw.numberItems + sw.cursor
|
cursor := sw.cursor + sw.numberItems
|
||||||
if !sw.hitLimit {
|
if !sw.hitLimit {
|
||||||
cursor = 0
|
cursor = 0
|
||||||
}
|
}
|
||||||
|
@ -275,9 +275,13 @@ func (sw *scanWriter) writeObject(opts ScanWriterParams) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
sw.count++
|
sw.count++
|
||||||
|
if sw.count <= sw.cursor {
|
||||||
|
return true
|
||||||
|
}
|
||||||
if sw.output == outputCount {
|
if sw.output == outputCount {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
switch sw.msg.OutputType {
|
switch sw.msg.OutputType {
|
||||||
case server.JSON:
|
case server.JSON:
|
||||||
var wr bytes.Buffer
|
var wr bytes.Buffer
|
||||||
|
|
|
@ -93,8 +93,7 @@ func (c *Controller) cmdSearchArgs(cmd string, vs []resp.Value, types []string)
|
||||||
if cmd == "nearby" {
|
if cmd == "nearby" {
|
||||||
// possible that this is KNN search
|
// possible that this is KNN search
|
||||||
s.knn = s.searchScanBaseTokens.ulimit && // must be true
|
s.knn = s.searchScanBaseTokens.ulimit && // must be true
|
||||||
!s.searchScanBaseTokens.usparse && // must be false
|
!s.searchScanBaseTokens.usparse // must be false
|
||||||
s.searchScanBaseTokens.cursor == 0 // must be zero
|
|
||||||
}
|
}
|
||||||
if !s.knn {
|
if !s.knn {
|
||||||
err = errInvalidArgument(slat)
|
err = errInvalidArgument(slat)
|
||||||
|
|
Loading…
Reference in New Issue