I need to scan very large JSONL files efficiently and am considering a parallel grep-style approach over line-delimited text.

Would love to hear how you would design it.

you are viewing a single comment's thread
view the rest of the comments
[–] 1 point 7 months ago (4 children)

Bad idea. First, file is read sequentially, and you can't parallelize this. Second, grep is a bad solution for structured files. Better use jq or something similar.

  • source
  • hideshow 4 child comments
  • [–] 3 points 7 months ago (3 children)

    https://jsonltools.com/what-is-jsonl

    First time hearing about it, but JSONL is like CSV with json per line. So not really structured.

    I don’t see why you couldn’t just use grep on it.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 0 points 7 months ago (2 children)

    Sorry, I missed that L, and I've never heard about JSONL before (although worked with JSON logs that are effectively JSONL). So, well, you may use grep, however it can be inefficient (depends on regex engine and how good you are in regexes). It is also easy to make a mistake if you are not very proficient in regexes. So I'd prefer using JSON parser (jq or another, maybe lower level if performance matters) over grep anyway.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 7 months ago (1 child)

    parsing will make it orders of magnitude slower

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 7 months ago

    It will not if your parser is not overcomplicated and does not populate some huge structures with data. You only need to find tokens and compare them with field names and values you are looking for. Regexes are slower and don't allow processing escaped characters correctly.

  • source
  • parent