대규모 스트리밍 데이터 세트를 쿼리하기 위한 실험적인 JSONPath 엔진입니다.
rsonpath
크레이트는 JSONPath 파서와 쿼리 실행 엔진 rq
제공합니다. 이 엔진은 SIMD 명령을 활용하여 기존 엔진에 비해 엄청난 처리량 향상을 제공합니다.
Pison 데이터세트의 SIMD가 없는 참조 엔진에 대한 rsonpath
의 벤치마크입니다. 참고: 규모는 대수적입니다!
파일에 대해 JSONPath 쿼리를 실행하려면 다음을 실행합니다.
rq '$..a.b' ./file.json
파일이 생략되면 엔진은 표준 입력을 읽습니다. JSON을 인라인으로 전달할 수도 있습니다.
$ rq ' $..a.b ' --json ' {"c":{"a":{"b":42}}} '
42
자세한 내용은 rq --help
또는 rsonbook을 참조하세요.
쿼리 실행 결과는 줄 바꿈으로 구분된 일치하는 값의 시퀀스입니다. 또는 --result count
전달하면 일치하는 항목 수만 반환되므로 훨씬 더 빠를 수 있습니다. 다른 결과 모드에 대해서는 --help
사용법 페이지를 참조하세요.
모든 최고 수준의 지원 대상에 대한 사전 컴파일된 바이너리 릴리스를 참조하세요.
cargo
가장 쉬운 설치 방법은 cargo
이용하는 것입니다.
$ cargo install rsonpath
...
최대 속도가 가장 중요하다면 기본 CPU 지침을 지원하는 rsonpath
설치해야 합니다. 이로 인해 이식성이 없는 바이너리가 생성되고 다른 시스템에서는 제대로 작동하지 않을 수 있지만 처리량의 모든 마지막 비트가 압박됩니다.
이렇게 하려면 다음 cargo install
변형을 실행하세요.
$ RUSTFLAGS= " -C target-cpu=native " cargo install rsonpath
...
rsonbook의 관련 장을 확인하세요.
이 프로젝트는 활발히 개발되고 있으며 현재 JSONPath 쿼리 언어의 하위 집합만 지원합니다. 쿼리는 각각 하나 이상의 선택기를 포함하는 일련의 세그먼트입니다.
분절 | 통사론 | 지원됨 | 부터 | 추적 문제 |
---|---|---|---|---|
하위 세그먼트(단일) | [<selector>] | ✔️ | v0.1.0 | |
하위 세그먼트(다중) | [<selector1>,...,<selectorN>] | |||
하위 세그먼트(단일) | ..[<selector>] | ✔️ | v0.1.0 | |
하위 세그먼트(다중) | ..[<selector1>,...,<selectorN>] |
선택자 | 통사론 | 지원됨 | 부터 | 추적 문제 |
---|---|---|---|---|
뿌리 | $ | ✔️ | v0.1.0 | |
이름 | .<member> , [<member>] | ✔️ | v0.1.0 | |
와일드카드 | .* , ..* , [*] | ✔️ | v0.4.0 | |
인덱스(배열 인덱스) | [<index>] | ✔️ | v0.5.0 | |
인덱스(끝에서부터 배열 인덱스) | [-<index>] | |||
배열 슬라이스(정방향, 양수 경계) | [<start>:<end>:<step>] | ✔️ | v0.9.0 | #152 |
배열 슬라이스(정방향, 임의 경계) | [<start>:<end>:<step>] | |||
배열 슬라이스(역방향, 임의 경계) | [<start>:<end>:-<step>] | |||
필터 – 실존 테스트 | [?<path>] | #154 | ||
필터 – const 원자 비교 | [?<path> <binop> <atom>] | #156 | ||
필터 – 논리식 | && , || , ! | |||
필터 – 중첩 | [?<expr>[?<expr>]...] | |||
필터 – 임의 비교 | [?<path> <binop> <path>] | |||
필터 – 기능 확장 | [?func(<path>)] |
크레이트는 모든 Tier 1 Rust 대상에 대해 지속적으로 구축되며, GitHub 작업 이미지로 실행할 수 있는 대상에 대해 테스트가 지속적으로 실행됩니다. SIMD는 x86/x86_64 플랫폼에서만 지원됩니다.
타겟 트리플 | nosimd 빌드 | SIMD 지원 | 지속적인 테스트 | 추적 문제 |
---|---|---|---|---|
aarch64-알 수 없는-리눅스-gnu | ✔️ | ✔️ | #21, #115 | |
i686-알 수 없는-리눅스-gnu | ✔️ | ✔️ | ✔️ | |
x86_64-알 수 없는-리눅스-gnu | ✔️ | ✔️ | ✔️ | |
x86_64-애플-다윈 | ✔️ | ✔️ | ✔️ | |
i686-pc-windows-gnu | ✔️ | ✔️ | ✔️ | |
i686-pc-windows-msvc | ✔️ | ✔️ | ✔️ | |
x86_64-pc-windows-gnu | ✔️ | ✔️ | ✔️ | |
x86_64-pc-windows-msvc | ✔️ | ✔️ | ✔️ |
SIMD 지원은 모듈별로 활성화됩니다. 일반적으로 지난 10년 동안 출시된 모든 CPU는 사용 가능한 모든 최적화를 지원하는 AVX2를 지원합니다.
SSE2 이상의 구형 CPU는 부분적으로 지원됩니다. rq --version
사용하여 정확히 무엇이 활성화되어 있는지 확인할 수 있습니다. SIMD support
필드를 확인하세요.
$ rq --version
rq 0.9.1
Commit SHA: c024e1bab89610455537b77aed249d2a05a81ed6
Features: default,simd
Opt level: 3
Target triple: x86_64-unknown-linux-gnu
Codegen flags: link-arg=-fuse-ld=lld
SIMD support: avx2;fast_quotes;fast_popcnt
fast_quotes
기능은 pclmulqdq
명령어에 따라 달라지며 fast_popcnt
popcnt
명령어에 따라 달라집니다.
모든 선택기가 지원되는 것은 아닙니다. 위의 지원 표를 참조하세요.
엔진은 입력 JSON의 모든 객체에 중복 키가 없다고 가정합니다. 중복 키에 대한 동작은 안정적이라고 보장되지 않지만, 현재 엔진은 단순히 첫 번째 키와 일치합니다.
$ rq ' $.key ' --json ' {"key":"value","key":"other value"} '
"value"
엔진은 멤버 이름의 유니코드 이스케이프 시퀀스를 구문 분석하지 않습니다 . 이는 의미상으로 동일한 문자열을 나타내더라도 "a"
키가 "u0041"
키와 다르다는 것을 의미합니다. 이는 실제로 현재 JSONPath 사양과 관련하여 설계된 것입니다. 유니코드 시퀀스를 구문 분석하는 데는 비용이 많이 들기 때문에 고성능을 위해 이에 대한 지원이 연기되었습니다. #117로 추적됩니다.
요점은 포크하고, 구현하고, 여기에서 PR을 만드는 것입니다. 자세한 내용은 CONTRIBUTING 문서에 있습니다.
개발 워크플로 just
. 포함된 Justfile
사용하세요. 귀하의 환경에 Cargo가 없음을 감지하면 rustup
도구를 사용하여 Rust를 자동으로 설치합니다.
$ just build
...
$ just test
...
rsonpath
에 대한 벤치마크는 이 기본 저장소에 git 하위 모듈로 포함된 별도의 저장소에 있습니다.
모든 벤치마크를 실행하는 가장 쉬운 방법 just bench
입니다. 자세한 내용은 하위 모듈의 README를 참조하세요.
ASPLOS '24에 rsonpath
에 대한 논문을 발표할 예정입니다! 여기서 읽을 수 있습니다.
이 프로젝트는 나의 논문으로 구상되었습니다. 엔진의 이론적 배경과 구현 세부 사항에 대한 자세한 내용을 읽을 수 있습니다.
직접적인 종속성을 표시합니다. 전체 그래프는 아래를 참조하세요.
cargo tree --package rsonpath --edges normal --depth 1
rsonpath v0.9.1 (/home/mat/src/rsonpath/crates/rsonpath)
├── clap v4.5.4
├── color-eyre v0.6.3
├── eyre v0.6.12
├── log v0.4.21
├── rsonpath-lib v0.9.1 (/home/mat/src/rsonpath/crates/rsonpath-lib)
├── rsonpath-syntax v0.3.1 (/home/mat/src/rsonpath/crates/rsonpath-syntax)
└── simple_logger v4.3.3
[build-dependencies]
├── rustflags v0.1.5
└── vergen v8.3.1
[build-dependencies]
cargo tree --package rsonpath-lib --edges normal --depth 1
rsonpath-lib v0.9.1 (/home/mat/src/rsonpath/crates/rsonpath-lib)
├── arbitrary v1.3.2
├── cfg-if v1.0.0
├── log v0.4.21
├── memmap2 v0.9.4
├── nom v7.1.3
├── rsonpath-syntax v0.3.1 (/home/mat/src/rsonpath/crates/rsonpath-syntax)
├── smallvec v1.13.2
├── static_assertions v1.1.0
├── thiserror v1.0.58
└── vector-map v1.0.1
clap
– CLI를 제공하는 표준 상자입니다.color-eyre
, eyre
– 파서에 대한 오류 메시지에 더 쉽게 접근할 수 있습니다.log
, simple-logger
– 컴파일 및 실행 중 진단 로그입니다.cfg-if
– SIMD 및 SIMD가 없는 버전을 지원하는 데 사용됩니다.memmap2
– 버퍼링된 복사본 대신 메모리 맵을 통해 소스 파일을 빠르게 읽습니다.nom
– 파서 구현용.smallvec
– 소규모 스택 성능에 중요합니다.static_assertions
– 컴파일 타임에 검증된 몇 가지 지속적인 가정을 통해 추가적인 신뢰성을 제공합니다.thiserror
- 관용적인 Error
구현입니다.vector_map
– 측정 가능한 성능 향상을 위해 쿼리 컴파일러에서 사용됩니다. cargo tree --package rsonpath --edges normal
rsonpath v0.9.1 (/home/mat/src/rsonpath/crates/rsonpath)
├── clap v4.5.4
│ ├── clap_builder v4.5.2
│ │ ├── anstream v0.6.13
│ │ │ ├── anstyle v1.0.6
│ │ │ ├── anstyle-parse v0.2.3
│ │ │ │ └── utf8parse v0.2.1
│ │ │ ├── anstyle-query v1.0.2
│ │ │ │ └── windows-sys v0.52.0
│ │ │ │ └── windows-targets v0.52.4
│ │ │ │ ├── windows_aarch64_gnullvm v0.52.4
│ │ │ │ ├── windows_aarch64_msvc v0.52.4
│ │ │ │ ├── windows_i686_gnu v0.52.4
│ │ │ │ ├── windows_i686_msvc v0.52.4
│ │ │ │ ├── windows_x86_64_gnu v0.52.4
│ │ │ │ ├── windows_x86_64_gnullvm v0.52.4
│ │ │ │ └── windows_x86_64_msvc v0.52.4
│ │ │ ├── anstyle-wincon v3.0.2
│ │ │ │ ├── anstyle v1.0.6
│ │ │ │ └── windows-sys v0.52.0 (*)
│ │ │ ├── colorchoice v1.0.0
│ │ │ └── utf8parse v0.2.1
│ │ ├── anstyle v1.0.6
│ │ ├── clap_lex v0.7.0
│ │ ├── strsim v0.11.1
│ │ └── terminal_size v0.3.0
│ │ ├── rustix v0.38.32
│ │ │ ├── bitflags v2.5.0
│ │ │ ├── errno v0.3.8
│ │ │ │ ├── libc v0.2.153
│ │ │ │ └── windows-sys v0.52.0 (*)
│ │ │ ├── libc v0.2.153
│ │ │ ├── linux-raw-sys v0.4.13
│ │ │ └── windows-sys v0.52.0 (*)
│ │ └── windows-sys v0.48.0
│ │ └── windows-targets v0.48.5
│ │ ├── windows_aarch64_gnullvm v0.48.5
│ │ ├── windows_aarch64_msvc v0.48.5
│ │ ├── windows_i686_gnu v0.48.5
│ │ ├── windows_i686_msvc v0.48.5
│ │ ├── windows_x86_64_gnu v0.48.5
│ │ ├── windows_x86_64_gnullvm v0.48.5
│ │ └── windows_x86_64_msvc v0.48.5
│ └── clap_derive v4.5.4 (proc-macro)
│ ├── heck v0.5.0
│ ├── proc-macro2 v1.0.79
│ │ └── unicode-ident v1.0.12
│ ├── quote v1.0.35
│ │ └── proc-macro2 v1.0.79 (*)
│ └── syn v2.0.58
│ ├── proc-macro2 v1.0.79 (*)
│ ├── quote v1.0.35 (*)
│ └── unicode-ident v1.0.12
├── color-eyre v0.6.3
│ ├── backtrace v0.3.71
│ │ ├── addr2line v0.21.0
│ │ │ └── gimli v0.28.1
│ │ ├── cfg-if v1.0.0
│ │ ├── libc v0.2.153
│ │ ├── miniz_oxide v0.7.2
│ │ │ └── adler v1.0.2
│ │ ├── object v0.32.2
│ │ │ └── memchr v2.7.2
│ │ └── rustc-demangle v0.1.23
│ │ [build-dependencies]
│ │ └── cc v1.0.90
│ ├── eyre v0.6.12
│ │ ├── indenter v0.3.3
│ │ └── once_cell v1.19.0
│ ├── indenter v0.3.3
│ ├── once_cell v1.19.0
│ └── owo-colors v3.5.0
├── eyre v0.6.12 (*)
├── log v0.4.21
├── rsonpath-lib v0.9.1 (/home/mat/src/rsonpath/crates/rsonpath-lib)
│ ├── cfg-if v1.0.0
│ ├── log v0.4.21
│ ├── memmap2 v0.9.4
│ │ └── libc v0.2.153
│ ├── nom v7.1.3
│ │ ├── memchr v2.7.2
│ │ └── minimal-lexical v0.2.1
│ ├── rsonpath-syntax v0.3.1 (/home/mat/src/rsonpath/crates/rsonpath-syntax)
│ │ ├── nom v7.1.3 (*)
│ │ ├── owo-colors v4.0.0
│ │ ├── thiserror v1.0.58
│ │ │ └── thiserror-impl v1.0.58 (proc-macro)
│ │ │ ├── proc-macro2 v1.0.79 (*)
│ │ │ ├── quote v1.0.35 (*)
│ │ │ └── syn v2.0.58 (*)
│ │ └── unicode-width v0.1.11
│ ├── smallvec v1.13.2
│ ├── static_assertions v1.1.0
│ ├── thiserror v1.0.58 (*)
│ └── vector-map v1.0.1
│ ├── contracts v0.4.0 (proc-macro)
│ │ ├── proc-macro2 v1.0.79 (*)
│ │ ├── quote v1.0.35 (*)
│ │ └── syn v1.0.109
│ │ ├── proc-macro2 v1.0.79 (*)
│ │ ├── quote v1.0.35 (*)
│ │ └── unicode-ident v1.0.12
│ └── rand v0.7.3
│ ├── getrandom v0.1.16
│ │ ├── cfg-if v1.0.0
│ │ ├── libc v0.2.153
│ │ └── wasi v0.9.0+wasi-snapshot-preview1
│ ├── libc v0.2.153
│ ├── rand_chacha v0.2.2
│ │ ├── ppv-lite86 v0.2.17
│ │ └── rand_core v0.5.1
│ │ └── getrandom v0.1.16 (*)
│ ├── rand_core v0.5.1 (*)
│ └── rand_hc v0.2.0
│ └── rand_core v0.5.1 (*)
├── rsonpath-syntax v0.3.1 (/home/mat/src/rsonpath/crates/rsonpath-syntax) (*)
└── simple_logger v4.3.3
├── colored v2.1.0
│ ├── lazy_static v1.4.0
│ └── windows-sys v0.48.0 (*)
├── log v0.4.21
├── time v0.3.34
│ ├── deranged v0.3.11
│ │ └── powerfmt v0.2.0
│ ├── itoa v1.0.11
│ ├── libc v0.2.153
│ ├── num-conv v0.1.0
│ ├── num_threads v0.1.7
│ │ └── libc v0.2.153
│ ├── powerfmt v0.2.0
│ ├── time-core v0.1.2
│ └── time-macros v0.2.17 (proc-macro)
│ ├── num-conv v0.1.0
│ └── time-core v0.1.2
└── windows-sys v0.48.0 (*)
[build-dependencies]
├── rustflags v0.1.5
└── vergen v8.3.1
├── anyhow v1.0.81
├── cargo_metadata v0.18.1
│ ├── camino v1.1.6
│ │ └── serde v1.0.197
│ │ └── serde_derive v1.0.197 (proc-macro)
│ │ ├── proc-macro2 v1.0.79 (*)
│ │ ├── quote v1.0.35 (*)
│ │ └── syn v2.0.58 (*)
│ ├── cargo-platform v0.1.8
│ │ └── serde v1.0.197 (*)
│ ├── semver v1.0.22
│ │ └── serde v1.0.197 (*)
│ ├── serde v1.0.197 (*)
│ ├── serde_json v1.0.115
│ │ ├── itoa v1.0.11
│ │ ├── ryu v1.0.17
│ │ └── serde v1.0.197 (*)
│ └── thiserror v1.0.58 (*)
├── cfg-if v1.0.0
├── regex v1.10.4
│ ├── aho-corasick v1.1.3
│ │ └── memchr v2.7.2
│ ├── memchr v2.7.2
│ ├── regex-automata v0.4.6
│ │ ├── aho-corasick v1.1.3 (*)
│ │ ├── memchr v2.7.2
│ │ └── regex-syntax v0.8.3
│ └── regex-syntax v0.8.3
├── rustc_version v0.4.0
│ └── semver v1.0.22 (*)
└── time v0.3.34
├── deranged v0.3.11 (*)
├── itoa v1.0.11
├── libc v0.2.153
├── num-conv v0.1.0
├── num_threads v0.1.7 (*)
├── powerfmt v0.2.0
└── time-core v0.1.2
[build-dependencies]
└── rustversion v1.0.14 (proc-macro)