# snappy

> Does streaming compression/decompression of the input using Google's [Snappy](https://github.com/google/snappy/blob/main/docs/README.md) framing format ([more info](../../README.md#automatic-compressiondecompression)).

**[Table of Contents](TableOfContents.md)** | **Source: [src/cmd/snappy.rs](https://github.com/dathere/qsv/blob/master/src/cmd/snappy.rs)** | [🚀](TableOfContents.md#legend "multithreaded even without an index.")[🌐](TableOfContents.md#legend "has web-aware options.")

<a name="nav"></a>
[Description](#description) | [Usage](#usage) | [Arguments](#arguments) | [Snappy Options](#snappy-options) | [Common Options](#common-options)

<a name="description"></a>

## Description [↩](#nav)

Does streaming compression/decompression of the input using the Snappy framing format.
<https://github.com/google/snappy/blob/main/framing_format.txt>

It has four subcommands:

```text
compress:   Compress the input (multithreaded).
decompress: Decompress the input (single-threaded).
check:      Quickly check if the input is a Snappy file by inspecting the 
            first 50 bytes of the input is valid Snappy data.
            Returns exitcode 0 if the first 50 bytes is valid Snappy data,
            exitcode 1 otherwise.
validate:   Validate if the ENTIRE input is a valid Snappy file.
            Returns exitcode 0 if valid, exitcode 1 otherwise.
```

Note that most qsv commands already automatically decompresses Snappy files if the
input file has an ".sz" extension. It will also automatically compress the output
file (though only single-threaded) if the --output file has an ".sz" extension.

This command's multithreaded compression is 5-6x faster than qsv's automatic
single-threaded compression.

Also, this command is not specific to CSV data, it can compress/decompress ANY file.

For examples, see <https://github.com/dathere/qsv/blob/master/tests/test_snappy.rs>.
See also <https://github.com/dathere/qsv/wiki/Conversion-and-IO#snappy>


<a name="usage"></a>

## Usage [↩](#nav)

```console
qsv snappy compress [options] [<input>]
qsv snappy decompress [options] [<input>]
qsv snappy check [options] [<input>]
qsv snappy validate [options] [<input>]
qsv snappy --help
```

<a name="arguments"></a>

## Arguments [↩](#nav)

| Argument&nbsp; | Description |
|----------|-------------|
| &nbsp;`<input>`&nbsp; | The input file to compress/decompress. This can be a local file, stdin, or a URL (http and https schemes supported). |

<a name="snappy-options"></a>

## Snappy Options [↩](#nav)

| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Option&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Type | Description | Default |
|--------|------|-------------|--------|
| &nbsp;`‑‑user‑agent`&nbsp; | string | Specify custom user agent to use when the input is a URL. It supports the following variables - $QSV_VERSION, $QSV_TARGET, $QSV_BIN_NAME, $QSV_KIND and $QSV_COMMAND. Try to follow the syntax here - <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent> |  |
| &nbsp;`‑‑timeout`&nbsp; | integer | Timeout for downloading URLs in seconds. | `60` |

<a name="common-options"></a>

## Common Options [↩](#nav)

| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Option&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Type | Description | Default |
|--------|------|-------------|--------|
| &nbsp;`‑h,`<br>`‑‑help`&nbsp; | flag | Display this message |  |
| &nbsp;`‑o,`<br>`‑‑output`&nbsp; | string | Write output to <output> instead of stdout. |  |
| &nbsp;`‑j,`<br>`‑‑jobs`&nbsp; | integer | The number of jobs to run in parallel when compressing. When not set, its set to the number of CPUs - 1 |  |
| &nbsp;`‑q,`<br>`‑‑quiet`&nbsp; | flag | Suppress status messages to stderr. |  |
| &nbsp;`‑p,`<br>`‑‑progressbar`&nbsp; | flag | Show download progress bars. Only valid for URL input. |  |

---
**Source:** [`src/cmd/snappy.rs`](https://github.com/dathere/qsv/blob/master/src/cmd/snappy.rs)
| **[Table of Contents](TableOfContents.md)** | **[README](../../README.md)**
