mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-04 22:53:08 +00:00
sorting keys - fix
This commit is contained in:
parent
8445920232
commit
84986c77c3
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user