Skip to content

Commit

Permalink
Support boolean filter values
Browse files Browse the repository at this point in the history
  • Loading branch information
aldahick committed Jan 1, 2024
1 parent 78665f7 commit 29b7259
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 13 deletions.
40 changes: 30 additions & 10 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ edition = "2021"
[dependencies]
clap = { version = "4.4.4", features = ["derive"] }
indicatif = "0.17.7"
simd-json = "0.11.0"
zstd = "0.12.4"
simd-json = "0.13.4"
zstd = "0.13.0"
14 changes: 13 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use clap::Parser;
use progress::create_progress_bar;
use simd_json::{to_borrowed_value, BorrowedValue, ValueAccess};
use simd_json::{
base::{ValueAsContainer, ValueAsScalar},
derived::TypedScalarValue,
to_borrowed_value, BorrowedValue,
};
use std::{collections::HashSet, error::Error, io::Write};

mod io;
Expand Down Expand Up @@ -42,6 +46,14 @@ struct Args {

fn is_filtered(row: &BorrowedValue, key: &str, filter: &str) -> Option<bool> {
let value = row.as_object()?.get(key)?;
if value.is_bool() {
let bool_value = value.as_bool()?;
if bool_value {
return Some(filter == "true");
} else {
return Some(filter == "false");
}
}
Some(value.as_str()? == filter)
}

Expand Down

0 comments on commit 29b7259

Please sign in to comment.