{"id":13593553,"url":"https://github.com/xerial/snappy-java","last_synced_at":"2025-05-15T01:00:48.086Z","repository":{"id":4554996,"uuid":"5695907","full_name":"xerial/snappy-java","owner":"xerial","description":"Snappy compressor/decompressor for Java","archived":false,"fork":false,"pushed_at":"2025-04-17T00:13:20.000Z","size":37540,"stargazers_count":1059,"open_issues_count":58,"forks_count":237,"subscribers_count":52,"default_branch":"master","last_synced_at":"2025-05-03T03:41:53.844Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xerial.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-09-06T01:30:21.000Z","updated_at":"2025-04-29T03:16:16.000Z","dependencies_parsed_at":"2023-11-18T09:28:58.345Z","dependency_job_id":"92f2180a-2992-4324-8981-e759f050863d","html_url":"https://github.com/xerial/snappy-java","commit_stats":{"total_commits":1054,"total_committers":73,"mean_commits":"14.438356164383562","dds":0.2874762808349146,"last_synced_commit":"9c73c6e6a2d2131e905e7819a6706474be660818"},"previous_names":[],"tags_count":81,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xerial%2Fsnappy-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xerial%2Fsnappy-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xerial%2Fsnappy-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xerial%2Fsnappy-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xerial","download_url":"https://codeload.github.com/xerial/snappy-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252882250,"owners_count":21819149,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T16:01:21.528Z","updated_at":"2025-05-07T12:47:12.580Z","avatar_url":"https://github.com/xerial.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"snappy-java\n[![Build Status](https://travis-ci.org/xerial/snappy-java.svg?branch=master)](https://travis-ci.org/xerial/snappy-java)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.xerial.snappy/snappy-java/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.xerial.snappy/snappy-java/)\n[![Javadoc](https://javadoc.io/badge2/org.xerial.snappy/snappy-java/javadoc.svg)](https://javadoc.io/doc/org.xerial.snappy/snappy-java)\n=== \nsnappy-java is a Java port of the [snappy](https://github.com/google/snappy), a fast C++ compresser/decompresser developed by Google.\n\n## Features\n  * Fast compression/decompression around 200~400MB/sec.\n  * Less memory usage. SnappyOutputStream uses only 32KB+ in default.\n  * JNI-based implementation to achieve comparable performance to the native C++ version.\n     * Although snappy-java uses JNI, it can be used safely with multiple class loaders (e.g. Tomcat, etc.).\n  * Compression/decompression of Java primitive arrays (`float[]`, `double[]`, `int[]`, `short[]`, `long[]`, etc.)\n     * To improve the compression ratios of these arrays, you can use a fast data-rearrangement implementation ([`BitShuffle`](https://oss.sonatype.org/service/local/repositories/releases/archive/org/xerial/snappy/snappy-java/1.1.8/snappy-java-1.1.8-javadoc.jar/!/org/xerial/snappy/BitShuffle.html)) before compression\n  * Portable across various operating systems; Snappy-java contains native libraries built for Window/Mac/Linux, etc. snappy-java loads one of these libraries according to your machine environment (It looks system properties, `os.name` and `os.arch`).\n  * Simple usage. Add the snappy-java-(version).jar file to your classpath. Then call compression/decompression methods in `org.xerial.snappy.Snappy`.\n  * [Framing-format support](https://github.com/google/snappy/blob/master/framing_format.txt) (Since 1.1.0 version)\n  * OSGi support\n  * [Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). Free for both commercial and non-commercial use.\n\n## Performance\n  * Snappy's main target is very high-speed compression/decompression with reasonable compression size. So the compression ratio of snappy-java is modest and about the same as `LZF` (ranging 20%-100% according to the dataset).\n\n  * Here are some [benchmark results](https://github.com/ning/jvm-compressor-benchmark/wiki), comparing\n snappy-java and the other compressors\n `LZO-java`/`LZF`/`QuickLZ`/`Gzip`/`Bzip2`. Thanks [Tatu Saloranta @cotowncoder](http://twitter.com/#!/cowtowncoder) for providing the benchmark suite.\n  * The benchmark result indicates snappy-java is the fastest compressor/decompressor in Java: https://ning.github.io/jvm-compressor-benchmark/results/canterbury-roundtrip-2011-07-28/index.html\n * The decompression speed is twice as fast as the others: https://ning.github.io/jvm-compressor-benchmark/results/canterbury-uncompress-2011-07-28/index.html\n\n\n## Download\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.xerial.snappy/snappy-java/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.xerial.snappy/snappy-java/)\n[![Javadoc](https://javadoc.io/badge2/org.xerial.snappy/snappy-java/javadoc.svg)](https://javadoc.io/doc/org.xerial.snappy/snappy-java)\n \n * [Release Notes](Milestone.md)\n\nThe current stable version is available from here:\n  * Release version: https://repo1.maven.org/maven2/org/xerial/snappy/snappy-java/\n  * Snapshot version (the latest beta version): https://oss.sonatype.org/content/repositories/snapshots/org/xerial/snappy/snappy-java/\n\n### Using with Maven\n  \nSnappy-java is available from Maven's central repository. Add the following dependency to your pom.xml:\n\n    \u003cdependency\u003e\n      \u003cgroupId\u003eorg.xerial.snappy\u003c/groupId\u003e\n      \u003cartifactId\u003esnappy-java\u003c/artifactId\u003e\n      \u003cversion\u003e(version)\u003c/version\u003e\n      \u003ctype\u003ejar\u003c/type\u003e\n      \u003cscope\u003ecompile\u003c/scope\u003e\n    \u003c/dependency\u003e\n\n### Using with sbt\n\n```\nlibraryDependencies += \"org.xerial.snappy\" % \"snappy-java\" % \"(version)\"\n```\n\n\n## Usage\nFirst, import `org.xerial.snapy.Snappy` in your Java code:\n\n```java\nimport org.xerial.snappy.Snappy;\n```\n\nThen use `Snappy.compress(byte[])` and `Snappy.uncompress(byte[])`:\n\n```java\nString input = \"Hello snappy-java! Snappy-java is a JNI-based wrapper of \"\n     + \"Snappy, a fast compresser/decompresser.\";\nbyte[] compressed = Snappy.compress(input.getBytes(\"UTF-8\"));\nbyte[] uncompressed = Snappy.uncompress(compressed);\n\nString result = new String(uncompressed, \"UTF-8\");\nSystem.out.println(result);\n```\n\nIn addition, high-level methods (`Snappy.compress(String)`, `Snappy.compress(float[] ..)` etc. ) and low-level ones (e.g. `Snappy.rawCompress(.. )`,  `Snappy.rawUncompress(..)`, etc.), which minimize memory copies, can be used.\n\n### Stream-based API\nStream-based compressor/decompressor `SnappyOutputStream`/`SnappyInputStream` are also available for reading/writing large data sets. `SnappyFramedOutputStream`/`SnappyFramedInputStream` can be used for the [framing format](https://github.com/google/snappy/blob/master/framing_format.txt). \n\n * See also [Javadoc API](https://oss.sonatype.org/service/local/repositories/releases/archive/org/xerial/snappy/snappy-java/1.1.3-M1/snappy-java-1.1.3-M1-javadoc.jar/!/index.html)\n\n#### Compatibility Notes\n\nThe original Snappy format definition did not define a file format. It later added\na \"framing\" format to define a file format, but by this point major software was\nalready using an industry standard instead -- represented in this library by the\n`SnappyOutputStream` and `SnappyInputStream` methods.\n\nFor interoperability with other libraries, check that compatible formats are used.\nNote that not all libraries support all variants.\n\n * `SnappyOutputStream` and `SnappyInputStream` use `[magic header:16 bytes]([block size:int32][compressed data:byte array])*` format. You can read the result of `Snappy.compress` with `SnappyInputStream`, but you cannot read the compressed data generated by `SnappyOutputStream` with `Snappy.uncompress`.\n * `SnappyHadoopCompatibleOutputStream` does not emit a file header but write out the current block size as a  preemble to each block\n\n#### Data format compatibility matrix:\n\n| Write\\Read      | `Snappy.uncompress`   | `SnappyInputStream`  | `SnappyFramedInputStream` | `org.apache.hadoop.io.compress.SnappyCodec` |\n| --------------- |:-------------------:|:------------------:|:-----------------------:|:-------------------------------------------:|\n| `Snappy.compress` | ok | ok | x | x |\n| `SnappyOutputStream`  | x | ok | x | x |\n| `SnappyFramedOutputStream` | x | x | ok | x |\n| `SnappyHadoopCompatibleOutputStream` | x | x | x | ok |\n\n### BitShuffle API (Since 1.1.3-M2)\n\nBitShuffle is an algorithm that reorders data bits (shuffle) for efficient compression (e.g., a sequence of integers, float values, etc.). To use BitShuffle routines, import `org.xerial.snapy.BitShuffle`:\n\n```java\nimport org.xerial.snappy.BitShuffle;\n\nint[] data = new int[] {1, 3, 34, 43, 34};\nbyte[] shuffledByteArray = BitShuffle.shuffle(data);\nbyte[] compressed = Snappy.compress(shuffledByteArray);\nbyte[] uncompressed = Snappy.uncompress(compressed);\nint[] result = BitShuffle.unshuffleIntArray(uncompress);\n\nSystem.out.println(result);\n```\n\nShuffling and unshuffling of primitive arrays (e.g., `short[]`, `long[]`,  `float[]`, `double[]`, etc.) are supported. See [Javadoc](http://static.javadoc.io/org.xerial.snappy/snappy-java/1.1.3-M1/org/xerial/snappy/BitShuffle.html) for the details.\n\n### Setting classpath\nIf you have snappy-java-(VERSION).jar in the current directory, use `-classpath` option as follows:\n\n    $ javac -classpath \".;snappy-java-(VERSION).jar\" Sample.java  # in Windows\n    or\n    $ javac -classpath \".:snappy-java-(VERSION).jar\" Sample.java  # in Mac or Linux\n\n\n## Public discussion group\nPost bug reports or feature request to the Issue Tracker: \u003chttps://github.com/xerial/snappy-java/issues\u003e\n\nPublic discussion forum is here: [Xerial Public Discussion Group](http://groups.google.com/group/xerial?hl=en)\n\n## For developers\n\nsnappy-java uses sbt (simple build tool for Scala) as a build tool. Here is a simple usage\n\n    $ ./sbt            # enter sbt console\n    \u003e ~test            # run tests upon source code change\n    \u003e ~testOnly        # run tests that matches a given name pattern  \n    \u003e publishM2        # publish jar to $HOME/.m2/repository\n    \u003e package          # create jar file\n    \u003e findbugs         # Produce findbugs report in target/findbugs\n    \u003e jacoco:cover     # Report the code coverage of tests to target/jacoco folder    \n\nIf you need to see detailed debug messages, launch sbt with `-Dloglevel=debug` option:\n\n```\n$ ./sbt -Dloglevel=debug\n```\n\nFor the details of sbt usage, see my blog post: [Building Java Projects with sbt](http://xerial.org/blog/2014/03/24/sbt/)\n\n### Building from the source code\n\nSee the [build instruction](https://github.com/xerial/snappy-java/blob/master/BUILD.md). Building from the source code is an option when your OS platform and CPU architecture is not supported. To build snappy-java, you need Git, JDK (1.6 or higher), g++ compiler (mingw in Windows) etc.\n\n    $ git clone https://github.com/xerial/snappy-java.git\n    $ cd snappy-java\n    $ make\n\nWhen building on Solaris, use `gmake`:\n\n    $ gmake\n\nA file `target/snappy-java-$(version).jar` is the product additionally containing the native library built for your platform.\n\n### Creating a new release\n\nGitHub action [https://github.com/xerial/snappy-java/blob/master/.github/workflows/release.yml] will publish a new relase to Maven Central (Sonatype) when a new tag vX.Y.Z is pushed.\n\n## Miscellaneous Notes\n\n### Using snappy-java with Tomcat 6 (or higher) Web Server\n\nSimply put the snappy-java's jar to WEB-INF/lib folder of your web application. Usual JNI-library specific problem no longer exists since snappy-java version 1.0.3 or higher can be loaded by multiple class loaders.\n\n\n### Configure snappy-java using property file\n\nPrepare org-xerial-snappy.properties file (under the root path of your library) in Java's property file format.\nHere is a list of the available properties:\n\n * org.xerial.snappy.lib.path   (directory containing a snappyjava's native library)\n * org.xerial.snappy.lib.name   (library file name)\n * org.xerial.snappy.tempdir    (temporary directory to extract a native library bundled in snappy-java)\n * org.xerial.snappy.use.systemlib  (if this value is true, use system installed libsnappyjava.so looking the path specified by java.library.path) \n\n----\nSnappy-java is developed by [Taro L. Saito](http://www.xerial.org/leo). Twitter  [@taroleo](http://twitter.com/#!/taroleo)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxerial%2Fsnappy-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxerial%2Fsnappy-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxerial%2Fsnappy-java/lists"}