Skip to content

Commit

Permalink
[feature/fix] Fix default num cpus, update gzp (#37)
Browse files Browse the repository at this point in the history
* Fix default num cpus, update gzp

* update changelog

* update readme
  • Loading branch information
sstadick authored Sep 8, 2021
1 parent e695689 commit 817ca3a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v0.6.3

- Change the number of compression threads used by default
- Update gzp version

## v0.6.2

- Output BGZF output by default, which can be indexed and queried with tabix
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ anyhow = "1.0.41"
bstr = "0.2.16"
env_logger = "0.8.4"
flate2 = { version = "1.0", features = ["zlib-ng-compat"], default-features = false }
gzp = {version = "0.8.0", default-features = false, features = ["deflate_zlib_ng","libdeflate"]}
gzp = {version = "0.8.1", default-features = false, features = ["deflate_zlib_ng","libdeflate"]}
grep-cli = "0.1.6"
lazy_static = "1.4.0"
log = "0.4.14"
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Additionally this tool allows for specification of the order of the output colum

No single feature of `hck` on its own makes it stand out over `awk`, `cut`, `xsv` or other such tools. Where `hck` excels is making common things easy, such as reordering output fields, or splitting records on a weird delimiter.
It is meant to be simple and easy to use while exploring datasets.
Think of this as filling a gap between `cut` and `awk`.

## Features

Expand Down Expand Up @@ -41,7 +42,11 @@ brew tap sstadick/hck
brew install hck
```

\* Built with profile guided optimizations
- Conda (coming soon!)

```bash
conda install -c conda-forge hck
```

- MacPorts

Expand Down
16 changes: 13 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@ use structopt::{clap::AppSettings::ColoredHelp, StructOpt};
use termcolor::ColorChoice;

lazy_static! {
/// Return the number of cpus as an &str
pub static ref NUM_CPU: String = num_cpus::get().to_string();
/// Default number of compression threads to use.
///
/// This will be 4 if >= 4 threads are present, otherwise it will
/// be num_cpus - 1.
pub static ref DEFAULT_CPUS: String = {
let num_cores = num_cpus::get();
if num_cores < 4 {
num_cores.saturating_sub(1)
} else {
4
}.to_string()
};
}

pub mod built_info {
Expand Down Expand Up @@ -169,7 +179,7 @@ struct Opts {
try_compress: bool,

/// Threads to use for compression, 0 will result in `hck` staying single threaded.
#[structopt(short = "t", long, default_value=NUM_CPU.as_str())]
#[structopt(short = "t", long, default_value=DEFAULT_CPUS.as_str())]
compression_threads: usize,

/// Compression level
Expand Down

0 comments on commit 817ca3a

Please sign in to comment.