sorting keys - fix

This commit is contained in:
Jaremy Creechley 2023-08-28 21:32:28 -07:00 committed by Dmitriy Ryajov
parent 8445920232
commit 84986c77c3
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
2 changed files with 11 additions and 3 deletions

View File

@ -24,8 +24,8 @@ type
proc `=destroy`*(x: var DataBufferHolder) =
## copy pointer implementation
if x.buf != nil:
when isMainModule or true:
echo "buffer: FREE: ", repr x.buf.pointer
# when isMainModule or true:
# echo "buffer: FREE: ", repr x.buf.pointer
deallocShared(x.buf)
proc len*(a: DataBuffer): int = a[].size

View File

@ -1,6 +1,7 @@
import std/tables
import std/sequtils
import std/strutils
import std/algorithm
import pkg/chronos
import pkg/questionable
@ -91,11 +92,14 @@ method put*(
proc keyIterator(self: MemoryDatastore, queryKey: string): iterator: KeyBuffer {.gcsafe.} =
return iterator(): KeyBuffer {.closure.} =
let keys = self.store.keys().toSeq()
var keys = self.store.keys().toSeq()
keys.sort(proc (x, y: KeyBuffer): int = cmp(x.toString, y.toString))
for key in keys:
if key.toString().startsWith(queryKey):
yield key
import pretty
method query*(
self: MemoryDatastore,
query: Query,
@ -108,10 +112,14 @@ method query*(
var
iter = QueryIter.new()
echo "queryKey: ", queryKey
proc next(): Future[?!QueryResponse] {.async.} =
let
kb = walker()
print "query: ", kb.toString
if finished(walker):
iter.finished = true
return success (Key.none, EmptyBytes)