mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-05 23:23:10 +00:00
sorting keys - fix
This commit is contained in:
parent
1b5609b5b8
commit
8ab9eee443
@ -24,8 +24,8 @@ type
|
|||||||
proc `=destroy`*(x: var DataBufferHolder) =
|
proc `=destroy`*(x: var DataBufferHolder) =
|
||||||
## copy pointer implementation
|
## copy pointer implementation
|
||||||
if x.buf != nil:
|
if x.buf != nil:
|
||||||
when isMainModule or true:
|
# when isMainModule or true:
|
||||||
echo "buffer: FREE: ", repr x.buf.pointer
|
# echo "buffer: FREE: ", repr x.buf.pointer
|
||||||
deallocShared(x.buf)
|
deallocShared(x.buf)
|
||||||
|
|
||||||
proc len*(a: DataBuffer): int = a[].size
|
proc len*(a: DataBuffer): int = a[].size
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import std/tables
|
import std/tables
|
||||||
import std/sequtils
|
import std/sequtils
|
||||||
import std/strutils
|
import std/strutils
|
||||||
|
import std/algorithm
|
||||||
|
|
||||||
import pkg/chronos
|
import pkg/chronos
|
||||||
import pkg/questionable
|
import pkg/questionable
|
||||||
@ -91,11 +92,14 @@ method put*(
|
|||||||
|
|
||||||
proc keyIterator(self: MemoryDatastore, queryKey: string): iterator: KeyBuffer {.gcsafe.} =
|
proc keyIterator(self: MemoryDatastore, queryKey: string): iterator: KeyBuffer {.gcsafe.} =
|
||||||
return iterator(): KeyBuffer {.closure.} =
|
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:
|
for key in keys:
|
||||||
if key.toString().startsWith(queryKey):
|
if key.toString().startsWith(queryKey):
|
||||||
yield key
|
yield key
|
||||||
|
|
||||||
|
import pretty
|
||||||
|
|
||||||
method query*(
|
method query*(
|
||||||
self: MemoryDatastore,
|
self: MemoryDatastore,
|
||||||
query: Query,
|
query: Query,
|
||||||
@ -108,10 +112,14 @@ method query*(
|
|||||||
var
|
var
|
||||||
iter = QueryIter.new()
|
iter = QueryIter.new()
|
||||||
|
|
||||||
|
echo "queryKey: ", queryKey
|
||||||
|
|
||||||
proc next(): Future[?!QueryResponse] {.async.} =
|
proc next(): Future[?!QueryResponse] {.async.} =
|
||||||
let
|
let
|
||||||
kb = walker()
|
kb = walker()
|
||||||
|
|
||||||
|
print "query: ", kb.toString
|
||||||
|
|
||||||
if finished(walker):
|
if finished(walker):
|
||||||
iter.finished = true
|
iter.finished = true
|
||||||
return success (Key.none, EmptyBytes)
|
return success (Key.none, EmptyBytes)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user