From a1163b658e2e46389108dafffc0d1dcfc1ef90ad Mon Sep 17 00:00:00 2001 From: John Anderson Date: Fri, 19 Apr 2024 10:16:38 -0400 Subject: [PATCH] rename to jch and add basic readme --- Cargo.lock | 28 ++++++++++++++-------------- Cargo.toml | 2 +- README.md | 15 +++++++++++++++ src/lib.rs | 16 ++++++++++++++++ src/main.rs | 26 +++++++++++++------------- 5 files changed, 59 insertions(+), 28 deletions(-) create mode 100644 README.md diff --git a/Cargo.lock b/Cargo.lock index 9bde38a..9c020cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,20 +24,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" -[[package]] -name = "cln" -version = "0.1.0" -dependencies = [ - "archery", - "countio", - "json-event-parser", - "rmp", - "rmp-serde", - "rpds", - "serde_json", - "serde_yaml", -] - [[package]] name = "countio" version = "0.2.17" @@ -72,6 +58,20 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "jch" +version = "0.1.0" +dependencies = [ + "archery", + "countio", + "json-event-parser", + "rmp", + "rmp-serde", + "rpds", + "serde_json", + "serde_yaml", +] + [[package]] name = "json-event-parser" version = "0.1.1" diff --git a/Cargo.toml b/Cargo.toml index 26f9834..df4cbd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cln" +name = "jch" version = "0.1.0" edition = "2021" diff --git a/README.md b/README.md new file mode 100644 index 0000000..7f30c6b --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# jch + +Parse really large json files, fast. Using a streaming parser so memory usage is limited. + +For example: + +- the schema for a 26Mb file is calculated in about 750ms using about 4Mb of RAM. + +- the schema for a 432Mb file is calculated in about 20s using about 4Mb of RAM. + +Currently only outputs the schema of a json file, in a non-standard format. + +Is designed in a modular way so you can use it as a base for filtering json. Like `jq`. + +Might grow some kind of path-filtering languages, like jsonpath or xpath. diff --git a/src/lib.rs b/src/lib.rs index bc9004f..cedf2b5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,19 @@ +/*! +Parse really large json files, fast. Using a streaming parser so memory usage is limited. + +For example: + +- the schema for a 26Mb file is calculated in about 750ms using about 4Mb of RAM. + +- the schema for a 432Mb file is calculated in about 20s using about 4Mb of RAM. + +Currently only outputs the schema of a json file, in a non-standard format. + +Is designed in a modular way so you can use it as a base for filtering json. Like `jq`. + +Might grow some kind of path-filtering languages, like jsonpath or xpath. +*/ + // parser and traits pub mod parser; pub mod jsonpath; diff --git a/src/main.rs b/src/main.rs index 5e83d8b..c470a4f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,12 @@ -use cln::plain; -use cln::valuer; -use cln::channel; -use cln::shredder; -use cln::parser; -use cln::jsonpath; -use cln::schema; -use cln::handler; -use cln::fn_snd; +use jch::plain; +use jch::valuer; +use jch::channel; +use jch::shredder; +use jch::parser; +use jch::jsonpath; +use jch::schema; +use jch::handler; +use jch::fn_snd; use std::process::exit; @@ -19,13 +19,13 @@ fn main() { match &args[1..] { ["-s", "-z"] => schema::sizes(&mut std::io::stdout()).unwrap(), ["-s", rst @ ..] => { - let istream = cln::make_readable(rst); + let istream = jch::make_readable(rst); let mut jevstream = parser::JsonEvents::new(istream); schema::schema(&mut jevstream); } // This are POC to see that the rest of the handlers and visitors work. ["-p", rst @ ..] => { - let istream = cln::make_readable(rst); + let istream = jch::make_readable(rst); let mut jevstream = parser::JsonEvents::new(istream); // just use a (mostly) simple function wrapper @@ -40,7 +40,7 @@ fn main() { .unwrap_or_else(|err| eprintln!("ending event reading because {err:?}")); } ["-v", rst @ ..] => { - let istream = cln::make_readable(rst); + let istream = jch::make_readable(rst); let mut jevstream = parser::JsonEvents::new(istream); // accept all paths, and convert leafs to serde_json::Value @@ -55,7 +55,7 @@ fn main() { .unwrap_or_else(|err| {eprintln!("ending event reading because {err:?}"); exit(1)}) } ["-c", rst @ ..] => { - let istream = cln::make_readable(rst); + let istream = jch::make_readable(rst); let mut jevstream = parser::JsonEvents::new(istream); // producer reads file and converts to serde_json events, consumer just receives them. channel::channels(&mut jevstream)