public class SnappyModule {
@JRubyMethod(module = true, name = {"deflate", "compress", "dump"})
public static IRubyObject deflate(ThreadContext context, IRubyObject self, IRubyObject str) throws IOException {
ByteList input = str.convertToString().getByteList();
byte[] compressed = new byte[Snappy.maxCompressedLength(input.length())];
int compressedLength = Snappy.compress(input.unsafeBytes(), input.begin(), input.length(), compressed, 0);
return RubyString.newStringNoCopy(context.runtime, compressed, 0, compressedLength);
}
@JRubyMethod(module = true, name = {"inflate", "uncompress", "load"})
public static IRubyObject inflate(ThreadContext context, IRubyObject self, IRubyObject str) throws IOException {