-
Notifications
You must be signed in to change notification settings - Fork 12
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
querymodule defines theJsonPathQuerystructure. It has two submodules, the parser and the compiler. - The
classificationmodule defines the classifier pipeline.- The
quotessubmodule defines theQuoteClassifiedIteratorthat serves as the first step of the pipeline, recognizing quoted strings and escape sequences. - The
structuralsubmodule defines theStructuralIteratorthat can be started or stopped on demand over aQuoteClassifiedIteratorand lexes structural characters from the input. - The
depthsubmodule defines theDepthIteratorthat can be started or stopped on demand over aQuoteClassifiedIteratorand facilitates fast-forwarding based on document depth.
- The
- The
enginemodule defines the core traitsCompilerandEngineand the two engine implementations ofrsonpath.- The
mainsubmodule defines the main engine,MainEngine. - The
recursivesubmodule defines the recursive-call engine,RecursiveEngine.
- The
- The
resultmodule defines theQueryResulttrait for consuming query matches, and its implementations.
rsonpath wiki, curated by Mateusz Gienieczko (V0ldek) (mat@gienieczko.com)