Skip to content

Commit

Permalink
feat!: separate rsonpath-syntax
Browse files Browse the repository at this point in the history
- The parsing logic and query AST
  are now moved to a separately published
  subcrate.
  • Loading branch information
V0ldek authored Nov 10, 2023
1 parent 1635e6e commit 7380b86
Show file tree
Hide file tree
Showing 60 changed files with 404 additions and 203 deletions.
8 changes: 4 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ updates:
directory: /crates/rsonpath-test-codegen
schedule:
interval: weekly
day: Monday
day: monday
time: "20:01"
assignees:
- V0ldek
Expand All @@ -46,7 +46,7 @@ updates:
directory: /crates/rsonpath-test
schedule:
interval: weekly
day: Monday
day: monday
time: "20:01"
assignees:
- V0ldek
Expand All @@ -62,7 +62,7 @@ updates:
directory: /fuzz
schedule:
interval: weekly
day: Monday
day: monday
time: "20:01"
assignees:
- V0ldek
Expand All @@ -78,7 +78,7 @@ updates:
directory: /.clusterfuzzlite
schedule:
interval: weekly
day: Monday
day: monday
time: "20:02"
assignees:
- V0ldek
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ jobs:
uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # stable
with:
toolchain: stable
- name: Publish rsonpath-syntax
run: cargo publish --token ${{ secrets.CRATES_TOKEN }} -p rsonpath-syntax --no-verify
- name: Publish rsonpath-lib
run: cargo publish --token ${{ secrets.CRATES_TOKEN }} -p rsonpath-lib --no-verify
- name: Publish rsonpath
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,14 @@ jobs:
~/.cargo/git/db/
target/
key: ubuntu-latest-nightly-avx2-cargo-${{ hashFiles('**/Cargo.toml') }}-doc
- name: cargo doc
- name: cargo doc (rsonpath-lib)
run: cargo doc --package rsonpath-lib --all-features --no-deps --release
env:
RUSTDOCFLAGS: "-Dwarnings --cfg docsrs"
- name: cargo doc (rsonpath-syntax)
run: cargo doc --package rsonpath-syntax --all-features --no-deps --release
env:
RUSTDOCFLAGS: "-Dwarnings --cfg docsrs"

format:
name: Format
Expand All @@ -343,7 +347,7 @@ jobs:
- name: Override toolchain
run: rustup override set stable
- name: Format
run: cargo fmt --package rsonpath rsonpath-lib -- --check
run: cargo fmt --package rsonpath rsonpath-lib rsonpath-syntax -- --check

cargo-deny:
name: Dependency scan (cargo-deny)
Expand Down
43 changes: 35 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
members = [
"crates/rsonpath",
"crates/rsonpath-lib",
"crates/rsonpath-syntax",
"crates/rsonpath-test"
]

Expand Down Expand Up @@ -34,3 +35,4 @@ strip = "debuginfo" # Smaller binary size.

[patch.crates-io]
rsonpath-lib = { path = "./crates/rsonpath-lib" }
rsonpath-syntax = { path = "./crates/rsonpath-syntax" }
8 changes: 5 additions & 3 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ test-x86-simd:
# Run doctests on the library.
test-doc:
-cargo install cargo-hack
cargo rsontest -p rsonpath-lib --doc
cargo rsontest --doc

# Run cmd tests
test-cmd:
Expand All @@ -143,6 +143,7 @@ test-cmd:
test-book:
rm -f ./target/debug/deps/librsonpath-*
cargo build -p rsonpath-lib
cargo build -p rsonpath-syntax
mdbook test ./book -L ./target/debug/deps

@add-test name:
Expand Down Expand Up @@ -173,7 +174,7 @@ alias v := verify-quick
alias verify := verify-full

# Run all lints and checks required.
verify-full: build-all verify-deny verify-clippy verify-doc verify-fmt test-full
verify-full: verify-fmt verify-doc verify-deny verify-clippy verify-bench test-full (build-bin "release")

# Run a quick formatting and compilation check.
verify-quick: verify-fmt verify-check verify-deny verify-bench
Expand All @@ -196,9 +197,10 @@ verify-clippy: (build-all "release")
cargo +nightly clippy --workspace --all-features --release -- --deny warnings

# Verify that documentation successfully builds for rsonpath-lib.
verify-doc $RUSTDOCFLAGS="--cfg docsrs": (build-bin "release")
verify-doc $RUSTDOCFLAGS="--cfg docsrs -D warnings":
cargo +nightly doc --package rsonpath-lib --no-default-features --no-deps
cargo +nightly doc --package rsonpath-lib --all-features --no-deps
cargo +nightly doc --package rsonpath-syntax --all-features --no-deps

# Verify formatting rules are not violated.
verify-fmt:
Expand Down
18 changes: 12 additions & 6 deletions book/src/lib/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ _This part of the book is a work in progress._

```rust
# extern crate rsonpath;
# extern crate rsonpath_syntax;
use rsonpath::engine::{Compiler, Engine, RsonpathEngine};
use rsonpath::input::BorrowedBytes;
use rsonpath::query::JsonPathQuery;
use rsonpath_syntax::JsonPathQuery;
use rsonpath::result::count::CountRecorder;
# use std::error::Error;

# fn main() -> Result<(), Box<dyn std::error::Error>> {
# fn main() -> Result<(), Box<dyn Error>> {
// Parse a JSONPath query from string.
let query = JsonPathQuery::parse("$..phoneNumbers[*].number")?;

let contents = r#"
// Convert the contents to the Input type required by the Engines.
let mut contents = r#"
{
"person": {
"name": "John",
Expand All @@ -27,10 +31,12 @@ let contents = r#"
}
]
}
}"#;

}
"#;
let input = BorrowedBytes::new(contents.as_bytes());
// Compile the query. The engine can be reused to run the same query on different contents.
let engine = RsonpathEngine::compile_query(&query)?;
// Count the number of occurrences of elements satisfying the query.
let count = engine.count(&input)?;

assert_eq!(2, count);
Expand Down
20 changes: 12 additions & 8 deletions crates/rsonpath-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
name = "rsonpath-lib"
version = "0.8.4"
authors = ["Mateusz Gienieczko <[email protected]>"]
edition = "2021"
description = "Blazing fast JSONPath query engine powered by SIMD. Core library of `rsonpath`."
readme = "README.md"
license = "MIT"
keywords = ["json", "jsonpath", "query", "simd", "parser"]
exclude = ["/tests", "/proptest-regressions"]
categories = [
"text-processing",
"parser-implementations",
keywords = ["json", "jsonpath", "query", "search", "simd"]
exclude = [
"/tests",
"/proptest-regressions",
"/src/classification/classifier_correctness_tests.rs",
"/src/classification/classifier_correctness_tests.proptest-regressions",
]
categories = ["text-processing"]
repository = "https://github.com/V0ldek/rsonpath"
homepage = "https://v0ldek.github.io/rsonpath/"
edition = "2021"
rust-version = "1.67.1"

[lib]
Expand All @@ -21,14 +24,15 @@ name = "rsonpath"

[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
features = [ "arbitrary" ]
all-features = true

[dependencies]
arbitrary = { version = "1.3.1", features = ["derive"], optional = true }
cfg-if = "1.0.0"
log = "0.4.20"
memmap2 = "0.9.0"
nom = "7.1.3"
rsonpath-syntax = { version = "0.1.0", path = "../rsonpath-syntax" }
smallvec = { version = "1.11.1", features = ["union"] }
static_assertions = "1.1.0"
thiserror = "1.0.50"
Expand All @@ -48,4 +52,4 @@ simd = []
[[example]]
name = "approx_spans_usage"
path = "examples/approx_spans_usage.rs"
doc-scrape-examples = true
doc-scrape-examples = true
2 changes: 1 addition & 1 deletion crates/rsonpath-lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![GitHub Release Date](https://img.shields.io/github/release-date/v0ldek/rsonpath?logo=github)](https://github.com/V0ldek/rsonpath/releases)
[![GitHub last commit](https://img.shields.io/github/last-commit/v0ldek/rsonpath?logo=github)](https://github.com/V0ldek/rsonpath/commits/main)

![MSRV](https://img.shields.io/badge/msrv-v1.67.1-orange?logo=rust "Minimum Supported Rust Version for `rq`")
![MSRV](https://img.shields.io/badge/msrv-v1.67.1-orange?logo=rust "Minimum Supported Rust Version for `rsonpath-lib`")
[![License](https://img.shields.io/crates/l/rsonpath)](https://choosealicense.com/licenses/mit/)

Library for [`rsonpath`](https://crates.io/crates/rsonpath), the JSONPath engine for querying massive streamed datasets.
Expand Down
2 changes: 1 addition & 1 deletion crates/rsonpath-lib/examples/approx_spans_usage.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use rsonpath::{
engine::{Compiler, Engine, RsonpathEngine},
input::MmapInput,
query::JsonPathQuery,
result::MatchWriter,
};
use rsonpath_syntax::JsonPathQuery;
use std::{env, error::Error, fs, io, process::ExitCode};

fn main() -> Result<ExitCode, Box<dyn Error>> {
Expand Down
Loading

0 comments on commit 7380b86

Please sign in to comment.