Skip to content

Commit

Permalink
Trying to fix new problem in msgpack4nim
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Dunn committed May 20, 2018
1 parent 9089276 commit 89bd9af
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/falcon/rr_hctg_track.nim
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ proc tostring(src: str9, dst: var string) =
proc hash(x: str9): hashes.Hash =
return hashes.hash(tostring(x))

proc unpack_type*(ss: streams.Stream, x: var str9) =
proc unpack_type*(ss: var msgpack4nim.MsgStream, x: var str9) =
var str: string
msgpack4nim.unpack(ss, str)
copyMem(addr x[0], addr str[0], 9)

proc pack_type*(ss: streams.Stream, x: str9) =
proc pack_type*(ss: var msgpack4nim.MsgStream, x: str9) =
let str: string = tostring(x)
msgpack4nim.pack(ss, str)

proc pack_type*(ss: streams.Stream, x: binaryheap.Heap[mytuple]) =
proc pack_type*(ss: var msgpack4nim.MsgStream, x: binaryheap.Heap[mytuple]) =
let xseq: seq[mytuple] = sequtils.toSeq(binaryheap.items(x)) # unsorted
msgpack4nim.pack(ss, xseq)
proc `$`(x: str9): string =
Expand Down Expand Up @@ -409,10 +409,11 @@ proc run_tr_stage1(db_fn, fn: string, min_len, bestn: int): string =
osproc.close(la4falcon_proc)
let fn_rtn = "$#.rr_hctg_track.partial.msgpack" % [fn]
log("Serialize '$#'" % [fn_rtn])
var msgss = msgpack4nim.initMsgStream() #you can pass some buffer capacity here https://github.com/jangko/msgpack4nim/issues/18
msgpack4nim.pack(msgss, rtn)
var ss = streams.newFileStream(fn_rtn, system.fmWrite)
defer: ss.close()
#ss.write($rtn)
msgpack4nim.pack(ss, rtn)
ss.write(msgss.data)
return fn_rtn

proc spawned_tr_stage1(db_fn, fn: string, min_len, bestn: int): string {.thread} =
Expand Down

0 comments on commit 89bd9af

Please sign in to comment.