Filter Before You Parse: Faster Analytics on Raw Data with Sparser
dawn.cs.stanford.edu
dawn.cs.stanford.edu
It’s still relatively immature. But it’s a more algorithmic approach that I think plays nice with pretty much any source of semistructred Data. Though simd acceleration certainly is pretty sweet too
Say you look for log lines (or jsons) that contain the username 'mamcx'; you first filter-away lines that do NOT contain 'mamcx', then parse only the remaining ones (and apply the condition again, on the properly-parsed ones)
generally you do some kind of faster/simpler parsing up front and then feed to a more expensive parser.
I've parsed more than my share of 1GB-20GB Turtle files and some up-front filtering gets a big speed boost over a conventional RDF parser.
//Dude, and the data above what?
"username": "mamcx",
"version": 3
}
So this need to backtrack a lot?Or this scan for separators ({}) then in each scan it again scan per line?
for line.scan("{", "}"):
for result.find("mamcx")But for this specific case I use https://www.newtonsoft.com/json.
Eventually could incorporate the idea in my arsenal and maybe build a format streaming pipeline utility that can use across platforms.
You've got one entity to search per line, let's presume (if not, pre-process once to a new big file so that you do).
You want to find all entities that have propertyName = "Foo". So run "grep 'Foo' file" and put the result into your actual parsing/processing. You just removed some percentage of your data before the difficult parsing even began. Need to search on multiple fields?
cat input | grep 'Foo' | grep 'Bar' | actualProcessing