{"id":17226476,"url":"https://github.com/willglynn/snappy-ruby","last_synced_at":"2025-04-14T01:11:25.566Z","repository":{"id":66323918,"uuid":"1521855","full_name":"willglynn/snappy-ruby","owner":"willglynn","description":"Snappy bindings for Ruby","archived":false,"fork":false,"pushed_at":"2014-10-22T12:51:06.000Z","size":135,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T23:48:20.395Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willglynn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-03-24T17:23:49.000Z","updated_at":"2020-09-11T17:43:06.000Z","dependencies_parsed_at":"2023-02-20T02:31:03.821Z","dependency_job_id":null,"html_url":"https://github.com/willglynn/snappy-ruby","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willglynn%2Fsnappy-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willglynn%2Fsnappy-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willglynn%2Fsnappy-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willglynn%2Fsnappy-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willglynn","download_url":"https://codeload.github.com/willglynn/snappy-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248804825,"owners_count":21164135,"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-10-15T04:16:20.914Z","updated_at":"2025-04-14T01:11:25.545Z","avatar_url":"https://github.com/willglynn.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"snappy-ruby\n===========\n\nThis repository contains a set of Ruby gems, collectively exposing the Snappy\ncompression algorithm to Ruby, a fast compressor/decompressor.\n\nAbout Snappy\n------------\n\nFrom the [official Snappy website](http://code.google.com/p/snappy/):\n\n\u003e Snappy is a compression/decompression library. It does not aim for maximum\n\u003e compression, or compatibility with any other compression library; instead, it\n\u003e aims for very high speeds and reasonable compression. For instance, compared\n\u003e to the fastest mode of zlib, Snappy is an order of magnitude faster for most\n\u003e inputs, but the resulting compressed files are anywhere from 20% to 100%\n\u003e bigger. On a single core of a Core i7 processor in 64-bit mode, Snappy\n\u003e compresses at about 250 MB/sec or more and decompresses at about 500 MB/sec\n\u003e or more.\n\u003e \n\u003e Snappy is widely used inside Google, in everything from BigTable and MapReduce\n\u003e to our internal RPC systems. (Snappy has previously been referred to as \"Zippy\"\n\u003e in some presentations and the likes.)\n\nExample\n-------\n\n    $ gem install snappy_ext\n    Building native extensions.  This could take a while...\n    \u003csnip\u003e\n    \n    $ irb -rubygems -rsnappy_ext\n    \u003e\u003e Snappy.compress \"1234567890\" * 10\n    =\u003e \"d$1234567890\\376\\n\\000f\\n\\000\"\n    \n    \u003e\u003e Snappy::Ext.uncompress \"d$1234567890\\376\\n\\000f\\n\\000\"\n    =\u003e \"1234567890123456789012345678901234567890...\n    \nRuby Gems\n---------\n\nI have made two bindings for Snappy:\n\n- `snappy_ext`\n\n  A C extension that builds and links libsnappy into itself as part of the\n  install process.\n\n- `snappy_ffi`\n\n  Uses FFI to communicate with libsnappy, which must be installed separately.\n  Works on non-MRI Ruby implementations.\n\nPut `snappy_ext` or `snappy_ffi` in your Gemfile as appropriate, but use the\nSnappy functions (instead of Snappy::Ext or Snappy::FFI) so you can change\nyour mind later.\n\nsnappy_ext\n----------\n\nThis gem compiles libsnappy into a C Ruby extension, resulting in no external\ndependencies. However, this doesn't work at all on most non-MRI Ruby\ninterpreters, and the build process is kind of... unusual, so it will probably\nbreak horribly on different platforms or when cross-compliling.\n\nIf it works for you, great. (And it seems to work on recent Linux distros and\nMacOSX.) If it doesn't, please use `snappy_ffi`, or tinker with it and send up\na patch. `mkmf` is dark magic, well beyond my powers. I probably can't help.\n\nsnappy_ffi\n----------\n\nThis gem relies on having a libsnappy dynamic library on the host machine.\n\n`snappy_ffi` is sort of a good news/bad news situation. Bad news is, libsnappy\nhas only a C++ interface, and C++ resists efforts to use it without a C++\ncompiler. Good news is, Google was kind enough to expose an interface that\nhides exceptions and can operate on caller-allocated buffers, so it's possible\nto use from FFI.\n\nThe last C++ hurdle is that `snappy::MaxCompressedLength()` will be exported\nby libsnappy as something like `__ZN6snappy19MaxCompressedLengthEm`, and the\nway the names are transformed varies from compiler to compiler.\n\nTo address this, `snappy_ffi` maintains a list of identifiers it's encountered\nin the wild, and attempts to automatically detect whatever library is installed\non your system. This works great on recent versions of Linux and OSX using the\nstandard toolchain.\n\nThat said, if you're using a different compiler or on a weird architecture,\n`snappy_ffi` might not know what's going on. If that happens, you will get an\nerror message to that effect. You'll need to do some platform-specific\ninvestigation to determine what the needed functions are called on your\nplatform. A general process might be:\n\n1. Find the libsnappy library on your system\n2. Get a list of exported symbols, using whatever tool your OS provides\n3. From this list, find four functions: MaxCompressedLength, RawCompress,\n   GetUncompressedLength, RawUncompress. Two of them have pointer and \"Source\"\n   versions. We need the pointer versions, so ignore anything that says \"Source\".\n4. Define a Ruby hash encoding your findings before loading snappy_ffi.\n\nYou'll want to do something like:\n\n    module Snappy\n      module FFI\n        LocalExportSet = {\n          :max_compressed_length =\u003e '_ZN6snappy19MaxCompressedLengthEm',\n          :get_uncompressed_length =\u003e '_ZN6snappy21GetUncompressedLengthEPKcmPm',\n          :raw_compress =\u003e '_ZN6snappy11RawCompressEPKcmPcPm',\n          :raw_uncompress =\u003e '_ZN6snappy13RawUncompressEPKcmPc'\n        }\n      end\n    end\n    \n    require 'snappy_ffi'\n\nOpen a GitHub issue too! Include your hash and your platform/compiler details. \nThat way, we can get your data included in the list of things to try by\ndefault.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillglynn%2Fsnappy-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillglynn%2Fsnappy-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillglynn%2Fsnappy-ruby/lists"}