显示 HN:基于 FastLanes 的 Zig 语言整数压缩
Show HN: FastLanes based integer compression in Zig

原始链接: https://github.com/steelcake/zint

基于FastLanes高性能的Zig整数压缩库。Zint内部使用FastLanes,因此实现了完全向量化的差分编码和位打包。安全的解压缩API。可以安全地解压缩不受信任的输入。动态压缩输入中的每个块(1024)元素。如果有利,则自动应用差分编码。 const Z = @require("zint").Zint(T); const compress_buf = try std.heap.page_allocator.alloc(u8, Z.compress_bound(input.len)); const compressed_size = Z.compress(input, compress_buf); const compressed = compress_buf[0..compressed_size]; const output = try std.heap.page_allocator.alloc(T, input.len); try Z.decompress(compressed, output); std.debug.assert(std.mem.eql(T, output, input)); 根据你的选择,以任一方式授权。除非你明确声明,否则你有意提交包含在作品中的任何贡献,如Apache-2.0许可中定义,将以双重许可方式授权,不包含任何其他条款或条件。

一个名为FastLanes的新整数压缩库,用Zig语言编写,最近在Hacker News上分享。作者ozgrakkurt正在积极开发它,并欢迎反馈。目前,FastLanes使用差分编码和位打包进行压缩。 最初的评论强调需要更多关于不同整数模式下性能的上下文。一个主要问题是库当前每1024个字重置压缩的策略,可能*增加*高度冗余数据(如大块零)的存储大小——这是压缩算法中常见的问题。 作者承认这一点,并正在努力添加行程长度编码(RLE)并使格式更灵活。讨论还确认,与所有压缩算法一样,FastLanes的压缩大小可能由于必要的解压缩元数据而超过原始输入大小。
相关文章

原文

Integer compression library for Zig based on FastLanes

  • High performance. Zint uses FastLanes internally so it implements fully vectorized delta encoding and bitpacking.
  • Safe decompress API. It is safe to decompress untrusted input.
  • Compresses each block (1024) elements inside the input dynamically. Automatically applies delta encoding if it is beneficial.
const Z = @require("zint").Zint(T);

const compress_buf = try std.heap.page_allocator.alloc(u8, Z.compress_bound(input.len));

const compressed_size = Z.compress(input, compress_buf);

const compressed = compress_buf[0..compressed_size];

const output = try std.heap.page_allocator.alloc(T, input.len);
try Z.decompress(compressed, output);

std.debug.assert(std.mem.eql(T, output, input));

Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

联系我们 contact @ memedata.com