#json #jsonpath #query #search #simd

rsonpath-lib

Blazing fast JSONPath query engine powered by SIMD. Core library of rsonpath.

21 releases (7 breaking)

0.8.6 Jan 15, 2024
0.8.4 Oct 30, 2023
0.5.1 Jul 3, 2023
0.3.3 Mar 29, 2023
0.1.2 Nov 19, 2022

#832 in Text processing

Download history 72/week @ 2023-10-27 16/week @ 2023-11-03 9/week @ 2023-11-10 14/week @ 2023-11-17 56/week @ 2023-11-24 62/week @ 2023-12-01 4/week @ 2023-12-08 23/week @ 2023-12-15 44/week @ 2023-12-22 21/week @ 2023-12-29 38/week @ 2024-01-05 52/week @ 2024-01-12 5/week @ 2024-01-19 30/week @ 2024-01-26 23/week @ 2024-02-02 33/week @ 2024-02-09

94 downloads per month
Used in rsonpath

MIT license

630KB
13K SLoC

rsonpath-lib – SIMD-powered JSONPath, as a library 🚀

Rust docs.rs Book

Crates.io GitHub Release Date GitHub last commit

MSRV License

Library for rsonpath, the JSONPath engine for querying massive streamed datasets.

The main target of this crate is the rsonpath CLI tool. Note that this API is unstable until we reach v1.0.0. This is going to happen (we have a roadmap), but our dev resources are quite limited. Contributions are welcome and appreciated.

Unsafe

The library uses unsafe for SIMD operations, because it has to, at least until portable-simd gets stabilized. Because of this, a compiled library is not portable – if you build on a platform supporting AVX2 and then use the same compiled code on an ARM platform, it will crash. We put special care to not use unsafe code anywhere else – in fact, the crate uses #[forbid(unsafe_code)] when compiled without the default simd feature.

Build & test

The dev workflow utilizes just. Use the included Justfile. It will automatically install Rust for you using the rustup tool if it detects there is no Cargo in your environment.

just build
just test

Architecture diagram

Below is a simplified overview of the module interactions and interfaces, and how data flows from the user's input (query, document) through the pipeline to produce results.

Architecture diagram

Optional features

The simd feature is enabled by default and is recommended to make use of the performance benefits of the project.

The arbitrary feature is optional and enables the arbitrary dependency, which provides an implementation of Arbitrary for the query struct.

Dependencies

Showing direct dependencies.

cargo tree --package rsonpath-lib --edges normal --depth 1
rsonpath-lib v0.8.6 (/home/mat/src/rsonpath/crates/rsonpath-lib)
├── arbitrary v1.3.2
├── cfg-if v1.0.0
├── log v0.4.20
├── memmap2 v0.9.3
├── nom v7.1.3
├── rsonpath-syntax v0.1.0 (/home/mat/src/rsonpath/crates/rsonpath-syntax)
├── smallvec v1.12.0
├── static_assertions v1.1.0
├── thiserror v1.0.56
└── vector-map v1.0.1

Justification

  • cfg-if – used to support SIMD and no-SIMD versions.
  • memchr – rapid, SIMDified substring search for fast-forwarding to labels.
  • memmap2 – for fast reading of source files via a memory map instead of buffered copies.
  • nom – for parser implementation.
  • replace_with – for safe handling of internal classifier state when switching classifiers.
  • smallvec – crucial for small-stack performance.
  • static_assertions – additional reliability by some constant assumptions validated at compile time.
  • thiserror – idiomatic Error implementations.
  • vector_map – used in the query compiler for measurably better performance.

Dependencies

~2–2.8MB
~55K SLoC