{"id":16130203,"url":"https://github.com/lambdacasserole/huff","last_synced_at":"2026-04-29T14:36:25.282Z","repository":{"id":75385873,"uuid":"59122288","full_name":"lambdacasserole/huff","owner":"lambdacasserole","description":"Huffman compression Maven package for Java.","archived":false,"fork":false,"pushed_at":"2016-05-26T01:03:28.000Z","size":32,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-03T11:53:36.692Z","etag":null,"topics":["compression","frequency-analysis","huffman-coding","jitpack","maven"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lambdacasserole.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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-18T14:19:52.000Z","updated_at":"2023-09-26T12:35:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"f060db4d-2503-468a-a7ea-faf9388ca1bf","html_url":"https://github.com/lambdacasserole/huff","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/lambdacasserole/huff","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdacasserole%2Fhuff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdacasserole%2Fhuff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdacasserole%2Fhuff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdacasserole%2Fhuff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lambdacasserole","download_url":"https://codeload.github.com/lambdacasserole/huff/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdacasserole%2Fhuff/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32429256,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T13:34:34.882Z","status":"ssl_error","status_checked_at":"2026-04-29T13:34:29.830Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["compression","frequency-analysis","huffman-coding","jitpack","maven"],"created_at":"2024-10-09T22:14:58.195Z","updated_at":"2026-04-29T14:36:25.237Z","avatar_url":"https://github.com/lambdacasserole.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Huff\nHuffman compression Maven package for Java.\n\nHuff is designed to provide a simple starting point for applications seeking to use Huffman coding to compress data. Given a byte array, an instance of the `HuffmanCompressor` class will:\n\n+ Calculate byte occurence frequencies for the data set.\n+ Create a Huffman tree using this set of frequencies.\n+ Build prefix codes for each byte based on its relative occurence frequency.\n+ Use the [backspin](https://github.com/lambdacasserole/backspin) bit manipulation package to write a compressed representation of the data to a `BitOutputStream`. \n+ Return the contents of this `BitOutputStream` as a compressed byte array, along with its length in bits (bit count) and a `PrefixCodeTable` for decompressing the data again.\n\nThe `HuffmanCompressor` class is also capable of decompressing the data using a prefix code table, a bit count and a compressed byte array.\n\n## Installation\nYou can pull this package into your Maven project straight from here using JitPack. Add JitPack as a repository first:\n\n```\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ejitpack.io\u003c/id\u003e\n        \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\nThen add a dependency on Huff:\n\n```\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.github.lambdacasserole\u003c/groupId\u003e\n        \u003cartifactId\u003ehuff\u003c/artifactId\u003e\n        \u003cversion\u003ev1.0\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n## Limitations\nHuff is absolutely not a package that will produce archive files out-of-the-box. It is also not an optimised-for-speed implementation. If you do use it for file compression, serializing the `PrefixCodeTable` and bit count for storage alongside your compressed data is up to you. \n\nThat said, when you need to transparently Huffman-code a byte array (or even just do a basic frequency analysis on it), Huff is a good choice. \n\n## Benchmarks\nOnce again, this package isn't designed for straight-up file compression out of the box. If you do use it for that, however, here are some benchmarks running against the [Canterbury Corpus](http://corpus.canterbury.ac.nz/). Note that the compressed sizes do not include any space for the serialized prefix code tables/bit count needed to decompress the files again. Times are for a 1.58GHz x64 CPU with 4GB available RAM.\n\n| File         | Uncompressed (Bytes) | Compressed (Bytes) | Ratio | Space Saving | Time (ms) |\n|--------------|----------------------|--------------------|-------|--------------|-----------|\n| alice29.txt  | 152089               | 87688              | 1.73  | 42%          | 321.2     |\n| asyoulik.txt | 125179               | 75807              | 1.65  | 39%          | 128.8     |\n| cp.html      | 24603                | 16199              | 1.52  | 34%          | 108.6     |\n| fields.c     | 11150                | 7026               | 1.59  | 37%          | 45.5      |\n| grammar.lsp  | 3721                 | 2170               | 1.71  | 42%          | 43.4      |\n| kennedy.xls  | 1029744              | 462532             | 2.23  | 55%          | 524.2     |\n| lcet10.txt   | 426754               | 250565             | 1.70  | 41%          | 287.5     |\n| plrabn12.txt | 481861               | 275585             | 1.75  | 43%          | 198.6     |\n| ptt5         | 513216               | 106551             | 4.82  | 79%          | 142.1     |\n| sum          | 38240                | 25646              | 1.49  | 33%          | 22.5      |\n| xargs.1      | 4227                 | 2602               | 1.62  | 38%          | 13.3      |\n\n## Contributing\nFor most intents and purposes, Huff is considered to fulfil its original use case. Bug fixes and suggestions are welcome, however, from any member of the community.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambdacasserole%2Fhuff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flambdacasserole%2Fhuff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambdacasserole%2Fhuff/lists"}