haskell-works / hw-json

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Talk: JSON Parsing with SIMD

newhoggy opened this issue · comments

Constructing in-memory index

"simd" -> do

"simd" -> do
(fptr :: ForeignPtr Word8, offset, size) <- IO.mmapFileForeignPtr filePath IO.ReadOnly Nothing
let !bs = BSI.fromForeignPtr (castForeignPtr fptr) offset size
case S.makeStandardJsonIbBps (LBS.resegmentPadded 512 (LBS.fromStrict bs)) of
Right ibBps -> do
let (!ib, !bp) = constructUnzipN size ibBps
let !cursor = JsonCursor bs (makeCsPoppy ib) (SimpleBalancedParens bp) 1
let !json = lightJsonAt cursor
let q = MQuery (DL.singleton json)
putPretty $ q >>= (entry >=> named "meta" >=> entry >=> named "view" >=> entry >=> named "columns" >=> item >=> entry >=> named "id") & count
Left msg -> IO.hPutStrLn IO.stderr $ "Unable to create semi-index: " <> show msg
m -> IO.hPutStrLn IO.stderr $ "Unrecognised method: " <> show m