-
Notifications
You must be signed in to change notification settings - Fork 10
Architecture
The rsonpath
library has to be finely modular for at least three separate reasons. We need to be able to (not necessarily in order of priority):
- swap parts of the algorithm between generic portable versions and hyperoptimized architecture-specific implementations;
- swap classifier algorithms in-flight for best engine performance (we call this the State-driven Classifier Pipeline);
- manage the complexity of the solution, since it would otherwise drive anyone trying to grasp it insane.
If anything, the last point should be the one driving engineering decisions. Remember that Correctness is the core principle, and even the fastest algorithm is useless if it's written in such a complex way it's unmaintainable. Managing complexity is, after all, the primary objective of software engineering.
The query string is parsed and compiled into a DFA. The input is read from a file or stdin. The quote classifier handles strings and escapes in the JSON. The engine executes the DFA on the input by consuming the structural classifier and examining the stream of structural characters. It calls provided result implementations when a query match occurs. For performance it interacts with the classifier pipeline by switching between the structural and depth classifiers, and toggling some of the structural characters from classification.
- The
query
module defines theJsonPathQuery
structure. It has two submodules, the parser and the compiler. - The
classification
module defines the classifier pipeline.- The
quotes
submodule defines theQuoteClassifiedIterator
that serves as the first step of the pipeline, recognizing quoted strings and escape sequences. - The
structural
submodule defines theStructuralIterator
that can be started or stopped on demand over aQuoteClassifiedIterator
and lexes structural characters from the input. - The
depth
submodule defines theDepthIterator
that can be started or stopped on demand over aQuoteClassifiedIterator
and facilitates fast-forwarding based on document depth.
- The
- The
engine
module defines the core traitsCompiler
andEngine
and the two engine implementations ofrsonpath
.- The
main
submodule defines the main engine,MainEngine
. - The
recursive
submodule defines the recursive-call engine,RecursiveEngine
.
- The
- The
result
module defines theQueryResult
trait for consuming query matches, and its implementations.
rsonpath wiki, curated by Mateusz Gienieczko (V0ldek) ([email protected])